bowang0911/leetcode huggingface dataset:
Smallest Common Region

You are given some lists of `regions` where the first region of each list includes all other regions in that list.

Naturally, if a region `x` contains another region `y` then `x` is bigger than `y`. Also, by definition, a region `x` contains itself.

Given two regions: `region1` and `region2`, return _the smallest region that contains both of them_.

If you are given regions `r1`, `r2`, and `r3` such that `r1` includes `r3`, it is guaranteed there is no `r2` such that `r2` includes `r3`.

It is guaranteed the smallest region exists.

**Example 1:**

**Input:**
regions = \[\[ "Earth ", "North America ", "South America "\],
\[ "North America ", "United States ", "Canada "\],
\[ "United States ", "New York ", "Boston "\],
\[ "Canada ", "Ontario ", "Quebec "\],
\[ "South America ", "Brazil "\]\],
region1 =  "Quebec ",
region2 =  "New York "
**Output:**  "North America "

**Example 2:**

**Input:** regions = \[\[ "Earth ",  "North America ",  "South America "\],\[ "North America ",  "United States ",  "Canada "\],\[ "United States ",  "New York ",  "Boston "\],\[ "Canada ",  "Ontario ",  "Quebec "\],\[ "South America ",  "Brazil "\]\], region1 =  "Canada ", region2 =  "South America "
**Output:**  "Earth "

**Constraints:**

*   `2 <= regions.length <= 104`
*   `2 <= regions[i].length <= 20`
*   `1 <= regions[i][j].length, region1.length, region2.length <= 20`
*   `region1 != region2`
*   `regions[i][j]`, `region1`, and `region2` consist of English letters.
Synonymous Sentences

You are given a list of equivalent string pairs `synonyms` where `synonyms[i] = [si, ti]` indicates that `si` and `ti` are equivalent strings. You are also given a sentence `text`.

Return _all possible synonymous sentences **sorted lexicographically**_.

**Example 1:**

**Input:** synonyms = \[\[ "happy ", "joy "\],\[ "sad ", "sorrow "\],\[ "joy ", "cheerful "\]\], text =  "I am happy today but was sad yesterday "
**Output:** \[ "I am cheerful today but was sad yesterday ", "I am cheerful today but was sorrow yesterday ", "I am happy today but was sad yesterday ", "I am happy today but was sorrow yesterday ", "I am joy today but was sad yesterday ", "I am joy today but was sorrow yesterday "\]

**Example 2:**

**Input:** synonyms = \[\[ "happy ", "joy "\],\[ "cheerful ", "glad "\]\], text =  "I am happy today but was sad yesterday "
**Output:** \[ "I am happy today but was sad yesterday ", "I am joy today but was sad yesterday "\]

**Constraints:**

*   `0 <= synonyms.length <= 10`
*   `synonyms[i].length == 2`
*   `1 <= si.length, ti.length <= 10`
*   `si != ti`
*   `text` consists of at most `10` words.
*   All the pairs of `synonyms` are **unique**.
*   The words of `text` are separated by single spaces.
Handshakes That Don't Cross

You are given an **even** number of people `numPeople` that stand around a circle and each person shakes hands with someone else so that there are `numPeople / 2` handshakes total.

Return _the number of ways these handshakes could occur such that none of the handshakes cross_.

Since the answer could be very large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** numPeople = 4
**Output:** 2
**Explanation:** There are two ways to do it, the first way is \[(1,2),(3,4)\] and the second one is \[(2,3),(4,1)\].

**Example 2:**

**Input:** numPeople = 6
**Output:** 5

**Constraints:**

*   `2 <= numPeople <= 1000`
*   `numPeople` is even.
Shift 2D Grid

Given a 2D `grid` of size `m x n` and an integer `k`. You need to shift the `grid` `k` times.

In one shift operation:

*   Element at `grid[i][j]` moves to `grid[i][j + 1]`.
*   Element at `grid[i][n - 1]` moves to `grid[i + 1][0]`.
*   Element at `grid[m - 1][n - 1]` moves to `grid[0][0]`.

Return the _2D grid_ after applying shift operation `k` times.

**Example 1:**

**Input:** `grid` = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\], k = 1
**Output:** \[\[9,1,2\],\[3,4,5\],\[6,7,8\]\]

**Example 2:**

