Prompt:
def longestPrefix(s: str) -> str:
    """
    A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).
    Given a string s, return the longest happy prefix of s. Return an empty string "" if no such prefix exists.

    Example 1:

    >>> longestPrefix(s = "level")
    >>> "l"
    Explanation: s contains 4 prefix excluding itself ("l", "le", "lev", "leve"), and suffix ("l", "el", "vel", "evel"). The largest prefix which is also suffix is given by "l".

    Example 2:

    >>> longestPrefix(s = "ababab")
    >>> "abab"
    Explanation: "abab" is the largest prefix which is also suffix. They can overlap in the original string.
    """


Prompt:
def findLucky(arr: List[int]) -> int:
    """
    Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
    Return the largest lucky integer in the array. If there is no lucky integer return -1.

    Example 1:

    >>> findLucky(arr = [2,2,3,4])
    >>> 2
    Explanation: The only lucky number in the array is 2 because frequency[2] == 2.

    Example 2:

    >>> findLucky(arr = [1,2,2,3,3,3])
    >>> 3
    Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them.

    Example 3:

    >>> findLucky(arr = [2,2,2,3,3])
    >>> -1
    Explanation: There are no lucky numbers in the array.
    """


Prompt:
def numTeams(rating: List[int]) -> int:
    """
    There are n soldiers standing in a line. Each soldier is assigned a unique rating value.
    You have to form a team of 3 soldiers amongst them under the following rules:

    Choose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).
    A team is valid if: (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).

    Return the number of teams you can form given the conditions. (soldiers can be part of multiple teams).

    Example 1:

    >>> numTeams(rating = [2,5,3,4,1])
    >>> 3
    Explanation: We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1).

    Example 2:

    >>> numTeams(rating = [2,1,3])
    >>> 0
    Explanation: We can't form any team given the conditions.

    Example 3:

    >>> numTeams(rating = [1,2,3,4])
    >>> 4
    """


Prompt:
def findGoodStrings(n: int, s1: str, s2: str, evil: str) -> int:
    """
    Given the strings s1 and s2 of size n and the string evil, return the number of good strings.
    A good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 109 + 7.

    Example 1:

    >>> findGoodStrings(n = 2, s1 = "aa", s2 = "da", evil = "b")
    >>> 51
    Explanation: There are 25 good strings starting with 'a': "aa","ac","ad",...,"az". Then there are 25 good strings starting with 'c': "ca","cc","cd",...,"cz" and finally there is one good string starting with 'd': "da".

    Example 2:

    >>> findGoodStrings(n = 8, s1 = "leetcode", s2 = "leetgoes", evil = "leet")
    >>> 0
    Explanation: All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix "leet", therefore, there is not any good string.

    Example 3:

    >>> findGoodStrings(n = 2, s1 = "gx", s2 = "gz", evil = "x")
    >>> 2
    """


Prompt:
def countLargestGroup(n: int) -> int:
    """
    You are given an integer n.
    Each number from 1 to n is grouped according to the sum of its digits.
    Return the number of groups that have the largest size.

    Example 1:

    >>> countLargestGroup(n = 13)
    >>> 4
    Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:
    [1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9].
    There are 4 groups with largest size.

    Example 2:

    >>> countLargestGroup(n = 2)
    >>> 2
    Explanation: There are 2 groups [1], [2] of size 1.
    """


Prompt:
def canConstruct(s: str, k: int) -> bool:
    """
    Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.

    Example 1:

    >>> canConstruct(s = "annabelle", k = 2)
    >>> true
    Explanation: You can construct two palindromes using all characters in s.
    Some possible constructions "anna" + "elble", "anbna" + "elle", "anellena" + "b"

    Example 2:

    >>> canConstruct(s = "leetcode", k = 3)
    >>> false
    Explanation: It is impossible to construct 3 palindromes using all the characters of s.

    Example 3:

    >>> canConstruct(s = "true", k = 4)
    >>> true
    Explanation: The only possible solution is to put each character in a separate string.
    """


Prompt:
def checkOverlap(radius: int, xCenter: int, yCenter: int, x1: int, y1: int, x2: int, y2: int) -> bool:
    """
    You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.
    Return true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.

    Example 1:

    >>> checkOverlap(radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1)
    >>> true
    Explanation: Circle and rectangle share the point (1,0).

    Example 2:

    >>> checkOverlap(radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1)
    >>> false

    Example 3:

    >>> checkOverlap(radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1)
    >>> true
    """


Prompt:
def maxSatisfaction(satisfaction: List[int]) -> int:
    """
    A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.
    Like-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].
    Return the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes.
    Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.

    Example 1:

    >>> maxSatisfaction(satisfaction = [-1,-8,0,5,-9])
    >>> 14
    Explanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14).
    Each dish is prepared in one unit of time.
    Example 2:

    >>> maxSatisfaction(satisfaction = [4,3,2])
    >>> 20
    Explanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)

    Example 3:

    >>> maxSatisfaction(satisfaction = [-1,-4,-5])
    >>> 0
    Explanation: People do not like the dishes. No dish is prepared.
    """


Prompt:
def minSubsequence(nums: List[int]) -> List[int]:
    """
    Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.
    If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.
    Note that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.

    Example 1:

    >>> minSubsequence(nums = [4,3,10,9,8])
    >>> [10,9]
    Explanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements.

    Example 2:

    >>> minSubsequence(nums = [4,4,7,6,7])
    >>> [7,7,6]
    Explanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-increasing order.
    """


Prompt:
def numSteps(s: str) -> int:
    """
    Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:

    If the current number is even, you have to divide it by 2.

    If the current number is odd, you have to add 1 to it.

    It is guaranteed that you can always reach one for all test cases.

    Example 1:

    >>> numSteps(s = "1101")
    >>> 6
    Explanation: "1101" corressponds to number 13 in their decimal representation.
    Step 1) 13 is odd, add 1 and obtain 14.
    Step 2) 14 is even, divide by 2 and obtain 7.
    Step 3) 7 is odd, add 1 and obtain 8.
    Step 4) 8 is even, divide by 2 and obtain 4.
    Step 5) 4 is even, divide by 2 and obtain 2.
    Step 6) 2 is even, divide by 2 and obtain 1.

    Example 2:

    >>> numSteps(s = "10")
    >>> 1
    Explanation: "10" corresponds to number 2 in their decimal representation.
    Step 1) 2 is even, divide by 2 and obtain 1.

    Example 3:

    >>> numSteps(s = "1")
    >>> 0
    """


Prompt:
def longestDiverseString(a: int, b: int, c: int) -> str:
    """
    A string s is called happy if it satisfies the following conditions:

    s only contains the letters 'a', 'b', and 'c'.
    s does not contain any of "aaa", "bbb", or "ccc" as a substring.
    s contains at most a occurrences of the letter 'a'.
    s contains at most b occurrences of the letter 'b'.
    s contains at most c occurrences of the letter 'c'.

    Given three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string "".
    A substring is a contiguous sequence of characters within a string.

    Example 1:

    >>> longestDiverseString(a = 1, b = 1, c = 7)
    >>> "ccaccbcc"
    Explanation: "ccbccacc" would also be a correct answer.

    Example 2:

    >>> longestDiverseString(a = 7, b = 1, c = 0)
    >>> "aabaa"
    Explanation: It is the only correct answer in this case.
    """


Prompt:
def stoneGameIII(stoneValue: List[int]) -> str:
    """
    Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
    Alice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.
    The score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.
    The objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.
    Assume Alice and Bob play optimally.
    Return "Alice" if Alice will win, "Bob" if Bob will win, or "Tie" if they will end the game with the same score.

    Example 1:

    >>> stoneGameIII(stoneValue = [1,2,3,7])
    >>> "Bob"
    Explanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.

    Example 2:

    >>> stoneGameIII(stoneValue = [1,2,3,-9])
    >>> "Alice"
    Explanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.
    If Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.
    If Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.
    Remember that both play optimally so here Alice will choose the scenario that makes her win.

    Example 3:

    >>> stoneGameIII(stoneValue = [1,2,3,6])
    >>> "Tie"
    Explanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.
    """


