Prompt:
def suggestedProducts(products: List[str], searchWord: str) -> List[List[str]]:
    """
    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:

    >>> suggestedProducts(products = ["mobile","mouse","moneypot","monitor","mousepad"], searchWord = "mouse")
    >>> [["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:

    >>> suggestedProducts(products = ["havana"], searchWord = "havana")
    >>> [["havana"],["havana"],["havana"],["havana"],["havana"],["havana"]]
    Explanation: The only word "havana" will be always suggested while typing the search word.
    """


Prompt:
def numWays(steps: int, arrLen: int) -> int:
    """
    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:

    >>> numWays(steps = 3, arrLen = 2)
    >>> 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:

    >>> numWays(steps = 2, arrLen = 4)
    >>> 2
    Explanation: There are 2 differents ways to stay at index 0 after 2 steps
    Right, Left
    Stay, Stay

    Example 3:

    >>> numWays(steps = 4, arrLen = 2)
    >>> 8
    """


Prompt:
def toHexspeak(num: str) -> str:
    """
    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:

    >>> toHexspeak(num = "257")
    >>> "IOI"
    Explanation: 257 is 101 in hexadecimal.

    Example 2:

    >>> toHexspeak(num = "3")
    >>> "ERROR"
    """


Prompt:
def removeInterval(intervals: List[List[int]], toBeRemoved: List[int]) -> List[List[int]]:
    """
    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:

    >>> removeInterval(intervals = [[0,2],[3,4],[5,7]], toBeRemoved = [1,6])
    >>> [[0,1],[6,7]]

    Example 2:

    >>> removeInterval(intervals = [[0,5]], toBeRemoved = [2,3])
    >>> [[0,2],[3,5]]

    Example 3:

    >>> removeInterval(intervals = [[-5,-4],[-3,-2],[1,2],[3,5],[8,9]], toBeRemoved = [-1,4])
    >>> [[-5,-4],[-3,-2],[4,5],[8,9]]
    """


Prompt:
def deleteTreeNodes(nodes: int, parent: List[int], value: List[int]) -> int:
    """
    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:

    >>> deleteTreeNodes(nodes = 7, parent = [-1,0,0,1,2,2,2], value = [1,-2,4,0,-2,-1,-1])
    >>> 2

    Example 2:

    >>> deleteTreeNodes(nodes = 7, parent = [-1,0,0,1,2,2,2], value = [1,-2,4,0,-2,-1,-2])
    >>> 6
    """


Prompt:
def tictactoe(moves: List[List[int]]) -> str:
    """
    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:

    >>> tictactoe(moves = [[0,0],[2,0],[1,1],[2,1],[2,2]])
    >>> "A"
    Explanation: A wins, they always play first.

    Example 2:

    >>> tictactoe(moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]])
    >>> "B"
    Explanation: B wins.

    Example 3:

    >>> tictactoe(moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]])
    >>> "Draw"
    Explanation: The game ends in a draw since there are no moves to make.
    """


Prompt:
def numOfBurgers(tomatoSlices: int, cheeseSlices: int) -> List[int]:
    """
    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:

    >>> numOfBurgers(tomatoSlices = 16, cheeseSlices = 7)
    >>> [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:

    >>> numOfBurgers(tomatoSlices = 17, cheeseSlices = 4)
    >>> []
    Explantion: There will be no way to use all ingredients to make small and jumbo burgers.

    Example 3:

    >>> numOfBurgers(tomatoSlices = 4, cheeseSlices = 17)
    >>> []
    Explantion: Making 1 jumbo burger there will be 16 cheese remaining and making 2 small burgers there will be 15 cheese remaining.
    """


Prompt:
def countSquares(matrix: List[List[int]]) -> int:
    """
    Given a m * n matrix of ones and zeros, return how many square submatrices have all ones.

    Example 1:

    [
      [0,1,1,1],
      [1,1,1,1],
      [0,1,1,1]
    ]
    >>> countSquares(matrix =)
    >>> 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:

    [
      [1,0,1],
      [1,1,0],
      [1,1,0]
    ]
    >>> countSquares(matrix =)
    >>> 7
    Explanation:
    There are 6 squares of side 1.
    There is 1 square of side 2.
    Total number of squares = 6 + 1 = 7.
    """


Prompt:
def palindromePartition(s: str, k: int) -> int:
    """
    You are given a string s containing lowercase letters and an integer k. You need to :

    First, change some characters of s to other lowercase English letters.
    Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.

    Return the minimal number of characters that you need to change to divide the string.

    Example 1:

    >>> palindromePartition(s = "abc", k = 2)
    >>> 1
    Explanation: You can split the string into "ab" and "c", and change 1 character in "ab" to make it palindrome.

    Example 2:

    >>> palindromePartition(s = "aabbc", k = 3)
    >>> 0
    Explanation: You can split the string into "aa", "bb" and "c", all of them are palindrome.
    Example 3:

    >>> palindromePartition(s = "leetcode", k = 8)
    >>> 0
    """


Prompt:
def subtractProductAndSum(n: int) -> int:
    """
    Given an integer number n, return the difference between the product of its digits and the sum of its digits.

    Example 1:

    >>> subtractProductAndSum(n = 234)
    >>> 15
    Explanation:
    Product of digits = 2 * 3 * 4 = 24
    Sum of digits = 2 + 3 + 4 = 9
    Result = 24 - 9 = 15

    Example 2:

    >>> subtractProductAndSum(n = 4421)
    >>> 21
    Explanation:
    Product of digits = 4 * 4 * 2 * 1 = 32
    Sum of digits = 4 + 4 + 2 + 1 = 11
    Result = 32 - 11 = 21
    """


Prompt:
def groupThePeople(groupSizes: List[int]) -> List[List[int]]:
    """
    There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.
    You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3.
    Return a list of groups such that each person i is in a group of size groupSizes[i].
    Each person should appear in exactly one group, and every person must be in a group. If there are multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.

    Example 1:

    >>> groupThePeople(groupSizes = [3,3,3,3,3,1,3])
    >>> [[5],[0,1,2],[3,4,6]]
    Explanation:
    The first group is [5]. The size is 1, and groupSizes[5] = 1.
    The second group is [0,1,2]. The size is 3, and groupSizes[0] = groupSizes[1] = groupSizes[2] = 3.
    The third group is [3,4,6]. The size is 3, and groupSizes[3] = groupSizes[4] = groupSizes[6] = 3.
    Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]].

    Example 2:

    >>> groupThePeople(groupSizes = [2,1,3,3,3,2])
    >>> [[1],[0,5],[2,3,4]]
    """


Prompt:
def smallestDivisor(nums: List[int], threshold: int) -> int:
    """
    Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.
    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).
    The test cases are generated so that there will be an answer.

    Example 1:

    >>> smallestDivisor(nums = [1,2,5,9], threshold = 6)
    >>> 5
    Explanation: We can get a sum to 17 (1+2+5+9) if the divisor is 1.
    If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2).

    Example 2:

    >>> smallestDivisor(nums = [44,22,33,11,1], threshold = 5)
    >>> 44
    """


Prompt:
def minFlips(mat: List[List[int]]) -> int:
    """
    Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge.
    Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.
    A binary matrix is a matrix with all cells equal to 0 or 1 only.
    A zero matrix is a matrix with all cells equal to 0.

    Example 1:

    >>> minFlips(mat = [[0,0],[0,1]])
    >>> 3
    Explanation: One possible solution is to flip (1, 0) then (0, 1) and finally (1, 1) as shown.

    Example 2:

    >>> minFlips(mat = [[0]])
    >>> 0
    Explanation: Given matrix is a zero matrix. We do not need to change it.

    Example 3:

    >>> minFlips(mat = [[1,0,0],[1,0,0]])
    >>> -1
    Explanation: Given matrix cannot be a zero matrix.
    """


Prompt:
def findSpecialInteger(arr: List[int]) -> int:
    """
    Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.

    Example 1:

    >>> findSpecialInteger(arr = [1,2,2,6,6,6,6,7,10])
    >>> 6

    Example 2:

    >>> findSpecialInteger(arr = [1,1])
    >>> 1
    """


Prompt:
def removeCoveredIntervals(intervals: List[List[int]]) -> int:
    """
    Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list.
    The interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d.
    Return the number of remaining intervals.

    Example 1:

    >>> removeCoveredIntervals(intervals = [[1,4],[3,6],[2,8]])
    >>> 2
    Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.

    Example 2:

    >>> removeCoveredIntervals(intervals = [[1,4],[2,3]])
    >>> 1
    """