**Input:** `grid` = \[\[3,8,1,9\],\[19,7,2,5\],\[4,6,11,10\],\[12,0,21,13\]\], k = 4
**Output:** \[\[12,0,21,13\],\[3,8,1,9\],\[19,7,2,5\],\[4,6,11,10\]\]

**Example 3:**

**Input:** `grid` = \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\], k = 9
**Output:** \[\[1,2,3\],\[4,5,6\],\[7,8,9\]\]

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m <= 50`
*   `1 <= n <= 50`
*   `-1000 <= grid[i][j] <= 1000`
*   `0 <= k <= 100`
Find Elements in a Contaminated Binary Tree

Given a binary tree with the following rules:

1.  `root.val == 0`
2.  If `treeNode.val == x` and `treeNode.left != null`, then `treeNode.left.val == 2 * x + 1`
3.  If `treeNode.val == x` and `treeNode.right != null`, then `treeNode.right.val == 2 * x + 2`

Now the binary tree is contaminated, which means all `treeNode.val` have been changed to `-1`.

Implement the `FindElements` class:

*   `FindElements(TreeNode* root)` Initializes the object with a contaminated binary tree and recovers it.
*   `bool find(int target)` Returns `true` if the `target` value exists in the recovered binary tree.

**Example 1:**

**Input**
\[ "FindElements ", "find ", "find "\]
\[\[\[-1,null,-1\]\],\[1\],\[2\]\]
**Output**
\[null,false,true\]
**Explanation**
FindElements findElements = new FindElements(\[-1,null,-1\]); 
findElements.find(1); // return False 
findElements.find(2); // return True 

**Example 2:**

**Input**
\[ "FindElements ", "find ", "find ", "find "\]
\[\[\[-1,-1,-1,-1,-1\]\],\[1\],\[3\],\[5\]\]
**Output**
\[null,true,true,false\]
**Explanation**
FindElements findElements = new FindElements(\[-1,-1,-1,-1,-1\]);
findElements.find(1); // return True
findElements.find(3); // return True
findElements.find(5); // return False

**Example 3:**

**Input**
\[ "FindElements ", "find ", "find ", "find ", "find "\]
\[\[\[-1,null,-1,-1,null,-1\]\],\[2\],\[3\],\[4\],\[5\]\]
**Output**
\[null,true,false,false,true\]
**Explanation**
FindElements findElements = new FindElements(\[-1,null,-1,-1,null,-1\]);
findElements.find(2); // return True
findElements.find(3); // return False
findElements.find(4); // return False
findElements.find(5); // return True

**Constraints:**

*   `TreeNode.val == -1`
*   The height of the binary tree is less than or equal to `20`
*   The total number of nodes is between `[1, 104]`
*   Total calls of `find()` is between `[1, 104]`
*   `0 <= target <= 106`
Greatest Sum Divisible by Three

Given an integer array `nums`, return _the **maximum possible sum** of elements of the array such that it is divisible by three_.

**Example 1:**

**Input:** nums = \[3,6,5,1,8\]
**Output:** 18
**Explanation:** Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3).

**Example 2:**

**Input:** nums = \[4\]
**Output:** 0
**Explanation:** Since 4 is not divisible by 3, do not pick any number.

**Example 3:**

**Input:** nums = \[1,2,3,4,4\]
**Output:** 12
**Explanation:** Pick numbers 1, 3, 4 and 4 their sum is 12 (maximum sum divisible by 3).

**Constraints:**

*   `1 <= nums.length <= 4 * 104`
*   `1 <= nums[i] <= 104`
Minimum Moves to Move a Box to Their Target Location

A storekeeper is a game in which the player pushes boxes around in a warehouse trying to get them to target locations.

The game is represented by an `m x n` grid of characters `grid` where each element is a wall, floor, or box.

Your task is to move the box `'B'` to the target position `'T'` under the following rules:

*   The character `'S'` represents the player. The player can move up, down, left, right in `grid` if it is a floor (empty cell).
*   The character `'.'` represents the floor which means a free cell to walk.
*   The character `'#'` represents the wall which means an obstacle (impossible to walk there).
*   There is only one box `'B'` and one target cell `'T'` in the `grid`.
*   The box can be moved to an adjacent free cell by standing next to the box and then moving in the direction of the box. This is a **push**.
*   The player cannot walk through the box.

Return _the minimum number of **pushes** to move the box to the target_. If there is no way to reach the target, return `-1`.

**Example 1:**

**Input:** grid = \[\[ "# ", "# ", "# ", "# ", "# ", "# "\],
               \[ "# ", "T ", "# ", "# ", "# ", "# "\],
               \[ "# ", ". ", ". ", "B ", ". ", "# "\],
               \[ "# ", ". ", "# ", "# ", ". ", "# "\],
               \[ "# ", ". ", ". ", ". ", "S ", "# "\],
               \[ "# ", "# ", "# ", "# ", "# ", "# "\]\]
**Output:** 3
**Explanation:** We return only the number of times the box is pushed.

**Example 2:**

**Input:** grid = \[\[ "# ", "# ", "# ", "# ", "# ", "# "\],
               \[ "# ", "T ", "# ", "# ", "# ", "# "\],
               \[ "# ", ". ", ". ", "B ", ". ", "# "\],
               \[ "# ", "# ", "# ", "# ", ". ", "# "\],
               \[ "# ", ". ", ". ", ". ", "S ", "# "\],
               \[ "# ", "# ", "# ", "# ", "# ", "# "\]\]
**Output:** -1

**Example 3:**

**Input:** grid = \[\[ "# ", "# ", "# ", "# ", "# ", "# "\],
               \[ "# ", "T ", ". ", ". ", "# ", "# "\],
               \[ "# ", ". ", "# ", "B ", ". ", "# "\],
               \[ "# ", ". ", ". ", ". ", ". ", "# "\],
               \[ "# ", ". ", ". ", ". ", "S ", "# "\],
               \[ "# ", "# ", "# ", "# ", "# ", "# "\]\]
**Output:** 5
**Explanation:** push the box down, left, left, up and up.

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m, n <= 20`
*   `grid` contains only characters `'.'`, `'#'`, `'S'`, `'T'`, or `'B'`.
*   There is only one character `'S'`, `'B'`, and `'T'` in the `grid`.
Print Immutable Linked List in Reverse