Prompt:
def stringMatching(words: List[str]) -> List[str]:
    """
    Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.

    Example 1:

    >>> stringMatching(words = ["mass","as","hero","superhero"])
    >>> ["as","hero"]
    Explanation: "as" is substring of "mass" and "hero" is substring of "superhero".
    ["hero","as"] is also a valid answer.

    Example 2:

    >>> stringMatching(words = ["leetcode","et","code"])
    >>> ["et","code"]
    Explanation: "et", "code" are substring of "leetcode".

    Example 3:

    >>> stringMatching(words = ["blue","green","bu"])
    >>> []
    Explanation: No string of words is substring of another string.
    """


Prompt:
def processQueries(queries: List[int], m: int) -> List[int]:
    """
    Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:

    In the beginning, you have the permutation P=[1,2,3,...,m].
    For the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].

    Return an array containing the result for the given queries.

    Example 1:

    >>> processQueries(queries = [3,1,2,1], m = 5)
    >>> [2,1,2,1]
    Explanation: The queries are processed as follow:
    For i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5].
    For i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5].
    For i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5].
    For i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5].
    Therefore, the array containing the result is [2,1,2,1].

    Example 2:

    >>> processQueries(queries = [4,1,2,2], m = 4)
    >>> [3,1,2,0]

    Example 3:

    >>> processQueries(queries = [7,5,5,8,3], m = 8)
    >>> [6,5,0,7,5]
    """


Prompt:
def entityParser(text: str) -> str:
    """
    HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.
    The special characters and their entities for HTML are:

    Quotation Mark: the entity is " and symbol character is ".
    Single Quote Mark: the entity is ' and symbol character is '.
    Ampersand: the entity is & and symbol character is &.
    Greater Than Sign: the entity is > and symbol character is >.
    Less Than Sign: the entity is < and symbol character is <.
    Slash: the entity is ⁄ and symbol character is /.

    Given the input text string to the HTML parser, you have to implement the entity parser.
    Return the text after replacing the entities by the special characters.

    Example 1:

    >>> entityParser(text = "& is an HTML entity but &ambassador; is not.")
    >>> "& is an HTML entity but &ambassador; is not."
    Explanation: The parser will replace the & entity by &

    Example 2:

    >>> entityParser(text = "and I quote: "..."")
    >>> "and I quote: \"...\""
    """


Prompt:
def numOfWays(n: int) -> int:
    """
    You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).
    Given n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.

    Example 1:

    >>> numOfWays(n = 1)
    >>> 12
    Explanation: There are 12 possible way to paint the grid as shown.

    Example 2:

    >>> numOfWays(n = 5000)
    >>> 30228214
    """


Prompt:
def minStartValue(nums: List[int]) -> int:
    """
    Given an array of integers nums, you start with an initial positive value startValue.
    In each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).
    Return the minimum positive value of startValue such that the step by step sum is never less than 1.

    Example 1:

    >>> minStartValue(nums = [-3,2,-3,4,2])
    >>> 5
    Explanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.
    step by step sum
    startValue = 4 | startValue = 5 | nums
      (4 -3 ) = 1  | (5 -3 ) = 2    |  -3
      (1 +2 ) = 3  | (2 +2 ) = 4    |   2
      (3 -3 ) = 0  | (4 -3 ) = 1    |  -3
      (0 +4 ) = 4  | (1 +4 ) = 5    |   4
      (4 +2 ) = 6  | (5 +2 ) = 7    |   2

    Example 2:

    >>> minStartValue(nums = [1,2])
    >>> 1
    Explanation: Minimum start value should be positive.

    Example 3:

    >>> minStartValue(nums = [1,-2,-3])
    >>> 5
    """


Prompt:
def findMinFibonacciNumbers(k: int) -> int:
    """
    Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.
    The Fibonacci numbers are defined as:

    F1 = 1
    F2 = 1
    Fn = Fn-1 + Fn-2 for n > 2.

    It is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.

    Example 1:

    >>> findMinFibonacciNumbers(k = 7)
    >>> 2
    Explanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ...
    For k = 7 we can use 2 + 5 = 7.
    Example 2:

    >>> findMinFibonacciNumbers(k = 10)
    >>> 2
    Explanation: For k = 10 we can use 2 + 8 = 10.

    Example 3:

    >>> findMinFibonacciNumbers(k = 19)
    >>> 3
    Explanation: For k = 19 we can use 1 + 5 + 13 = 19.
    """


Prompt:
def getHappyString(n: int, k: int) -> str:
    """
    A happy string is a string that:

    consists only of letters of the set ['a', 'b', 'c'].
    s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).

    For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
    Given two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.
    Return the kth string of this list or return an empty string if there are less than k happy strings of length n.

    Example 1:

    >>> getHappyString(n = 1, k = 3)
    >>> "c"
    Explanation: The list ["a", "b", "c"] contains all happy strings of length 1. The third string is "c".

    Example 2:

    >>> getHappyString(n = 1, k = 4)
    >>> ""
    Explanation: There are only 3 happy strings of length 1.

    Example 3:

    >>> getHappyString(n = 3, k = 9)
    >>> "cab"
    Explanation: There are 12 different happy string of length 3 ["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"]. You will find the 9th string = "cab"
    """


Prompt:
def numberOfArrays(s: str, k: int) -> int:
    """
    A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.
    Given the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> numberOfArrays(s = "1000", k = 10000)
    >>> 1
    Explanation: The only possible array is [1000]

    Example 2:

    >>> numberOfArrays(s = "1000", k = 10)
    >>> 0
    Explanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.

    Example 3:

    >>> numberOfArrays(s = "1317", k = 2000)
    >>> 8
    Explanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]
    """


Prompt:
def reformat(s: str) -> str:
    """
    You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).
    You have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.
    Return the reformatted string or return an empty string if it is impossible to reformat the string.

    Example 1:

    >>> reformat(s = "a0b1c2")
    >>> "0a1b2c"
    Explanation: No two adjacent characters have the same type in "0a1b2c". "a0b1c2", "0a1b2c", "0c2a1b" are also valid permutations.

    Example 2:

    >>> reformat(s = "leetcode")
    >>> ""
    Explanation: "leetcode" has only characters so we cannot separate them by digits.

    Example 3:

    >>> reformat(s = "1229857369")
    >>> ""
    Explanation: "1229857369" has only digits so we cannot separate them by characters.
    """


Prompt:
def displayTable(orders: List[List[str]]) -> List[List[str]]:
    """
    Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNumberi is the table customer sit at, and foodItemi is the item customer orders.\r
    \r
    Return the restaurant's “display table”. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> displayTable(orders = [["David","3","Ceviche"],["Corina","10","Beef Burrito"],["David","3","Fried Chicken"],["Carla","5","Water"],["Carla","5","Ceviche"],["Rous","3","Ceviche"]]\r)
    >>> [["Table","Beef Burrito","Ceviche","Fried Chicken","Water"],["3","0","2","1","0"],["5","0","1","0","1"],["10","1","0","0","0"]] \r
    Explanation:\r
    The displaying table looks like:\r
    Table,Beef Burrito,Ceviche,Fried Chicken,Water\r
    3    ,0           ,2      ,1            ,0\r
    5    ,0           ,1      ,0            ,1\r
    10   ,1           ,0      ,0            ,0\r
    For the table 3: David orders "Ceviche" and "Fried Chicken", and Rous orders "Ceviche".\r
    For the table 5: Carla orders "Water" and "Ceviche".\r
    For the table 10: Corina orders "Beef Burrito". \r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> displayTable(orders = [["James","12","Fried Chicken"],["Ratesh","12","Fried Chicken"],["Amadeus","12","Fried Chicken"],["Adam","1","Canadian Waffles"],["Brianna","1","Canadian Waffles"]]\r)
    >>> [["Table","Canadian Waffles","Fried Chicken"],["1","2","0"],["12","0","3"]] \r
    Explanation: \r
    For the table 1: Adam and Brianna order "Canadian Waffles".\r
    For the table 12: James, Ratesh and Amadeus order "Fried Chicken".\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> displayTable(orders = [["Laura","2","Bean Burrito"],["Jhon","2","Beef Burrito"],["Melissa","2","Soda"]]\r)
    >>> [["Table","Bean Burrito","Beef Burrito","Soda"],["2","1","1","1"]]\r
    \r
    \r
     \r
    """