Prompt:
def minFallingPathSum(grid: List[List[int]]) -> int:
    """
    Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.
    A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column.

    Example 1:

    >>> minFallingPathSum(grid = [[1,2,3],[4,5,6],[7,8,9]])
    >>> 13
    Explanation:
    The possible falling paths are:
    [1,5,9], [1,5,7], [1,6,7], [1,6,8],
    [2,4,8], [2,4,9], [2,6,7], [2,6,8],
    [3,4,8], [3,4,9], [3,5,7], [3,5,9]
    The falling path with the smallest sum is [1,5,7], so the answer is 13.

    Example 2:

    >>> minFallingPathSum(grid = [[7]])
    >>> 7
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def getDecimalValue(head: Optional[ListNode]) -> int:
    """
    Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.
    Return the decimal value of the number in the linked list.
    The most significant bit is at the head of the linked list.

    Example 1:

    >>> __init__(head = [1,0,1])
    >>> 5
    Explanation: (101) in base 2 = (5) in base 10

    Example 2:

    >>> __init__(head = [0])
    >>> 0
    """


Prompt:
def sequentialDigits(low: int, high: int) -> List[int]:
    """
    An integer has sequential digits if and only if each digit in the number is one more than the previous digit.
    Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.

    Example 1:
    >>> sequentialDigits(low = 100, high = 300)
    >>> [123,234]
    Example 2:
    >>> sequentialDigits(low = 1000, high = 13000)
    >>> [1234,2345,3456,4567,5678,6789,12345]
    """


Prompt:
def maxSideLength(mat: List[List[int]], threshold: int) -> int:
    """
    Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.

    Example 1:

    >>> maxSideLength(mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4)
    >>> 2
    Explanation: The maximum side length of square with sum less than 4 is 2 as shown.

    Example 2:

    >>> maxSideLength(mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1)
    >>> 0
    """


Prompt:
def shortestPath(grid: List[List[int]], k: int) -> int:
    """
    You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step.
    Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.

    Example 1:

    >>> shortestPath(grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1)
    >>> 6
    Explanation:
    The shortest path without eliminating any obstacle is 10.
    The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).

    Example 2:

    >>> shortestPath(grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1)
    >>> -1
    Explanation: We need to eliminate at least two obstacles to find such a walk.
    """


Prompt:
def findNumbers(nums: List[int]) -> int:
    """
    Given an array nums of integers, return how many of them contain an even number of digits.

    Example 1:

    >>> findNumbers(nums = [12,345,2,6,7896])
    >>> 2
    Explanation:
    12 contains 2 digits (even number of digits).
    345 contains 3 digits (odd number of digits).
    2 contains 1 digit (odd number of digits).
    6 contains 1 digit (odd number of digits).
    7896 contains 4 digits (even number of digits).
    Therefore only 12 and 7896 contain an even number of digits.

    Example 2:

    >>> findNumbers(nums = [555,901,482,1771])
    >>> 1
    Explanation:
    Only 1771 contains an even number of digits.
    """


Prompt:
def isPossibleDivide(nums: List[int], k: int) -> bool:
    """
    Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
    Return true if it is possible. Otherwise, return false.

    Example 1:

    >>> isPossibleDivide(nums = [1,2,3,3,4,4,5,6], k = 4)
    >>> true
    Explanation: Array can be divided into [1,2,3,4] and [3,4,5,6].

    Example 2:

    >>> isPossibleDivide(nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3)
    >>> true
    Explanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].

    Example 3:

    >>> isPossibleDivide(nums = [1,2,3,4], k = 3)
    >>> false
    Explanation: Each array should be divided in subarrays of size 3.
    """


Prompt:
def maxFreq(s: str, maxLetters: int, minSize: int, maxSize: int) -> int:
    """
    Given a string s, return the maximum number of occurrences of any substring under the following rules:

    The number of unique characters in the substring must be less than or equal to maxLetters.
    The substring size must be between minSize and maxSize inclusive.

    Example 1:

    >>> maxFreq(s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4)
    >>> 2
    Explanation: Substring "aab" has 2 occurrences in the original string.
    It satisfies the conditions, 2 unique letters and size 3 (between minSize and maxSize).

    Example 2:

    >>> maxFreq(s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3)
    >>> 2
    Explanation: Substring "aaa" occur 2 times in the string. It can overlap.
    """


Prompt:
def maxCandies(status: List[int], candies: List[int], keys: List[List[int]], containedBoxes: List[List[int]], initialBoxes: List[int]) -> int:
    """
    You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:

    status[i] is 1 if the ith box is open and 0 if the ith box is closed,
    candies[i] is the number of candies in the ith box,
    keys[i] is a list of the labels of the boxes you can open after opening the ith box.
    containedBoxes[i] is a list of the boxes you found inside the ith box.

    You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.
    Return the maximum number of candies you can get following the rules above.

    Example 1:

    >>> maxCandies(status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0])
    >>> 16
    Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.
    Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
    In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
    Total number of candies collected = 7 + 4 + 5 = 16 candy.

    Example 2:

    >>> maxCandies(status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0])
    >>> 6
    Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.
    The total number of candies will be 6.
    """


Prompt:
def replaceElements(arr: List[int]) -> List[int]:
    """
    Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1.
    After doing so, return the array.

    Example 1:

    >>> replaceElements(arr = [17,18,5,4,6,1])
    >>> [18,6,6,6,1,-1]
    Explanation:
    - index 0 --> the greatest element to the right of index 0 is index 1 (18).
    - index 1 --> the greatest element to the right of index 1 is index 4 (6).
    - index 2 --> the greatest element to the right of index 2 is index 4 (6).
    - index 3 --> the greatest element to the right of index 3 is index 4 (6).
    - index 4 --> the greatest element to the right of index 4 is index 5 (1).
    - index 5 --> there are no elements to the right of index 5, so we put -1.

    Example 2:

    >>> replaceElements(arr = [400])
    >>> [-1]
    Explanation: There are no elements to the right of index 0.
    """


Prompt:
def findBestValue(arr: List[int], target: int) -> int:
    """
    Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.
    In case of a tie, return the minimum such integer.
    Notice that the answer is not neccesarilly a number from arr.

    Example 1:

    >>> findBestValue(arr = [4,9,3], target = 10)
    >>> 3
    Explanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.

    Example 2:

    >>> findBestValue(arr = [2,3,5], target = 10)
    >>> 5

    Example 3:

    >>> findBestValue(arr = [60864,25176,27249,21296,20204], target = 56803)
    >>> 11361
    """


Prompt:
def pathsWithMaxScore(board: List[str]) -> List[int]:
    """
    You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'.\r
    \r
    You need to reach the top left square marked with the character 'E'. The rest of the squares are labeled either with a numeric character 1, 2, ..., 9 or with an obstacle 'X'. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.\r
    \r
    Return a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, taken modulo 10^9 + 7.\r
    \r
    In case there is no path, return [0, 0].\r
    \r
     \r
    Example 1:\r
    >>> pathsWithMaxScore(board = ["E23","2X2","12S"]\r)
    >>> [7,1]\r
    Example 2:\r
    >>> pathsWithMaxScore(board = ["E12","1X1","21S"]\r)
    >>> [4,2]\r
    Example 3:\r
    >>> pathsWithMaxScore(board = ["E11","XXX","11S"]\r)
    >>> [0,0]\r
    \r
     \r
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def deepestLeavesSum(root: Optional[TreeNode]) -> int:
    """
    Given the root of a binary tree, return the sum of values of its deepest leaves.

    Example 1:

    >>> __init__(root = [1,2,3,4,5,null,6,7,null,null,null,null,8])
    >>> 15

    Example 2:

    >>> __init__(root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5])
    >>> 19
    """


