bowang0911/leetcode huggingface dataset:
Check If a Word Occurs As a Prefix of Any Word in a Sentence

Given a `sentence` that consists of some words separated by a **single space**, and a `searchWord`, check if `searchWord` is a prefix of any word in `sentence`.

Return _the index of the word in_ `sentence` _(**1-indexed**) where_ `searchWord` _is a prefix of this word_. If `searchWord` is a prefix of more than one word, return the index of the first word **(minimum index)**. If there is no such word return `-1`.

A **prefix** of a string `s` is any leading contiguous substring of `s`.

**Example 1:**

**Input:** sentence =  "i love eating burger ", searchWord =  "burg "
**Output:** 4
**Explanation:**  "burg " is prefix of  "burger " which is the 4th word in the sentence.

**Example 2:**

**Input:** sentence =  "this problem is an easy problem ", searchWord =  "pro "
**Output:** 2
**Explanation:**  "pro " is prefix of  "problem " which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.

**Example 3:**

**Input:** sentence =  "i am tired ", searchWord =  "you "
**Output:** -1
**Explanation:**  "you " is not a prefix of any word in the sentence.

**Constraints:**

*   `1 <= sentence.length <= 100`
*   `1 <= searchWord.length <= 10`
*   `sentence` consists of lowercase English letters and spaces.
*   `searchWord` consists of lowercase English letters.
Maximum Number of Vowels in a Substring of Given Length

Given a string `s` and an integer `k`, return _the maximum number of vowel letters in any substring of_ `s` _with length_ `k`.

**Vowel letters** in English are `'a'`, `'e'`, `'i'`, `'o'`, and `'u'`.

**Example 1:**

**Input:** s =  "abciiidef ", k = 3
**Output:** 3
**Explanation:** The substring  "iii " contains 3 vowel letters.

**Example 2:**

**Input:** s =  "aeiou ", k = 2
**Output:** 2
**Explanation:** Any substring of length 2 contains 2 vowels.

**Example 3:**