Prompt:
def minNumberOfFrogs(croakOfFrogs: str) -> int:
    """
    You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple "croak" are mixed.
    Return the minimum number of different frogs to finish all the croaks in the given string.
    A valid "croak" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid "croak" return -1.

    Example 1:

    >>> minNumberOfFrogs(croakOfFrogs = "croakcroak")
    >>> 1
    Explanation: One frog yelling "croak" twice.

    Example 2:

    >>> minNumberOfFrogs(croakOfFrogs = "crcoakroak")
    >>> 2
    Explanation: The minimum number of frogs is two.
    The first frog could yell "crcoakroak".
    The second frog could yell later "crcoakroak".

    Example 3:

    >>> minNumberOfFrogs(croakOfFrogs = "croakcrook")
    >>> -1
    Explanation: The given string is an invalid combination of "croak" from different frogs.
    """


Prompt:
def numOfArrays(n: int, m: int, k: int) -> int:
    """
    You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:

    You should build the array arr which has the following properties:

    arr has exactly n integers.
    1 <= arr[i] <= m where (0 <= i < n).
    After applying the mentioned algorithm to arr, the value search_cost is equal to k.

    Return the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 109 + 7.

    Example 1:

    >>> numOfArrays(n = 2, m = 3, k = 1)
    >>> 6
    Explanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]

    Example 2:

    >>> numOfArrays(n = 5, m = 2, k = 3)
    >>> 0
    Explanation: There are no possible arrays that satisfy the mentioned conditions.

    Example 3:

    >>> numOfArrays(n = 9, m = 1, k = 1)
    >>> 1
    Explanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]
    """


Prompt:
def maxScore(s: str) -> int:
    """
    Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).
    The score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.

    Example 1:

    >>> maxScore(s = "011101")
    >>> 5
    Explanation:
    All possible ways of splitting s into two non-empty substrings are:
    left = "0" and right = "11101", score = 1 + 4 = 5
    left = "01" and right = "1101", score = 1 + 3 = 4
    left = "011" and right = "101", score = 1 + 2 = 3
    left = "0111" and right = "01", score = 1 + 1 = 2
    left = "01110" and right = "1", score = 2 + 1 = 3

    Example 2:

    >>> maxScore(s = "00111")
    >>> 5
    Explanation: When left = "00" and right = "111", we get the maximum score = 2 + 3 = 5

    Example 3:

    >>> maxScore(s = "1111")
    >>> 3
    """


Prompt:
def maxScore(cardPoints: List[int], k: int) -> int:
    """
    There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.
    In one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.
    Your score is the sum of the points of the cards you have taken.
    Given the integer array cardPoints and the integer k, return the maximum score you can obtain.

    Example 1:

    >>> maxScore(cardPoints = [1,2,3,4,5,6,1], k = 3)
    >>> 12
    Explanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.

    Example 2:

    >>> maxScore(cardPoints = [2,2,2], k = 2)
    >>> 4
    Explanation: Regardless of which two cards you take, your score will always be 4.

    Example 3:

    >>> maxScore(cardPoints = [9,7,7,9,7,7,9], k = 7)
    >>> 55
    Explanation: You have to take all the cards. Your score is the sum of points of all cards.
    """


Prompt:
def findDiagonalOrder(nums: List[List[int]]) -> List[int]:
    """
    Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.

    Example 1:

    >>> findDiagonalOrder(nums = [[1,2,3],[4,5,6],[7,8,9]])
    >>> [1,4,2,7,5,3,8,6,9]

    Example 2:

    >>> findDiagonalOrder(nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]])
    >>> [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]
    """


Prompt:
def constrainedSubsetSum(nums: List[int], k: int) -> int:
    """
    Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.
    A subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.

    Example 1:

    >>> constrainedSubsetSum(nums = [10,2,-10,5,20], k = 2)
    >>> 37
    Explanation: The subsequence is [10, 2, 5, 20].

    Example 2:

    >>> constrainedSubsetSum(nums = [-1,-2,-3], k = 1)
    >>> -1
    Explanation: The subsequence must be non-empty, so we choose the largest number.

    Example 3:

    >>> constrainedSubsetSum(nums = [10,-2,-10,-5,20], k = 2)
    >>> 23
    Explanation: The subsequence is [10, -2, -5, 20].
    """


Prompt:
def countElements(arr: List[int]) -> int:
    """
    Given an integer array arr, count how many elements x there are, such that x + 1 is also in arr. If there are duplicates in arr, count them separately.

    Example 1:

    >>> countElements(arr = [1,2,3])
    >>> 2
    Explanation: 1 and 2 are counted cause 2 and 3 are in arr.

    Example 2:

    >>> countElements(arr = [1,1,3,3,5,5,7,7])
    >>> 0
    Explanation: No numbers are counted, cause there is no 2, 4, 6, or 8 in arr.
    """