Prompt:
def sumZero(n: int) -> List[int]:
    """
    Given an integer n, return any array containing n unique integers such that they add up to 0.

    Example 1:

    >>> sumZero(n = 5)
    >>> [-7,-1,1,3,4]
    Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].

    Example 2:

    >>> sumZero(n = 3)
    >>> [-1,0,1]

    Example 3:

    >>> sumZero(n = 1)
    >>> [0]
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def getAllElements(root1: Optional[TreeNode], root2: Optional[TreeNode]) -> List[int]:
    """
    Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.

    Example 1:

    >>> __init__(root1 = [2,1,4], root2 = [1,0,3])
    >>> [0,1,1,2,3,4]

    Example 2:

    >>> __init__(root1 = [1,null,8], root2 = [8,1])
    >>> [1,1,8,8]
    """


Prompt:
def canReach(arr: List[int], start: int) -> bool:
    """
    Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0.
    Notice that you can not jump outside of the array at any time.

    Example 1:

    >>> canReach(arr = [4,2,3,0,3,1,2], start = 5)
    >>> true
    Explanation:
    All possible ways to reach at index 3 with value 0 are:
    index 5 -> index 4 -> index 1 -> index 3
    index 5 -> index 6 -> index 4 -> index 1 -> index 3

    Example 2:

    >>> canReach(arr = [4,2,3,0,3,1,2], start = 0)
    >>> true
    Explanation:
    One possible way to reach at index 3 with value 0 is:
    index 0 -> index 4 -> index 1 -> index 3

    Example 3:

    >>> canReach(arr = [3,0,2,1,2], start = 2)
    >>> false
    Explanation: There is no way to reach at index 1 with value 0.
    """


Prompt:
def isSolvable(words: List[str], result: str) -> bool:
    """
    Given an equation, represented by words on the left side and the result on the right side.
    You need to check if the equation is solvable under the following rules:

    Each character is decoded as one digit (0 - 9).
    No two characters can map to the same digit.
    Each words[i] and result are decoded as one number without leading zeros.
    Sum of numbers on the left side (words) will equal to the number on the right side (result).

    Return true if the equation is solvable, otherwise return false.

    Example 1:

    >>> isSolvable(words = ["SEND","MORE"], result = "MONEY")
    >>> true
    Explanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'
    Such that: "SEND" + "MORE" = "MONEY" ,  9567 + 1085 = 10652
    Example 2:

    >>> isSolvable(words = ["SIX","SEVEN","SEVEN"], result = "TWENTY")
    >>> true
    Explanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4
    Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENTY" ,  650 + 68782 + 68782 = 138214
    Example 3:

    >>> isSolvable(words = ["LEET","CODE"], result = "POINT")
    >>> false
    Explanation: There is no possible mapping to satisfy the equation, so we return false.
    Note that two different characters cannot map to the same digit.
    """


Prompt:
def freqAlphabets(s: str) -> str:
    """
    You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:

    Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.

    Return the string formed after mapping.
    The test cases are generated so that a unique mapping will always exist.

    Example 1:

    >>> freqAlphabets(s = "10#11#12")
    >>> "jkab"
    Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".

    Example 2:

    >>> freqAlphabets(s = "1326#")
    >>> "acz"
    """


Prompt:
def xorQueries(arr: List[int], queries: List[List[int]]) -> List[int]:
    """
    You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].
    For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).
    Return an array answer where answer[i] is the answer to the ith query.

    Example 1:

    >>> xorQueries(arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]])
    >>> [2,7,14,8]
    Explanation:
    The binary representation of the elements in the array are:
    1 = 0001
    3 = 0011
    4 = 0100
    8 = 1000
    The XOR values for queries are:
    [0,1] = 1 xor 3 = 2
    [1,2] = 3 xor 4 = 7
    [0,3] = 1 xor 3 xor 4 xor 8 = 14
    [3,3] = 8

    Example 2:

    >>> xorQueries(arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]])
    >>> [8,0,4,4]
    """


Prompt:
def watchedVideosByFriends(watchedVideos: List[List[str]], friends: List[List[int]], id: int, level: int) -> List[str]:
    """
    There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.
    Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest.

    Example 1:

    >>> watchedVideosByFriends(watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1)
    >>> ["B","C"]
    Explanation:
    You have id = 0 (green color in the figure) and your friends are (yellow color in the figure):
    Person with id = 1 -> watchedVideos = ["C"]
    Person with id = 2 -> watchedVideos = ["B","C"]
    The frequencies of watchedVideos by your friends are:
    B -> 1
    C -> 2

    Example 2:

    >>> watchedVideosByFriends(watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2)
    >>> ["D"]
    Explanation:
    You have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).
    """


Prompt:
def minInsertions(s: str) -> int:
    """
    Given a string s. In one step you can insert any character at any index of the string.
    Return the minimum number of steps to make s palindrome.
    A Palindrome String is one that reads the same backward as well as forward.

    Example 1:

    >>> minInsertions(s = "zzazz")
    >>> 0
    Explanation: The string "zzazz" is already palindrome we do not need any insertions.

    Example 2:

    >>> minInsertions(s = "mbadm")
    >>> 2
    Explanation: String can be "mbdadbm" or "mdbabdm".

    Example 3:

    >>> minInsertions(s = "leetcode")
    >>> 5
    Explanation: Inserting 5 characters the string becomes "leetcodocteel".
    """


Prompt:
def decompressRLElist(nums: List[int]) -> List[int]:
    """
    We are given a list nums of integers representing a list compressed with run-length encoding.
    Consider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.
    Return the decompressed list.

    Example 1:

    >>> decompressRLElist(nums = [1,2,3,4])
    >>> [2,4,4,4]
    Explanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].
    The second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].
    At the end the concatenation [2] + [4,4,4] is [2,4,4,4].

    Example 2:

    >>> decompressRLElist(nums = [1,1,2,3])
    >>> [1,3,3]
    """


Prompt:
def matrixBlockSum(mat: List[List[int]], k: int) -> List[List[int]]:
    """
    Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:

    i - k <= r <= i + k,
    j - k <= c <= j + k, and
    (r, c) is a valid position in the matrix.

    Example 1:

    >>> matrixBlockSum(mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1)
    >>> [[12,21,16],[27,45,33],[24,39,28]]

    Example 2:

    >>> matrixBlockSum(mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2)
    >>> [[45,45,45],[45,45,45],[45,45,45]]
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def sumEvenGrandparent(root: Optional[TreeNode]) -> int:
    """
    Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0.
    A grandparent of a node is the parent of its parent if it exists.

    Example 1:

    >>> __init__(root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5])
    >>> 18
    Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.

    Example 2:

    >>> __init__(root = [1])
    >>> 0
    """


Prompt:
def distinctEchoSubstrings(text: str) -> int:
    """
    Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).

    Example 1:

    >>> distinctEchoSubstrings(text = "abcabcabc")
    >>> 3
    Explanation: The 3 substrings are "abcabc", "bcabca" and "cabcab".

    Example 2:

    >>> distinctEchoSubstrings(text = "leetcodeleetcode")
    >>> 2
    Explanation: The 2 substrings are "ee" and "leetcodeleetcode".
    """


Prompt:
def getNoZeroIntegers(n: int) -> List[int]:
    """
    No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.
    Given an integer n, return a list of two integers [a, b] where:

    a and b are No-Zero integers.
    a + b = n

    The test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can return any of them.

    Example 1:

    >>> getNoZeroIntegers(n = 2)
    >>> [1,1]
    Explanation: Let a = 1 and b = 1.
    Both a and b are no-zero integers, and a + b = 2 = n.

    Example 2:

    >>> getNoZeroIntegers(n = 11)
    >>> [2,9]
    Explanation: Let a = 2 and b = 9.
    Both a and b are no-zero integers, and a + b = 11 = n.
    Note that there are other valid answers as [8, 3] that can be accepted.
    """


Prompt:
def minFlips(a: int, b: int, c: int) -> int:
    """
    Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).\r
    Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    \r
    \r
    >>> minFlips(a = 2, b = 6, c = 5\r)
    >>> 3\r
    Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)\r
    \r
    Example 2:\r
    \r
    \r
    >>> minFlips(a = 4, b = 2, c = 7\r)
    >>> 1\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> minFlips(a = 1, b = 2, c = 3\r)
    >>> 0\r
    \r
    \r
     \r
    """


Prompt:
def makeConnected(n: int, connections: List[List[int]]) -> int:
    """
    There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.
    You are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.
    Return the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.

    Example 1:

    >>> makeConnected(n = 4, connections = [[0,1],[0,2],[1,2]])
    >>> 1
    Explanation: Remove cable between computer 1 and 2 and place between computers 1 and 3.

    Example 2:

    >>> makeConnected(n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]])
    >>> 2

    Example 3:

    >>> makeConnected(n = 6, connections = [[0,1],[0,2],[0,3],[1,2]])
    >>> -1
    Explanation: There are not enough cables.
    """


Prompt:
def minimumDistance(word: str) -> int:
    """
    You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.

    For example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at coordinate (4, 1).

    Given the string word, return the minimum total distance to type such string using only two fingers.
    The distance between coordinates (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|.
    Note that the initial positions of your two fingers are considered free so do not count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.

    Example 1:

    >>> minimumDistance(word = "CAKE")
    >>> 3
    Explanation: Using two fingers, one optimal way to type "CAKE" is:
    Finger 1 on letter 'C' -> cost = 0
    Finger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2
    Finger 2 on letter 'K' -> cost = 0
    Finger 2 on letter 'E' -> cost = Distance from letter 'K' to letter 'E' = 1
    Total distance = 3

    Example 2:

    >>> minimumDistance(word = "HAPPY")
    >>> 6
    Explanation: Using two fingers, one optimal way to type "HAPPY" is:
    Finger 1 on letter 'H' -> cost = 0
    Finger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2
    Finger 2 on letter 'P' -> cost = 0
    Finger 2 on letter 'P' -> cost = Distance from letter 'P' to letter 'P' = 0
    Finger 1 on letter 'Y' -> cost = Distance from letter 'A' to letter 'Y' = 4
    Total distance = 6
    """