You are given an immutable linked list, print out all values of each node in reverse with the help of the following interface:

*   `ImmutableListNode`: An interface of immutable linked list, you are given the head of the list.

You need to use the following functions to access the linked list (you **can't** access the `ImmutableListNode` directly):

*   `ImmutableListNode.printValue()`: Print value of the current node.
*   `ImmutableListNode.getNext()`: Return the next node.

The input is only given to initialize the linked list internally. You must solve this problem without modifying the linked list. In other words, you must operate the linked list using only the mentioned APIs.

**Example 1:**

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

**Example 2:**

**Input:** head = \[0,-4,-1,3,-5\]
**Output:** \[-5,3,-1,-4,0\]

**Example 3:**

**Input:** head = \[-2,0,6,4,4,-6\]
**Output:** \[-6,4,4,6,0,-2\]

**Constraints:**

*   The length of the linked list is between `[1, 1000]`.
*   The value of each node in the linked list is between `[-1000, 1000]`.

**Follow up:**

Could you solve this problem in:

*   Constant space complexity?
*   Linear time complexity and less than linear space complexity?
Minimum Time Visiting All Points

On a 2D plane, there are `n` points with integer coordinates `points[i] = [xi, yi]`. Return _the **minimum time** in seconds to visit all the points in the order given by_ `points`.

You can move according to these rules:

*   In `1` second, you can either:
    *   move vertically by one unit,
    *   move horizontally by one unit, or
    *   move diagonally `sqrt(2)` units (in other words, move one unit vertically then one unit horizontally in `1` second).
*   You have to visit the points in the same order as they appear in the array.
*   You are allowed to pass through points that appear later in the order, but these do not count as visits.

**Example 1:**

**Input:** points = \[\[1,1\],\[3,4\],\[-1,0\]\]
**Output:** 7
**Explanation:** One optimal path is **\[1,1\]** -> \[2,2\] -> \[3,3\] -> **\[3,4\]** \-> \[2,3\] -> \[1,2\] -> \[0,1\] -> **\[-1,0\]**   
Time from \[1,1\] to \[3,4\] = 3 seconds 
Time from \[3,4\] to \[-1,0\] = 4 seconds
Total time = 7 seconds

**Example 2:**

**Input:** points = \[\[3,2\],\[-2,2\]\]
**Output:** 5

**Constraints:**

*   `points.length == n`
*   `1 <= n <= 100`
*   `points[i].length == 2`
*   `-1000 <= points[i][0], points[i][1] <= 1000`
Count Servers that Communicate

You are given a map of a server center, represented as a `m * n` integer matrix `grid`, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.  
  
Return the number of servers that communicate with any other server.

**Example 1:**

**Input:** grid = \[\[1,0\],\[0,1\]\]
**Output:** 0
**Explanation:** No servers can communicate with others.

**Example 2:**

**Input:** grid = \[\[1,0\],\[1,1\]\]
**Output:** 3
**Explanation:** All three servers can communicate with at least one other server.

**Example 3:**

**Input:** grid = \[\[1,1,0,0\],\[0,0,1,0\],\[0,0,1,0\],\[0,0,0,1\]\]
**Output:** 4
**Explanation:** The two servers in the first row can communicate with each other. The two servers in the third column can communicate with each other. The server at right bottom corner can't communicate with any other server.

**Constraints:**

*   `m == grid.length`
*   `n == grid[i].length`
*   `1 <= m <= 250`
*   `1 <= n <= 250`
*   `grid[i][j] == 0 or 1`
Search Suggestions System

You are given an array of strings `products` and a string `searchWord`.

Design a system that suggests at most three product names from `products` after each character of `searchWord` is typed. Suggested products should have common prefix with `searchWord`. If there are more than three products with a common prefix return the three lexicographically minimums products.

Return _a list of lists of the suggested products after each character of_ `searchWord` _is typed_.

**Example 1:**

**Input:** products = \[ "mobile ", "mouse ", "moneypot ", "monitor ", "mousepad "\], searchWord =  "mouse "
**Output:** \[\[ "mobile ", "moneypot ", "monitor "\],\[ "mobile ", "moneypot ", "monitor "\],\[ "mouse ", "mousepad "\],\[ "mouse ", "mousepad "\],\[ "mouse ", "mousepad "\]\]
**Explanation:** products sorted lexicographically = \[ "mobile ", "moneypot ", "monitor ", "mouse ", "mousepad "\].
After typing m and mo all products match and we show user \[ "mobile ", "moneypot ", "monitor "\].
After typing mou, mous and mouse the system suggests \[ "mouse ", "mousepad "\].

**Example 2:**

**Input:** products = \[ "havana "\], searchWord =  "havana "
**Output:** \[\[ "havana "\],\[ "havana "\],\[ "havana "\],\[ "havana "\],\[ "havana "\],\[ "havana "\]\]
**Explanation:** The only word  "havana " will be always suggested while typing the search word.

**Constraints:**

*   `1 <= products.length <= 1000`
*   `1 <= products[i].length <= 3000`
*   `1 <= sum(products[i].length) <= 2 * 104`
*   All the strings of `products` are **unique**.
*   `products[i]` consists of lowercase English letters.
*   `1 <= searchWord.length <= 1000`
*   `searchWord` consists of lowercase English letters.
Number of Ways to Stay in the Same Place After Some Steps

You have a pointer at index `0` in an array of size `arrLen`. At each step, you can move 1 position to the left, 1 position to the right in the array, or stay in the same place (The pointer should not be placed outside the array at any time).

Given two integers `steps` and `arrLen`, return the number of ways such that your pointer is still at index `0` after **exactly** `steps` steps. Since the answer may be too large, return it **modulo** `109 + 7`.

**Example 1:**

**Input:** steps = 3, arrLen = 2
**Output:** 4
**Explanation:** There are 4 differents ways to stay at index 0 after 3 steps.
Right, Left, Stay
Stay, Right, Left
Right, Stay, Left
Stay, Stay, Stay

**Example 2:**

**Input:** steps = 2, arrLen = 4
**Output:** 2
**Explanation:** There are 2 differents ways to stay at index 0 after 2 steps
Right, Left
Stay, Stay

**Example 3:**

**Input:** steps = 4, arrLen = 2
**Output:** 8

**Constraints:**

*   `1 <= steps <= 500`
*   `1 <= arrLen <= 106`
Hexspeak

A decimal number can be converted to its **Hexspeak representation** by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit `'0'` with the letter `'O'`, and the digit `'1'` with the letter `'I'`. Such a representation is valid if and only if it consists only of the letters in the set `{'A', 'B', 'C', 'D', 'E', 'F', 'I', 'O'}`.

Given a string `num` representing a decimal integer `n`, _return the **Hexspeak representation** of_ `n` _if it is valid, otherwise return_ `"ERROR "`.

**Example 1:**

**Input:** num =  "257 "
**Output:**  "IOI "
**Explanation:** 257 is 101 in hexadecimal.

**Example 2:**

**Input:** num =  "3 "
**Output:**  "ERROR "

**Constraints:**

*   `1 <= num.length <= 12`
*   `num` does not contain leading zeros.
*   num represents an integer in the range `[1, 1012]`.
Remove Interval

A set of real numbers can be represented as the union of several disjoint intervals, where each interval is in the form `[a, b)`. A real number `x` is in the set if one of its intervals `[a, b)` contains `x` (i.e. `a <= x < b`).

You are given a **sorted** list of disjoint intervals `intervals` representing a set of real numbers as described above, where `intervals[i] = [ai, bi]` represents the interval `[ai, bi)`. You are also given another interval `toBeRemoved`.

Return _the set of real numbers with the interval_ `toBeRemoved` _**removed** from_ `intervals`_. In other words, return the set of real numbers such that every_ `x` _in the set is in_ `intervals` _but **not** in_ `toBeRemoved`_. Your answer should be a **sorted** list of disjoint intervals as described above._

**Example 1:**

**Input:** intervals = \[\[0,2\],\[3,4\],\[5,7\]\], toBeRemoved = \[1,6\]
**Output:** \[\[0,1\],\[6,7\]\]

**Example 2:**

**Input:** intervals = \[\[0,5\]\], toBeRemoved = \[2,3\]
**Output:** \[\[0,2\],\[3,5\]\]

**Example 3:**

**Input:** intervals = \[\[-5,-4\],\[-3,-2\],\[1,2\],\[3,5\],\[8,9\]\], toBeRemoved = \[-1,4\]
**Output:** \[\[-5,-4\],\[-3,-2\],\[4,5\],\[8,9\]\]

**Constraints:**

*   `1 <= intervals.length <= 104`
*   `-109 <= ai < bi <= 109`
Delete Tree Nodes

A tree rooted at node 0 is given as follows:

*   The number of nodes is `nodes`;
*   The value of the `ith` node is `value[i]`;
*   The parent of the `ith` node is `parent[i]`.

Remove every subtree whose sum of values of nodes is zero.

Return _the number of the remaining nodes in the tree_.

**Example 1:**

**Input:** nodes = 7, parent = \[-1,0,0,1,2,2,2\], value = \[1,-2,4,0,-2,-1,-1\]
**Output:** 2

**Example 2:**

**Input:** nodes = 7, parent = \[-1,0,0,1,2,2,2\], value = \[1,-2,4,0,-2,-1,-2\]
**Output:** 6

**Constraints:**

*   `1 <= nodes <= 104`
*   `parent.length == nodes`
*   `0 <= parent[i] <= nodes - 1`
*   `parent[0] == -1` which indicates that `0` is the root.
*   `value.length == nodes`
*   `-105 <= value[i] <= 105`
*   The given input is **guaranteed** to represent a **valid tree**.
Number of Ships in a Rectangle

_(This problem is an **interactive problem**.)_

Each ship is located at an integer point on the sea represented by a cartesian plane, and each integer point may contain at most 1 ship.

You have a function `Sea.hasShips(topRight, bottomLeft)` which takes two points as arguments and returns `true` If there is at least one ship in the rectangle represented by the two points, including on the boundary.

Given two points: the top right and bottom left corners of a rectangle, return the number of ships present in that rectangle. It is guaranteed that there are **at most 10 ships** in that rectangle.

Submissions making **more than 400 calls** to `hasShips` will be judged _Wrong Answer_. Also, any solutions that attempt to circumvent the judge will result in disqualification.

**Example :**

**Input:** 
ships = \[\[1,1\],\[2,2\],\[3,3\],\[5,5\]\], topRight = \[4,4\], bottomLeft = \[0,0\]
**Output:** 3
**Explanation:** From \[0,0\] to \[4,4\] we can count 3 ships within the range.

**Example 2:**

**Input:** ans = \[\[1,1\],\[2,2\],\[3,3\]\], topRight = \[1000,1000\], bottomLeft = \[0,0\]
**Output:** 3

**Constraints:**

*   On the input `ships` is only given to initialize the map internally. You must solve this problem "blindfolded ". In other words, you must find the answer using the given `hasShips` API, without knowing the `ships` position.
*   `0 <= bottomLeft[0] <= topRight[0] <= 1000`
*   `0 <= bottomLeft[1] <= topRight[1] <= 1000`
*   `topRight != bottomLeft`
Find Winner on a Tic Tac Toe Game

**Tic-tac-toe** is played by two players `A` and `B` on a `3 x 3` grid. The rules of Tic-Tac-Toe are:

*   Players take turns placing characters into empty squares `' '`.
*   The first player `A` always places `'X'` characters, while the second player `B` always places `'O'` characters.
*   `'X'` and `'O'` characters are always placed into empty squares, never on filled ones.
*   The game ends when there are **three** of the same (non-empty) character filling any row, column, or diagonal.
*   The game also ends if all squares are non-empty.
*   No more moves can be played if the game is over.

Given a 2D integer array `moves` where `moves[i] = [rowi, coli]` indicates that the `ith` move will be played on `grid[rowi][coli]`. return _the winner of the game if it exists_ (`A` or `B`). In case the game ends in a draw return `"Draw "`. If there are still movements to play return `"Pending "`.

You can assume that `moves` is valid (i.e., it follows the rules of **Tic-Tac-Toe**), the grid is initially empty, and `A` will play first.

**Example 1:**

**Input:** moves = \[\[0,0\],\[2,0\],\[1,1\],\[2,1\],\[2,2\]\]
**Output:**  "A "
**Explanation:** A wins, they always play first.

**Example 2:**

**Input:** moves = \[\[0,0\],\[1,1\],\[0,1\],\[0,2\],\[1,0\],\[2,0\]\]
**Output:**  "B "
**Explanation:** B wins.

**Example 3:**

**Input:** moves = \[\[0,0\],\[1,1\],\[2,0\],\[1,0\],\[1,2\],\[2,1\],\[0,1\],\[0,2\],\[2,2\]\]
**Output:**  "Draw "
**Explanation:** The game ends in a draw since there are no moves to make.

**Constraints:**

*   `1 <= moves.length <= 9`
*   `moves[i].length == 2`
*   `0 <= rowi, coli <= 2`
*   There are no repeated elements on `moves`.
*   `moves` follow the rules of tic tac toe.
Number of Burgers with No Waste of Ingredients

Given two integers `tomatoSlices` and `cheeseSlices`. The ingredients of different burgers are as follows:

*   **Jumbo Burger:** `4` tomato slices and `1` cheese slice.
*   **Small Burger:** `2` Tomato slices and `1` cheese slice.

Return `[total_jumbo, total_small]` so that the number of remaining `tomatoSlices` equal to `0` and the number of remaining `cheeseSlices` equal to `0`. If it is not possible to make the remaining `tomatoSlices` and `cheeseSlices` equal to `0` return `[]`.

**Example 1:**

**Input:** tomatoSlices = 16, cheeseSlices = 7
**Output:** \[1,6\]
**Explantion:** To make one jumbo burger and 6 small burgers we need 4\*1 + 2\*6 = 16 tomato and 1 + 6 = 7 cheese.
There will be no remaining ingredients.

**Example 2:**

**Input:** tomatoSlices = 17, cheeseSlices = 4
**Output:** \[\]
**Explantion:** There will be no way to use all ingredients to make small and jumbo burgers.

**Example 3:**

**Input:** tomatoSlices = 4, cheeseSlices = 17
**Output:** \[\]
**Explantion:** Making 1 jumbo burger there will be 16 cheese remaining and making 2 small burgers there will be 15 cheese remaining.

**Constraints:**

*   `0 <= tomatoSlices, cheeseSlices <= 107`
Count Square Submatrices with All Ones

Given a `m * n` matrix of ones and zeros, return how many **square** submatrices have all ones.

**Example 1:**

**Input:** matrix =
\[
  \[0,1,1,1\],
  \[1,1,1,1\],
  \[0,1,1,1\]
\]
**Output:** 15
**Explanation:** 
There are **10** squares of side 1.
There are **4** squares of side 2.
There is  **1** square of side 3.
Total number of squares = 10 + 4 + 1 = **15**.

**Example 2:**

**Input:** matrix = 
\[
  \[1,0,1\],
  \[1,1,0\],
  \[1,1,0\]
\]
**Output:** 7
**Explanation:** 
There are **6** squares of side 1.  
There is **1** square of side 2. 
Total number of squares = 6 + 1 = **7**.

**Constraints:**

*   `1 <= arr.length <= 300`
*   `1 <= arr[0].length <= 300`
*   `0 <= arr[i][j] <= 1`