bowang0911/leetcode huggingface dataset:
Number of Distinct Islands II

You are given an `m x n` binary matrix `grid`. An island is a group of `1`'s (representing land) connected **4-directionally** (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

An island is considered to be the same as another if they have the same shape, or have the same shape after **rotation** (90, 180, or 270 degrees only) or **reflection** (left/right direction or up/down direction).

Return _the number of **distinct** islands_.

**Example 1:**

**Input:** grid = \[\[1,1,0,0,0\],\[1,0,0,0,0\],\[0,0,0,0,1\],\[0,0,0,1,1\]\]
**Output:** 1
**Explanation:** The two islands are considered the same because if we make a 180 degrees clockwise rotation on the first island, then two islands will have the same shapes.

**Example 2:**

**Input:** grid = \[\[1,1,0,0,0\],\[1,1,0,0,0\],\[0,0,0,1,1\],\[0,0,0,1,1\]\]
**Output:** 1

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 50`
*   `grid[i][j]` is either `0` or `1`.
Minimum ASCII Delete Sum for Two Strings

Given two strings `s1` and `s2`, return _the lowest **ASCII** sum of deleted characters to make two strings equal_.

**Example 1:**

**Input:** s1 =  "sea ", s2 =  "eat "
**Output:** 231
**Explanation:** Deleting  "s " from  "sea " adds the ASCII value of  "s " (115) to the sum.
Deleting  "t " from  "eat " adds 116 to the sum.
At the end, both strings are equal, and 115 + 116 = 231 is the minimum sum possible to achieve this.

**Example 2:**

**Input:** s1 =  "delete ", s2 =  "leet "
**Output:** 403
**Explanation:** Deleting  "dee " from  "delete " to turn the string into  "let ",
adds 100\[d\] + 101\[e\] + 101\[e\] to the sum.
Deleting  "e " from  "leet " adds 101\[e\] to the sum.
At the end, both strings are equal to  "let ", and the answer is 100+101+101+101 = 403.
If instead we turned both strings into  "lee " or  "eet ", we would get answers of 433 or 417, which are higher.

**Constraints:**

*   `1 <= s1.length, s2.length <= 1000`
*   `s1` and `s2` consist of lowercase English letters.
Subarray Product Less Than K

Given an array of integers `nums` and an integer `k`, return _the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than_ `k`.

**Example 1:**

**Input:** nums = \[10,5,2,6\], k = 100
**Output:** 8
**Explanation:** The 8 subarrays that have product less than 100 are:
\[10\], \[5\], \[2\], \[6\], \[10, 5\], \[5, 2\], \[2, 6\], \[5, 2, 6\]
Note that \[10, 5, 2\] is not included as the product of 100 is not strictly less than k.

**Example 2:**

**Input:** nums = \[1,2,3\], k = 0
**Output:** 0

**Constraints:**

*   `1 <= nums.length <= 3 * 104`
*   `1 <= nums[i] <= 1000`
*   `0 <= k <= 106`
Best Time to Buy and Sell Stock with Transaction Fee

You are given an array `prices` where `prices[i]` is the price of a given stock on the `ith` day, and an integer `fee` representing a transaction fee.

Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.

**Note:** You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

**Example 1:**

**Input:** prices = \[1,3,2,8,4,9\], fee = 2
**Output:** 8
**Explanation:** The maximum profit can be achieved by:
- Buying at prices\[0\] = 1
- Selling at prices\[3\] = 8
- Buying at prices\[4\] = 4
- Selling at prices\[5\] = 9
The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.

**Example 2:**

**Input:** prices = \[1,3,7,5,10,3\], fee = 3
**Output:** 6

**Constraints:**

*   `1 <= prices.length <= 5 * 104`
*   `1 <= prices[i] < 5 * 104`
*   `0 <= fee < 5 * 104`
Max Stack

Design a max stack data structure that supports the stack operations and supports finding the stack's maximum element.

Implement the `MaxStack` class:

*   `MaxStack()` Initializes the stack object.
*   `void push(int x)` Pushes element `x` onto the stack.
*   `int pop()` Removes the element on top of the stack and returns it.
*   `int top()` Gets the element on the top of the stack without removing it.
*   `int peekMax()` Retrieves the maximum element in the stack without removing it.
*   `int popMax()` Retrieves the maximum element in the stack and removes it. If there is more than one maximum element, only remove the **top-most** one.

You must come up with a solution that supports `O(1)` for each `top` call and `O(logn)` for each other call.

**Example 1:**

**Input**
\[ "MaxStack ",  "push ",  "push ",  "push ",  "top ",  "popMax ",  "top ",  "peekMax ",  "pop ",  "top "\]
\[\[\], \[5\], \[1\], \[5\], \[\], \[\], \[\], \[\], \[\], \[\]\]
**Output**
\[null, null, null, null, 5, 5, 1, 5, 1, 5\]

**Explanation**
MaxStack stk = new MaxStack();
stk.push(5);   // \[**5**\] the top of the stack and the maximum number is 5.
stk.push(1);   // \[5, **1**\] the top of the stack is 1, but the maximum is 5.
stk.push(5);   // \[5, 1, **5**\] the top of the stack is 5, which is also the maximum, because it is the top most one.
stk.top();     // return 5, \[5, 1, **5**\] the stack did not change.
stk.popMax();  // return 5, \[5, **1**\] the stack is changed now, and the top is different from the max.
stk.top();     // return 1, \[5, **1**\] the stack did not change.
stk.peekMax(); // return 5, \[5, **1**\] the stack did not change.
stk.pop();     // return 1, \[**5**\] the top of the stack and the max element is now 5.
stk.top();     // return 5, \[**5**\] the stack did not change.

**Constraints:**

*   `-107 <= x <= 107`
*   At most `105` calls will be made to `push`, `pop`, `top`, `peekMax`, and `popMax`.
*   There will be **at least one element** in the stack when `pop`, `top`, `peekMax`, or `popMax` is called.
1-bit and 2-bit Characters

We have two special characters:

*   The first character can be represented by one bit `0`.
*   The second character can be represented by two bits (`10` or `11`).

Given a binary array `bits` that ends with `0`, return `true` if the last character must be a one-bit character.

**Example 1:**

**Input:** bits = \[1,0,0\]
**Output:** true
**Explanation:** The only way to decode it is two-bit character and one-bit character.
So the last character is one-bit character.

**Example 2:**

**Input:** bits = \[1,1,1,0\]
**Output:** false
**Explanation:** The only way to decode it is two-bit character and two-bit character.
So the last character is not one-bit character.

**Constraints:**

*   `1 <= bits.length <= 1000`
*   `bits[i]` is either `0` or `1`.
Maximum Length of Repeated Subarray

Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_.

**Example 1:**

**Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\]
**Output:** 3
**Explanation:** The repeated subarray with maximum length is \[3,2,1\].

**Example 2:**

**Input:** nums1 = \[0,0,0,0,0\], nums2 = \[0,0,0,0,0\]
**Output:** 5
**Explanation:** The repeated subarray with maximum length is \[0,0,0,0,0\].

**Constraints:**

*   `1 <= nums1.length, nums2.length <= 1000`
*   `0 <= nums1[i], nums2[i] <= 100`
Find K-th Smallest Pair Distance

The **distance of a pair** of integers `a` and `b` is defined as the absolute difference between `a` and `b`.

Given an integer array `nums` and an integer `k`, return _the_ `kth` _smallest **distance among all the pairs**_ `nums[i]` _and_ `nums[j]` _where_ `0 <= i < j < nums.length`.

**Example 1:**

**Input:** nums = \[1,3,1\], k = 1
**Output:** 0
**Explanation:** Here are all the pairs:
(1,3) -> 2
(1,1) -> 0
(3,1) -> 2
Then the 1st smallest distance pair is (1,1), and its distance is 0.

**Example 2:**

**Input:** nums = \[1,1,1\], k = 2
**Output:** 0

**Example 3:**

**Input:** nums = \[1,6,1\], k = 3
**Output:** 5

**Constraints:**

*   `n == nums.length`
*   `2 <= n <= 104`
*   `0 <= nums[i] <= 106`
*   `1 <= k <= n * (n - 1) / 2`
Longest Word in Dictionary

Given an array of strings `words` representing an English Dictionary, return _the longest word in_ `words` _that can be built one character at a time by other words in_ `words`.

If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty string.

Note that the word should be built from left to right with each additional character being added to the end of a previous word.

**Example 1:**

**Input:** words = \[ "w ", "wo ", "wor ", "worl ", "world "\]
**Output:**  "world "
**Explanation:** The word  "world " can be built one character at a time by  "w ",  "wo ",  "wor ", and  "worl ".

**Example 2:**

**Input:** words = \[ "a ", "banana ", "app ", "appl ", "ap ", "apply ", "apple "\]
**Output:**  "apple "
**Explanation:** Both  "apply " and  "apple " can be built from other words in the dictionary. However,  "apple " is lexicographically smaller than  "apply ".

**Constraints:**

*   `1 <= words.length <= 1000`
*   `1 <= words[i].length <= 30`
*   `words[i]` consists of lowercase English letters.
Accounts Merge

Given a list of `accounts` where each element `accounts[i]` is a list of strings, where the first element `accounts[i][0]` is a name, and the rest of the elements are **emails** representing emails of the account.

Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some common email to both accounts. Note that even if two accounts have the same name, they may belong to different people as people could have the same name. A person can have any number of accounts initially, but all of their accounts definitely have the same name.

After merging the accounts, return the accounts in the following format: the first element of each account is the name, and the rest of the elements are emails **in sorted order**. The accounts themselves can be returned in **any order**.

**Example 1:**

**Input:** accounts = \[\[ "John ", "johnsmith@mail.com ", "john\_newyork@mail.com "\],\[ "John ", "johnsmith@mail.com ", "john00@mail.com "\],\[ "Mary ", "mary@mail.com "\],\[ "John ", "johnnybravo@mail.com "\]\]
**Output:** \[\[ "John ", "john00@mail.com ", "john\_newyork@mail.com ", "johnsmith@mail.com "\],\[ "Mary ", "mary@mail.com "\],\[ "John ", "johnnybravo@mail.com "\]\]
**Explanation:**
The first and second John's are the same person as they have the common email  "johnsmith@mail.com ".
The third John and Mary are different people as none of their email addresses are used by other accounts.
We could return these lists in any order, for example the answer \[\['Mary', 'mary@mail.com'\], \['John', 'johnnybravo@mail.com'\], 
\['John', 'john00@mail.com', 'john\_newyork@mail.com', 'johnsmith@mail.com'\]\] would still be accepted.

**Example 2:**

**Input:** accounts = \[\[ "Gabe ", "Gabe0@m.co ", "Gabe3@m.co ", "Gabe1@m.co "\],\[ "Kevin ", "Kevin3@m.co ", "Kevin5@m.co ", "Kevin0@m.co "\],\[ "Ethan ", "Ethan5@m.co ", "Ethan4@m.co ", "Ethan0@m.co "\],\[ "Hanzo ", "Hanzo3@m.co ", "Hanzo1@m.co ", "Hanzo0@m.co "\],\[ "Fern ", "Fern5@m.co ", "Fern1@m.co ", "Fern0@m.co "\]\]
**Output:** \[\[ "Ethan ", "Ethan0@m.co ", "Ethan4@m.co ", "Ethan5@m.co "\],\[ "Gabe ", "Gabe0@m.co ", "Gabe1@m.co ", "Gabe3@m.co "\],\[ "Hanzo ", "Hanzo0@m.co ", "Hanzo1@m.co ", "Hanzo3@m.co "\],\[ "Kevin ", "Kevin0@m.co ", "Kevin3@m.co ", "Kevin5@m.co "\],\[ "Fern ", "Fern0@m.co ", "Fern1@m.co ", "Fern5@m.co "\]\]

**Constraints:**

*   `1 <= accounts.length <= 1000`
*   `2 <= accounts[i].length <= 10`
*   `1 <= accounts[i][j].length <= 30`
*   `accounts[i][0]` consists of English letters.
*   `accounts[i][j] (for j > 0)` is a valid email.
Candy Crush

This question is about implementing a basic elimination algorithm for Candy Crush.

Given an `m x n` integer array `board` representing the grid of candy where `board[i][j]` represents the type of candy. A value of `board[i][j] == 0` represents that the cell is empty.

The given board represents the state of the game following the player's move. Now, you need to restore the board to a stable state by crushing candies according to the following rules:

*   If three or more candies of the same type are adjacent vertically or horizontally, crush them all at the same time - these positions become empty.
*   After crushing all candies simultaneously, if an empty space on the board has candies on top of itself, then these candies will drop until they hit a candy or bottom at the same time. No new candies will drop outside the top boundary.
*   After the above steps, there may exist more candies that can be crushed. If so, you need to repeat the above steps.
*   If there does not exist more candies that can be crushed (i.e., the board is stable), then return the current board.

You need to perform the above rules until the board becomes stable, then return _the stable board_.

**Example 1:**

**Input:** board = \[\[110,5,112,113,114\],\[210,211,5,213,214\],\[310,311,3,313,314\],\[410,411,412,5,414\],\[5,1,512,3,3\],\[610,4,1,613,614\],\[710,1,2,713,714\],\[810,1,2,1,1\],\[1,1,2,2,2\],\[4,1,4,4,1014\]\]
**Output:** \[\[0,0,0,0,0\],\[0,0,0,0,0\],\[0,0,0,0,0\],\[110,0,0,0,114\],\[210,0,0,0,214\],\[310,0,0,113,314\],\[410,0,0,213,414\],\[610,211,112,313,614\],\[710,311,412,613,714\],\[810,411,512,713,1014\]\]

**Example 2:**

**Input:** board = \[\[1,3,5,5,2\],\[3,4,3,3,1\],\[3,2,4,5,2\],\[2,4,4,5,5\],\[1,4,4,1,1\]\]
**Output:** \[\[1,3,0,0,0\],\[3,4,0,5,2\],\[3,2,0,3,1\],\[2,4,0,5,2\],\[1,4,3,1,1\]\]

**Constraints:**

*   `m == board.length`
*   `n == board[i].length`
*   `3 <= m, n <= 50`
*   `1 <= board[i][j] <= 2000`
Find Pivot Index

Given an array of integers `nums`, calculate the **pivot index** of this array.

The **pivot index** is the index where the sum of all the numbers **strictly** to the left of the index is equal to the sum of all the numbers **strictly** to the index's right.

If the index is on the left edge of the array, then the left sum is `0` because there are no elements to the left. This also applies to the right edge of the array.

Return _the **leftmost pivot index**_. If no such index exists, return `-1`.

**Example 1:**

**Input:** nums = \[1,7,3,6,5,6\]
**Output:** 3
**Explanation:**
The pivot index is 3.
Left sum = nums\[0\] + nums\[1\] + nums\[2\] = 1 + 7 + 3 = 11
Right sum = nums\[4\] + nums\[5\] = 5 + 6 = 11

**Example 2:**

**Input:** nums = \[1,2,3\]
**Output:** -1
**Explanation:**
There is no index that satisfies the conditions in the problem statement.

**Example 3:**

**Input:** nums = \[2,1,-1\]
**Output:** 0
**Explanation:**
The pivot index is 0.
Left sum = 0 (no elements to the left of index 0)
Right sum = nums\[1\] + nums\[2\] = 1 + -1 = 0

**Constraints:**

*   `1 <= nums.length <= 104`
*   `-1000 <= nums[i] <= 1000`

**Note:** This question is the same as 1991: [https://leetcode.com/problems/find-the-middle-index-in-array/](https://leetcode.com/problems/find-the-middle-index-in-array/)
Split Linked List in Parts

Given the `head` of a singly linked list and an integer `k`, split the linked list into `k` consecutive linked list parts.

The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being null.

The parts should be in the order of occurrence in the input list, and parts occurring earlier should always have a size greater than or equal to parts occurring later.

Return _an array of the_ `k` _parts_.

**Example 1:**

**Input:** head = \[1,2,3\], k = 5
**Output:** \[\[1\],\[2\],\[3\],\[\],\[\]\]
**Explanation:**
The first element output\[0\] has output\[0\].val = 1, output\[0\].next = null.
The last element output\[4\] is null, but its string representation as a ListNode is \[\].

**Example 2:**

**Input:** head = \[1,2,3,4,5,6,7,8,9,10\], k = 3
**Output:** \[\[1,2,3,4\],\[5,6,7\],\[8,9,10\]\]
**Explanation:**
The input has been split into consecutive parts with size difference at most 1, and earlier parts are a larger size than the later parts.

**Constraints:**

*   The number of nodes in the list is in the range `[0, 1000]`.
*   `0 <= Node.val <= 1000`
*   `1 <= k <= 50`
Number of Atoms

Given a string `formula` representing a chemical formula, return _the count of each atom_.

The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.

One or more digits representing that element's count may follow if the count is greater than `1`. If the count is `1`, no digits will follow.

*   For example, `"H2O "` and `"H2O2 "` are possible, but `"H1O2 "` is impossible.

Two formulas are concatenated together to produce another formula.

*   For example, `"H2O2He3Mg4 "` is also a formula.

A formula placed in parentheses, and a count (optionally added) is also a formula.

*   For example, `"(H2O2) "` and `"(H2O2)3 "` are formulas.

Return the count of all elements as a string in the following form: the first name (in sorted order), followed by its count (if that count is more than `1`), followed by the second name (in sorted order), followed by its count (if that count is more than `1`), and so on.

The test cases are generated so that all the values in the output fit in a **32-bit** integer.

**Example 1:**

**Input:** formula =  "H2O "
**Output:**  "H2O "
**Explanation:** The count of elements are {'H': 2, 'O': 1}.

**Example 2:**

**Input:** formula =  "Mg(OH)2 "
**Output:**  "H2MgO2 "
**Explanation:** The count of elements are {'H': 2, 'Mg': 1, 'O': 2}.

**Example 3:**

**Input:** formula =  "K4(ON(SO3)2)2 "
**Output:**  "K4N2O14S4 "
**Explanation:** The count of elements are {'K': 4, 'N': 2, 'O': 14, 'S': 4}.

**Constraints:**

*   `1 <= formula.length <= 1000`
*   `formula` consists of English letters, digits, `'('`, and `')'`.
*   `formula` is always valid.
Minimum Window Subsequence

Given strings `s1` and `s2`, return _the minimum contiguous substring part of_ `s1`_, so that_ `s2` _is a subsequence of the part_.

If there is no such window in `s1` that covers all characters in `s2`, return the empty string `" "`. If there are multiple such minimum-length windows, return the one with the **left-most starting index**.

**Example 1:**

**Input:** s1 =  "abcdebdde ", s2 =  "bde "
**Output:**  "bcde "
**Explanation:** 
 "bcde " is the answer because it occurs before  "bdde " which has the same length.
 "deb " is not a smaller window because the elements of s2 in the window must occur in order.

**Example 2:**

**Input:** s1 =  "jmeqksfrsdcmsiwvaovztaqenprpvnbstl ", s2 =  "u "
**Output:**  " "

**Constraints:**

*   `1 <= s1.length <= 2 * 104`
*   `1 <= s2.length <= 100`
*   `s1` and `s2` consist of lowercase English letters.
Self Dividing Numbers

A **self-dividing number** is a number that is divisible by every digit it contains.

*   For example, `128` is **a self-dividing number** because `128 % 1 == 0`, `128 % 2 == 0`, and `128 % 8 == 0`.

A **self-dividing number** is not allowed to contain the digit zero.

Given two integers `left` and `right`, return _a list of all the **self-dividing numbers** in the range_ `[left, right]`.

**Example 1:**

**Input:** left = 1, right = 22
**Output:** \[1,2,3,4,5,6,7,8,9,11,12,15,22\]

**Example 2:**

**Input:** left = 47, right = 85
**Output:** \[48,55,66,77\]

**Constraints:**

*   `1 <= left <= right <= 104`
My Calendar I

You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **double booking**.

A **double booking** happens when two events have some non-empty intersection (i.e., some moment is common to both events.).

The event can be represented as a pair of integers `start` and `end` that represents a booking on the half-open interval `[start, end)`, the range of real numbers `x` such that `start <= x < end`.

Implement the `MyCalendar` class:

*   `MyCalendar()` Initializes the calendar object.
*   `boolean book(int start, int end)` Returns `true` if the event can be added to the calendar successfully without causing a **double booking**. Otherwise, return `false` and do not add the event to the calendar.

**Example 1:**

**Input**
\[ "MyCalendar ",  "book ",  "book ",  "book "\]
\[\[\], \[10, 20\], \[15, 25\], \[20, 30\]\]
**Output**
\[null, true, false, true\]

**Explanation**
MyCalendar myCalendar = new MyCalendar();
myCalendar.book(10, 20); // return True
myCalendar.book(15, 25); // return False, It can not be booked because time 15 is already booked by another event.
myCalendar.book(20, 30); // return True, The event can be booked, as the first event takes every time less than 20, but not including 20.

**Constraints:**

*   `0 <= start < end <= 109`
*   At most `1000` calls will be made to `book`.
Count Different Palindromic Subsequences

Given a string s, return _the number of different non-empty palindromic subsequences in_ `s`. Since the answer may be very large, return it **modulo** `109 + 7`.

A subsequence of a string is obtained by deleting zero or more characters from the string.

A sequence is palindromic if it is equal to the sequence reversed.

Two sequences `a1, a2, ...` and `b1, b2, ...` are different if there is some `i` for which `ai != bi`.

**Example 1:**

**Input:** s =  "bccb "
**Output:** 6
**Explanation:** The 6 different non-empty palindromic subsequences are 'b', 'c', 'bb', 'cc', 'bcb', 'bccb'.
Note that 'bcb' is counted only once, even though it occurs twice.

**Example 2:**

**Input:** s =  "abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba "
**Output:** 104860361
**Explanation:** There are 3104860382 different non-empty palindromic subsequences, which is 104860361 modulo 109 + 7.

**Constraints:**

*   `1 <= s.length <= 1000`
*   `s[i]` is either `'a'`, `'b'`, `'c'`, or `'d'`.
My Calendar II

You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a **triple booking**.

A **triple booking** happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).

The event can be represented as a pair of integers `start` and `end` that represents a booking on the half-open interval `[start, end)`, the range of real numbers `x` such that `start <= x < end`.

Implement the `MyCalendarTwo` class:

*   `MyCalendarTwo()` Initializes the calendar object.
*   `boolean book(int start, int end)` Returns `true` if the event can be added to the calendar successfully without causing a **triple booking**. Otherwise, return `false` and do not add the event to the calendar.

**Example 1:**

**Input**
\[ "MyCalendarTwo ",  "book ",  "book ",  "book ",  "book ",  "book ",  "book "\]
\[\[\], \[10, 20\], \[50, 60\], \[10, 40\], \[5, 15\], \[5, 10\], \[25, 55\]\]
**Output**
\[null, true, true, true, false, true, true\]

**Explanation**
MyCalendarTwo myCalendarTwo = new MyCalendarTwo();
myCalendarTwo.book(10, 20); // return True, The event can be booked. 
myCalendarTwo.book(50, 60); // return True, The event can be booked. 
myCalendarTwo.book(10, 40); // return True, The event can be double booked. 
myCalendarTwo.book(5, 15);  // return False, The event cannot be booked, because it would result in a triple booking.
myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked.
myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in \[25, 40) will be double booked with the third event, the time \[40, 50) will be single booked, and the time \[50, 55) will be double booked with the second event.

**Constraints:**

*   `0 <= start < end <= 109`
*   At most `1000` calls will be made to `book`.