Prompt:
def printVertically(s: str) -> List[str]:
    """
    Given a string s. Return all the words vertically in the same order in which they appear in s.\r
    Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).\r
    Each word would be put on only one column and that in one column there will be only one word.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> printVertically(s = "HOW ARE YOU"\r)
    >>> ["HAY","ORO","WEU"]\r
    Explanation: Each word is printed vertically. \r
     "HAY"\r
     "ORO"\r
     "WEU"\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> printVertically(s = "TO BE OR NOT TO BE"\r)
    >>> ["TBONTB","OEROOE","   T"]\r
    Explanation: Trailing spaces is not allowed. \r
    "TBONTB"\r
    "OEROOE"\r
    "   T"\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> printVertically(s = "CONTEST IS COMING"\r)
    >>> ["CIC","OSO","N M","T I","E N","S G","T"]\r
    \r
    \r
     \r
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def removeLeafNodes(root: Optional[TreeNode], target: int) -> Optional[TreeNode]:
    """
    Given a binary tree root and an integer target, delete all the leaf nodes with value target.
    Note that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).

    Example 1:

    >>> __init__(root = [1,2,3,2,null,2,4], target = 2)
    >>> [1,null,3,null,4]
    Explanation: Leaf nodes in green with value (target = 2) are removed (Picture in left).
    After removing, new nodes become leaf nodes with value (target = 2) (Picture in center).

    Example 2:

    >>> __init__(root = [1,3,3,3,2], target = 3)
    >>> [1,3,null,null,2]

    Example 3:

    >>> __init__(root = [1,2,null,2,null,2], target = 2)
    >>> [1]
    Explanation: Leaf nodes in green with value (target = 2) are removed at each step.
    """


Prompt:
def minTaps(n: int, ranges: List[int]) -> int:
    """
    There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).
    There are n + 1 taps located at points [0, 1, ..., n] in the garden.
    Given an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.
    Return the minimum number of taps that should be open to water the whole garden, If the garden cannot be watered return -1.

    Example 1:

    >>> minTaps(n = 5, ranges = [3,4,1,1,0,0])
    >>> 1
    Explanation: The tap at point 0 can cover the interval [-3,3]
    The tap at point 1 can cover the interval [-3,5]
    The tap at point 2 can cover the interval [1,3]
    The tap at point 3 can cover the interval [2,4]
    The tap at point 4 can cover the interval [4,4]
    The tap at point 5 can cover the interval [5,5]
    Opening Only the second tap will water the whole garden [0,5]

    Example 2:

    >>> minTaps(n = 3, ranges = [0,0,0,0])
    >>> -1
    Explanation: Even if you activate all the four taps you cannot water the whole garden.
    """


Prompt:
def breakPalindrome(palindrome: str) -> str:
    """
    Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.
    Return the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.
    A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, a has a character strictly smaller than the corresponding character in b. For example, "abcc" is lexicographically smaller than "abcd" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.

    Example 1:

    >>> breakPalindrome(palindrome = "abccba")
    >>> "aaccba"
    Explanation: There are many ways to make "abccba" not a palindrome, such as "zbccba", "aaccba", and "abacba".
    Of all the ways, "aaccba" is the lexicographically smallest.

    Example 2:

    >>> breakPalindrome(palindrome = "a")
    >>> ""
    Explanation: There is no way to replace a single character to make "a" not a palindrome, so return an empty string.
    """


Prompt:
def diagonalSort(mat: List[List[int]]) -> List[List[int]]:
    """
    A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2].
    Given an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.

    Example 1:

    >>> diagonalSort(mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]])
    >>> [[1,1,1,1],[1,2,2,2],[1,2,3,3]]

    Example 2:

    >>> diagonalSort(mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]])
    >>> [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]
    """


Prompt:
def maxValueAfterReverse(nums: List[int]) -> int:
    """
    You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.
    You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.
    Find maximum possible value of the final array.

    Example 1:

    >>> maxValueAfterReverse(nums = [2,3,1,5,4])
    >>> 10
    Explanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.

    Example 2:

    >>> maxValueAfterReverse(nums = [2,4,9,24,2,1,10])
    >>> 68
    """


Prompt:
def arrayRankTransform(arr: List[int]) -> List[int]:
    """
    Given an array of integers arr, replace each element with its rank.
    The rank represents how large the element is. The rank has the following rules:

    Rank is an integer starting from 1.
    The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
    Rank should be as small as possible.

    Example 1:

    >>> arrayRankTransform(arr = [40,10,20,30])
    >>> [4,1,2,3]
    Explanation: 40 is the largest element. 10 is the smallest. 20 is the second smallest. 30 is the third smallest.
    Example 2:

    >>> arrayRankTransform(arr = [100,100,100])
    >>> [1,1,1]
    Explanation: Same elements share the same rank.

    Example 3:

    >>> arrayRankTransform(arr = [37,12,28,9,100,56,80,5,12])
    >>> [5,3,4,2,8,6,7,1,3]
    """


Prompt:
def removePalindromeSub(s: str) -> int:
    """
    You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.
    Return the minimum number of steps to make the given string empty.
    A string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.
    A string is called palindrome if is one that reads the same backward as well as forward.

    Example 1:

    >>> removePalindromeSub(s = "ababa")
    >>> 1
    Explanation: s is already a palindrome, so its entirety can be removed in a single step.

    Example 2:

    >>> removePalindromeSub(s = "abb")
    >>> 2
    Explanation: "abb" -> "bb" -> "".
    Remove palindromic subsequence "a" then "bb".

    Example 3:

    >>> removePalindromeSub(s = "baabb")
    >>> 2
    Explanation: "baabb" -> "b" -> "".
    Remove palindromic subsequence "baab" then "b".
    """


Prompt:
def filterRestaurants(restaurants: List[List[int]], veganFriendly: int, maxPrice: int, maxDistance: int) -> List[int]:
    """
    Given the array restaurants where  restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You have to filter the restaurants using three filters.
    The veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any restaurant). In addition, you have the filters maxPrice and maxDistance which are the maximum value for price and distance of restaurants you should consider respectively.
    Return the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest. For simplicity veganFriendlyi and veganFriendly take value 1 when it is true, and 0 when it is false.

    Example 1:

    >>> filterRestaurants(restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 1, maxPrice = 50, maxDistance = 10)
    >>> [3,1,5]
    Explanation:
    The restaurants are:
    Restaurant 1 [id=1, rating=4, veganFriendly=1, price=40, distance=10]
    Restaurant 2 [id=2, rating=8, veganFriendly=0, price=50, distance=5]
    Restaurant 3 [id=3, rating=8, veganFriendly=1, price=30, distance=4]
    Restaurant 4 [id=4, rating=10, veganFriendly=0, price=10, distance=3]
    Restaurant 5 [id=5, rating=1, veganFriendly=1, price=15, distance=1]
    After filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = 10 we have restaurant 3, restaurant 1 and restaurant 5 (ordered by rating from highest to lowest).

    Example 2:

    >>> filterRestaurants(restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 50, maxDistance = 10)
    >>> [4,3,2,1,5]
    Explanation: The restaurants are the same as in example 1, but in this case the filter veganFriendly = 0, therefore all restaurants are considered.

    Example 3:

    >>> filterRestaurants(restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 30, maxDistance = 3)
    >>> [4,5]
    """


Prompt:
def findTheCity(n: int, edges: List[List[int]], distanceThreshold: int) -> int:
    """
    There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.
    Return the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.
    Notice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.

    Example 1:

    >>> findTheCity(n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4)
    >>> 3
    Explanation: The figure above describes the graph.
    The neighboring cities at a distanceThreshold = 4 for each city are:
    City 0 -> [City 1, City 2]
    City 1 -> [City 0, City 2, City 3]
    City 2 -> [City 0, City 1, City 3]
    City 3 -> [City 1, City 2]
    Cities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.

    Example 2:

    >>> findTheCity(n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2)
    >>> 0
    Explanation: The figure above describes the graph.
    The neighboring cities at a distanceThreshold = 2 for each city are:
    City 0 -> [City 1]
    City 1 -> [City 0, City 4]
    City 2 -> [City 3, City 4]
    City 3 -> [City 2, City 4]
    City 4 -> [City 1, City 2, City 3]
    The city 0 has 1 neighboring city at a distanceThreshold = 2.
    """


Prompt:
def minDifficulty(jobDifficulty: List[int], d: int) -> int:
    """
    You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).
    You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.
    You are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].
    Return the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.

    Example 1:

    >>> minDifficulty(jobDifficulty = [6,5,4,3,2,1], d = 2)
    >>> 7
    Explanation: First day you can finish the first 5 jobs, total difficulty = 6.
    Second day you can finish the last job, total difficulty = 1.
    The difficulty of the schedule = 6 + 1 = 7

    Example 2:

    >>> minDifficulty(jobDifficulty = [9,9,9], d = 4)
    >>> -1
    Explanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.

    Example 3:

    >>> minDifficulty(jobDifficulty = [1,1,1], d = 3)
    >>> 3
    Explanation: The schedule is one job per day. total difficulty will be 3.
    """


Prompt:
def kWeakestRows(mat: List[List[int]], k: int) -> List[int]:
    """
    You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.
    A row i is weaker than a row j if one of the following is true:

    The number of soldiers in row i is less than the number of soldiers in row j.
    Both rows have the same number of soldiers and i < j.

    Return the indices of the k weakest rows in the matrix ordered from weakest to strongest.

    Example 1:

    [[1,1,0,0,0],
     [1,1,1,1,0],
     [1,0,0,0,0],
     [1,1,0,0,0],
     [1,1,1,1,1]],
    k = 3
    >>> kWeakestRows(mat =)
    >>> [2,0,3]
    Explanation:
    The number of soldiers in each row is:
    - Row 0: 2
    - Row 1: 4
    - Row 2: 1
    - Row 3: 2
    - Row 4: 5
    The rows ordered from weakest to strongest are [2,0,3,1,4].

    Example 2:

    [[1,0,0,0],
     [1,1,1,1],
     [1,0,0,0],
     [1,0,0,0]],
    k = 2
    >>> kWeakestRows(mat =)
    >>> [0,2]
    Explanation:
    The number of soldiers in each row is:
    - Row 0: 1
    - Row 1: 4
    - Row 2: 1
    - Row 3: 1
    The rows ordered from weakest to strongest are [0,2,3,1].
    """


Prompt:
def minSetSize(arr: List[int]) -> int:
    """
    You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.
    Return the minimum size of the set so that at least half of the integers of the array are removed.

    Example 1:

    >>> minSetSize(arr = [3,3,3,3,5,5,5,2,2,7])
    >>> 2
    Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).
    Possible sets of size 2 are {3,5},{3,2},{5,2}.
    Choosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.

    Example 2:

    >>> minSetSize(arr = [7,7,7,7,7,7])
    >>> 1
    Explanation: The only possible set you can choose is {7}. This will make the new array empty.
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def maxProduct(root: Optional[TreeNode]) -> int:
    """
    Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.
    Return the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7.
    Note that you need to maximize the answer before taking the mod and not after taking it.

    Example 1:

    >>> __init__(root = [1,2,3,4,5,6])
    >>> 110
    Explanation: Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11*10)

    Example 2:

    >>> __init__(root = [1,null,2,3,4,null,null,5,6])
    >>> 90
    Explanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)
    """


