bowang0911/leetcode huggingface dataset:
Guess the Majority in a Hidden Array

We have an integer array `nums`, where all the integers in `nums` are **0** or **1**. You will not be given direct access to the array, instead, you will have an **API** `ArrayReader` which have the following functions:

*   `int query(int a, int b, int c, int d)`: where `0 <= a < b < c < d < ArrayReader.length()`. The function returns the distribution of the value of the 4 elements and returns:
    *   **4** : if the values of the 4 elements are the same (0 or 1).
    *   **2** : if three elements have a value equal to 0 and one element has value equal to 1 or vice versa.
    *   **0** : if two element have a value equal to 0 and two elements have a value equal to 1.
*   `int length()`: Returns the size of the array.

You are allowed to call `query()` **2 \* n times** at most where n is equal to `ArrayReader.length()`.

Return **any** index of the most frequent value in `nums`, in case of tie, return -1.

**Example 1:**

**Input:** nums = \[0,0,1,0,1,1,1,1\]
**Output:** 5
**Explanation:** The following calls to the API
reader.length() // returns 8 because there are 8 elements in the hidden array.
reader.query(0,1,2,3) // returns 2 this is a query that compares the elements nums\[0\], nums\[1\], nums\[2\], nums\[3\]
// Three elements have a value equal to 0 and one element has value equal to 1 or viceversa.
reader.query(4,5,6,7) // returns 4 because nums\[4\], nums\[5\], nums\[6\], nums\[7\] have the same value.
we can infer that the most frequent value is found in the last 4 elements.
Index 2, 4, 6, 7 is also a correct answer.

**Example 2:**

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

**Example 3:**

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

**Constraints:**

*   `5 <= nums.length <= 105`
*   `0 <= nums[i] <= 1`

**Follow up:** What is the minimum number of calls needed to find the majority element?
Kth Missing Positive Number

Given an array `arr` of positive integers sorted in a **strictly increasing order**, and an integer `k`.

Return _the_ `kth` _**positive** integer that is **missing** from this array._

**Example 1:**

**Input:** arr = \[2,3,4,7,11\], k = 5
**Output:** 9
**Explanation:** The missing positive integers are \[1,5,6,8,9,10,12,13,...\]. The 5th missing positive integer is 9.

**Example 2:**

**Input:** arr = \[1,2,3,4\], k = 2
**Output:** 6
**Explanation:** The missing positive integers are \[5,6,7,...\]. The 2nd missing positive integer is 6.

**Constraints:**

*   `1 <= arr.length <= 1000`
*   `1 <= arr[i] <= 1000`
*   `1 <= k <= 1000`
*   `arr[i] < arr[j]` for `1 <= i < j <= arr.length`

**Follow up:**

Could you solve this problem in less than O(n) complexity?
Can Convert String in K Moves

Given two strings `s` and `t`, your goal is to convert `s` into `t` in `k` moves or less.

During the `ith` (`1 <= i <= k`) move you can:

*   Choose any index `j` (1-indexed) from `s`, such that `1 <= j <= s.length` and `j` has not been chosen in any previous move, and shift the character at that index `i` times.
*   Do nothing.

Shifting a character means replacing it by the next letter in the alphabet (wrapping around so that `'z'` becomes `'a'`). Shifting a character by `i` means applying the shift operations `i` times.

Remember that any index `j` can be picked at most once.

Return `true` if it's possible to convert `s` into `t` in no more than `k` moves, otherwise return `false`.

**Example 1:**

**Input:** s =  "input ", t =  "ouput ", k = 9
**Output:** true
**Explanation:** In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.

**Example 2:**

**Input:** s =  "abc ", t =  "bcd ", k = 10
**Output:** false
**Explanation:** We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.

**Example 3:**

**Input:** s =  "aab ", t =  "bbb ", k = 27
**Output:** true
**Explanation:** In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.

**Constraints:**

*   `1 <= s.length, t.length <= 10^5`
*   `0 <= k <= 10^9`
*   `s`, `t` contain only lowercase English letters.
Minimum Insertions to Balance a Parentheses String

Given a parentheses string `s` containing only the characters `'('` and `')'`. A parentheses string is **balanced** if:

*   Any left parenthesis `'('` must have a corresponding two consecutive right parenthesis `'))'`.
*   Left parenthesis `'('` must go before the corresponding two consecutive right parenthesis `'))'`.