Prompt:
def stringShift(s: str, shift: List[List[int]]) -> str:
    """
    You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [directioni, amounti]:

    directioni can be 0 (for left shift) or 1 (for right shift).
    amounti is the amount by which string s is to be shifted.
    A left shift by 1 means remove the first character of s and append it to the end.
    Similarly, a right shift by 1 means remove the last character of s and add it to the beginning.

    Return the final string after all operations.

    Example 1:

    >>> stringShift(s = "abc", shift = [[0,1],[1,2]])
    >>> "cab"
    Explanation:
    [0,1] means shift to left by 1. "abc" -> "bca"
    [1,2] means shift to right by 2. "bca" -> "cab"
    Example 2:

    >>> stringShift(s = "abcdefg", shift = [[1,1],[1,1],[0,2],[1,3]])
    >>> "efgabcd"
    Explanation:
    [1,1] means shift to right by 1. "abcdefg" -> "gabcdef"
    [1,1] means shift to right by 1. "gabcdef" -> "fgabcde"
    [0,2] means shift to left by 2. "fgabcde" -> "abcdefg"
    [1,3] means shift to right by 3. "abcdefg" -> "efgabcd"
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def isValidSequence(root: Optional[TreeNode], arr: List[int]) -> bool:
    """
    Given a binary tree where each path going from the root to any leaf form a valid sequence, check if a given string is a valid sequence in such binary tree.
    We get the given string from the concatenation of an array of integers arr and the concatenation of all values of the nodes along a path results in a sequence in the given binary tree.

    Example 1:

    >>> __init__(root = [0,1,0,0,1,0,null,null,1,0,0], arr = [0,1,0,1])
    >>> true
    Explanation:
    The path 0 -> 1 -> 0 -> 1 is a valid sequence (green color in the figure).
    Other valid sequences are:
    0 -> 1 -> 1 -> 0
    0 -> 0 -> 0

    Example 2:

    >>> __init__(root = [0,1,0,0,1,0,null,null,1,0,0], arr = [0,0,1])
    >>> false
    Explanation: The path 0 -> 0 -> 1 does not exist, therefore it is not even a sequence.

    Example 3:

    >>> __init__(root = [0,1,0,0,1,0,null,null,1,0,0], arr = [0,1,1])
    >>> false
    Explanation: The path 0 -> 1 -> 1 is a sequence, but it is not a valid sequence.
    """


Prompt:
def kidsWithCandies(candies: List[int], extraCandies: int) -> List[bool]:
    """
    There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have.
    Return a boolean array result of length n, where result[i] is true if, after giving the ith kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.
    Note that multiple kids can have the greatest number of candies.

    Example 1:

    >>> kidsWithCandies(candies = [2,3,5,1,3], extraCandies = 3)
    >>> [true,true,true,false,true]
    Explanation: If you give all extraCandies to:
    - Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.
    - Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.
    - Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.
    - Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.
    - Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.

    Example 2:

    >>> kidsWithCandies(candies = [4,2,1,1,2], extraCandies = 1)
    >>> [true,false,false,false,false]
    Explanation: There is only 1 extra candy.
    Kid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.

    Example 3:

    >>> kidsWithCandies(candies = [12,1,12], extraCandies = 10)
    >>> [true,false,true]
    """


Prompt:
def maxDiff(num: int) -> int:
    """
    You are given an integer num. You will apply the following steps exactly two times:

    Pick a digit x (0 <= x <= 9).
    Pick another digit y (0 <= y <= 9). The digit y can be equal to x.
    Replace all the occurrences of x in the decimal representation of num by y.
    The new integer cannot have any leading zeros, also the new integer cannot be 0.

    Let a and b be the results of applying the operations to num the first and second times, respectively.
    Return the max difference between a and b.

    Example 1:

    >>> maxDiff(num = 555)
    >>> 888
    Explanation: The first time pick x = 5 and y = 9 and store the new integer in a.
    The second time pick x = 5 and y = 1 and store the new integer in b.
    We have now a = 999 and b = 111 and max difference = 888

    Example 2:

    >>> maxDiff(num = 9)
    >>> 8
    Explanation: The first time pick x = 9 and y = 9 and store the new integer in a.
    The second time pick x = 9 and y = 1 and store the new integer in b.
    We have now a = 9 and b = 1 and max difference = 8
    """


Prompt:
def checkIfCanBreak(s1: str, s2: str) -> bool:
    """
    Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.
    A string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.

    Example 1:

    >>> checkIfCanBreak(s1 = "abc", s2 = "xya")
    >>> true
    Explanation: "ayx" is a permutation of s2="xya" which can break to string "abc" which is a permutation of s1="abc".

    Example 2:

    >>> checkIfCanBreak(s1 = "abe", s2 = "acd")
    >>> false
    Explanation: All permutations for s1="abe" are: "abe", "aeb", "bae", "bea", "eab" and "eba" and all permutation for s2="acd" are: "acd", "adc", "cad", "cda", "dac" and "dca". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.

    Example 3:

    >>> checkIfCanBreak(s1 = "leetcodee", s2 = "interview")
    >>> true
    """


Prompt:
def numberWays(hats: List[List[int]]) -> int:
    """
    There are n people and 40 types of hats labeled from 1 to 40.
    Given a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.
    Return the number of ways that n people can wear different hats from each other.
    Since the answer may be too large, return it modulo 109 + 7.

    Example 1:

    >>> numberWays(hats = [[3,4],[4,5],[5]])
    >>> 1
    Explanation: There is only one way to choose hats given the conditions.
    First person choose hat 3, Second person choose hat 4 and last one hat 5.

    Example 2:

    >>> numberWays(hats = [[3,5,1],[3,5]])
    >>> 4
    Explanation: There are 4 ways to choose hats:
    (3,5), (5,3), (1,3) and (1,5)

    Example 3:

    >>> numberWays(hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]])
    >>> 24
    Explanation: Each person can choose hats labeled from 1 to 4.
    Number of Permutations of (1,2,3,4) = 24.
    """


Prompt:
def destCity(paths: List[List[str]]) -> str:
    """
    You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.
    It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.

    Example 1:

    >>> destCity(paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]])
    >>> "Sao Paulo"
    Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo".

    Example 2:

    >>> destCity(paths = [["B","C"],["D","B"],["C","A"]])
    >>> "A"
    Explanation: All possible trips are:
    "D" -> "B" -> "C" -> "A".
    "B" -> "C" -> "A".
    "C" -> "A".
    "A".
    Clearly the destination city is "A".

    Example 3:

    >>> destCity(paths = [["A","Z"]])
    >>> "Z"
    """


Prompt:
def kLengthApart(nums: List[int], k: int) -> bool:
    """
    Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.

    Example 1:

    >>> kLengthApart(nums = [1,0,0,0,1,0,0,1], k = 2)
    >>> true
    Explanation: Each of the 1s are at least 2 places away from each other.

    Example 2:

    >>> kLengthApart(nums = [1,0,0,1,0,1], k = 2)
    >>> false
    Explanation: The second 1 and third 1 are only one apart from each other.
    """


Prompt:
def longestSubarray(nums: List[int], limit: int) -> int:
    """
    Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.

    Example 1:

    >>> longestSubarray(nums = [8,2,4,7], limit = 4)
    >>> 2
    Explanation: All subarrays are:
    [8] with maximum absolute diff |8-8| = 0 <= 4.
    [8,2] with maximum absolute diff |8-2| = 6 > 4.
    [8,2,4] with maximum absolute diff |8-2| = 6 > 4.
    [8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.
    [2] with maximum absolute diff |2-2| = 0 <= 4.
    [2,4] with maximum absolute diff |2-4| = 2 <= 4.
    [2,4,7] with maximum absolute diff |2-7| = 5 > 4.
    [4] with maximum absolute diff |4-4| = 0 <= 4.
    [4,7] with maximum absolute diff |4-7| = 3 <= 4.
    [7] with maximum absolute diff |7-7| = 0 <= 4.
    Therefore, the size of the longest subarray is 2.

    Example 2:

    >>> longestSubarray(nums = [10,1,2,4,7,2], limit = 5)
    >>> 4
    Explanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.

    Example 3:

    >>> longestSubarray(nums = [4,2,2,2,4,4,2,2], limit = 0)
    >>> 3
    """


Prompt:
def kthSmallest(mat: List[List[int]], k: int) -> int:
    """
    You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.
    You are allowed to choose exactly one element from each row to form an array.
    Return the kth smallest array sum among all possible arrays.

    Example 1:

    >>> kthSmallest(mat = [[1,3,11],[2,4,6]], k = 5)
    >>> 7
    Explanation: Choosing one element from each row, the first k smallest sum are:
    [1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.

    Example 2:

    >>> kthSmallest(mat = [[1,3,11],[2,4,6]], k = 9)
    >>> 17

    Example 3:

    >>> kthSmallest(mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7)
    >>> 9
    Explanation: Choosing one element from each row, the first k smallest sum are:
    [1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9.
    """


Prompt:
def buildArray(target: List[int], n: int) -> List[str]:
    """
    You are given an integer array target and an integer n.
    You have an empty stack with the two following operations:

    "Push": pushes an integer to the top of the stack.
    "Pop": removes the integer on the top of the stack.

    You also have a stream of the integers in the range [1, n].
    Use the two stack operations to make the numbers in the stack (from the bottom to the top) equal to target. You should follow the following rules:

    If the stream of the integers is not empty, pick the next integer from the stream and push it to the top of the stack.
    If the stack is not empty, pop the integer at the top of the stack.
    If, at any moment, the elements in the stack (from the bottom to the top) are equal to target, do not read new integers from the stream and do not do more operations on the stack.

    Return the stack operations needed to build target following the mentioned rules. If there are multiple valid answers, return any of them.

    Example 1:

    >>> buildArray(target = [1,3], n = 3)
    >>> ["Push","Push","Pop","Push"]
    Explanation: Initially the stack s is empty. The last element is the top of the stack.
    Read 1 from the stream and push it to the stack. s = [1].
    Read 2 from the stream and push it to the stack. s = [1,2].
    Pop the integer on the top of the stack. s = [1].
    Read 3 from the stream and push it to the stack. s = [1,3].

    Example 2:

    >>> buildArray(target = [1,2,3], n = 3)
    >>> ["Push","Push","Push"]
    Explanation: Initially the stack s is empty. The last element is the top of the stack.
    Read 1 from the stream and push it to the stack. s = [1].
    Read 2 from the stream and push it to the stack. s = [1,2].
    Read 3 from the stream and push it to the stack. s = [1,2,3].

    Example 3:

    >>> buildArray(target = [1,2], n = 4)
    >>> ["Push","Push"]
    Explanation: Initially the stack s is empty. The last element is the top of the stack.
    Read 1 from the stream and push it to the stack. s = [1].
    Read 2 from the stream and push it to the stack. s = [1,2].
    Since the stack (from the bottom to the top) is equal to target, we stop the stack operations.
    The answers that read integer 3 from the stream are not accepted.
    """


Prompt:
def countTriplets(arr: List[int]) -> int:
    """
    Given an array of integers arr.
    We want to select three indices i, j and k where (0 <= i < j <= k < arr.length).
    Let's define a and b as follows:

    a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]
    b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]

    Note that ^ denotes the bitwise-xor operation.
    Return the number of triplets (i, j and k) Where a == b.

    Example 1:

    >>> countTriplets(arr = [2,3,1,6,7])
    >>> 4
    Explanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)

    Example 2:

    >>> countTriplets(arr = [1,1,1,1,1])
    >>> 10
    """


Prompt:
def ways(pizza: List[str], k: int) -> int:
    """
    Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts.
    For each cut you choose the direction: vertical or horizontal, then you choose a cut position at the cell boundary and cut the pizza into two pieces. If you cut the pizza vertically, give the left part of the pizza to a person. If you cut the pizza horizontally, give the upper part of the pizza to a person. Give the last piece of pizza to the last person.
    Return the number of ways of cutting the pizza such that each piece contains at least one apple. Since the answer can be a huge number, return this modulo 10^9 + 7.

    Example 1:

    >>> ways(pizza = ["A..","AAA","..."], k = 3)
    >>> 3
    Explanation: The figure above shows the three ways to cut the pizza. Note that pieces must contain at least one apple.

    Example 2:

    >>> ways(pizza = ["A..","AA.","..."], k = 3)
    >>> 1

    Example 3:

    >>> ways(pizza = ["A..","A..","..."], k = 1)
    >>> 1
    """


Prompt:
def maxPower(s: str) -> int:
    """
    The power of the string is the maximum length of a non-empty substring that contains only one unique character.
    Given a string s, return the power of s.

    Example 1:

    >>> maxPower(s = "leetcode")
    >>> 2
    Explanation: The substring "ee" is of length 2 with the character 'e' only.

    Example 2:

    >>> maxPower(s = "abbcccddddeeeeedcba")
    >>> 5
    Explanation: The substring "eeeee" is of length 5 with the character 'e' only.
    """


Prompt:
def simplifiedFractions(n: int) -> List[str]:
    """
    Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.

    Example 1:

    >>> simplifiedFractions(n = 2)
    >>> ["1/2"]
    Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2.

    Example 2:

    >>> simplifiedFractions(n = 3)
    >>> ["1/2","1/3","2/3"]

    Example 3:

    >>> simplifiedFractions(n = 4)
    >>> ["1/2","1/3","1/4","2/3","3/4"]
    Explanation: "2/4" is not a simplified fraction because it can be simplified to "1/2".
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def goodNodes(root: Optional[TreeNode]) -> int:
    """
    Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.\r
    \r
    Return the number of good nodes in the binary tree.\r
    \r
     \r
    Example 1:\r
    \r
    \r
    \r
    \r
    >>> __init__(root = [3,1,4,3,null,1,5]\r)
    >>> 4\r
    Explanation: Nodes in blue are good.\r
    Root Node (3) is always a good node.\r
    Node 4 -> (3,4) is the maximum value in the path starting from the root.\r
    Node 5 -> (3,4,5) is the maximum value in the path\r
    Node 3 -> (3,1,3) is the maximum value in the path.\r
    \r
    Example 2:\r
    \r
    \r
    \r
    \r
    >>> __init__(root = [3,3,null,4,2]\r)
    >>> 3\r
    Explanation: Node 2 -> (3, 3, 2) is not good, because "3" is higher than it.\r
    \r
    Example 3:\r
    \r
    \r
    >>> __init__(root = [1]\r)
    >>> 1\r
    Explanation: Root is considered as good.\r
    \r
     \r
    """