Prompt:
def maxJumps(arr: List[int], d: int) -> int:
    """
    Given an array of integers arr and an integer d. In one step you can jump from index i to index:

    i + x where: i + x < arr.length and  0 < x <= d.
    i - x where: i - x >= 0 and  0 < x <= d.

    In addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).
    You can choose any index of the array and start jumping. Return the maximum number of indices you can visit.
    Notice that you can not jump outside of the array at any time.

    Example 1:

    >>> maxJumps(arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2)
    >>> 4
    Explanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.
    Note that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.
    Similarly You cannot jump from index 3 to index 2 or index 1.

    Example 2:

    >>> maxJumps(arr = [3,3,3,3,3], d = 3)
    >>> 1
    Explanation: You can start at any index. You always cannot jump to any index.

    Example 3:

    >>> maxJumps(arr = [7,6,5,4,3,2,1], d = 1)
    >>> 7
    Explanation: Start at index 0. You can visit all the indicies.
    """


Prompt:
def numberOfSteps(num: int) -> int:
    """
    Given an integer num, return the number of steps to reduce it to zero.
    In one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.

    Example 1:

    >>> numberOfSteps(num = 14)
    >>> 6
    Explanation:
    Step 1) 14 is even; divide by 2 and obtain 7.
    Step 2) 7 is odd; subtract 1 and obtain 6.
    Step 3) 6 is even; divide by 2 and obtain 3.
    Step 4) 3 is odd; subtract 1 and obtain 2.
    Step 5) 2 is even; divide by 2 and obtain 1.
    Step 6) 1 is odd; subtract 1 and obtain 0.

    Example 2:

    >>> numberOfSteps(num = 8)
    >>> 4
    Explanation:
    Step 1) 8 is even; divide by 2 and obtain 4.
    Step 2) 4 is even; divide by 2 and obtain 2.
    Step 3) 2 is even; divide by 2 and obtain 1.
    Step 4) 1 is odd; subtract 1 and obtain 0.

    Example 3:

    >>> numberOfSteps(num = 123)
    >>> 12
    """


Prompt:
def numOfSubarrays(arr: List[int], k: int, threshold: int) -> int:
    """
    Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.

    Example 1:

    >>> numOfSubarrays(arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4)
    >>> 3
    Explanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).

    Example 2:

    >>> numOfSubarrays(arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5)
    >>> 6
    Explanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.
    """


Prompt:
def angleClock(hour: int, minutes: int) -> float:
    """
    Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.
    Answers within 10-5 of the actual value will be accepted as correct.

    Example 1:

    >>> angleClock(hour = 12, minutes = 30)
    >>> 165

    Example 2:

    >>> angleClock(hour = 3, minutes = 30)
    >>> 75

    Example 3:

    >>> angleClock(hour = 3, minutes = 15)
    >>> 7.5
    """


Prompt:
def minJumps(arr: List[int]) -> int:
    """
    Given an array of integers arr, you are initially positioned at the first index of the array.
    In one step you can jump from index i to index:

    i + 1 where: i + 1 < arr.length.
    i - 1 where: i - 1 >= 0.
    j where: arr[i] == arr[j] and i != j.

    Return the minimum number of steps to reach the last index of the array.
    Notice that you can not jump outside of the array at any time.

    Example 1:

    >>> minJumps(arr = [100,-23,-23,404,100,23,23,23,3,404])
    >>> 3
    Explanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.

    Example 2:

    >>> minJumps(arr = [7])
    >>> 0
    Explanation: Start index is the last index. You do not need to jump.

    Example 3:

    >>> minJumps(arr = [7,6,9,6,9,6,9,7])
    >>> 1
    Explanation: You can jump directly from index 0 to index 7 which is last index of the array.
    """


Prompt:
def checkIfExist(arr: List[int]) -> bool:
    """
    Given an array arr of integers, check if there exist two indices i and j such that :

    i != j
    0 <= i, j < arr.length
    arr[i] == 2 * arr[j]

    Example 1:

    >>> checkIfExist(arr = [10,2,5,3])
    >>> true
    Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]

    Example 2:

    >>> checkIfExist(arr = [3,1,7,11])
    >>> false
    Explanation: There is no i and j that satisfy the conditions.
    """


Prompt:
def minSteps(s: str, t: str) -> int:
    """
    You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
    Return the minimum number of steps to make t an anagram of s.
    An Anagram of a string is a string that contains the same characters with a different (or the same) ordering.

    Example 1:

    >>> minSteps(s = "bab", t = "aba")
    >>> 1
    Explanation: Replace the first 'a' in t with b, t = "bba" which is anagram of s.

    Example 2:

    >>> minSteps(s = "leetcode", t = "practice")
    >>> 5
    Explanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.

    Example 3:

    >>> minSteps(s = "anagram", t = "mangaar")
    >>> 0
    Explanation: "anagram" and "mangaar" are anagrams.
    """


Prompt:
def maxStudents(seats: List[List[str]]) -> int:
    """
    Given a m * n matrix seats  that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.
    Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible.
    Students must be placed in seats in good condition.

    Example 1:

                    [".","#","#","#","#","."],
                    ["#",".","#","#",".","#"]]
    >>> maxStudents(seats = [["#",".","#","#",".","#"],)
    >>> 4
    Explanation: Teacher can place 4 students in available seats so they don't cheat on the exam.

    Example 2:

                    ["#","#"],
                    ["#","."],
                    ["#","#"],
                    [".","#"]]
    >>> maxStudents(seats = [[".","#"],)
    >>> 3
    Explanation: Place all students in available seats.

    Example 3:

                    [".","#",".","#","."],
                    [".",".","#",".","."],
                    [".","#",".","#","."],
                    ["#",".",".",".","#"]]
    >>> maxStudents(seats = [["#",".",".",".","#"],)
    >>> 10
    Explanation: Place students in available seats in column 1, 3 and 5.
    """