In other words, we treat `'('` as an opening parenthesis and `'))'` as a closing parenthesis.

*   For example, `"()) "`, `"())(()))) "` and `"(())()))) "` are balanced, `")() "`, `"())) "` and `"(())) "` are not balanced.

You can insert the characters `'('` and `')'` at any position of the string to balance it if needed.

Return _the minimum number of insertions_ needed to make `s` balanced.

**Example 1:**

**Input:** s =  "(())) "
**Output:** 1
**Explanation:** The second '(' has two matching '))', but the first '(' has only ')' matching. We need to add one more ')' at the end of the string to be  "(()))) " which is balanced.

**Example 2:**

**Input:** s =  "()) "
**Output:** 0
**Explanation:** The string is already balanced.

**Example 3:**

**Input:** s =  "))())( "
**Output:** 3
**Explanation:** Add '(' to match the first '))', Add '))' to match the last '('.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s` consists of `'('` and `')'` only.
Find Longest Awesome Substring

You are given a string `s`. An **awesome** substring is a non-empty substring of `s` such that we can make any number of swaps in order to make it a palindrome.

Return _the length of the maximum length **awesome substring** of_ `s`.

**Example 1:**

**Input:** s =  "3242415 "
**Output:** 5
**Explanation:**  "24241 " is the longest awesome substring, we can form the palindrome  "24142 " with some swaps.

**Example 2:**

**Input:** s =  "12345678 "
**Output:** 1

**Example 3:**

**Input:** s =  "213123 "
**Output:** 6
**Explanation:**  "213123 " is the longest awesome substring, we can form the palindrome  "231132 " with some swaps.

**Constraints:**

*   `1 <= s.length <= 105`
*   `s` consists only of digits.
Make The String Great

Given a string `s` of lower and upper case English letters.

A good string is a string which doesn't have **two adjacent characters** `s[i]` and `s[i + 1]` where:

*   `0 <= i <= s.length - 2`
*   `s[i]` is a lower-case letter and `s[i + 1]` is the same letter but in upper-case or **vice-versa**.

To make the string good, you can choose **two adjacent** characters that make the string bad and remove them. You can keep doing this until the string becomes good.

Return _the string_ after making it good. The answer is guaranteed to be unique under the given constraints.

**Notice** that an empty string is also good.

**Example 1:**

**Input:** s =  "leEeetcode "
**Output:**  "leetcode "
**Explanation:** In the first step, either you choose i = 1 or i = 2, both will result  "leEeetcode " to be reduced to  "leetcode ".

**Example 2:**

**Input:** s =  "abBAcC "
**Output:**  " "
**Explanation:** We have many possible scenarios, and all lead to the same answer. For example:
 "abBAcC " -->  "aAcC " -->  "cC " -->  " "
 "abBAcC " -->  "abBA " -->  "aA " -->  " "

**Example 3:**

**Input:** s =  "s "
**Output:**  "s "

**Constraints:**

*   `1 <= s.length <= 100`
*   `s` contains only lower and upper case English letters.
Find Kth Bit in Nth Binary String

Given two positive integers `n` and `k`, the binary string `Sn` is formed as follows:

*   `S1 = "0 "`
*   `Si = Si - 1 + "1 " + reverse(invert(Si - 1))` for `i > 1`

Where `+` denotes the concatenation operation, `reverse(x)` returns the reversed string `x`, and `invert(x)` inverts all the bits in `x` (`0` changes to `1` and `1` changes to `0`).

For example, the first four strings in the above sequence are:

*   `S1 = "0 "`
*   `S2 = "0**1**1 "`
*   `S3 = "011**1**001 "`
*   `S4 = "0111001**1**0110001 "`

Return _the_ `kth` _bit_ _in_ `Sn`. It is guaranteed that `k` is valid for the given `n`.

**Example 1:**

**Input:** n = 3, k = 1
**Output:**  "0 "
**Explanation:** S3 is  "**0**111001 ".
The 1st bit is  "0 ".

**Example 2:**

**Input:** n = 4, k = 11
**Output:**  "1 "
**Explanation:** S4 is  "0111001101**1**0001 ".
The 11th bit is  "1 ".

**Constraints:**

*   `1 <= n <= 20`
*   `1 <= k <= 2n - 1`
Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Given an array `nums` and an integer `target`, return _the maximum number of **non-empty** **non-overlapping** subarrays such that the sum of values in each subarray is equal to_ `target`.

**Example 1:**

**Input:** nums = \[1,1,1,1,1\], target = 2
**Output:** 2
**Explanation:** There are 2 non-overlapping subarrays \[**1,1**,1,**1,1**\] with sum equals to target(2).

**Example 2:**

**Input:** nums = \[-1,3,5,1,4,2,-9\], target = 6
**Output:** 2
**Explanation:** There are 3 subarrays with sum equal to 6.
(\[5,1\], \[4,2\], \[3,5,1,4,2,-9\]) but only the first 2 are non-overlapping.

**Constraints:**

*   `1 <= nums.length <= 105`
*   `-104 <= nums[i] <= 104`
*   `0 <= target <= 106`
Minimum Cost to Cut a Stick

Given a wooden stick of length `n` units. The stick is labelled from `0` to `n`. For example, a stick of length **6** is labelled as follows:

Given an integer array `cuts` where `cuts[i]` denotes a position you should perform a cut at.

You should perform the cuts in order, you can change the order of the cuts as you wish.

The cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.

Return _the minimum total cost_ of the cuts.

**Example 1:**

**Input:** n = 7, cuts = \[1,3,4,5\]
**Output:** 16
**Explanation:** Using cuts order = \[1, 3, 4, 5\] as in the input leads to the following scenario:
 
The first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20.
Rearranging the cuts to be \[3, 5, 1, 4\] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).

**Example 2:**

**Input:** n = 9, cuts = \[5,6,1,4,2\]
**Output:** 22
**Explanation:** If you try the given cuts ordering the cost will be 25.
There are much ordering with total cost <= 25, for example, the order \[4, 6, 5, 2, 1\] has total cost = 22 which is the minimum possible.

**Constraints:**

*   `2 <= n <= 106`
*   `1 <= cuts.length <= min(n - 1, 100)`
*   `1 <= cuts[i] <= n - 1`
*   All the integers in `cuts` array are **distinct**.
The Most Similar Path in a Graph

We have `n` cities and `m` bi-directional `roads` where `roads[i] = [ai, bi]` connects city `ai` with city `bi`. Each city has a name consisting of exactly three upper-case English letters given in the string array `names`. Starting at any city `x`, you can reach any city `y` where `y != x` (i.e., the cities and the roads are forming an undirected connected graph).

You will be given a string array `targetPath`. You should find a path in the graph of the **same length** and with the **minimum edit distance** to `targetPath`.

You need to return _the order of the nodes in the path with the minimum edit distance_. The path should be of the same length of `targetPath` and should be valid (i.e., there should be a direct road between `ans[i]` and `ans[i + 1]`). If there are multiple answers return any one of them.

The **edit distance** is defined as follows:

**Example 1:**

**Input:** n = 5, roads = \[\[0,2\],\[0,3\],\[1,2\],\[1,3\],\[1,4\],\[2,4\]\], names = \[ "ATL ", "PEK ", "LAX ", "DXB ", "HND "\], targetPath = \[ "ATL ", "DXB ", "HND ", "LAX "\]
**Output:** \[0,2,4,2\]
**Explanation:** \[0,2,4,2\], \[0,3,0,2\] and \[0,3,1,2\] are accepted answers.
\[0,2,4,2\] is equivalent to \[ "ATL ", "LAX ", "HND ", "LAX "\] which has edit distance = 1 with targetPath.
\[0,3,0,2\] is equivalent to \[ "ATL ", "DXB ", "ATL ", "LAX "\] which has edit distance = 1 with targetPath.
\[0,3,1,2\] is equivalent to \[ "ATL ", "DXB ", "PEK ", "LAX "\] which has edit distance = 1 with targetPath.

**Example 2:**

**Input:** n = 4, roads = \[\[1,0\],\[2,0\],\[3,0\],\[2,1\],\[3,1\],\[3,2\]\], names = \[ "ATL ", "PEK ", "LAX ", "DXB "\], targetPath = \[ "ABC ", "DEF ", "GHI ", "JKL ", "MNO ", "PQR ", "STU ", "VWX "\]
**Output:** \[0,1,0,1,0,1,0,1\]
**Explanation:** Any path in this graph has edit distance = 8 with targetPath.

**Example 3:**

**Input:** n = 6, roads = \[\[0,1\],\[1,2\],\[2,3\],\[3,4\],\[4,5\]\], names = \[ "ATL ", "PEK ", "LAX ", "ATL ", "DXB ", "HND "\], targetPath = \[ "ATL ", "DXB ", "HND ", "DXB ", "ATL ", "LAX ", "PEK "\]
**Output:** \[3,4,5,4,3,2,1\]
**Explanation:** \[3,4,5,4,3,2,1\] is the only path with edit distance = 0 with targetPath.
It's equivalent to \[ "ATL ", "DXB ", "HND ", "DXB ", "ATL ", "LAX ", "PEK "\]

**Constraints:**

*   `2 <= n <= 100`
*   `m == roads.length`
*   `n - 1 <= m <= (n * (n - 1) / 2)`
*   `0 <= ai, bi <= n - 1`
*   `ai != bi`
*   The graph is guaranteed to be **connected** and each pair of nodes may have **at most one** direct road.
*   `names.length == n`
*   `names[i].length == 3`
*   `names[i]` consists of upper-case English letters.
*   There can be two cities with **the same** name.
*   `1 <= targetPath.length <= 100`
*   `targetPath[i].length == 3`
*   `targetPath[i]` consists of upper-case English letters.

**Follow up:** If each node can be visited only once in the path, What should you change in your solution?
Three Consecutive Odds

Given an integer array `arr`, return `true` if there are three consecutive odd numbers in the array. Otherwise, return `false`.

**Example 1:**

**Input:** arr = \[2,6,4,1\]
**Output:** false
**Explanation:** There are no three consecutive odds.

**Example 2:**

**Input:** arr = \[1,2,34,3,4,5,7,23,12\]
**Output:** true
**Explanation:** \[5,7,23\] are three consecutive odds.

**Constraints:**

*   `1 <= arr.length <= 1000`
*   `1 <= arr[i] <= 1000`
Minimum Operations to Make Array Equal

You have an array `arr` of length `n` where `arr[i] = (2 * i) + 1` for all valid values of `i` (i.e., `0 <= i < n`).

In one operation, you can select two indices `x` and `y` where `0 <= x, y < n` and subtract `1` from `arr[x]` and add `1` to `arr[y]` (i.e., perform `arr[x] -=1` and `arr[y] += 1`). The goal is to make all the elements of the array **equal**. It is **guaranteed** that all the elements of the array can be made equal using some operations.

Given an integer `n`, the length of the array, return _the minimum number of operations_ needed to make all the elements of arr equal.

**Example 1:**

**Input:** n = 3
**Output:** 2
**Explanation:** arr = \[1, 3, 5\]
First operation choose x = 2 and y = 0, this leads arr to be \[2, 3, 4\]
In the second operation choose x = 2 and y = 0 again, thus arr = \[3, 3, 3\].

**Example 2:**

**Input:** n = 6
**Output:** 9

**Constraints:**

*   `1 <= n <= 104`
Magnetic Force Between Two Balls

In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has `n` empty baskets, the `ith` basket is at `position[i]`, Morty has `m` balls and needs to distribute the balls into the baskets such that the **minimum magnetic force** between any two balls is **maximum**.

Rick stated that magnetic force between two different balls at positions `x` and `y` is `|x - y|`.

Given the integer array `position` and the integer `m`. Return _the required force_.

**Example 1:**

**Input:** position = \[1,2,3,4,7\], m = 3
**Output:** 3
**Explanation:** Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs \[3, 3, 6\]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.

**Example 2:**

**Input:** position = \[5,4,3,2,1,1000000000\], m = 2
**Output:** 999999999
**Explanation:** We can use baskets 1 and 1000000000.

**Constraints:**

*   `n == position.length`
*   `2 <= n <= 105`
*   `1 <= position[i] <= 109`
*   All integers in `position` are **distinct**.
*   `2 <= m <= position.length`
Minimum Number of Days to Eat N Oranges

There are `n` oranges in the kitchen and you decided to eat some of these oranges every day as follows:

*   Eat one orange.
*   If the number of remaining oranges `n` is divisible by `2` then you can eat `n / 2` oranges.
*   If the number of remaining oranges `n` is divisible by `3` then you can eat `2 * (n / 3)` oranges.

You can only choose one of the actions per day.

Given the integer `n`, return _the minimum number of days to eat_ `n` _oranges_.

**Example 1:**

**Input:** n = 10
**Output:** 4
**Explanation:** You have 10 oranges.
Day 1: Eat 1 orange,  10 - 1 = 9.  
Day 2: Eat 6 oranges, 9 - 2\*(9/3) = 9 - 6 = 3. (Since 9 is divisible by 3)
Day 3: Eat 2 oranges, 3 - 2\*(3/3) = 3 - 2 = 1. 
Day 4: Eat the last orange  1 - 1  = 0.
You need at least 4 days to eat the 10 oranges.

**Example 2:**

**Input:** n = 6
**Output:** 3
**Explanation:** You have 6 oranges.
Day 1: Eat 3 oranges, 6 - 6/2 = 6 - 3 = 3. (Since 6 is divisible by 2).
Day 2: Eat 2 oranges, 3 - 2\*(3/3) = 3 - 2 = 1. (Since 3 is divisible by 3)
Day 3: Eat the last orange  1 - 1  = 0.
You need at least 3 days to eat the 6 oranges.

**Constraints:**

*   `1 <= n <= 2 * 109`
Strings Differ by One Character

Given a list of strings `dict` where all the strings are of the same length.

Return `true` if there are 2 strings that only differ by 1 character in the same index, otherwise return `false`.

**Example 1:**

**Input:** dict = \[ "abcd ", "acbd ",  "aacd "\]
**Output:** true
**Explanation:** Strings  "a**b**cd " and  "a**a**cd " differ only by one character in the index 1.

**Example 2:**

**Input:** dict = \[ "ab ", "cd ", "yz "\]
**Output:** false

**Example 3:**

**Input:** dict = \[ "abcd ", "cccc ", "abyd ", "abab "\]
**Output:** true

**Constraints:**

*   The number of characters in `dict <= 105`
*   `dict[i].length == dict[j].length`
*   `dict[i]` should be unique.
*   `dict[i]` contains only lowercase English letters.

**Follow up:** Could you solve this problem in `O(n * m)` where n is the length of `dict` and `m` is the length of each string.
Thousand Separator

Given an integer `n`, add a dot ( ". ") as the thousands separator and return it in string format.

**Example 1:**

**Input:** n = 987
**Output:**  "987 "

**Example 2:**

**Input:** n = 1234
**Output:**  "1.234 "

**Constraints:**

*   `0 <= n <= 231 - 1`
Minimum Number of Vertices to Reach All Nodes

Given a **directed acyclic graph**, with `n` vertices numbered from `0` to `n-1`, and an array `edges` where `edges[i] = [fromi, toi]` represents a directed edge from node `fromi` to node `toi`.

Find _the smallest set of vertices from which all nodes in the graph are reachable_. It's guaranteed that a unique solution exists.

Notice that you can return the vertices in any order.

**Example 1:**

**Input:** n = 6, edges = \[\[0,1\],\[0,2\],\[2,5\],\[3,4\],\[4,2\]\]
**Output:** \[0,3\]
**Explanation:** It's not possible to reach all the nodes from a single vertex. From 0 we can reach \[0,1,2,5\]. From 3 we can reach \[3,4,2,5\]. So we output \[0,3\].

**Example 2:**

**Input:** n = 5, edges = \[\[0,1\],\[2,1\],\[3,1\],\[1,4\],\[2,4\]\]
**Output:** \[0,2,3\]
**Explanation:** Notice that vertices 0, 3 and 2 are not reachable from any other node, so we must include them. Also any of these vertices can reach nodes 1 and 4.

**Constraints:**

*   `2 <= n <= 10^5`
*   `1 <= edges.length <= min(10^5, n * (n - 1) / 2)`
*   `edges[i].length == 2`
*   `0 <= fromi, toi < n`
*   All pairs `(fromi, toi)` are distinct.
Minimum Numbers of Function Calls to Make Target Array

You are given an integer array `nums`. You have an integer array `arr` of the same length with all values set to `0` initially. You also have the following `modify` function:

You want to use the modify function to covert `arr` to `nums` using the minimum number of calls.

Return _the minimum number of function calls to make_ `nums` _from_ `arr`.

The test cases are generated so that the answer fits in a **32-bit** signed integer.

**Example 1:**

**Input:** nums = \[1,5\]
**Output:** 5
**Explanation:** Increment by 1 (second element): \[0, 0\] to get \[0, 1\] (1 operation).
Double all the elements: \[0, 1\] -> \[0, 2\] -> \[0, 4\] (2 operations).
Increment by 1 (both elements)  \[0, 4\] -> \[1, 4\] -> **\[1, 5\]** (2 operations).
Total of operations: 1 + 2 + 2 = 5.

**Example 2:**

**Input:** nums = \[2,2\]
**Output:** 3
**Explanation:** Increment by 1 (both elements) \[0, 0\] -> \[0, 1\] -> \[1, 1\] (2 operations).
Double all the elements: \[1, 1\] -> **\[2, 2\]** (1 operation).
Total of operations: 2 + 1 = 3.

**Example 3:**

**Input:** nums = \[4,2,5\]
**Output:** 6
**Explanation:** (initial)\[0,0,0\] -> \[1,0,0\] -> \[1,0,1\] -> \[2,0,2\] -> \[2,1,2\] -> \[4,2,4\] -> **\[4,2,5\]**(nums).

**Constraints:**

*   `1 <= nums.length <= 105`
*   `0 <= nums[i] <= 109`
Detect Cycles in 2D Grid

Given a 2D array of characters `grid` of size `m x n`, you need to find if there exists any cycle consisting of the **same value** in `grid`.

A cycle is a path of **length 4 or more** in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the **same value** of the current cell.

Also, you cannot move to the cell that you visited in your last move. For example, the cycle `(1, 1) -> (1, 2) -> (1, 1)` is invalid because from `(1, 2)` we visited `(1, 1)` which was the last visited cell.

Return `true` if any cycle of the same value exists in `grid`, otherwise, return `false`.

**Example 1:**

**Input:** grid = \[\[ "a ", "a ", "a ", "a "\],\[ "a ", "b ", "b ", "a "\],\[ "a ", "b ", "b ", "a "\],\[ "a ", "a ", "a ", "a "\]\]
**Output:** true
**Explanation:** There are two valid cycles shown in different colors in the image below:
 

**Example 2:**

**Input:** grid = \[\[ "c ", "c ", "c ", "a "\],\[ "c ", "d ", "c ", "c "\],\[ "c ", "c ", "e ", "c "\],\[ "f ", "c ", "c ", "c "\]\]
**Output:** true
**Explanation:** There is only one valid cycle highlighted in the image below:
 

**Example 3:**

**Input:** grid = \[\[ "a ", "b ", "b "\],\[ "b ", "z ", "b "\],\[ "b ", "b ", "a "\]\]
**Output:** false

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 500`
*   `grid` consists only of lowercase English letters.
Most Visited Sector in  a Circular Track