Prompt:
def largestNumber(cost: List[int], target: int) -> str:
    """
    Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:

    The cost of painting a digit (i + 1) is given by cost[i] (0-indexed).
    The total cost used must be equal to target.
    The integer does not have 0 digits.

    Since the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return "0".

    Example 1:

    >>> largestNumber(cost = [4,3,2,5,6,7,2,5,5], target = 9)
    >>> "7772"
    Explanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost("7772") = 2*3+ 3*1 = 9. You could also paint "977", but "7772" is the largest number.
    Digit    cost
      1  ->   4
      2  ->   3
      3  ->   2
      4  ->   5
      5  ->   6
      6  ->   7
      7  ->   2
      8  ->   5
      9  ->   5

    Example 2:

    >>> largestNumber(cost = [7,6,5,5,5,6,8,7,8], target = 12)
    >>> "85"
    Explanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost("85") = 7 + 5 = 12.

    Example 3:

    >>> largestNumber(cost = [2,4,6,2,4,6,4,4,4], target = 5)
    >>> "0"
    Explanation: It is impossible to paint any integer with total cost equal to target.
    """


Prompt:
def busyStudent(startTime: List[int], endTime: List[int], queryTime: int) -> int:
    """
    Given two integer arrays startTime and endTime and given an integer queryTime.
    The ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].
    Return the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.

    Example 1:

    >>> busyStudent(startTime = [1,2,3], endTime = [3,2,7], queryTime = 4)
    >>> 1
    Explanation: We have 3 students where:
    The first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.
    The second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.
    The third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.

    Example 2:

    >>> busyStudent(startTime = [4], endTime = [4], queryTime = 4)
    >>> 1
    Explanation: The only student was doing their homework at the queryTime.
    """


Prompt:
def arrangeWords(text: str) -> str:
    """
    Given a sentence text (A sentence is a string of space-separated words) in the following format:

    First letter is in upper case.
    Each word in text are separated by a single space.

    Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.
    Return the new text following the format shown above.

    Example 1:

    >>> arrangeWords(text = "Leetcode is cool")
    >>> "Is cool leetcode"
    Explanation: There are 3 words, "Leetcode" of length 8, "is" of length 2 and "cool" of length 4.
    Output is ordered by length and the new first word starts with capital letter.

    Example 2:

    >>> arrangeWords(text = "Keep calm and code on")
    >>> "On and keep calm code"
    Explanation: Output is ordered as follows:
    "On" 2 letters.
    "and" 3 letters.
    "keep" 4 letters in case of tie order by position in original text.
    "calm" 4 letters.
    "code" 4 letters.

    Example 3:

    >>> arrangeWords(text = "To be or not to be")
    >>> "To be or to be not"
    """


Prompt:
def peopleIndexes(favoriteCompanies: List[List[str]]) -> List[int]:
    """
    Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).
    Return the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.

    Example 1:

    >>> peopleIndexes(favoriteCompanies = [["leetcode","google","facebook"],["google","microsoft"],["google","facebook"],["google"],["amazon"]])
    >>> [0,1,4]
    Explanation:
    Person with index=2 has favoriteCompanies[2]=["google","facebook"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] corresponding to the person with index 0.
    Person with index=3 has favoriteCompanies[3]=["google"] which is a subset of favoriteCompanies[0]=["leetcode","google","facebook"] and favoriteCompanies[1]=["google","microsoft"].
    Other lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].

    Example 2:

    >>> peopleIndexes(favoriteCompanies = [["leetcode","google","facebook"],["leetcode","amazon"],["facebook","google"]])
    >>> [0,1]
    Explanation: In this case favoriteCompanies[2]=["facebook","google"] is a subset of favoriteCompanies[0]=["leetcode","google","facebook"], therefore, the answer is [0,1].

    Example 3:

    >>> peopleIndexes(favoriteCompanies = [["leetcode"],["google"],["facebook"],["amazon"]])
    >>> [0,1,2,3]
    """


Prompt:
def numPoints(darts: List[List[int]], r: int) -> int:
    """
    Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.
    Bob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.
    Given the integer r, return the maximum number of darts that can lie on the dartboard.

    Example 1:

    >>> numPoints(darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2)
    >>> 4
    Explanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.

    Example 2:

    >>> numPoints(darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5)
    >>> 5
    Explanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).
    """


Prompt:
def isPrefixOfWord(sentence: str, searchWord: str) -> int:
    """
    Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.
    Return the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.
    A prefix of a string s is any leading contiguous substring of s.

    Example 1:

    >>> isPrefixOfWord(sentence = "i love eating burger", searchWord = "burg")
    >>> 4
    Explanation: "burg" is prefix of "burger" which is the 4th word in the sentence.

    Example 2:

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

    Example 3:

    >>> isPrefixOfWord(sentence = "i am tired", searchWord = "you")
    >>> -1
    Explanation: "you" is not a prefix of any word in the sentence.
    """


Prompt:
def maxVowels(s: str, k: int) -> int:
    """
    Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
    Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

    Example 1:

    >>> maxVowels(s = "abciiidef", k = 3)
    >>> 3
    Explanation: The substring "iii" contains 3 vowel letters.

    Example 2:

    >>> maxVowels(s = "aeiou", k = 2)
    >>> 2
    Explanation: Any substring of length 2 contains 2 vowels.

    Example 3:

    >>> maxVowels(s = "leetcode", k = 3)
    >>> 2
    Explanation: "lee", "eet" and "ode" contain 2 vowels.
    """


Prompt:
def maxDotProduct(nums1: List[int], nums2: List[int]) -> int:
    """
    Given two arrays nums1 and nums2.
    Return the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.
    A subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).

    Example 1:

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

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

    >>> maxDotProduct(nums1 = [-1,-1], nums2 = [1,1])
    >>> -1
    Explanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.
    Their dot product is -1.
    """