Prompt:
def countNegatives(grid: List[List[int]]) -> int:
    """
    Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.

    Example 1:

    >>> countNegatives(grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]])
    >>> 8
    Explanation: There are 8 negatives number in the matrix.

    Example 2:

    >>> countNegatives(grid = [[3,2],[1,0]])
    >>> 0
    """


Prompt:
def maxEvents(events: List[List[int]]) -> int:
    """
    You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.
    You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.
    Return the maximum number of events you can attend.

    Example 1:

    >>> maxEvents(events = [[1,2],[2,3],[3,4]])
    >>> 3
    Explanation: You can attend all the three events.
    One way to attend them all is as shown.
    Attend the first event on day 1.
    Attend the second event on day 2.
    Attend the third event on day 3.

    Example 2:

    >>> maxEvents(events= [[1,2],[2,3],[3,4],[1,2]])
    >>> 4
    """


Prompt:
def isPossible(target: List[int]) -> bool:
    """
    You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :

    let x be the sum of all elements currently in your array.
    choose index i, such that 0 <= i < n and set the value of arr at index i to x.
    You may repeat this procedure as many times as needed.

    Return true if it is possible to construct the target array from arr, otherwise, return false.

    Example 1:

    >>> isPossible(target = [9,3,5])
    >>> true
    Explanation: Start with arr = [1, 1, 1]
    [1, 1, 1], sum = 3 choose index 1
    [1, 3, 1], sum = 5 choose index 2
    [1, 3, 5], sum = 9 choose index 0
    [9, 3, 5] Done

    Example 2:

    >>> isPossible(target = [1,1,1,2])
    >>> false
    Explanation: Impossible to create target array from [1,1,1,1].

    Example 3:

    >>> isPossible(target = [8,5])
    >>> true
    """


Prompt:
def sortByBits(arr: List[int]) -> List[int]:
    """
    You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.
    Return the array after sorting it.

    Example 1:

    >>> sortByBits(arr = [0,1,2,3,4,5,6,7,8])
    >>> [0,1,2,4,8,3,5,6,7]
    Explantion: [0] is the only integer with 0 bits.
    [1,2,4,8] all have 1 bit.
    [3,5,6] have 2 bits.
    [7] has 3 bits.
    The sorted array by bits is [0,1,2,4,8,3,5,6,7]

    Example 2:

    >>> sortByBits(arr = [1024,512,256,128,64,32,16,8,4,2,1])
    >>> [1,2,4,8,16,32,64,128,256,512,1024]
    Explantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order.
    """


Prompt:
def numberOfSubstrings(s: str) -> int:
    """
    Given a string s consisting only of characters a, b and c.
    Return the number of substrings containing at least one occurrence of all these characters a, b and c.

    Example 1:

    >>> numberOfSubstrings(s = "abcabc")
    >>> 10
    Explanation: The substrings containing at least one occurrence of the characters a, b and c are "abc", "abca", "abcab", "abcabc", "bca", "bcab", "bcabc", "cab", "cabc" and "abc" (again).

    Example 2:

    >>> numberOfSubstrings(s = "aaacb")
    >>> 3
    Explanation: The substrings containing at least one occurrence of the characters a, b and c are "aaacb", "aacb" and "acb".

    Example 3:

    >>> numberOfSubstrings(s = "abc")
    >>> 1
    """


Prompt:
def countOrders(n: int) -> int:
    """
    Given n orders, each order consists of a pickup and a delivery service.
    Count all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i).
    Since the answer may be too large, return it modulo 10^9 + 7.

    Example 1:

    >>> countOrders(n = 1)
    >>> 1
    Explanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.

    Example 2:

    >>> countOrders(n = 2)
    >>> 6
    Explanation: All possible orders:
    (P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).
    This is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.

    Example 3:

    >>> countOrders(n = 3)
    >>> 90
    """


Prompt:
def daysBetweenDates(date1: str, date2: str) -> int:
    """
    Write a program to count the number of days between two dates.
    The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.

    Example 1:
    >>> daysBetweenDates(date1 = "2019-06-29", date2 = "2019-06-30")
    >>> 1
    Example 2:
    >>> daysBetweenDates(date1 = "2020-01-15", date2 = "2019-12-31")
    >>> 15
    """


Prompt:
def validateBinaryTreeNodes(n: int, leftChild: List[int], rightChild: List[int]) -> bool:
    """
    You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.
    If node i has no left child then leftChild[i] will equal -1, similarly for the right child.
    Note that the nodes have no values and that we only use the node numbers in this problem.

    Example 1:

    >>> validateBinaryTreeNodes(n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1])
    >>> true

    Example 2:

    >>> validateBinaryTreeNodes(n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1])
    >>> false

    Example 3:

    >>> validateBinaryTreeNodes(n = 2, leftChild = [1,0], rightChild = [-1,-1])
    >>> false
    """


Prompt:
def closestDivisors(num: int) -> List[int]:
    """
    Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.
    Return the two integers in any order.

    Example 1:

    >>> closestDivisors(num = 8)
    >>> [3,3]
    Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.

    Example 2:

    >>> closestDivisors(num = 123)
    >>> [5,25]

    Example 3:

    >>> closestDivisors(num = 999)
    >>> [40,25]
    """


Prompt:
def largestMultipleOfThree(digits: List[int]) -> str:
    """
    Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.
    Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.

    Example 1:

    >>> largestMultipleOfThree(digits = [8,1,9])
    >>> "981"

    Example 2:

    >>> largestMultipleOfThree(digits = [8,6,7,1,0])
    >>> "8760"

    Example 3:

    >>> largestMultipleOfThree(digits = [1])
    >>> ""
    """


Prompt:
def smallerNumbersThanCurrent(nums: List[int]) -> List[int]:
    """
    Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].
    Return the answer in an array.

    Example 1:

    >>> smallerNumbersThanCurrent(nums = [8,1,2,2,3])
    >>> [4,0,1,1,3]
    Explanation:
    For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3).
    For nums[1]=1 does not exist any smaller number than it.
    For nums[2]=2 there exist one smaller number than it (1).
    For nums[3]=2 there exist one smaller number than it (1).
    For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).

    Example 2:

    >>> smallerNumbersThanCurrent(nums = [6,5,4,8])
    >>> [2,1,0,3]

    Example 3:

    >>> smallerNumbersThanCurrent(nums = [7,7,7,7])
    >>> [0,0,0,0]
    """