**Input:** s =  "leetcode ", k = 3
**Output:** 2
**Explanation:**  "lee ",  "eet " and  "ode " contain 2 vowels.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s` consists of lowercase English letters.
*   `1 <= k <= s.length`
Pseudo-Palindromic Paths in a Binary Tree

Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be **pseudo-palindromic** if at least one permutation of the node values in the path is a palindrome.

_Return the number of **pseudo-palindromic** paths going from the root node to leaf nodes._

**Example 1:**

**Input:** root = \[2,3,1,3,1,null,1\]
**Output:** 2 
**Explanation:** The figure above represents the given binary tree. There are three paths going from the root node to leaf nodes: the red path \[2,3,3\], the green path \[2,1,1\], and the path \[2,3,1\]. Among these paths only red path and green path are pseudo-palindromic paths since the red path \[2,3,3\] can be rearranged in \[3,2,3\] (palindrome) and the green path \[2,1,1\] can be rearranged in \[1,2,1\] (palindrome).

**Example 2:**

**Input:** root = \[2,1,1,1,3,null,null,null,null,null,1\]
**Output:** 1 
**Explanation:** The figure above represents the given binary tree. There are three paths going from the root node to leaf nodes: the green path \[2,1,1\], the path \[2,1,3,1\], and the path \[2,1\]. Among these paths only the green path is pseudo-palindromic since \[2,1,1\] can be rearranged in \[1,2,1\] (palindrome).

**Example 3:**

**Input:** root = \[9\]
**Output:** 1

**Constraints:**

*   The number of nodes in the tree is in the range `[1, 105]`.
*   `1 <= Node.val <= 9`
Max Dot Product of Two Subsequences

Given two arrays `nums1` and `nums2`.

Return the maximum dot product between **non-empty** subsequences of nums1 and nums2 with the same length.

A subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, `[2,3,5]` is a subsequence of `[1,2,3,4,5]` while `[1,5,3]` is not).

**Example 1:**

**Input:** nums1 = \[2,1,-2,5\], nums2 = \[3,0,-6\]
**Output:** 18
**Explanation:** Take subsequence \[2,-2\] from nums1 and subsequence \[3,-6\] from nums2.
Their dot product is (2\*3 + (-2)\*(-6)) = 18.

**Example 2:**

**Input:** nums1 = \[3,-2\], nums2 = \[2,-6,7\]
**Output:** 21
**Explanation:** Take subsequence \[3\] from nums1 and subsequence \[7\] from nums2.
Their dot product is (3\*7) = 21.

**Example 3:**

**Input:** nums1 = \[-1,-1\], nums2 = \[1,1\]
**Output:** -1
**Explanation:** Take subsequence \[-1\] from nums1 and subsequence \[1\] from nums2.
Their dot product is -1.

**Constraints:**

*   `1 <= nums1.length, nums2.length <= 500`
*   `-1000 <= nums1[i], nums2[i] <= 1000`
Make Two Arrays Equal by Reversing Subarrays

You are given two integer arrays of equal length `target` and `arr`. In one step, you can select any **non-empty subarray** of `arr` and reverse it. You are allowed to make any number of steps.

Return `true` _if you can make_ `arr` _equal to_ `target` _or_ `false` _otherwise_.

**Example 1:**

**Input:** target = \[1,2,3,4\], arr = \[2,4,1,3\]
**Output:** true
**Explanation:** You can follow the next steps to convert arr to target:
1- Reverse subarray \[2,4,1\], arr becomes \[1,4,2,3\]
2- Reverse subarray \[4,2\], arr becomes \[1,2,4,3\]
3- Reverse subarray \[4,3\], arr becomes \[1,2,3,4\]
There are multiple ways to convert arr to target, this is not the only way to do so.

**Example 2:**

**Input:** target = \[7\], arr = \[7\]
**Output:** true
**Explanation:** arr is equal to target without any reverses.

**Example 3:**

**Input:** target = \[3,7,9\], arr = \[3,7,11\]
**Output:** false
**Explanation:** arr does not have value 9 and it can never be converted to target.

**Constraints:**

*   `target.length == arr.length`
*   `1 <= target.length <= 1000`
*   `1 <= target[i] <= 1000`
*   `1 <= arr[i] <= 1000`
Check If a String Contains All Binary Codes of Size K

Given a binary string `s` and an integer `k`, return `true` _if every binary code of length_ `k` _is a substring of_ `s`. Otherwise, return `false`.

**Example 1:**

**Input:** s =  "00110110 ", k = 2
**Output:** true
**Explanation:** The binary codes of length 2 are  "00 ",  "01 ",  "10 " and  "11 ". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.

**Example 2:**

**Input:** s =  "0110 ", k = 1
**Output:** true
**Explanation:** The binary codes of length 1 are  "0 " and  "1 ", it is clear that both exist as a substring. 

**Example 3:**

**Input:** s =  "0110 ", k = 2
**Output:** false
**Explanation:** The binary code  "00 " is of length 2 and does not exist in the array.

**Constraints:**

*   `1 <= s.length <= 5 * 105`
*   `s[i]` is either `'0'` or `'1'`.
*   `1 <= k <= 20`
Course Schedule IV

There are a total of `numCourses` courses you have to take, labeled from `0` to `numCourses - 1`. You are given an array `prerequisites` where `prerequisites[i] = [ai, bi]` indicates that you **must** take course `ai` first if you want to take course `bi`.

*   For example, the pair `[0, 1]` indicates that you have to take course `0` before you can take course `1`.

Prerequisites can also be **indirect**. If course `a` is a prerequisite of course `b`, and course `b` is a prerequisite of course `c`, then course `a` is a prerequisite of course `c`.

You are also given an array `queries` where `queries[j] = [uj, vj]`. For the `jth` query, you should answer whether course `uj` is a prerequisite of course `vj` or not.

Return _a boolean array_ `answer`_, where_ `answer[j]` _is the answer to the_ `jth` _query._

**Example 1:**

**Input:** numCourses = 2, prerequisites = \[\[1,0\]\], queries = \[\[0,1\],\[1,0\]\]
**Output:** \[false,true\]
**Explanation:** The pair \[1, 0\] indicates that you have to take course 1 before you can take course 0.
Course 0 is not a prerequisite of course 1, but the opposite is true.

**Example 2:**

**Input:** numCourses = 2, prerequisites = \[\], queries = \[\[1,0\],\[0,1\]\]
**Output:** \[false,false\]
**Explanation:** There are no prerequisites, and each course is independent.

**Example 3:**

**Input:** numCourses = 3, prerequisites = \[\[1,2\],\[1,0\],\[2,0\]\], queries = \[\[1,0\],\[1,2\]\]
**Output:** \[true,true\]

**Constraints:**

*   `2 <= numCourses <= 100`
*   `0 <= prerequisites.length <= (numCourses * (numCourses - 1) / 2)`
*   `prerequisites[i].length == 2`
*   `0 <= ai, bi <= n - 1`
*   `ai != bi`
*   All the pairs `[ai, bi]` are **unique**.
*   The prerequisites graph has no cycles.
*   `1 <= queries.length <= 104`
*   `0 <= ui, vi <= n - 1`
*   `ui != vi`
Cherry Pickup II

You are given a `rows x cols` matrix `grid` representing a field of cherries where `grid[i][j]` represents the number of cherries that you can collect from the `(i, j)` cell.

You have two robots that can collect cherries for you:

*   **Robot #1** is located at the **top-left corner** `(0, 0)`, and
*   **Robot #2** is located at the **top-right corner** `(0, cols - 1)`.

Return _the maximum number of cherries collection using both robots by following the rules below_:

*   From a cell `(i, j)`, robots can move to cell `(i + 1, j - 1)`, `(i + 1, j)`, or `(i + 1, j + 1)`.
*   When any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.
*   When both robots stay in the same cell, only one takes the cherries.
*   Both robots cannot move outside of the grid at any moment.
*   Both robots should reach the bottom row in `grid`.

**Example 1:**

**Input:** grid = \[\[3,1,1\],\[2,5,1\],\[1,5,5\],\[2,1,1\]\]
**Output:** 24
**Explanation:** Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.
Cherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.
Total of cherries: 12 + 12 = 24.

**Example 2:**

**Input:** grid = \[\[1,0,0,0,0,0,1\],\[2,0,0,0,0,3,0\],\[2,0,9,0,0,0,0\],\[0,3,0,5,4,0,0\],\[1,0,2,3,0,0,6\]\]
**Output:** 28
**Explanation:** Path of robot #1 and #2 are described in color green and blue respectively.
Cherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.
Cherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.
Total of cherries: 17 + 11 = 28.

**Constraints:**

*   `rows == grid.length`
*   `cols == grid[i].length`
*   `2 <= rows, cols <= 70`
*   `0 <= grid[i][j] <= 100`
Maximum Product of Two Elements in an Array

Given the array of integers `nums`, you will choose two different indices `i` and `j` of that array. _Return the maximum value of_ `(nums[i]-1)*(nums[j]-1)`.

**Example 1:**

**Input:** nums = \[3,4,5,2\]
**Output:** 12 
**Explanation:** If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums\[1\]-1)\*(nums\[2\]-1) = (4-1)\*(5-1) = 3\*4 = 12. 

**Example 2:**

**Input:** nums = \[1,5,4,5\]
**Output:** 16
**Explanation:** Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)\*(5-1) = 16.

**Example 3:**

**Input:** nums = \[3,7\]
**Output:** 12

**Constraints:**

*   `2 <= nums.length <= 500`
*   `1 <= nums[i] <= 10^3`
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts

You are given a rectangular cake of size `h x w` and two arrays of integers `horizontalCuts` and `verticalCuts` where:

*   `horizontalCuts[i]` is the distance from the top of the rectangular cake to the `ith` horizontal cut and similarly, and
*   `verticalCuts[j]` is the distance from the left of the rectangular cake to the `jth` vertical cut.

Return _the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays_ `horizontalCuts` _and_ `verticalCuts`. Since the answer can be a large number, return this **modulo** `109 + 7`.

**Example 1:**

**Input:** h = 5, w = 4, horizontalCuts = \[1,2,4\], verticalCuts = \[1,3\]
**Output:** 4 
**Explanation:** The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.

**Example 2:**

**Input:** h = 5, w = 4, horizontalCuts = \[3,1\], verticalCuts = \[1\]
**Output:** 6
**Explanation:** The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.

**Example 3:**

**Input:** h = 5, w = 4, horizontalCuts = \[3\], verticalCuts = \[3\]
**Output:** 9

**Constraints:**

*   `2 <= h, w <= 109`
*   `1 <= horizontalCuts.length <= min(h - 1, 105)`
*   `1 <= verticalCuts.length <= min(w - 1, 105)`
*   `1 <= horizontalCuts[i] < h`
*   `1 <= verticalCuts[i] < w`
*   All the elements in `horizontalCuts` are distinct.
*   All the elements in `verticalCuts` are distinct.
Reorder Routes to Make All Paths Lead to the City Zero

There are `n` cities numbered from `0` to `n - 1` and `n - 1` roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.

Roads are represented by `connections` where `connections[i] = [ai, bi]` represents a road from city `ai` to city `bi`.

This year, there will be a big event in the capital (city `0`), and many people want to travel to this city.

Your task consists of reorienting some roads such that each city can visit the city `0`. Return the **minimum** number of edges changed.

It's **guaranteed** that each city can reach city `0` after reorder.

**Example 1:**

**Input:** n = 6, connections = \[\[0,1\],\[1,3\],\[2,3\],\[4,0\],\[4,5\]\]
**Output:** 3
**Explanation:** Change the direction of edges show in red such that each node can reach the node 0 (capital).

**Example 2:**

**Input:** n = 5, connections = \[\[1,0\],\[1,2\],\[3,2\],\[3,4\]\]
**Output:** 2
**Explanation:** Change the direction of edges show in red such that each node can reach the node 0 (capital).

**Example 3:**

**Input:** n = 3, connections = \[\[1,0\],\[2,0\]\]
**Output:** 0

**Constraints:**

*   `2 <= n <= 5 * 104`
*   `connections.length == n - 1`
*   `connections[i].length == 2`
*   `0 <= ai, bi <= n - 1`
*   `ai != bi`
Probability of a Two Boxes Having The Same Number of Distinct Balls

Given `2n` balls of `k` distinct colors. You will be given an integer array `balls` of size `k` where `balls[i]` is the number of balls of color `i`.

All the balls will be **shuffled uniformly at random**, then we will distribute the first `n` balls to the first box and the remaining `n` balls to the other box (Please read the explanation of the second example carefully).

Please note that the two boxes are considered different. For example, if we have two balls of colors `a` and `b`, and two boxes `[]` and `()`, then the distribution `[a] (b)` is considered different than the distribution `[b] (a)` (Please read the explanation of the first example carefully).

Return _the probability_ that the two boxes have the same number of distinct balls. Answers within `10-5` of the actual value will be accepted as correct.

**Example 1:**

**Input:** balls = \[1,1\]
**Output:** 1.00000
**Explanation:** Only 2 ways to divide the balls equally:
- A ball of color 1 to box 1 and a ball of color 2 to box 2
- A ball of color 2 to box 1 and a ball of color 1 to box 2
In both ways, the number of distinct colors in each box is equal. The probability is 2/2 = 1

**Example 2:**

**Input:** balls = \[2,1,1\]
**Output:** 0.66667
**Explanation:** We have the set of balls \[1, 1, 2, 3\]
This set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12):
\[1,1 / 2,3\], \[1,1 / 3,2\], \[1,2 / 1,3\], \[1,2 / 3,1\], \[1,3 / 1,2\], \[1,3 / 2,1\], \[2,1 / 1,3\], \[2,1 / 3,1\], \[2,3 / 1,1\], \[3,1 / 1,2\], \[3,1 / 2,1\], \[3,2 / 1,1\]
After that, we add the first two balls to the first box and the second two balls to the second box.
We can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box.
Probability is 8/12 = 0.66667

**Example 3:**

**Input:** balls = \[1,2,1,2\]
**Output:** 0.60000
**Explanation:** The set of balls is \[1, 2, 2, 3, 4, 4\]. It is hard to display all the 180 possible random shuffles of this set but it is easy to check that 108 of them will have the same number of distinct colors in each box.
Probability = 108 / 180 = 0.6

**Constraints:**

*   `1 <= balls.length <= 8`
*   `1 <= balls[i] <= 6`
*   `sum(balls)` is even.
Find All The Lonely Nodes

In a binary tree, a **lonely** node is a node that is the only child of its parent node. The root of the tree is not lonely because it does not have a parent node.

Given the `root` of a binary tree, return _an array containing the values of all lonely nodes_ in the tree. Return the list **in any order**.

**Example 1:**

**Input:** root = \[1,2,3,null,4\]
**Output:** \[4\]
**Explanation:** Light blue node is the only lonely node.
Node 1 is the root and is not lonely.
Nodes 2 and 3 have the same parent and are not lonely.

**Example 2:**

**Input:** root = \[7,1,4,6,null,5,3,null,null,null,null,null,2\]
**Output:** \[6,2\]
**Explanation:** Light blue nodes are lonely nodes.
Please remember that order doesn't matter, \[2,6\] is also an acceptable answer.

**Example 3:**

**Input:** root = \[11,99,88,77,null,null,66,55,null,null,44,33,null,null,22\]
**Output:** \[77,55,33,66,44,22\]
**Explanation:** Nodes 99 and 88 share the same parent. Node 11 is the root.
All other nodes are lonely.

**Constraints:**

*   The number of nodes in the `tree` is in the range `[1, 1000].`
*   `1 <= Node.val <= 106`
Shuffle the Array

Given the array `nums` consisting of `2n` elements in the form `[x1,x2,...,xn,y1,y2,...,yn]`.

_Return the array in the form_ `[x1,y1,x2,y2,...,xn,yn]`.

**Example 1:**

**Input:** nums = \[2,5,1,3,4,7\], n = 3
**Output:** \[2,3,5,4,1,7\] 
**Explanation:** Since x1\=2, x2\=5, x3\=1, y1\=3, y2\=4, y3\=7 then the answer is \[2,3,5,4,1,7\].

**Example 2:**

**Input:** nums = \[1,2,3,4,4,3,2,1\], n = 4
**Output:** \[1,4,2,3,3,2,4,1\]

**Example 3:**

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

**Constraints:**

*   `1 <= n <= 500`
*   `nums.length == 2n`
*   `1 <= nums[i] <= 10^3`
The k Strongest Values in an Array

Given an array of integers `arr` and an integer `k`.

A value `arr[i]` is said to be stronger than a value `arr[j]` if `|arr[i] - m| > |arr[j] - m|` where `m` is the **median** of the array.  
If `|arr[i] - m| == |arr[j] - m|`, then `arr[i]` is said to be stronger than `arr[j]` if `arr[i] > arr[j]`.

Return _a list of the strongest `k`_ values in the array. return the answer **in any arbitrary order**.

**Median** is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position `((n - 1) / 2)` in the sorted list **(0-indexed)**.

*   For `arr = [6, -3, 7, 2, 11]`, `n = 5` and the median is obtained by sorting the array `arr = [-3, 2, 6, 7, 11]` and the median is `arr[m]` where `m = ((5 - 1) / 2) = 2`. The median is `6`.
*   For `arr = [-7, 22, 17, 3]`, `n = 4` and the median is obtained by sorting the array `arr = [-7, 3, 17, 22]` and the median is `arr[m]` where `m = ((4 - 1) / 2) = 1`. The median is `3`.

**Example 1:**

**Input:** arr = \[1,2,3,4,5\], k = 2
**Output:** \[5,1\]
**Explanation:** Median is 3, the elements of the array sorted by the strongest are \[5,1,4,2,3\]. The strongest 2 elements are \[5, 1\]. \[1, 5\] is also **accepted** answer.
Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 > 1.

**Example 2:**

**Input:** arr = \[1,1,3,5,5\], k = 2
**Output:** \[5,5\]
**Explanation:** Median is 3, the elements of the array sorted by the strongest are \[5,5,1,1,3\]. The strongest 2 elements are \[5, 5\].

**Example 3:**

**Input:** arr = \[6,7,11,7,6,8\], k = 5
**Output:** \[11,8,6,6,7\]
**Explanation:** Median is 7, the elements of the array sorted by the strongest are \[11,8,6,6,7,7\].
Any permutation of \[11,8,6,6,7\] is **accepted**.

**Constraints:**

*   `1 <= arr.length <= 105`
*   `-105 <= arr[i] <= 105`
*   `1 <= k <= arr.length`
Design Browser History

You have a **browser** of one tab where you start on the `homepage` and you can visit another `url`, get back in the history number of `steps` or move forward in the history number of `steps`.

Implement the `BrowserHistory` class:

*   `BrowserHistory(string homepage)` Initializes the object with the `homepage` of the browser.
*   `void visit(string url)` Visits `url` from the current page. It clears up all the forward history.
*   `string back(int steps)` Move `steps` back in history. If you can only return `x` steps in the history and `steps > x`, you will return only `x` steps. Return the current `url` after moving back in history **at most** `steps`.
*   `string forward(int steps)` Move `steps` forward in history. If you can only forward `x` steps in the history and `steps > x`, you will forward only `x` steps. Return the current `url` after forwarding in history **at most** `steps`.

**Example:**

**Input:**
\[ "BrowserHistory ", "visit ", "visit ", "visit ", "back ", "back ", "forward ", "visit ", "forward ", "back ", "back "\]
\[\[ "leetcode.com "\],\[ "google.com "\],\[ "facebook.com "\],\[ "youtube.com "\],\[1\],\[1\],\[1\],\[ "linkedin.com "\],\[2\],\[2\],\[7\]\]
**Output:**
\[null,null,null,null, "facebook.com ", "google.com ", "facebook.com ",null, "linkedin.com ", "google.com ", "leetcode.com "\]

**Explanation:**
BrowserHistory browserHistory = new BrowserHistory( "leetcode.com ");
browserHistory.visit( "google.com ");       // You are in  "leetcode.com ". Visit  "google.com "
browserHistory.visit( "facebook.com ");     // You are in  "google.com ". Visit  "facebook.com "
browserHistory.visit( "youtube.com ");      // You are in  "facebook.com ". Visit  "youtube.com "
browserHistory.back(1);                   // You are in  "youtube.com ", move back to  "facebook.com " return  "facebook.com "
browserHistory.back(1);                   // You are in  "facebook.com ", move back to  "google.com " return  "google.com "
browserHistory.forward(1);                // You are in  "google.com ", move forward to  "facebook.com " return  "facebook.com "
browserHistory.visit( "linkedin.com ");     // You are in  "facebook.com ". Visit  "linkedin.com "
browserHistory.forward(2);                // You are in  "linkedin.com ", you cannot move forward any steps.
browserHistory.back(2);                   // You are in  "linkedin.com ", move back two steps to  "facebook.com " then to  "google.com ". return  "google.com "
browserHistory.back(7);                   // You are in  "google.com ", you can move back only one step to  "leetcode.com ". return  "leetcode.com "

**Constraints:**

*   `1 <= homepage.length <= 20`
*   `1 <= url.length <= 20`
*   `1 <= steps <= 100`
*   `homepage` and `url` consist of '.' or lower case English letters.
*   At most `5000` calls will be made to `visit`, `back`, and `forward`.