Prompt:
def canBeEqual(target: List[int], arr: List[int]) -> bool:
    """
    You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.
    Return true if you can make arr equal to target or false otherwise.

    Example 1:

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

    Example 2:

    >>> canBeEqual(target = [7], arr = [7])
    >>> true
    Explanation: arr is equal to target without any reverses.

    Example 3:

    >>> canBeEqual(target = [3,7,9], arr = [3,7,11])
    >>> false
    Explanation: arr does not have value 9 and it can never be converted to target.
    """


Prompt:
def hasAllCodes(s: str, k: int) -> bool:
    """
    Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.

    Example 1:

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

    Example 2:

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

    Example 3:

    >>> hasAllCodes(s = "0110", k = 2)
    >>> false
    Explanation: The binary code "00" is of length 2 and does not exist in the array.
    """


Prompt:
def checkIfPrerequisite(numCourses: int, prerequisites: List[List[int]], queries: List[List[int]]) -> List[bool]:
    """
    There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course ai first if you want to take course bi.

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

    Prerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.
    You are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether course uj is a prerequisite of course vj or not.
    Return a boolean array answer, where answer[j] is the answer to the jth query.

    Example 1:

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

    Example 2:

    >>> checkIfPrerequisite(numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]])
    >>> [false,false]
    Explanation: There are no prerequisites, and each course is independent.

    Example 3:

    >>> checkIfPrerequisite(numCourses = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]])
    >>> [true,true]
    """


Prompt:
def cherryPickup(grid: List[List[int]]) -> int:
    """
    You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.
    You have two robots that can collect cherries for you:

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

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

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

    Example 1:

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

    Example 2:

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


Prompt:
def maxProduct(nums: List[int]) -> int:
    """
    Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).

    Example 1:

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

    Example 2:

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

    Example 3:

    >>> maxProduct(nums = [3,7])
    >>> 12
    """


Prompt:
def maxArea(h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
    """
    You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:

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

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

    Example 1:

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

    Example 2:

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

    Example 3:

    >>> maxArea(h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3])
    >>> 9
    """


Prompt:
def minReorder(n: int, connections: List[List[int]]) -> int:
    """
    There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.
    Roads are represented by connections where connections[i] = [ai, bi] represents a road from city ai to city bi.
    This year, there will be a big event in the capital (city 0), and many people want to travel to this city.
    Your task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.
    It's guaranteed that each city can reach city 0 after reorder.

    Example 1:

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

    Example 2:

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

    Example 3:

    >>> minReorder(n = 3, connections = [[1,0],[2,0]])
    >>> 0
    """


Prompt:
def getProbability(balls: List[int]) -> float:
    """
    Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.
    All the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).
    Please note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).
    Return the probability that the two boxes have the same number of distinct balls. Answers within 10-5 of the actual value will be accepted as correct.

    Example 1:

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

    Example 2:

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

    Example 3:

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


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def getLonelyNodes(root: Optional[TreeNode]) -> List[int]:
    """
    In a binary tree, a lonely node is a node that is the only child of its parent node. The root of the tree is not lonely because it does not have a parent node.
    Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. Return the list in any order.

    Example 1:

    >>> __init__(root = [1,2,3,null,4])
    >>> [4]
    Explanation: Light blue node is the only lonely node.
    Node 1 is the root and is not lonely.
    Nodes 2 and 3 have the same parent and are not lonely.

    Example 2:

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

    Example 3:

    >>> __init__(root = [11,99,88,77,null,null,66,55,null,null,44,33,null,null,22])
    >>> [77,55,33,66,44,22]
    Explanation: Nodes 99 and 88 share the same parent. Node 11 is the root.
    All other nodes are lonely.
    """


Prompt:
def shuffle(nums: List[int], n: int) -> List[int]:
    """
    Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].\r
    \r
    Return the array in the form [x1,y1,x2,y2,...,xn,yn].\r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> shuffle(nums = [2,5,1,3,4,7], n = 3\r)
    >>> [2,3,5,4,1,7] \r
    Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7].\r
    \r
    \r
    Example 2:\r
    \r
    \r
    >>> shuffle(nums = [1,2,3,4,4,3,2,1], n = 4\r)
    >>> [1,4,2,3,3,2,4,1]\r
    \r
    \r
    Example 3:\r
    \r
    \r
    >>> shuffle(nums = [1,1,2,2], n = 2\r)
    >>> [1,2,1,2]\r
    \r
    \r
     \r
    """


Prompt:
def getStrongest(arr: List[int], k: int) -> List[int]:
    """
    Given an array of integers arr and an integer k.
    A value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the centre of the array.
    If |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].
    Return a list of the strongest k values in the array. return the answer in any arbitrary order.
    The centre is the middle value in an ordered integer list. More formally, if the length of the list is n, the centre is the element in position ((n - 1) / 2) in the sorted list (0-indexed).

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

    Example 1:

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

    Example 2:

    >>> getStrongest(arr = [1,1,3,5,5], k = 2)
    >>> [5,5]
    Explanation: Centre is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].

    Example 3:

    >>> getStrongest(arr = [6,7,11,7,6,8], k = 5)
    >>> [11,8,6,6,7]
    Explanation: Centre is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].
    Any permutation of [11,8,6,6,7] is accepted.
    """