Prompt:
def rankTeams(votes: List[str]) -> str:
    """
    In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.
    The ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie again, we continue this process until the ties are resolved. If two or more teams are still tied after considering all positions, we rank them alphabetically based on their team letter.
    You are given an array of strings votes which is the votes of all voters in the ranking systems. Sort all teams according to the ranking system described above.
    Return a string of all teams sorted by the ranking system.

    Example 1:

    >>> rankTeams(votes = ["ABC","ACB","ABC","ACB","ACB"])
    >>> "ACB"
    Explanation:
    Team A was ranked first place by 5 voters. No other team was voted as first place, so team A is the first team.
    Team B was ranked second by 2 voters and ranked third by 3 voters.
    Team C was ranked second by 3 voters and ranked third by 2 voters.
    As most of the voters ranked C second, team C is the second team, and team B is the third.

    Example 2:

    >>> rankTeams(votes = ["WXYZ","XYZW"])
    >>> "XWYZ"
    Explanation:
    X is the winner due to the tie-breaking rule. X has the same votes as W for the first position, but X has one vote in the second position, while W does not have any votes in the second position.

    Example 3:

    >>> rankTeams(votes = ["ZMNAGUEDSJYLBOPHRQICWFXTVK"])
    >>> "ZMNAGUEDSJYLBOPHRQICWFXTVK"
    Explanation: Only one voter, so their votes are used for the ranking.
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
# Definition for a binary tree node.
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def isSubPath(head: Optional[ListNode], root: Optional[TreeNode]) -> bool:
    """
    Given a binary tree root and a linked list with head as the first node.
    Return True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False.
    In this context downward path means a path that starts at some node and goes downwards.

    Example 1:

    >>> __init__(head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3])
    >>> true
    Explanation: Nodes in blue form a subpath in the binary Tree.

    Example 2:

    >>> __init__(head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3])
    >>> true

    Example 3:

    >>> __init__(head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3])
    >>> false
    Explanation: There is no path in the binary tree that contains all the elements of the linked list from head.
    """


Prompt:
def minCost(grid: List[List[int]]) -> int:
    """
    Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:

    1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])
    2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])
    3 which means go to the lower cell. (i.e go from grid[i][j] to grid[i + 1][j])
    4 which means go to the upper cell. (i.e go from grid[i][j] to grid[i - 1][j])

    Notice that there could be some signs on the cells of the grid that point outside the grid.
    You will initially start at the upper left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1) following the signs on the grid. The valid path does not have to be the shortest.
    You can modify the sign on a cell with cost = 1. You can modify the sign on a cell one time only.
    Return the minimum cost to make the grid have at least one valid path.

    Example 1:

    >>> minCost(grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]])
    >>> 3
    Explanation: You will start at point (0, 0).
    The path to (3, 3) is as follows. (0, 0) --> (0, 1) --> (0, 2) --> (0, 3) change the arrow to down with cost = 1 --> (1, 3) --> (1, 2) --> (1, 1) --> (1, 0) change the arrow to down with cost = 1 --> (2, 0) --> (2, 1) --> (2, 2) --> (2, 3) change the arrow to down with cost = 1 --> (3, 3)
    The total cost = 3.

    Example 2:

    >>> minCost(grid = [[1,1,3],[3,2,2],[1,1,4]])
    >>> 0
    Explanation: You can follow the path from (0, 0) to (2, 2).

    Example 3:

    >>> minCost(grid = [[1,2],[4,3]])
    >>> 1
    """


Prompt:
def sortString(s: str) -> str:
    """
    You are given a string s. Reorder the string using the following algorithm:

    Remove the smallest character from s and append it to the result.
    Remove the smallest character from s that is greater than the last appended character, and append it to the result.
    Repeat step 2 until no more characters can be removed.
    Remove the largest character from s and append it to the result.
    Remove the largest character from s that is smaller than the last appended character, and append it to the result.
    Repeat step 5 until no more characters can be removed.
    Repeat steps 1 through 6 until all characters from s have been removed.

    If the smallest or largest character appears more than once, you may choose any occurrence to append to the result.
    Return the resulting string after reordering s using this algorithm.

    Example 1:

    >>> sortString(s = "aaaabbbbcccc")
    >>> "abccbaabccba"
    Explanation: After steps 1, 2 and 3 of the first iteration, result = "abc"
    After steps 4, 5 and 6 of the first iteration, result = "abccba"
    First iteration is done. Now s = "aabbcc" and we go back to step 1
    After steps 1, 2 and 3 of the second iteration, result = "abccbaabc"
    After steps 4, 5 and 6 of the second iteration, result = "abccbaabccba"

    Example 2:

    >>> sortString(s = "rat")
    >>> "art"
    Explanation: The word "rat" becomes "art" after re-ordering it with the mentioned algorithm.
    """


Prompt:
def findTheLongestSubstring(s: str) -> int:
    """
    Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.

    Example 1:

    >>> findTheLongestSubstring(s = "eleetminicoworoep")
    >>> 13
    Explanation: The longest substring is "leetminicowor" which contains two each of the vowels: e, i and o and zero of the vowels: a and u.

    Example 2:

    >>> findTheLongestSubstring(s = "leetcodeisgreat")
    >>> 5
    Explanation: The longest substring is "leetc" which contains two e's.

    Example 3:

    >>> findTheLongestSubstring(s = "bcbcbc")
    >>> 6
    Explanation: In this case, the given string "bcbcbc" is the longest because all vowels: a, e, i, o and u appear zero times.
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def longestZigZag(root: Optional[TreeNode]) -> int:
    """
    You are given the root of a binary tree.
    A ZigZag path for a binary tree is defined as follow:

    Choose any node in the binary tree and a direction (right or left).
    If the current direction is right, move to the right child of the current node; otherwise, move to the left child.
    Change the direction from right to left or from left to right.
    Repeat the second and third steps until you can't move in the tree.

    Zigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).
    Return the longest ZigZag path contained in that tree.

    Example 1:

    >>> __init__(root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1])
    >>> 3
    Explanation: Longest ZigZag path in blue nodes (right -> left -> right).

    Example 2:

    >>> __init__(root = [1,1,1,null,1,null,null,1,1,null,1])
    >>> 4
    Explanation: Longest ZigZag path in blue nodes (left -> right -> left -> right).

    Example 3:

    >>> __init__(root = [1])
    >>> 0
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def maxSumBST(root: Optional[TreeNode]) -> int:
    """
    Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).
    Assume a BST is defined as follows:

    The left subtree of a node contains only nodes with keys less than the node's key.
    The right subtree of a node contains only nodes with keys greater than the node's key.
    Both the left and right subtrees must also be binary search trees.

    Example 1:

    >>> __init__(root = [1,4,3,2,4,2,5,null,null,null,null,null,null,4,6])
    >>> 20
    Explanation: Maximum sum in a valid Binary search tree is obtained in root node with key equal to 3.

    Example 2:

    >>> __init__(root = [4,3,null,1,2])
    >>> 2
    Explanation: Maximum sum in a valid Binary search tree is obtained in a single root node with key equal to 2.

    Example 3:

    >>> __init__(root = [-4,-2,-5])
    >>> 0
    Explanation: All values are negatives. Return an empty BST.
    """


Prompt:
def generateTheString(n: int) -> str:
    """
    Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.
    The returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.

    Example 1:

    >>> generateTheString(n = 4)
    >>> "pppz"
    Explanation: "pppz" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as "ohhh" and "love".

    Example 2:

    >>> generateTheString(n = 2)
    >>> "xy"
    Explanation: "xy" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as "ag" and "ur".

    Example 3:

    >>> generateTheString(n = 7)
    >>> "holasss"
    """


Prompt:
def numTimesAllBlue(flips: List[int]) -> int:
    """
    You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index i will be flipped in the ith step.
    A binary string is prefix-aligned if, after the ith step, all the bits in the inclusive range [1, i] are ones and all the other bits are zeros.
    Return the number of times the binary string is prefix-aligned during the flipping process.

    Example 1:

    >>> numTimesAllBlue(flips = [3,2,4,1,5])
    >>> 2
    Explanation: The binary string is initially "00000".
    After applying step 1: The string becomes "00100", which is not prefix-aligned.
    After applying step 2: The string becomes "01100", which is not prefix-aligned.
    After applying step 3: The string becomes "01110", which is not prefix-aligned.
    After applying step 4: The string becomes "11110", which is prefix-aligned.
    After applying step 5: The string becomes "11111", which is prefix-aligned.
    We can see that the string was prefix-aligned 2 times, so we return 2.

    Example 2:

    >>> numTimesAllBlue(flips = [4,1,2,3])
    >>> 1
    Explanation: The binary string is initially "0000".
    After applying step 1: The string becomes "0001", which is not prefix-aligned.
    After applying step 2: The string becomes "1001", which is not prefix-aligned.
    After applying step 3: The string becomes "1101", which is not prefix-aligned.
    After applying step 4: The string becomes "1111", which is prefix-aligned.
    We can see that the string was prefix-aligned 1 time, so we return 1.
    """


Prompt:
def numOfMinutes(n: int, headID: int, manager: List[int], informTime: List[int]) -> int:
    """
    A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.
    Each employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination relationships have a tree structure.
    The head of the company wants to inform all the company employees of an urgent piece of news. He will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news.
    The i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e., After informTime[i] minutes, all his direct subordinates can start spreading the news).
    Return the number of minutes needed to inform all the employees about the urgent news.

    Example 1:

    >>> numOfMinutes(n = 1, headID = 0, manager = [-1], informTime = [0])
    >>> 0
    Explanation: The head of the company is the only employee in the company.

    Example 2:

    >>> numOfMinutes(n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0])
    >>> 1
    Explanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.
    The tree structure of the employees in the company is shown.
    """


Prompt:
def frogPosition(n: int, edges: List[List[int]], t: int, target: int) -> float:
    """
    Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it jumps randomly to one of them with the same probability. Otherwise, when the frog can not jump to any unvisited vertex, it jumps forever on the same vertex.
    The edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.
    Return the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> frogPosition(n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4)
    >>> 0.16666666666666666
    Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666.

    Example 2:

    >>> frogPosition(n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7)
    >>> 0.3333333333333333
    Explanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1.
    """


Prompt:
# class TreeNode:
#     def __init__(x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def getTargetCopy(original: TreeNode, cloned: TreeNode, target: TreeNode) -> TreeNode:
    """
    Given two binary trees original and cloned and given a reference to a node target in the original tree.
    The cloned tree is a copy of the original tree.
    Return a reference to the same node in the cloned tree.
    Note that you are not allowed to change any of the two trees or the target node and the answer must be a reference to a node in the cloned tree.

    Example 1:

    >>> __init__(tree = [7,4,3,null,null,6,19], target = 3)
    >>> 3
    Explanation: In all examples the original and cloned trees are shown. The target node is a green node from the original tree. The answer is the yellow node from the cloned tree.

    Example 2:

    >>> __init__(tree = [7], target =  7)
    >>> 7

    Example 3:

    >>> __init__(tree = [8,null,6,null,5,null,4,null,3,null,2,null,1], target = 4)
    >>> 4
    """


Prompt:
def luckyNumbers(matrix: List[List[int]]) -> List[int]:
    """
    Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.
    A lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.

    Example 1:

    >>> luckyNumbers(matrix = [[3,7,8],[9,11,13],[15,16,17]])
    >>> [15]
    Explanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column.

    Example 2:

    >>> luckyNumbers(matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]])
    >>> [12]
    Explanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column.

    Example 3:

    >>> luckyNumbers(matrix = [[7,8],[1,2]])
    >>> [7]
    Explanation: 7 is the only lucky number since it is the minimum in its row and the maximum in its column.
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def balanceBST(root: Optional[TreeNode]) -> Optional[TreeNode]:
    """
    Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.
    A binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1.

    Example 1:

    >>> __init__(root = [1,null,2,null,3,null,4,null,null])
    >>> [2,1,3,null,null,null,4]
    Explanation: This is not the only correct answer, [3,1,4,null,2] is also correct.

    Example 2:

    >>> __init__(root = [2,1,3])
    >>> [2,1,3]
    """