Given an integer `n` and an integer array `rounds`. We have a circular track which consists of `n` sectors labeled from `1` to `n`. A marathon will be held on this track, the marathon consists of `m` rounds. The `ith` round starts at sector `rounds[i - 1]` and ends at sector `rounds[i]`. For example, round 1 starts at sector `rounds[0]` and ends at sector `rounds[1]`

Return _an array of the most visited sectors_ sorted in **ascending** order.

Notice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).

**Example 1:**

**Input:** n = 4, rounds = \[1,3,1,2\]
**Output:** \[1,2\]
**Explanation:** The marathon starts at sector 1. The order of the visited sectors is as follows:
1 --> 2 --> 3 (end of round 1) --> 4 --> 1 (end of round 2) --> 2 (end of round 3 and the marathon)
We can see that both sectors 1 and 2 are visited twice and they are the most visited sectors. Sectors 3 and 4 are visited only once.

**Example 2:**

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

**Example 3:**

**Input:** n = 7, rounds = \[1,3,5,7\]
**Output:** \[1,2,3,4,5,6,7\]

**Constraints:**

*   `2 <= n <= 100`
*   `1 <= m <= 100`
*   `rounds.length == m + 1`
*   `1 <= rounds[i] <= n`
*   `rounds[i] != rounds[i + 1]` for `0 <= i < m`