Prompt:
def minCost(houses: List[int], cost: List[List[int]], m: int, n: int, target: int) -> int:
    """
    There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again.
    A neighborhood is a maximal group of continuous houses that are painted with the same color.

    For example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].

    Given an array houses, an m x n matrix cost and an integer target where:

    houses[i]: is the color of the house i, and 0 if the house is not painted yet.
    cost[i][j]: is the cost of paint the house i with the color j + 1.

    Return the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods. If it is not possible, return -1.

    Example 1:

    >>> minCost(houses = [0,0,0,0,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3)
    >>> 9
    Explanation: Paint houses of this way [1,2,2,1,1]
    This array contains target = 3 neighborhoods, [{1}, {2,2}, {1,1}].
    Cost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.

    Example 2:

    >>> minCost(houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3)
    >>> 11
    Explanation: Some houses are already painted, Paint the houses of this way [2,2,1,2,2]
    This array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}].
    Cost of paint the first and last house (10 + 1) = 11.

    Example 3:

    >>> minCost(houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3)
    >>> -1
    Explanation: Houses are already painted with a total of 4 neighborhoods [{3},{1},{2},{3}] different of target = 3.
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def deleteNodes(head: Optional[ListNode], m: int, n: int) -> Optional[ListNode]:
    """
    You are given the head of a linked list and two integers m and n.
    Traverse the linked list and remove some nodes in the following way:

    Start with the head as the current node.
    Keep the first m nodes starting with the current node.
    Remove the next n nodes
    Keep repeating steps 2 and 3 until you reach the end of the list.

    Return the head of the modified list after removing the mentioned nodes.

    Example 1:

    >>> __init__(head = [1,2,3,4,5,6,7,8,9,10,11,12,13], m = 2, n = 3)
    >>> [1,2,6,7,11,12]
    Explanation: Keep the first (m = 2) nodes starting from the head of the linked List  (1 ->2) show in black nodes.
    Delete the next (n = 3) nodes (3 -> 4 -> 5) show in read nodes.
    Continue with the same procedure until reaching the tail of the Linked List.
    Head of the linked list after removing nodes is returned.

    Example 2:

    >>> __init__(head = [1,2,3,4,5,6,7,8,9,10,11], m = 1, n = 3)
    >>> [1,5,9]
    Explanation: Head of linked list after removing nodes is returned.
    """


Prompt:
def finalPrices(prices: List[int]) -> List[int]:
    """
    You are given an integer array prices where prices[i] is the price of the ith item in a shop.
    There is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.
    Return an integer array answer where answer[i] is the final price you will pay for the ith item of the shop, considering the special discount.

    Example 1:

    >>> finalPrices(prices = [8,4,6,2,3])
    >>> [4,2,4,2,3]
    Explanation:
    For item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.
    For item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.
    For item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.
    For items 3 and 4 you will not receive any discount at all.

    Example 2:

    >>> finalPrices(prices = [1,2,3,4,5])
    >>> [1,2,3,4,5]
    Explanation: In this case, for all items, you will not receive any discount at all.

    Example 3:

    >>> finalPrices(prices = [10,1,1,6])
    >>> [9,0,1,6]
    """


Prompt:
def minSumOfLengths(arr: List[int], target: int) -> int:
    """
    You are given an array of integers arr and an integer target.
    You have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.
    Return the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.

    Example 1:

    >>> minSumOfLengths(arr = [3,2,2,4,3], target = 3)
    >>> 2
    Explanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.

    Example 2:

    >>> minSumOfLengths(arr = [7,3,4,7], target = 7)
    >>> 2
    Explanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.

    Example 3:

    >>> minSumOfLengths(arr = [4,3,2,6,2,3,4], target = 6)
    >>> -1
    Explanation: We have only one sub-array of sum = 6.
    """


Prompt:
def minDistance(houses: List[int], k: int) -> int:
    """
    Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.
    Return the minimum total distance between each house and its nearest mailbox.
    The test cases are generated so that the answer fits in a 32-bit integer.

    Example 1:

    >>> minDistance(houses = [1,4,8,10,20], k = 3)
    >>> 5
    Explanation: Allocate mailboxes in position 3, 9 and 20.
    Minimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5

    Example 2:

    >>> minDistance(houses = [2,3,5,12,18], k = 2)
    >>> 9
    Explanation: Allocate mailboxes in position 3 and 14.
    Minimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.
    """


Prompt:
def runningSum(nums: List[int]) -> List[int]:
    """
    Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).
    Return the running sum of nums.

    Example 1:

    >>> runningSum(nums = [1,2,3,4])
    >>> [1,3,6,10]
    Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
    Example 2:

    >>> runningSum(nums = [1,1,1,1,1])
    >>> [1,2,3,4,5]
    Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].
    Example 3:

    >>> runningSum(nums = [3,1,2,10,1])
    >>> [3,4,6,16,17]
    """


Prompt:
def findLeastNumOfUniqueInts(arr: List[int], k: int) -> int:
    """
    Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\r
    \r
    \r
    \r
    \r
     \r
    Example 1:\r
    \r
    \r
    >>> findLeastNumOfUniqueInts(arr = [5,5,4], k = 1\r)
    >>> 1\r
    Explanation: Remove the single 4, only 5 is left.\r
    \r
    Example 2:\r
    \r
    \r
    >>> findLeastNumOfUniqueInts(arr = [4,3,1,1,3,3,2], k = 3\r)
    >>> 2\r
    Explanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.\r
    \r
     \r
    """


Prompt:
def minDays(bloomDay: List[int], m: int, k: int) -> int:
    """
    You are given an integer array bloomDay, an integer m and an integer k.
    You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.
    The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.
    Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

    Example 1:

    >>> minDays(bloomDay = [1,10,3,10,2], m = 3, k = 1)
    >>> 3
    Explanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.
    We need 3 bouquets each should contain 1 flower.
    After day 1: [x, _, _, _, _]   // we can only make one bouquet.
    After day 2: [x, _, _, _, x]   // we can only make two bouquets.
    After day 3: [x, _, x, _, x]   // we can make 3 bouquets. The answer is 3.

    Example 2:

    >>> minDays(bloomDay = [1,10,3,10,2], m = 3, k = 2)
    >>> -1
    Explanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.

    Example 3:

    >>> minDays(bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3)
    >>> 12
    Explanation: We need 2 bouquets each should have 3 flowers.
    Here is the garden after the 7 and 12 days:
    After day 7: [x, x, x, x, _, x, x]
    We can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.
    After day 12: [x, x, x, x, x, x, x]
    It is obvious that we can make two bouquets in different ways.
    """


Prompt:
# class Node:
#     def __init__(val=0, left=None, right=None, random=None):
#         self.val = val
#         self.left = left
#         self.right = right
#         self.random = random

class Solution:
    def copyRandomBinaryTree(root: 'Optional[Node]') -> 'Optional[NodeCopy]':
    """
    A binary tree is given such that each node contains an additional random pointer which could point to any node in the tree or null.
    Return a deep copy of the tree.
    The tree is represented in the same input/output way as normal binary trees where each node is represented as a pair of [val, random_index] where:

    val: an integer representing Node.val
    random_index: the index of the node (in the input) where the random pointer points to, or null if it does not point to any node.

    You will be given the tree in class Node and you should return the cloned tree in class NodeCopy. NodeCopy class is just a clone of Node class with the same attributes and constructors.

    Example 1:

    >>> __init__(root = [[1,null],null,[4,3],[7,0]])
    >>> [[1,null],null,[4,3],[7,0]]
    Explanation: The original binary tree is [1,null,4,7].
    The random pointer of node one is null, so it is represented as [1, null].
    The random pointer of node 4 is node 7, so it is represented as [4, 3] where 3 is the index of node 7 in the array representing the tree.
    The random pointer of node 7 is node 1, so it is represented as [7, 0] where 0 is the index of node 1 in the array representing the tree.

    Example 2:

    >>> __init__(root = [[1,4],null,[1,0],null,[1,5],[1,5]])
    >>> [[1,4],null,[1,0],null,[1,5],[1,5]]
    Explanation: The random pointer of a node can be the node itself.

    Example 3:

    >>> __init__(root = [[1,6],[2,5],[3,4],[4,3],[5,2],[6,1],[7,0]])
    >>> [[1,6],[2,5],[3,4],[4,3],[5,2],[6,1],[7,0]]
    """


Prompt:
def xorOperation(n: int, start: int) -> int:
    """
    You are given an integer n and an integer start.
    Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.
    Return the bitwise XOR of all elements of nums.

    Example 1:

    >>> xorOperation(n = 5, start = 0)
    >>> 8
    Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
    Where "^" corresponds to bitwise XOR operator.

    Example 2:

    >>> xorOperation(n = 4, start = 3)
    >>> 8
    Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.
    """


Prompt:
def getFolderNames(names: List[str]) -> List[str]:
    """
    Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].
    Since two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.
    Return an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.

    Example 1:

    >>> getFolderNames(names = ["pes","fifa","gta","pes(2019)"])
    >>> ["pes","fifa","gta","pes(2019)"]
    Explanation: Let's see how the file system creates folder names:
    "pes" --> not assigned before, remains "pes"
    "fifa" --> not assigned before, remains "fifa"
    "gta" --> not assigned before, remains "gta"
    "pes(2019)" --> not assigned before, remains "pes(2019)"

    Example 2:

    >>> getFolderNames(names = ["gta","gta(1)","gta","avalon"])
    >>> ["gta","gta(1)","gta(2)","avalon"]
    Explanation: Let's see how the file system creates folder names:
    "gta" --> not assigned before, remains "gta"
    "gta(1)" --> not assigned before, remains "gta(1)"
    "gta" --> the name is reserved, system adds (k), since "gta(1)" is also reserved, systems put k = 2. it becomes "gta(2)"
    "avalon" --> not assigned before, remains "avalon"

    Example 3:

    >>> getFolderNames(names = ["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece"])
    >>> ["onepiece","onepiece(1)","onepiece(2)","onepiece(3)","onepiece(4)"]
    Explanation: When the last folder is created, the smallest positive valid k is 4, and it becomes "onepiece(4)".
    """


Prompt:
def avoidFlood(rains: List[int]) -> List[int]:
    """
    Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake that is full of water, there will be a flood. Your goal is to avoid floods in any lake.
    Given an integer array rains where:

    rains[i] > 0 means there will be rains over the rains[i] lake.
    rains[i] == 0 means there are no rains this day and you can choose one lake this day and dry it.

    Return an array ans where:

    ans.length == rains.length
    ans[i] == -1 if rains[i] > 0.
    ans[i] is the lake you choose to dry in the ith day if rains[i] == 0.

    If there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.
    Notice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes.

    Example 1:

    >>> avoidFlood(rains = [1,2,3,4])
    >>> [-1,-1,-1,-1]
    Explanation: After the first day full lakes are [1]
    After the second day full lakes are [1,2]
    After the third day full lakes are [1,2,3]
    After the fourth day full lakes are [1,2,3,4]
    There's no day to dry any lake and there is no flood in any lake.

    Example 2:

    >>> avoidFlood(rains = [1,2,0,0,2,1])
    >>> [-1,-1,2,1,-1,-1]
    Explanation: After the first day full lakes are [1]
    After the second day full lakes are [1,2]
    After the third day, we dry lake 2. Full lakes are [1]
    After the fourth day, we dry lake 1. There is no full lakes.
    After the fifth day, full lakes are [2].
    After the sixth day, full lakes are [1,2].
    It is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another acceptable scenario.

    Example 3:

    >>> avoidFlood(rains = [1,2,0,1,2])
    >>> []
    Explanation: After the second day, full lakes are  [1,2]. We have to dry one lake in the third day.
    After that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.
    """


Prompt:
def findCriticalAndPseudoCriticalEdges(n: int, edges: List[List[int]]) -> List[List[int]]:
    """
    Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.
    Find all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.
    Note that you can return the indices of the edges in any order.

    Example 1:

    >>> findCriticalAndPseudoCriticalEdges(n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]])
    >>> [[0,1],[2,3,4,5]]
    Explanation: The figure above describes the graph.
    The following figure shows all the possible MSTs:

    Notice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.
    The edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.

    Example 2:

    >>> findCriticalAndPseudoCriticalEdges(n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]])
    >>> [[],[0,1,2,3]]
    Explanation: We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.
    """


Prompt:
def average(salary: List[int]) -> float:
    """
    You are given an array of unique integers salary where salary[i] is the salary of the ith employee.
    Return the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> average(salary = [4000,3000,1000,2000])
    >>> 2500.00000
    Explanation: Minimum salary and maximum salary are 1000 and 4000 respectively.
    Average salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500

    Example 2:

    >>> average(salary = [1000,2000,3000])
    >>> 2000.00000
    Explanation: Minimum salary and maximum salary are 1000 and 3000 respectively.
    Average salary excluding minimum and maximum salary is (2000) / 1 = 2000
    """


Prompt:
def kthFactor(n: int, k: int) -> int:
    """
    You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.
    Consider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.

    Example 1:

    >>> kthFactor(n = 12, k = 3)
    >>> 3
    Explanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.

    Example 2:

    >>> kthFactor(n = 7, k = 2)
    >>> 7
    Explanation: Factors list is [1, 7], the 2nd factor is 7.

    Example 3:

    >>> kthFactor(n = 4, k = 4)
    >>> -1
    Explanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1.
    """


Prompt:
def longestSubarray(nums: List[int]) -> int:
    """
    Given a binary array nums, you should delete one element from it.
    Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.

    Example 1:

    >>> longestSubarray(nums = [1,1,0,1])
    >>> 3
    Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.

    Example 2:

    >>> longestSubarray(nums = [0,1,1,1,0,1,1,0,1])
    >>> 5
    Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].

    Example 3:

    >>> longestSubarray(nums = [1,1,1])
    >>> 2
    Explanation: You must delete one element.
    """


Prompt:
def minNumberOfSemesters(n: int, relations: List[List[int]], k: int) -> int:
    """
    You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. Also, you are given the integer k.
    In one semester, you can take at most k courses as long as you have taken all the prerequisites in the previous semesters for the courses you are taking.
    Return the minimum number of semesters needed to take all courses. The testcases will be generated such that it is possible to take every course.

    Example 1:

    >>> minNumberOfSemesters(n = 4, relations = [[2,1],[3,1],[1,4]], k = 2)
    >>> 3
    Explanation: The figure above represents the given graph.
    In the first semester, you can take courses 2 and 3.
    In the second semester, you can take course 1.
    In the third semester, you can take course 4.

    Example 2:

    >>> minNumberOfSemesters(n = 5, relations = [[2,1],[3,1],[4,1],[1,5]], k = 2)
    >>> 4
    Explanation: The figure above represents the given graph.
    In the first semester, you can only take courses 2 and 3 since you cannot take more than two per semester.
    In the second semester, you can take course 4.
    In the third semester, you can take course 1.
    In the fourth semester, you can take course 5.
    """


Prompt:
def isPathCrossing(path: str) -> bool:
    """
    Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.
    Return true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.

    Example 1:

    >>> isPathCrossing(path = "NES")
    >>> false
    Explanation: Notice that the path doesn't cross any point more than once.

    Example 2:

    >>> isPathCrossing(path = "NESWW")
    >>> true
    Explanation: Notice that the path visits the origin twice.
    """


Prompt:
def canArrange(arr: List[int], k: int) -> bool:
    """
    Given an array of integers arr of even length n and an integer k.
    We want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.
    Return true If you can find a way to do that or false otherwise.

    Example 1:

    >>> canArrange(arr = [1,2,3,4,5,10,6,7,8,9], k = 5)
    >>> true
    Explanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).

    Example 2:

    >>> canArrange(arr = [1,2,3,4,5,6], k = 7)
    >>> true
    Explanation: Pairs are (1,6),(2,5) and(3,4).

    Example 3:

    >>> canArrange(arr = [1,2,3,4,5,6], k = 10)
    >>> false
    Explanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.
    """


Prompt:
def numSubseq(nums: List[int], target: int) -> int:
    """
    You are given an array of integers nums and an integer target.
    Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.

    Example 1:

    >>> numSubseq(nums = [3,5,6,7], target = 9)
    >>> 4
    Explanation: There are 4 subsequences that satisfy the condition.
    [3] -> Min value + max value <= target (3 + 3 <= 9)
    [3,5] -> (3 + 5 <= 9)
    [3,5,6] -> (3 + 6 <= 9)
    [3,6] -> (3 + 6 <= 9)

    Example 2:

    >>> numSubseq(nums = [3,3,6,8], target = 10)
    >>> 6
    Explanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).
    [3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]

    Example 3:

    >>> numSubseq(nums = [2,3,3,4,6,7], target = 12)
    >>> 61
    Explanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).
    Number of valid subsequences (63 - 2 = 61).
    """


Prompt:
def findMaxValueOfEquation(points: List[List[int]], k: int) -> int:
    """
    You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.
    Return the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length.
    It is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.

    Example 1:

    >>> findMaxValueOfEquation(points = [[1,3],[2,0],[5,10],[6,-10]], k = 1)
    >>> 4
    Explanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.
    No other pairs satisfy the condition, so we return the max of 4 and 1.

    Example 2:

    >>> findMaxValueOfEquation(points = [[0,0],[3,0],[9,2]], k = 3)
    >>> 3
    Explanation: Only the first two points have an absolute difference of 3 or less in the x-values, and give the value of 0 + 0 + |0 - 3| = 3.
    """


Prompt:
def canMakeArithmeticProgression(arr: List[int]) -> bool:
    """
    A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.
    Given an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.

    Example 1:

    >>> canMakeArithmeticProgression(arr = [3,5,1])
    >>> true
    Explanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.

    Example 2:

    >>> canMakeArithmeticProgression(arr = [1,2,4])
    >>> false
    Explanation: There is no way to reorder the elements to obtain an arithmetic progression.
    """


Prompt:
def getLastMoment(n: int, left: List[int], right: List[int]) -> int:
    """
    We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.
    When two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.
    When an ant reaches one end of the plank at a time t, it falls out of the plank immediately.
    Given an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.

    Example 1:

    >>> getLastMoment(n = 4, left = [4,3], right = [0,1])
    >>> 4
    Explanation: In the image above:
    -The ant at index 0 is named A and going to the right.
    -The ant at index 1 is named B and going to the right.
    -The ant at index 3 is named C and going to the left.
    -The ant at index 4 is named D and going to the left.
    The last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).

    Example 2:

    >>> getLastMoment(n = 7, left = [], right = [0,1,2,3,4,5,6,7])
    >>> 7
    Explanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.

    Example 3:

    >>> getLastMoment(n = 7, left = [0,1,2,3,4,5,6,7], right = [])
    >>> 7
    Explanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.
    """


Prompt:
def numSubmat(mat: List[List[int]]) -> int:
    """
    Given an m x n binary matrix mat, return the number of submatrices that have all ones.

    Example 1:

    >>> numSubmat(mat = [[1,0,1],[1,1,0],[1,1,0]])
    >>> 13
    Explanation:
    There are 6 rectangles of side 1x1.
    There are 2 rectangles of side 1x2.
    There are 3 rectangles of side 2x1.
    There is 1 rectangle of side 2x2.
    There is 1 rectangle of side 3x1.
    Total number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.

    Example 2:

    >>> numSubmat(mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]])
    >>> 24
    Explanation:
    There are 8 rectangles of side 1x1.
    There are 5 rectangles of side 1x2.
    There are 2 rectangles of side 1x3.
    There are 4 rectangles of side 2x1.
    There are 2 rectangles of side 2x2.
    There are 2 rectangles of side 3x1.
    There is 1 rectangle of side 3x2.
    Total number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.
    """