Prompt:
def maxPerformance(n: int, speed: List[int], efficiency: List[int], k: int) -> int:
    """
    You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively.
    Choose at most k different engineers out of the n engineers to form a team with the maximum performance.
    The performance of a team is the sum of its engineers' speeds multiplied by the minimum efficiency among its engineers.
    Return the maximum performance of this team. Since the answer can be a huge number, return it modulo 109 + 7.

    Example 1:

    >>> maxPerformance(n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2)
    >>> 60
    Explanation:
    We have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.

    Example 2:

    >>> maxPerformance(n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3)
    >>> 68
    Explanation:
    This is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.

    Example 3:

    >>> maxPerformance(n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4)
    >>> 72
    """


Prompt:
def findTheDistanceValue(arr1: List[int], arr2: List[int], d: int) -> int:
    """
    Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.
    The distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.

    Example 1:

    >>> findTheDistanceValue(arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2)
    >>> 2
    Explanation:
    For arr1[0]=4 we have:
    |4-10|=6 > d=2
    |4-9|=5 > d=2
    |4-1|=3 > d=2
    |4-8|=4 > d=2
    For arr1[1]=5 we have:
    |5-10|=5 > d=2
    |5-9|=4 > d=2
    |5-1|=4 > d=2
    |5-8|=3 > d=2
    For arr1[2]=8 we have:
    |8-10|=2 <= d=2
    |8-9|=1 <= d=2
    |8-1|=7 > d=2
    |8-8|=0 <= d=2

    Example 2:

    >>> findTheDistanceValue(arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3)
    >>> 2

    Example 3:

    >>> findTheDistanceValue(arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6)
    >>> 1
    """


Prompt:
def maxNumberOfFamilies(n: int, reservedSeats: List[List[int]]) -> int:
    """
    A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.
    Given the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i] = [3,8] means the seat located in row 3 and labelled with 8 is already reserved.
    Return the maximum number of four-person groups you can assign on the cinema seats. A four-person group occupies four adjacent seats in one single row. Seats across an aisle (such as [3,3] and [3,4]) are not considered to be adjacent, but there is an exceptional case on which an aisle split a four-person group, in that case, the aisle split a four-person group in the middle, which means to have two people on each side.

    Example 1:

    >>> maxNumberOfFamilies(n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]])
    >>> 4
    Explanation: The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.

    Example 2:

    >>> maxNumberOfFamilies(n = 2, reservedSeats = [[2,1],[1,8],[2,6]])
    >>> 2

    Example 3:

    >>> maxNumberOfFamilies(n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]])
    >>> 4
    """


Prompt:
def getKth(lo: int, hi: int, k: int) -> int:
    """
    The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:

    if x is even then x = x / 2
    if x is odd then x = 3 * x + 1

    For example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).
    Given three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.
    Return the kth integer in the range [lo, hi] sorted by the power value.
    Notice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.

    Example 1:

    >>> getKth(lo = 12, hi = 15, k = 2)
    >>> 13
    Explanation: The power of 12 is 9 (12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)
    The power of 13 is 9
    The power of 14 is 17
    The power of 15 is 17
    The interval sorted by the power value [12,13,14,15]. For k = 2 answer is the second element which is 13.
    Notice that 12 and 13 have the same power value and we sorted them in ascending order. Same for 14 and 15.

    Example 2:

    >>> getKth(lo = 7, hi = 11, k = 4)
    >>> 7
    Explanation: The power array corresponding to the interval [7, 8, 9, 10, 11] is [16, 3, 19, 6, 14].
    The interval sorted by power is [8, 10, 11, 7, 9].
    The fourth number in the sorted array is 7.
    """


Prompt:
def maxSizeSlices(slices: List[int]) -> int:
    """
    There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:

    You will pick any pizza slice.
    Your friend Alice will pick the next slice in the anti-clockwise direction of your pick.
    Your friend Bob will pick the next slice in the clockwise direction of your pick.
    Repeat until there are no more slices of pizzas.

    Given an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.

    Example 1:

    >>> maxSizeSlices(slices = [1,2,3,4,5,6])
    >>> 10
    Explanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.

    Example 2:

    >>> maxSizeSlices(slices = [8,9,8,6,1,1])
    >>> 16
    Explanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.
    """


Prompt:
def createTargetArray(nums: List[int], index: List[int]) -> List[int]:
    """
    Given two arrays of integers nums and index. Your task is to create target array under the following rules:

    Initially target array is empty.
    From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.
    Repeat the previous step until there are no elements to read in nums and index.

    Return the target array.
    It is guaranteed that the insertion operations will be valid.

    Example 1:

    >>> createTargetArray(nums = [0,1,2,3,4], index = [0,1,2,2,1])
    >>> [0,4,1,3,2]
    Explanation:
    nums       index     target
    0            0        [0]
    1            1        [0,1]
    2            2        [0,1,2]
    3            2        [0,1,3,2]
    4            1        [0,4,1,3,2]

    Example 2:

    >>> createTargetArray(nums = [1,2,3,4,0], index = [0,1,2,3,0])
    >>> [0,1,2,3,4]
    Explanation:
    nums       index     target
    1            0        [1]
    2            1        [1,2]
    3            2        [1,2,3]
    4            3        [1,2,3,4]
    0            0        [0,1,2,3,4]

    Example 3:

    >>> createTargetArray(nums = [1], index = [0])
    >>> [1]
    """


Prompt:
def sumFourDivisors(nums: List[int]) -> int:
    """
    Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.

    Example 1:

    >>> sumFourDivisors(nums = [21,4,7])
    >>> 32
    Explanation:
    21 has 4 divisors: 1, 3, 7, 21
    4 has 3 divisors: 1, 2, 4
    7 has 2 divisors: 1, 7
    The answer is the sum of divisors of 21 only.

    Example 2:

    >>> sumFourDivisors(nums = [21,21])
    >>> 64

    Example 3:

    >>> sumFourDivisors(nums = [1,2,3,4,5])
    >>> 0
    """


Prompt:
def hasValidPath(grid: List[List[int]]) -> bool:
    """
    You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:

    1 which means a street connecting the left cell and the right cell.
    2 which means a street connecting the upper cell and the lower cell.
    3 which means a street connecting the left cell and the lower cell.
    4 which means a street connecting the right cell and the lower cell.
    5 which means a street connecting the left cell and the upper cell.
    6 which means a street connecting the right cell and the upper cell.

    You will initially start at the street of the upper-left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1). The path should only follow the streets.
    Notice that you are not allowed to change any street.
    Return true if there is a valid path in the grid or false otherwise.

    Example 1:

    >>> hasValidPath(grid = [[2,4,3],[6,5,2]])
    >>> true
    Explanation: As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).

    Example 2:

    >>> hasValidPath(grid = [[1,2,1],[1,2,1]])
    >>> false
    Explanation: As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)

    Example 3:

    >>> hasValidPath(grid = [[1,1,2]])
    >>> false
    Explanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).
    """