Prompt:
def maxIncreaseKeepingSkyline(grid: List[List[int]]) -> int:
    """
    There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix grid where grid[r][c] represents the height of the building located in the block at row r and column c.
    A city's skyline is the outer contour formed by all the building when viewing the side of the city from a distance. The skyline from each cardinal direction north, east, south, and west may be different.
    We are allowed to increase the height of any number of buildings by any amount (the amount can be different per building). The height of a 0-height building can also be increased. However, increasing the height of a building should not affect the city's skyline from any cardinal direction.
    Return the maximum total sum that the height of the buildings can be increased by without changing the city's skyline from any cardinal direction.

    Example 1:

    >>> maxIncreaseKeepingSkyline(grid = [[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]])
    >>> 35
    Explanation: The building heights are shown in the center of the above image.
    The skylines when viewed from each cardinal direction are drawn in red.
    The grid after increasing the height of buildings without affecting skylines is:
    gridNew = [ [8, 4, 8, 7],
                [7, 4, 7, 7],
                [9, 4, 8, 7],
                [3, 3, 3, 3] ]

    Example 2:

    >>> maxIncreaseKeepingSkyline(grid = [[0,0,0],[0,0,0],[0,0,0]])
    >>> 0
    Explanation: Increasing the height of any building will result in the skyline changing.
    """


Prompt:
def soupServings(n: int) -> float:
    """
    There are two types of soup: type A and type B. Initially, we have n ml of each type of soup. There are four kinds of operations:

    Serve 100 ml of soup A and 0 ml of soup B,
    Serve 75 ml of soup A and 25 ml of soup B,
    Serve 50 ml of soup A and 50 ml of soup B, and
    Serve 25 ml of soup A and 75 ml of soup B.

    When we serve some soup, we give it to someone, and we no longer have it. Each turn, we will choose from the four operations with an equal probability 0.25. If the remaining volume of soup is not enough to complete the operation, we will serve as much as possible. We stop once we no longer have some quantity of both types of soup.
    Note that we do not have an operation where all 100 ml's of soup B are used first.
    Return the probability that soup A will be empty first, plus half the probability that A and B become empty at the same time. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> soupServings(n = 50)
    >>> 0.62500
    Explanation: If we choose the first two operations, A will become empty first.
    For the third operation, A and B will become empty at the same time.
    For the fourth operation, B will become empty first.
    So the total probability of A becoming empty first plus half the probability that A and B become empty at the same time, is 0.25 * (1 + 1 + 0.5 + 0) = 0.625.

    Example 2:

    >>> soupServings(n = 100)
    >>> 0.71875
    """


Prompt:
def expressiveWords(s: str, words: List[str]) -> int:
    """
    Sometimes people repeat letters to represent extra feeling. For example:

    "hello" -> "heeellooo"
    "hi" -> "hiiii"

    In these strings like "heeellooo", we have groups of adjacent letters that are all the same: "h", "eee", "ll", "ooo".
    You are given a string s and an array of query strings words. A query word is stretchy if it can be made to be equal to s by any number of applications of the following extension operation: choose a group consisting of characters c, and add some number of characters c to the group so that the size of the group is three or more.

    For example, starting with "hello", we could do an extension on the group "o" to get "hellooo", but we cannot get "helloo" since the group "oo" has a size less than three. Also, we could do another extension like "ll" -> "lllll" to get "helllllooo". If s = "helllllooo", then the query word "hello" would be stretchy because of these two extension operations: query = "hello" -> "hellooo" -> "helllllooo" = s.

    Return the number of query strings that are stretchy.

    Example 1:

    >>> expressiveWords(s = "heeellooo", words = ["hello", "hi", "helo"])
    >>> 1
    Explanation:
    We can extend "e" and "o" in the word "hello" to get "heeellooo".
    We can't extend "helo" to get "heeellooo" because the group "ll" is not size 3 or more.

    Example 2:

    >>> expressiveWords(s = "zzzzzyyyyy", words = ["zzyy","zy","zyy"])
    >>> 3
    """


Prompt:
def xorGame(nums: List[int]) -> bool:
    """
    You are given an array of integers nums represents the numbers written on a chalkboard.
    Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0.
    Also, if any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player wins.
    Return true if and only if Alice wins the game, assuming both players play optimally.

    Example 1:

    >>> xorGame(nums = [1,1,2])
    >>> false
    Explanation:
    Alice has two choices: erase 1 or erase 2.
    If she erases 1, the nums array becomes [1, 2]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 2 = 3. Now Bob can remove any element he wants, because Alice will be the one to erase the last element and she will lose.
    If Alice erases 2 first, now nums become [1, 1]. The bitwise XOR of all the elements of the chalkboard is 1 XOR 1 = 0. Alice will lose.

    Example 2:

    >>> xorGame(nums = [0,1])
    >>> true

    Example 3:

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


Prompt:
def subdomainVisits(cpdomains: List[str]) -> List[str]:
    """
    A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitly.
    A count-paired domain is a domain that has one of the two formats "rep d1.d2.d3" or "rep d1.d2" where rep is the number of visits to the domain and d1.d2.d3 is the domain itself.

    For example, "9001 discuss.leetcode.com" is a count-paired domain that indicates that discuss.leetcode.com was visited 9001 times.

    Given an array of count-paired domains cpdomains, return an array of the count-paired domains of each subdomain in the input. You may return the answer in any order.

    Example 1:

    >>> subdomainVisits(cpdomains = ["9001 discuss.leetcode.com"])
    >>> ["9001 leetcode.com","9001 discuss.leetcode.com","9001 com"]
    Explanation: We only have one website domain: "discuss.leetcode.com".
    As discussed above, the subdomain "leetcode.com" and "com" will also be visited. So they will all be visited 9001 times.

    Example 2:

    >>> subdomainVisits(cpdomains = ["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5 wiki.org"])
    >>> ["901 mail.com","50 yahoo.com","900 google.mail.com","5 wiki.org","5 org","1 intel.mail.com","951 com"]
    Explanation: We will visit "google.mail.com" 900 times, "yahoo.com" 50 times, "intel.mail.com" once and "wiki.org" 5 times.
    For the subdomains, we will visit "mail.com" 900 + 1 = 901 times, "com" 900 + 50 + 1 = 951 times, and "org" 5 times.
    """


Prompt:
def largestTriangleArea(points: List[List[int]]) -> float:
    """
    Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> largestTriangleArea(points = [[0,0],[0,1],[1,0],[0,2],[2,0]])
    >>> 2.00000
    Explanation: The five points are shown in the above figure. The red triangle is the largest.

    Example 2:

    >>> largestTriangleArea(points = [[1,0],[0,0],[0,1]])
    >>> 0.50000
    """


Prompt:
def largestSumOfAverages(nums: List[int], k: int) -> float:
    """
    You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of each subarray.
    Note that the partition must use every integer in nums, and that the score is not necessarily an integer.
    Return the maximum score you can achieve of all the possible partitions. Answers within 10-6 of the actual answer will be accepted.

    Example 1:

    >>> largestSumOfAverages(nums = [9,1,2,3,9], k = 3)
    >>> 20.00000
    Explanation:
    The best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.
    We could have also partitioned nums into [9, 1], [2], [3, 9], for example.
    That partition would lead to a score of 5 + 2 + 6 = 13, which is worse.

    Example 2:

    >>> largestSumOfAverages(nums = [1,2,3,4,5,6,7], k = 4)
    >>> 20.50000
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def pruneTree(root: Optional[TreeNode]) -> Optional[TreeNode]:
    """
    Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed.
    A subtree of a node node is node plus every node that is a descendant of node.

    Example 1:

    >>> __init__(root = [1,null,0,0,1])
    >>> [1,null,0,null,1]
    Explanation:
    Only the red nodes satisfy the property "every subtree not containing a 1".
    The diagram on the right represents the answer.

    Example 2:

    >>> __init__(root = [1,0,1,0,0,0,1])
    >>> [1,null,1,null,1]

    Example 3:

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


Prompt:
def numBusesToDestination(routes: List[List[int]], source: int, target: int) -> int:
    """
    You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever.

    For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever.

    You will start at the bus stop source (You are not on any bus initially), and you want to go to the bus stop target. You can travel between bus stops by buses only.
    Return the least number of buses you must take to travel from source to target. Return -1 if it is not possible.

    Example 1:

    >>> numBusesToDestination(routes = [[1,2,7],[3,6,7]], source = 1, target = 6)
    >>> 2
    Explanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.

    Example 2:

    >>> numBusesToDestination(routes = [[7,12],[4,5,15],[6],[15,19],[9,12,13]], source = 15, target = 12)
    >>> -1
    """


Prompt:
def ambiguousCoordinates(s: str) -> List[str]:
    """
    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s.

    For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" becomes s = "(205)".

    Return a list of strings representing all possibilities for what our original coordinates could have been.
    Our original representation never had extraneous zeroes, so we never started with numbers like "00", "0.0", "0.00", "1.0", "001", "00.01", or any other number that can be represented with fewer digits. Also, a decimal point within a number never occurs without at least one digit occurring before it, so we never started with numbers like ".1".
    The final answer list can be returned in any order. All coordinates in the final answer have exactly one space between them (occurring after the comma.)

    Example 1:

    >>> ambiguousCoordinates(s = "(123)")
    >>> ["(1, 2.3)","(1, 23)","(1.2, 3)","(12, 3)"]

    Example 2:

    >>> ambiguousCoordinates(s = "(0123)")
    >>> ["(0, 1.23)","(0, 12.3)","(0, 123)","(0.1, 2.3)","(0.1, 23)","(0.12, 3)"]
    Explanation: 0.0, 00, 0001 or 00.01 are not allowed.

    Example 3:

    >>> ambiguousCoordinates(s = "(00011)")
    >>> ["(0, 0.011)","(0.001, 1)"]
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def numComponents(head: Optional[ListNode], nums: List[int]) -> int:
    """
    You are given the head of a linked list containing unique integer values and an integer array nums that is a subset of the linked list values.
    Return the number of connected components in nums where two values are connected if they appear consecutively in the linked list.

    Example 1:

    >>> __init__(head = [0,1,2,3], nums = [0,1,3])
    >>> 2
    Explanation: 0 and 1 are connected, so [0, 1] and [3] are the two connected components.

    Example 2:

    >>> __init__(head = [0,1,2,3,4], nums = [0,3,1,4])
    >>> 2
    Explanation: 0 and 1 are connected, 3 and 4 are connected, so [0, 1] and [3, 4] are the two connected components.
    """


Prompt:
def racecar(target: int) -> int:
    """
    Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse):

    When you get an instruction 'A', your car does the following:

    position += speed
    speed *= 2

    When you get an instruction 'R', your car does the following:

    If your speed is positive then speed = -1
    otherwise speed = 1

    	Your position stays the same.

    For example, after commands "AAR", your car goes to positions 0 --> 1 --> 3 --> 3, and your speed goes to 1 --> 2 --> 4 --> -1.
    Given a target position target, return the length of the shortest sequence of instructions to get there.

    Example 1:

    >>> racecar(target = 3)
    >>> 2
    Explanation:
    The shortest instruction sequence is "AA".
    Your position goes from 0 --> 1 --> 3.

    Example 2:

    >>> racecar(target = 6)
    >>> 5
    Explanation:
    The shortest instruction sequence is "AAARA".
    Your position goes from 0 --> 1 --> 3 --> 7 --> 7 --> 6.
    """


Prompt:
def minimumLengthEncoding(words: List[str]) -> int:
    """
    A valid encoding of an array of words is any reference string s and array of indices indices such that:

    words.length == indices.length
    The reference string s ends with the '#' character.
    For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next '#' character is equal to words[i].

    Given an array of words, return the length of the shortest reference string s possible of any valid encoding of words.

    Example 1:

    >>> minimumLengthEncoding(words = ["time", "me", "bell"])
    >>> 10
    Explanation: A valid encoding would be s = "time#bell#" and indices = [0, 2, 5].
    words[0] = "time", the substring of s starting from indices[0] = 0 to the next '#' is underlined in "time#bell#"
    words[1] = "me", the substring of s starting from indices[1] = 2 to the next '#' is underlined in "time#bell#"
    words[2] = "bell", the substring of s starting from indices[2] = 5 to the next '#' is underlined in "time#bell#"

    Example 2:

    >>> minimumLengthEncoding(words = ["t"])
    >>> 2
    Explanation: A valid encoding would be s = "t#" and indices = [0].
    """


Prompt:
def shortestToChar(s: str, c: str) -> List[int]:
    """
    Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s.
    The distance between two indices i and j is abs(i - j), where abs is the absolute value function.

    Example 1:

    >>> shortestToChar(s = "loveleetcode", c = "e")
    >>> [3,2,1,0,1,0,0,1,2,2,1,0]
    Explanation: The character 'e' appears at indices 3, 5, 6, and 11 (0-indexed).
    The closest occurrence of 'e' for index 0 is at index 3, so the distance is abs(0 - 3) = 3.
    The closest occurrence of 'e' for index 1 is at index 3, so the distance is abs(1 - 3) = 2.
    For index 4, there is a tie between the 'e' at index 3 and the 'e' at index 5, but the distance is still the same: abs(4 - 3) == abs(4 - 5) = 1.
    The closest occurrence of 'e' for index 8 is at index 6, so the distance is abs(8 - 6) = 2.

    Example 2:

    >>> shortestToChar(s = "aaab", c = "b")
    >>> [3,2,1,0]
    """


Prompt:
def flipgame(fronts: List[int], backs: List[int]) -> int:
    """
    You are given two 0-indexed integer arrays fronts and backs of length n, where the ith card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may flip over any number of cards (possibly zero).
    After flipping the cards, an integer is considered good if it is facing down on some card and not facing up on any card.
    Return the minimum possible good integer after flipping the cards. If there are no good integers, return 0.

    Example 1:

    >>> flipgame(fronts = [1,2,4,4,7], backs = [1,3,4,1,3])
    >>> 2
    Explanation:
    If we flip the second card, the face up numbers are [1,3,4,4,7] and the face down are [1,2,4,1,3].
    2 is the minimum good integer as it appears facing down but not facing up.
    It can be shown that 2 is the minimum possible good integer obtainable after flipping some cards.

    Example 2:

    >>> flipgame(fronts = [1], backs = [1])
    >>> 0
    Explanation:
    There are no good integers no matter how we flip the cards, so we return 0.
    """


Prompt:
def numFactoredBinaryTrees(arr: List[int]) -> int:
    """
    Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1.
    We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children.
    Return the number of binary trees we can make. The answer may be too large so return the answer modulo 109 + 7.

    Example 1:

    >>> numFactoredBinaryTrees(arr = [2,4])
    >>> 3
    Explanation: We can make these trees: [2], [4], [4, 2, 2]
    Example 2:

    >>> numFactoredBinaryTrees(arr = [2,4,5,10])
    >>> 7
    Explanation: We can make these trees: [2], [4], [5], [10], [4, 2, 2], [10, 2, 5], [10, 5, 2].
    """


Prompt:
def toGoatLatin(sentence: str) -> str:
    """
    You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.
    We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:

    If a word begins with a vowel ('a', 'e', 'i', 'o', or 'u'), append "ma" to the end of the word.

    For example, the word "apple" becomes "applema".

    If a word begins with a consonant (i.e., not a vowel), remove the first letter and append it to the end, then add "ma".

    For example, the word "goat" becomes "oatgma".

    Add one letter 'a' to the end of each word per its word index in the sentence, starting with 1.

    For example, the first word gets "a" added to the end, the second word gets "aa" added to the end, and so on.

    Return the final sentence representing the conversion from sentence to Goat Latin.

    Example 1:
    >>> toGoatLatin(sentence = "I speak Goat Latin")
    >>> "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"
    Example 2:
    >>> toGoatLatin(sentence = "The quick brown fox jumped over the lazy dog")
    >>> "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"
    """


Prompt:
def numFriendRequests(ages: List[int]) -> int:
    """
    There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the ith person.
    A Person x will not send a friend request to a person y (x != y) if any of the following conditions is true:

    age[y] <= 0.5 * age[x] + 7
    age[y] > age[x]
    age[y] > 100 && age[x] < 100

    Otherwise, x will send a friend request to y.
    Note that if x sends a request to y, y will not necessarily send a request to x. Also, a person will not send a friend request to themself.
    Return the total number of friend requests made.

    Example 1:

    >>> numFriendRequests(ages = [16,16])
    >>> 2
    Explanation: 2 people friend request each other.

    Example 2:

    >>> numFriendRequests(ages = [16,17,18])
    >>> 2
    Explanation: Friend requests are made 17 -> 16, 18 -> 17.

    Example 3:

    >>> numFriendRequests(ages = [20,30,100,110,120])
    >>> 3
    Explanation: Friend requests are made 110 -> 100, 120 -> 110, 120 -> 100.
    """


Prompt:
def maxProfitAssignment(difficulty: List[int], profit: List[int], worker: List[int]) -> int:
    """
    You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where:

    difficulty[i] and profit[i] are the difficulty and the profit of the ith job, and
    worker[j] is the ability of jth worker (i.e., the jth worker can only complete a job with difficulty at most worker[j]).

    Every worker can be assigned at most one job, but one job can be completed multiple times.

    For example, if three workers attempt the same job that pays $1, then the total profit will be $3. If a worker cannot complete any job, their profit is $0.

    Return the maximum profit we can achieve after assigning the workers to the jobs.

    Example 1:

    >>> maxProfitAssignment(difficulty = [2,4,6,8,10], profit = [10,20,30,40,50], worker = [4,5,6,7])
    >>> 100
    Explanation: Workers are assigned jobs of difficulty [4,4,6,6] and they get a profit of [20,20,30,30] separately.

    Example 2:

    >>> maxProfitAssignment(difficulty = [85,47,57], profit = [24,66,99], worker = [40,25,25])
    >>> 0
    """


Prompt:
def largestIsland(grid: List[List[int]]) -> int:
    """
    You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1.
    Return the size of the largest island in grid after applying this operation.
    An island is a 4-directionally connected group of 1s.

    Example 1:

    >>> largestIsland(grid = [[1,0],[0,1]])
    >>> 3
    Explanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3.

    Example 2:

    >>> largestIsland(grid = [[1,1],[1,0]])
    >>> 4
    Explanation: Change the 0 to 1 and make the island bigger, only one island with area = 4.
    Example 3:

    >>> largestIsland(grid = [[1,1],[1,1]])
    >>> 4
    Explanation: Can't change any 0 to 1, only one island with area = 4.
    """


Prompt:
def uniqueLetterString(s: str) -> int:
    """
    Let's define a function countUniqueChars(s) that returns the number of unique characters in s.

    For example, calling countUniqueChars(s) if s = "LEETCODE" then "L", "T", "C", "O", "D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.

    Given a string s, return the sum of countUniqueChars(t) where t is a substring of s. The test cases are generated such that the answer fits in a 32-bit integer.
    Notice that some substrings can be repeated so in this case you have to count the repeated ones too.

    Example 1:

    >>> uniqueLetterString(s = "ABC")
    >>> 10
    Explanation: All possible substrings are: "A","B","C","AB","BC" and "ABC".
    Every substring is composed with only unique letters.
    Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10

    Example 2:

    >>> uniqueLetterString(s = "ABA")
    >>> 8
    Explanation: The same as example 1, except countUniqueChars("ABA") = 1.

    Example 3:

    >>> uniqueLetterString(s = "LEETCODE")
    >>> 92
    """


Prompt:
def consecutiveNumbersSum(n: int) -> int:
    """
    Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.

    Example 1:

    >>> consecutiveNumbersSum(n = 5)
    >>> 2
    Explanation: 5 = 2 + 3

    Example 2:

    >>> consecutiveNumbersSum(n = 9)
    >>> 3
    Explanation: 9 = 4 + 5 = 2 + 3 + 4

    Example 3:

    >>> consecutiveNumbersSum(n = 15)
    >>> 4
    Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
    """


Prompt:
def largeGroupPositions(s: str) -> List[List[int]]:
    """
    In a string s of lowercase letters, these letters form consecutive groups of the same character.
    For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy".
    A group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group. In the above example, "xxxx" has the interval [3,6].
    A group is considered large if it has 3 or more characters.
    Return the intervals of every large group sorted in increasing order by start index.

    Example 1:

    >>> largeGroupPositions(s = "abbxxxxzzy")
    >>> [[3,6]]
    Explanation: "xxxx" is the only large group with start index 3 and end index 6.

    Example 2:

    >>> largeGroupPositions(s = "abc")
    >>> []
    Explanation: We have groups "a", "b", and "c", none of which are large groups.

    Example 3:

    >>> largeGroupPositions(s = "abcdddeeeeaabbbcd")
    >>> [[3,5],[6,9],[12,14]]
    Explanation: The large groups are "ddd", "eeee", and "bbb".
    """


Prompt:
def maskPII(s: str) -> str:
    """
    You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules.
    Email address:
    An email address is:

    A name consisting of uppercase and lowercase English letters, followed by
    The '@' symbol, followed by
    The domain consisting of uppercase and lowercase English letters with a dot '.' somewhere in the middle (not the first or last character).

    To mask an email:

    The uppercase letters in the name and domain must be converted to lowercase letters.
    The middle letters of the name (i.e., all but the first and last letters) must be replaced by 5 asterisks "*****".

    Phone number:
    A phone number is formatted as follows:

    The phone number contains 10-13 digits.
    The last 10 digits make up the local number.
    The remaining 0-3 digits, in the beginning, make up the country code.
    Separation characters from the set {'+', '-', '(', ')', ' '} separate the above digits in some way.

    To mask a phone number:

    Remove all separation characters.
    The masked phone number should have the form:

    "***-***-XXXX" if the country code has 0 digits.
    "+*-***-***-XXXX" if the country code has 1 digit.
    "+**-***-***-XXXX" if the country code has 2 digits.
    "+***-***-***-XXXX" if the country code has 3 digits.

    "XXXX" is the last 4 digits of the local number.

    Example 1:

    >>> maskPII(s = "LeetCode@LeetCode.com")
    >>> "l*****e@leetcode.com"
    Explanation: s is an email address.
    The name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.

    Example 2:

    >>> maskPII(s = "AB@qq.com")
    >>> "a*****b@qq.com"
    Explanation: s is an email address.
    The name and domain are converted to lowercase, and the middle of the name is replaced by 5 asterisks.
    Note that even though "ab" is 2 characters, it still must have 5 asterisks in the middle.

    Example 3:

    >>> maskPII(s = "1(234)567-890")
    >>> "***-***-7890"
    Explanation: s is a phone number.
    There are 10 digits, so the local number is 10 digits and the country code is 0 digits.
    Thus, the resulting masked number is "***-***-7890".
    """


Prompt:
def flipAndInvertImage(image: List[List[int]]) -> List[List[int]]:
    """
    Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
    To flip an image horizontally means that each row of the image is reversed.

    For example, flipping [1,1,0] horizontally results in [0,1,1].

    To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0.

    For example, inverting [0,1,1] results in [1,0,0].

    Example 1:

    >>> flipAndInvertImage(image = [[1,1,0],[1,0,1],[0,0,0]])
    >>> [[1,0,0],[0,1,0],[1,1,1]]
    Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]].
    Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]]

    Example 2:

    >>> flipAndInvertImage(image = [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]])
    >>> [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
    Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]].
    Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]]
    """


Prompt:
def findReplaceString(s: str, indices: List[int], sources: List[str], targets: List[str]) -> str:
    """
    You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k.
    To complete the ith replacement operation:

    Check if the substring sources[i] occurs at index indices[i] in the original string s.
    If it does not occur, do nothing.
    Otherwise if it does occur, replace that substring with targets[i].

    For example, if s = "abcd", indices[i] = 0, sources[i] = "ab", and targets[i] = "eee", then the result of this replacement will be "eeecd".
    All replacement operations must occur simultaneously, meaning the replacement operations should not affect the indexing of each other. The testcases will be generated such that the replacements will not overlap.

    For example, a testcase with s = "abc", indices = [0, 1], and sources = ["ab","bc"] will not be generated because the "ab" and "bc" replacements overlap.

    Return the resulting string after performing all replacement operations on s.
    A substring is a contiguous sequence of characters in a string.

    Example 1:

    >>> findReplaceString(s = "abcd", indices = [0, 2], sources = ["a", "cd"], targets = ["eee", "ffff"])
    >>> "eeebffff"
    Explanation:
    "a" occurs at index 0 in s, so we replace it with "eee".
    "cd" occurs at index 2 in s, so we replace it with "ffff".

    Example 2:

    >>> findReplaceString(s = "abcd", indices = [0, 2], sources = ["ab","ec"], targets = ["eee","ffff"])
    >>> "eeecd"
    Explanation:
    "ab" occurs at index 0 in s, so we replace it with "eee".
    "ec" does not occur at index 2 in s, so we do nothing.
    """


Prompt:
def sumOfDistancesInTree(n: int, edges: List[List[int]]) -> List[int]:
    """
    There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.
    You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.
    Return an array answer of length n where answer[i] is the sum of the distances between the ith node in the tree and all other nodes.

    Example 1:

    >>> sumOfDistancesInTree(n = 6, edges = [[0,1],[0,2],[2,3],[2,4],[2,5]])
    >>> [8,12,6,10,10,10]
    Explanation: The tree is shown above.
    We can see that dist(0,1) + dist(0,2) + dist(0,3) + dist(0,4) + dist(0,5)
    equals 1 + 1 + 2 + 2 + 2 = 8.
    Hence, answer[0] = 8, and so on.

    Example 2:

    >>> sumOfDistancesInTree(n = 1, edges = [])
    >>> [0]

    Example 3:

    >>> sumOfDistancesInTree(n = 2, edges = [[1,0]])
    >>> [1,1]
    """


Prompt:
def largestOverlap(img1: List[List[int]], img2: List[List[int]]) -> int:
    """
    You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values.
    We translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calculate the overlap by counting the number of positions that have a 1 in both images.
    Note also that a translation does not include any kind of rotation. Any 1 bits that are translated outside of the matrix borders are erased.
    Return the largest possible overlap.

    Example 1:

    >>> largestOverlap(img1 = [[1,1,0],[0,1,0],[0,1,0]], img2 = [[0,0,0],[0,1,1],[0,0,1]])
    >>> 3
    Explanation: We translate img1 to right by 1 unit and down by 1 unit.

    The number of positions that have a 1 in both images is 3 (shown in red).

    Example 2:

    >>> largestOverlap(img1 = [[1]], img2 = [[1]])
    >>> 1

    Example 3:

    >>> largestOverlap(img1 = [[0]], img2 = [[0]])
    >>> 0
    """


Prompt:
def isRectangleOverlap(rec1: List[int], rec2: List[int]) -> bool:
    """
    An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis.
    Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap.
    Given two axis-aligned rectangles rec1 and rec2, return true if they overlap, otherwise return false.

    Example 1:
    >>> isRectangleOverlap(rec1 = [0,0,2,2], rec2 = [1,1,3,3])
    >>> true
    Example 2:
    >>> isRectangleOverlap(rec1 = [0,0,1,1], rec2 = [1,0,2,1])
    >>> false
    Example 3:
    >>> isRectangleOverlap(rec1 = [0,0,1,1], rec2 = [2,2,3,3])
    >>> false
    """


Prompt:
def new21Game(n: int, k: int, maxPts: int) -> float:
    """
    Alice plays the following game, loosely based on the card game "21".
    Alice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is independent and the outcomes have equal probabilities.
    Alice stops drawing numbers when she gets k or more points.
    Return the probability that Alice has n or fewer points.
    Answers within 10-5 of the actual answer are considered accepted.

    Example 1:

    >>> new21Game(n = 10, k = 1, maxPts = 10)
    >>> 1.00000
    Explanation: Alice gets a single card, then stops.

    Example 2:

    >>> new21Game(n = 6, k = 1, maxPts = 10)
    >>> 0.60000
    Explanation: Alice gets a single card, then stops.
    In 6 out of 10 possibilities, she is at or below 6 points.

    Example 3:

    >>> new21Game(n = 21, k = 17, maxPts = 10)
    >>> 0.73278
    """


Prompt:
def pushDominoes(dominoes: str) -> str:
    """
    There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.
    After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right.
    When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces.
    For the purposes of this question, we will consider that a falling domino expends no additional force to a falling or already fallen domino.
    You are given a string dominoes representing the initial state where:

    dominoes[i] = 'L', if the ith domino has been pushed to the left,
    dominoes[i] = 'R', if the ith domino has been pushed to the right, and
    dominoes[i] = '.', if the ith domino has not been pushed.

    Return a string representing the final state.

    Example 1:

    >>> pushDominoes(dominoes = "RR.L")
    >>> "RR.L"
    Explanation: The first domino expends no additional force on the second domino.

    Example 2:

    >>> pushDominoes(dominoes = ".L.R...LR..L..")
    >>> "LL.RR.LLRRLL.."
    """


Prompt:
def numSimilarGroups(strs: List[str]) -> int:
    """
    Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X.
    For example, "tars" and "rats" are similar (swapping at positions 0 and 2), and "rats" and "arts" are similar, but "star" is not similar to "tars", "rats", or "arts".
    Together, these form two connected groups by similarity: {"tars", "rats", "arts"} and {"star"}.  Notice that "tars" and "arts" are in the same group even though they are not similar.  Formally, each group is such that a word is in the group if and only if it is similar to at least one other word in the group.
    We are given a list strs of strings where every string in strs is an anagram of every other string in strs. How many groups are there?

    Example 1:

    >>> numSimilarGroups(strs = ["tars","rats","arts","star"])
    >>> 2

    Example 2:

    >>> numSimilarGroups(strs = ["omv","ovm"])
    >>> 1
    """


Prompt:
def numMagicSquaresInside(grid: List[List[int]]) -> int:
    """
    A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.
    Given a row x col grid of integers, how many 3 x 3 magic square subgrids are there?
    Note: while a magic square can only contain numbers from 1 to 9, grid may contain numbers up to 15.

    Example 1:

    >>> numMagicSquaresInside(grid = [[4,3,8,4],[9,5,1,9],[2,7,6,2]])
    >>> 1
    Explanation:
    The following subgrid is a 3 x 3 magic square:

    while this one is not:

    In total, there is only one magic square inside the given grid.

    Example 2:

    >>> numMagicSquaresInside(grid = [[8]])
    >>> 0
    """


Prompt:
def canVisitAllRooms(rooms: List[List[int]]) -> bool:
    """
    There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.
    When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, and you can take all of them with you to unlock the other rooms.
    Given an array rooms where rooms[i] is the set of keys that you can obtain if you visited room i, return true if you can visit all the rooms, or false otherwise.

    Example 1:

    >>> canVisitAllRooms(rooms = [[1],[2],[3],[]])
    >>> true
    Explanation:
    We visit room 0 and pick up key 1.
    We then visit room 1 and pick up key 2.
    We then visit room 2 and pick up key 3.
    We then visit room 3.
    Since we were able to visit every room, we return true.

    Example 2:

    >>> canVisitAllRooms(rooms = [[1,3],[3,0,1],[2],[0]])
    >>> false
    Explanation: We can not enter room number 2 since the only key that unlocks it is in that room.
    """


Prompt:
def splitIntoFibonacci(num: str) -> List[int]:
    """
    You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579].
    Formally, a Fibonacci-like sequence is a list f of non-negative integers such that:

    0 <= f[i] < 231, (that is, each integer fits in a 32-bit signed integer type),
    f.length >= 3, and
    f[i] + f[i + 1] == f[i + 2] for all 0 <= i < f.length - 2.

    Note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.
    Return any Fibonacci-like sequence split from num, or return [] if it cannot be done.

    Example 1:

    >>> splitIntoFibonacci(num = "1101111")
    >>> [11,0,11,11]
    Explanation: The output [110, 1, 111] would also be accepted.

    Example 2:

    >>> splitIntoFibonacci(num = "112358130")
    >>> []
    Explanation: The task is impossible.

    Example 3:

    >>> splitIntoFibonacci(num = "0123")
    >>> []
    Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.
    """


Prompt:
def backspaceCompare(s: str, t: str) -> bool:
    """
    Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.
    Note that after backspacing an empty text, the text will continue empty.

    Example 1:

    >>> backspaceCompare(s = "ab#c", t = "ad#c")
    >>> true
    Explanation: Both s and t become "ac".

    Example 2:

    >>> backspaceCompare(s = "ab##", t = "c#d#")
    >>> true
    Explanation: Both s and t become "".

    Example 3:

    >>> backspaceCompare(s = "a#c", t = "b")
    >>> false
    Explanation: s becomes "c" while t becomes "b".
    """


Prompt:
def longestMountain(arr: List[int]) -> int:
    """
    You may recall that an array arr is a mountain array if and only if:

    arr.length >= 3
    There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:

    arr[0] < arr[1] < ... < arr[i - 1] < arr[i]
    arr[i] > arr[i + 1] > ... > arr[arr.length - 1]

    Given an integer array arr, return the length of the longest subarray, which is a mountain. Return 0 if there is no mountain subarray.

    Example 1:

    >>> longestMountain(arr = [2,1,4,7,3,2,5])
    >>> 5
    Explanation: The largest mountain is [1,4,7,3,2] which has length 5.

    Example 2:

    >>> longestMountain(arr = [2,2,2])
    >>> 0
    Explanation: There is no mountain.
    """


Prompt:
def isNStraightHand(hand: List[int], groupSize: int) -> bool:
    """
    Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.
    Given an integer array hand where hand[i] is the value written on the ith card and an integer groupSize, return true if she can rearrange the cards, or false otherwise.

    Example 1:

    >>> isNStraightHand(hand = [1,2,3,6,2,3,4,7,8], groupSize = 3)
    >>> true
    Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8]

    Example 2:

    >>> isNStraightHand(hand = [1,2,3,4,5], groupSize = 4)
    >>> false
    Explanation: Alice's hand can not be rearranged into groups of 4.
    """


Prompt:
def shortestPathLength(graph: List[List[int]]) -> int:
    """
    You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge.
    Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges.

    Example 1:

    >>> shortestPathLength(graph = [[1,2,3],[0],[0],[0]])
    >>> 4
    Explanation: One possible path is [1,0,2,0,3]

    Example 2:

    >>> shortestPathLength(graph = [[1],[0,2,4],[1,3,4],[2],[1,2]])
    >>> 4
    Explanation: One possible path is [0,1,4,2,3]
    """


Prompt:
def shiftingLetters(s: str, shifts: List[int]) -> str:
    """
    You are given a string s of lowercase English letters and an integer array shifts of the same length.
    Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a').

    For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'.

    Now for each shifts[i] = x, we want to shift the first i + 1 letters of s, x times.
    Return the final string after all such shifts to s are applied.

    Example 1:

    >>> shiftingLetters(s = "abc", shifts = [3,5,9])
    >>> "rpl"
    Explanation: We start with "abc".
    After shifting the first 1 letters of s by 3, we have "dbc".
    After shifting the first 2 letters of s by 5, we have "igc".
    After shifting the first 3 letters of s by 9, we have "rpl", the answer.

    Example 2:

    >>> shiftingLetters(s = "aaa", shifts = [1,2,3])
    >>> "gfd"
    """


Prompt:
def maxDistToClosest(seats: List[int]) -> int:
    """
    You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
    There is at least one empty seat, and at least one person sitting.
    Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.
    Return that maximum distance to the closest person.

    Example 1:

    >>> maxDistToClosest(seats = [1,0,0,0,1,0,1])
    >>> 2
    Explanation:
    If Alex sits in the second open seat (i.e. seats[2]), then the closest person has distance 2.
    If Alex sits in any other open seat, the closest person has distance 1.
    Thus, the maximum distance to the closest person is 2.

    Example 2:

    >>> maxDistToClosest(seats = [1,0,0,0])
    >>> 3
    Explanation:
    If Alex sits in the last seat (i.e. seats[3]), the closest person is 3 seats away.
    This is the maximum distance possible, so the answer is 3.

    Example 3:

    >>> maxDistToClosest(seats = [0,1])
    >>> 1
    """


Prompt:
def rectangleArea(rectangles: List[List[int]]) -> int:
    """
    You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [xi1, yi1, xi2, yi2] denotes the ith rectangle where (xi1, yi1) are the coordinates of the bottom-left corner, and (xi2, yi2) are the coordinates of the top-right corner.
    Calculate the total area covered by all rectangles in the plane. Any area covered by two or more rectangles should only be counted once.
    Return the total area. Since the answer may be too large, return it modulo 109 + 7.

    Example 1:

    >>> rectangleArea(rectangles = [[0,0,2,2],[1,0,2,3],[1,0,3,1]])
    >>> 6
    Explanation: A total area of 6 is covered by all three rectangles, as illustrated in the picture.
    From (1,1) to (2,2), the green and red rectangles overlap.
    From (1,0) to (2,3), all three rectangles overlap.

    Example 2:

    >>> rectangleArea(rectangles = [[0,0,1000000000,1000000000]])
    >>> 49
    Explanation: The answer is 1018 modulo (109 + 7), which is 49.
    """


Prompt:
def loudAndRich(richer: List[List[int]], quiet: List[int]) -> List[int]:
    """
    There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness.
    You are given an array richer where richer[i] = [ai, bi] indicates that ai has more money than bi and an integer array quiet where quiet[i] is the quietness of the ith person. All the given data in richer are logically correct (i.e., the data will not lead you to a situation where x is richer than y and y is richer than x at the same time).
    Return an integer array answer where answer[x] = y if y is the least quiet person (that is, the person y with the smallest value of quiet[y]) among all people who definitely have equal to or more money than the person x.

    Example 1:

    >>> loudAndRich(richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0])
    >>> [5,5,2,5,4,5,6,7]
    Explanation:
    answer[0] = 5.
    Person 5 has more money than 3, which has more money than 1, which has more money than 0.
    The only person who is quieter (has lower quiet[x]) is person 7, but it is not clear if they have more money than person 0.
    answer[7] = 7.
    Among all people that definitely have equal to or more money than person 7 (which could be persons 3, 4, 5, 6, or 7), the person who is the quietest (has lower quiet[x]) is person 7.
    The other answers can be filled out with similar reasoning.

    Example 2:

    >>> loudAndRich(richer = [], quiet = [0])
    >>> [0]
    """


Prompt:
def peakIndexInMountainArray(arr: List[int]) -> int:
    """
    You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.
    Return the index of the peak element.
    Your task is to solve it in O(log(n)) time complexity.

    Example 1:

    >>> peakIndexInMountainArray(arr = [0,1,0])
    >>> 1

    Example 2:

    >>> peakIndexInMountainArray(arr = [0,2,1,0])
    >>> 1

    Example 3:

    >>> peakIndexInMountainArray(arr = [0,10,5,2])
    >>> 1
    """


Prompt:
def carFleet(target: int, position: List[int], speed: List[int]) -> int:
    """
    There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.
    You are given two integer array position and speed, both of length n, where position[i] is the starting mile of the ith car and speed[i] is the speed of the ith car in miles per hour.
    A car cannot pass another car, but it can catch up and then travel next to it at the speed of the slower car.
    A car fleet is a car or cars driving next to each other. The speed of the car fleet is the minimum speed of any car in the fleet.
    If a car catches up to a car fleet at the mile target, it will still be considered as part of the car fleet.
    Return the number of car fleets that will arrive at the destination.

    Example 1:

    >>> carFleet(target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3])
    >>> 3
    Explanation:

    The cars starting at 10 (speed 2) and 8 (speed 4) become a fleet, meeting each other at 12. The fleet forms at target.
    The car starting at 0 (speed 1) does not catch up to any other car, so it is a fleet by itself.
    The cars starting at 5 (speed 1) and 3 (speed 3) become a fleet, meeting each other at 6. The fleet moves at speed 1 until it reaches target.

    Example 2:

    >>> carFleet(target = 10, position = [3], speed = [3])
    >>> 1
    Explanation:
    There is only one car, hence there is only one fleet.
    Example 3:

    >>> carFleet(target = 100, position = [0,2,4], speed = [4,2,1])
    >>> 1
    Explanation:

    The cars starting at 0 (speed 4) and 2 (speed 2) become a fleet, meeting each other at 4. The car starting at 4 (speed 1) travels to 5.
    Then, the fleet at 4 (speed 2) and the car at position 5 (speed 1) become one fleet, meeting each other at 6. The fleet moves at speed 1 until it reaches target.
    """


Prompt:
def kSimilarity(s1: str, s2: str) -> int:
    """
    Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2.
    Given two anagrams s1 and s2, return the smallest k for which s1 and s2 are k-similar.

    Example 1:

    >>> kSimilarity(s1 = "ab", s2 = "ba")
    >>> 1
    Explanation: The two string are 1-similar because we can use one swap to change s1 to s2: "ab" --> "ba".

    Example 2:

    >>> kSimilarity(s1 = "abc", s2 = "bca")
    >>> 2
    Explanation: The two strings are 2-similar because we can use two swaps to change s1 to s2: "abc" --> "bac" --> "bca".
    """


Prompt:
def scoreOfParentheses(s: str) -> int:
    """
    Given a balanced parentheses string s, return the score of the string.
    The score of a balanced parentheses string is based on the following rule:

    "()" has score 1.
    AB has score A + B, where A and B are balanced parentheses strings.
    (A) has score 2 * A, where A is a balanced parentheses string.

    Example 1:

    >>> scoreOfParentheses(s = "()")
    >>> 1

    Example 2:

    >>> scoreOfParentheses(s = "(())")
    >>> 2

    Example 3:

    >>> scoreOfParentheses(s = "()()")
    >>> 2
    """


Prompt:
def mincostToHireWorkers(quality: List[int], wage: List[int], k: int) -> float:
    """
    There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the ith worker and wage[i] is the minimum wage expectation for the ith worker.
    We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following rules:

    Every worker in the paid group must be paid at least their minimum wage expectation.
    In the group, each worker's pay must be directly proportional to their quality. This means if a worker’s quality is double that of another worker in the group, then they must be paid twice as much as the other worker.

    Given the integer k, return the least amount of money needed to form a paid group satisfying the above conditions. Answers within 10-5 of the actual answer will be accepted.

    Example 1:

    >>> mincostToHireWorkers(quality = [10,20,5], wage = [70,50,30], k = 2)
    >>> 105.00000
    Explanation: We pay 70 to 0th worker and 35 to 2nd worker.

    Example 2:

    >>> mincostToHireWorkers(quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3)
    >>> 30.66667
    Explanation: We pay 4 to 0th worker, 13.33333 to 2nd and 3rd workers separately.
    """


Prompt:
def mirrorReflection(p: int, q: int) -> int:
    """
    There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2.
    The square room has walls of length p and a laser ray from the southwest corner first meets the east wall at a distance q from the 0th receptor.
    Given the two integers p and q, return the number of the receptor that the ray meets first.
    The test cases are guaranteed so that the ray will meet a receptor eventually.

    Example 1:

    >>> mirrorReflection(p = 2, q = 1)
    >>> 2
    Explanation: The ray meets receptor 2 the first time it gets reflected back to the left wall.

    Example 2:

    >>> mirrorReflection(p = 3, q = 1)
    >>> 1
    """


Prompt:
def buddyStrings(s: str, goal: str) -> bool:
    """
    Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.
    Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j].

    For example, swapping at indices 0 and 2 in "abcd" results in "cbad".

    Example 1:

    >>> buddyStrings(s = "ab", goal = "ba")
    >>> true
    Explanation: You can swap s[0] = 'a' and s[1] = 'b' to get "ba", which is equal to goal.

    Example 2:

    >>> buddyStrings(s = "ab", goal = "ab")
    >>> false
    Explanation: The only letters you can swap are s[0] = 'a' and s[1] = 'b', which results in "ba" != goal.

    Example 3:

    >>> buddyStrings(s = "aa", goal = "aa")
    >>> true
    Explanation: You can swap s[0] = 'a' and s[1] = 'a' to get "aa", which is equal to goal.
    """


Prompt:
def lemonadeChange(bills: List[int]) -> bool:
    """
    At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction is that the customer pays $5.
    Note that you do not have any change in hand at first.
    Given an integer array bills where bills[i] is the bill the ith customer pays, return true if you can provide every customer with the correct change, or false otherwise.

    Example 1:

    >>> lemonadeChange(bills = [5,5,5,10,20])
    >>> true
    Explanation:
    From the first 3 customers, we collect three $5 bills in order.
    From the fourth customer, we collect a $10 bill and give back a $5.
    From the fifth customer, we give a $10 bill and a $5 bill.
    Since all customers got correct change, we output true.

    Example 2:

    >>> lemonadeChange(bills = [5,5,10,10,20])
    >>> false
    Explanation:
    From the first two customers in order, we collect two $5 bills.
    For the next two customers in order, we collect a $10 bill and give back a $5 bill.
    For the last customer, we can not give the change of $15 back because we only have two $10 bills.
    Since not every customer received the correct change, the answer is false.
    """


Prompt:
def matrixScore(grid: List[List[int]]) -> int:
    """
    You are given an m x n binary matrix grid.
    A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).
    Every row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers.
    Return the highest possible score after making any number of moves (including zero moves).

    Example 1:

    >>> matrixScore(grid = [[0,0,1,1],[1,0,1,0],[1,1,0,0]])
    >>> 39
    Explanation: 0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39

    Example 2:

    >>> matrixScore(grid = [[0]])
    >>> 1
    """


Prompt:
def shortestSubarray(nums: List[int], k: int) -> int:
    """
    Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.
    A subarray is a contiguous part of an array.

    Example 1:
    >>> shortestSubarray(nums = [1], k = 1)
    >>> 1
    Example 2:
    >>> shortestSubarray(nums = [1,2], k = 4)
    >>> -1
    Example 3:
    >>> shortestSubarray(nums = [2,-1,2], k = 3)
    >>> 3
    """


Prompt:
def shortestPathAllKeys(grid: List[str]) -> int:
    """
    You are given an m x n grid grid where:

    '.' is an empty cell.
    '#' is a wall.
    '@' is the starting point.
    Lowercase letters represent keys.
    Uppercase letters represent locks.

    You start at the starting point and one move consists of walking one space in one of the four cardinal directions. You cannot walk outside the grid, or walk into a wall.
    If you walk over a key, you can pick it up and you cannot walk over a lock unless you have its corresponding key.
    For some 1 <= k <= 6, there is exactly one lowercase and one uppercase letter of the first k letters of the English alphabet in the grid. This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks were chosen in the same order as the English alphabet.
    Return the lowest number of moves to acquire all keys. If it is impossible, return -1.

    Example 1:

    >>> shortestPathAllKeys(grid = ["@.a..","###.#","b.A.B"])
    >>> 8
    Explanation: Note that the goal is to obtain all the keys not to open all the locks.

    Example 2:

    >>> shortestPathAllKeys(grid = ["@..aA","..B#.","....b"])
    >>> 6

    Example 3:

    >>> shortestPathAllKeys(grid = ["@Aa"])
    >>> -1
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def subtreeWithAllDeepest(root: Optional[TreeNode]) -> Optional[TreeNode]:
    """
    Given the root of a binary tree, the depth of each node is the shortest distance to the root.
    Return the smallest subtree such that it contains all the deepest nodes in the original tree.
    A node is called the deepest if it has the largest depth possible among any node in the entire tree.
    The subtree of a node is a tree consisting of that node, plus the set of all descendants of that node.

    Example 1:

    >>> __init__(root = [3,5,1,6,2,0,8,null,null,7,4])
    >>> [2,7,4]
    Explanation: We return the node with value 2, colored in yellow in the diagram.
    The nodes coloured in blue are the deepest nodes of the tree.
    Notice that nodes 5, 3 and 2 contain the deepest nodes in the tree but node 2 is the smallest subtree among them, so we return it.

    Example 2:

    >>> __init__(root = [1])
    >>> [1]
    Explanation: The root is the deepest node in the tree.

    Example 3:

    >>> __init__(root = [0,1,3,null,2])
    >>> [2]
    Explanation: The deepest node in the tree is 2, the valid subtrees are the subtrees of nodes 2, 1 and 0 but the subtree of node 2 is the smallest.
    """


Prompt:
def primePalindrome(n: int) -> int:
    """
    Given an integer n, return the smallest prime palindrome greater than or equal to n.
    An integer is prime if it has exactly two divisors: 1 and itself. Note that 1 is not a prime number.

    For example, 2, 3, 5, 7, 11, and 13 are all primes.

    An integer is a palindrome if it reads the same from left to right as it does from right to left.

    For example, 101 and 12321 are palindromes.

    The test cases are generated so that the answer always exists and is in the range [2, 2 * 108].

    Example 1:
    >>> primePalindrome(n = 6)
    >>> 7
    Example 2:
    >>> primePalindrome(n = 8)
    >>> 11
    Example 3:
    >>> primePalindrome(n = 13)
    >>> 101
    """


Prompt:
def transpose(matrix: List[List[int]]) -> List[List[int]]:
    """
    Given a 2D integer array matrix, return the transpose of matrix.
    The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.

    Example 1:

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

    Example 2:

    >>> transpose(matrix = [[1,2,3],[4,5,6]])
    >>> [[1,4],[2,5],[3,6]]
    """


Prompt:
def binaryGap(n: int) -> int:
    """
    Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0.
    Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between their bit positions. For example, the two 1's in "1001" have a distance of 3.

    Example 1:

    >>> binaryGap(n = 22)
    >>> 2
    Explanation: 22 in binary is "10110".
    The first adjacent pair of 1's is "10110" with a distance of 2.
    The second adjacent pair of 1's is "10110" with a distance of 1.
    The answer is the largest of these two distances, which is 2.
    Note that "10110" is not a valid pair since there is a 1 separating the two 1's underlined.

    Example 2:

    >>> binaryGap(n = 8)
    >>> 0
    Explanation: 8 in binary is "1000".
    There are not any adjacent pairs of 1's in the binary representation of 8, so we return 0.

    Example 3:

    >>> binaryGap(n = 5)
    >>> 2
    Explanation: 5 in binary is "101".
    """


Prompt:
def reorderedPowerOf2(n: int) -> bool:
    """
    You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero.
    Return true if and only if we can do this so that the resulting number is a power of two.

    Example 1:

    >>> reorderedPowerOf2(n = 1)
    >>> true

    Example 2:

    >>> reorderedPowerOf2(n = 10)
    >>> false
    """


Prompt:
def advantageCount(nums1: List[int], nums2: List[int]) -> List[int]:
    """
    You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i].
    Return any permutation of nums1 that maximizes its advantage with respect to nums2.

    Example 1:
    >>> advantageCount(nums1 = [2,7,11,15], nums2 = [1,10,4,11])
    >>> [2,11,7,15]
    Example 2:
    >>> advantageCount(nums1 = [12,24,8,32], nums2 = [13,25,32,11])
    >>> [24,32,8,12]
    """


Prompt:
def minRefuelStops(target: int, startFuel: int, stations: List[List[int]]) -> int:
    """
    A car travels from a starting position to a destination which is target miles east of the starting position.
    There are gas stations along the way. The gas stations are represented as an array stations where stations[i] = [positioni, fueli] indicates that the ith gas station is positioni miles east of the starting position and has fueli liters of gas.
    The car starts with an infinite tank of gas, which initially has startFuel liters of fuel in it. It uses one liter of gas per one mile that it drives. When the car reaches a gas station, it may stop and refuel, transferring all the gas from the station into the car.
    Return the minimum number of refueling stops the car must make in order to reach its destination. If it cannot reach the destination, return -1.
    Note that if the car reaches a gas station with 0 fuel left, the car can still refuel there. If the car reaches the destination with 0 fuel left, it is still considered to have arrived.

    Example 1:

    >>> minRefuelStops(target = 1, startFuel = 1, stations = [])
    >>> 0
    Explanation: We can reach the target without refueling.

    Example 2:

    >>> minRefuelStops(target = 100, startFuel = 1, stations = [[10,100]])
    >>> -1
    Explanation: We can not reach the target (or even the first gas station).

    Example 3:

    >>> minRefuelStops(target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]])
    >>> 2
    Explanation: We start with 10 liters of fuel.
    We drive to position 10, expending 10 liters of fuel.  We refuel from 0 liters to 60 liters of gas.
    Then, we drive from position 10 to position 60 (expending 50 liters of fuel),
    and refuel from 10 liters to 50 liters of gas.  We then drive to and reach the target.
    We made 2 refueling stops along the way, so we return 2.
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def leafSimilar(root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool:
    """
    Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence.

    For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8).
    Two binary trees are considered leaf-similar if their leaf value sequence is the same.
    Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar.

    Example 1:

    >>> __init__(root1 = [3,5,1,6,2,9,8,null,null,7,4], root2 = [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8])
    >>> true

    Example 2:

    >>> __init__(root1 = [1,2,3], root2 = [1,3,2])
    >>> false
    """


Prompt:
def lenLongestFibSubseq(arr: List[int]) -> int:
    """
    A sequence x1, x2, ..., xn is Fibonacci-like if:

    n >= 3
    xi + xi+1 == xi+2 for all i + 2 <= n

    Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like subsequence of arr. If one does not exist, return 0.
    A subsequence is derived from another sequence arr by deleting any number of elements (including none) from arr, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].

    Example 1:

    >>> lenLongestFibSubseq(arr = [1,2,3,4,5,6,7,8])
    >>> 5
    Explanation: The longest subsequence that is fibonacci-like: [1,2,3,5,8].
    Example 2:

    >>> lenLongestFibSubseq(arr = [1,3,7,11,12,14,18])
    >>> 3
    Explanation: The longest subsequence that is fibonacci-like: [1,11,12], [3,11,14] or [7,11,18].
    """


Prompt:
def robotSim(commands: List[int], obstacles: List[List[int]]) -> int:
    """
    A robot on an infinite XY-plane starts at point (0, 0) facing north. The robot receives an array of integers commands, which represents a sequence of moves that it needs to execute. There are only three possible types of instructions the robot can receive:

    -2: Turn left 90 degrees.
    -1: Turn right 90 degrees.
    1 <= k <= 9: Move forward k units, one unit at a time.

    Some of the grid squares are obstacles. The ith obstacle is at grid point obstacles[i] = (xi, yi). If the robot runs into an obstacle, it will stay in its current location (on the block adjacent to the obstacle) and move onto the next command.
    Return the maximum squared Euclidean distance that the robot reaches at any point in its path (i.e. if the distance is 5, return 25).
    Note:

    There can be an obstacle at (0, 0). If this happens, the robot will ignore the obstacle until it has moved off the origin. However, it will be unable to return to (0, 0) due to the obstacle.
    North means +Y direction.
    East means +X direction.
    South means -Y direction.
    West means -X direction.

    Example 1:

    >>> robotSim(commands = [4,-1,3], obstacles = [])
    >>> 25
    Explanation:
    The robot starts at (0, 0):

    Move north 4 units to (0, 4).
    Turn right.
    Move east 3 units to (3, 4).

    The furthest point the robot ever gets from the origin is (3, 4), which squared is 32 + 42 = 25 units away.

    Example 2:

    >>> robotSim(commands = [4,-1,4,-2,4], obstacles = [[2,4]])
    >>> 65
    Explanation:
    The robot starts at (0, 0):

    Move north 4 units to (0, 4).
    Turn right.
    Move east 1 unit and get blocked by the obstacle at (2, 4), robot is at (1, 4).
    Turn left.
    Move north 4 units to (1, 8).

    The furthest point the robot ever gets from the origin is (1, 8), which squared is 12 + 82 = 65 units away.

    Example 3:

    >>> robotSim(commands = [6,-1,-1,6], obstacles = [[0,0]])
    >>> 36
    Explanation:
    The robot starts at (0, 0):

    Move north 6 units to (0, 6).
    Turn right.
    Turn right.
    Move south 5 units and get blocked by the obstacle at (0,0), robot is at (0, 1).

    The furthest point the robot ever gets from the origin is (0, 6), which squared is 62 = 36 units away.
    """


Prompt:
def minEatingSpeed(piles: List[int], h: int) -> int:
    """
    Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.
    Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour.
    Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.
    Return the minimum integer k such that she can eat all the bananas within h hours.

    Example 1:

    >>> minEatingSpeed(piles = [3,6,7,11], h = 8)
    >>> 4

    Example 2:

    >>> minEatingSpeed(piles = [30,11,23,4,20], h = 5)
    >>> 30

    Example 3:

    >>> minEatingSpeed(piles = [30,11,23,4,20], h = 6)
    >>> 23
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def middleNode(head: Optional[ListNode]) -> Optional[ListNode]:
    """
    Given the head of a singly linked list, return the middle node of the linked list.
    If there are two middle nodes, return the second middle node.

    Example 1:

    >>> __init__(head = [1,2,3,4,5])
    >>> [3,4,5]
    Explanation: The middle node of the list is node 3.

    Example 2:

    >>> __init__(head = [1,2,3,4,5,6])
    >>> [4,5,6]
    Explanation: Since the list has two middle nodes with values 3 and 4, we return the second one.
    """


Prompt:
def stoneGame(piles: List[int]) -> bool:
    """
    Alice and Bob play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of stones piles[i].
    The objective of the game is to end with the most stones. The total number of stones across all the piles is odd, so there are no ties.
    Alice and Bob take turns, with Alice starting first. Each turn, a player takes the entire pile of stones either from the beginning or from the end of the row. This continues until there are no more piles left, at which point the person with the most stones wins.
    Assuming Alice and Bob play optimally, return true if Alice wins the game, or false if Bob wins.

    Example 1:

    >>> stoneGame(piles = [5,3,4,5])
    >>> true
    Explanation:
    Alice starts first, and can only take the first 5 or the last 5.
    Say she takes the first 5, so that the row becomes [3, 4, 5].
    If Bob takes 3, then the board is [4, 5], and Alice takes 5 to win with 10 points.
    If Bob takes the last 5, then the board is [3, 4], and Alice takes 4 to win with 9 points.
    This demonstrated that taking the first 5 was a winning move for Alice, so we return true.

    Example 2:

    >>> stoneGame(piles = [3,7,2,3])
    >>> true
    """


Prompt:
def nthMagicalNumber(n: int, a: int, b: int) -> int:
    """
    A positive integer is magical if it is divisible by either a or b.
    Given the three integers n, a, and b, return the nth magical number. Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> nthMagicalNumber(n = 1, a = 2, b = 3)
    >>> 2

    Example 2:

    >>> nthMagicalNumber(n = 4, a = 2, b = 3)
    >>> 6
    """


Prompt:
def profitableSchemes(n: int, minProfit: int, group: List[int], profit: List[int]) -> int:
    """
    There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can't participate in another crime.
    Let's call a profitable scheme any subset of these crimes that generates at least minProfit profit, and the total number of members participating in that subset of crimes is at most n.
    Return the number of schemes that can be chosen. Since the answer may be very large, return it modulo 109 + 7.

    Example 1:

    >>> profitableSchemes(n = 5, minProfit = 3, group = [2,2], profit = [2,3])
    >>> 2
    Explanation: To make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1.
    In total, there are 2 schemes.
    Example 2:

    >>> profitableSchemes(n = 10, minProfit = 5, group = [2,3,5], profit = [6,7,8])
    >>> 7
    Explanation: To make a profit of at least 5, the group could commit any crimes, as long as they commit one.
    There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).
    """


Prompt:
def decodeAtIndex(s: str, k: int) -> str:
    """
    You are given an encoded string s. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:

    If the character read is a letter, that letter is written onto the tape.
    If the character read is a digit d, the entire current tape is repeatedly written d - 1 more times in total.

    Given an integer k, return the kth letter (1-indexed) in the decoded string.

    Example 1:

    >>> decodeAtIndex(s = "leet2code3", k = 10)
    >>> "o"
    Explanation: The decoded string is "leetleetcodeleetleetcodeleetleetcode".
    The 10th letter in the string is "o".

    Example 2:

    >>> decodeAtIndex(s = "ha22", k = 5)
    >>> "h"
    Explanation: The decoded string is "hahahaha".
    The 5th letter is "h".

    Example 3:

    >>> decodeAtIndex(s = "a2345678999999999999999", k = 1)
    >>> "a"
    Explanation: The decoded string is "a" repeated 8301530446056247680 times.
    The 1st letter is "a".
    """


Prompt:
def numRescueBoats(people: List[int], limit: int) -> int:
    """
    You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit. Each boat carries at most two people at the same time, provided the sum of the weight of those people is at most limit.
    Return the minimum number of boats to carry every given person.

    Example 1:

    >>> numRescueBoats(people = [1,2], limit = 3)
    >>> 1
    Explanation: 1 boat (1, 2)

    Example 2:

    >>> numRescueBoats(people = [3,2,2,1], limit = 3)
    >>> 3
    Explanation: 3 boats (1, 2), (2) and (3)

    Example 3:

    >>> numRescueBoats(people = [3,5,3,4], limit = 5)
    >>> 4
    Explanation: 4 boats (3), (3), (4), (5)
    """


Prompt:
def reachableNodes(edges: List[List[int]], maxMoves: int, n: int) -> int:
    """
    You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.
    The graph is given as a 2D array of edges where edges[i] = [ui, vi, cnti] indicates that there is an edge between nodes ui and vi in the original graph, and cnti is the total number of new nodes that you will subdivide the edge into. Note that cnti == 0 means you will not subdivide the edge.
    To subdivide the edge [ui, vi], replace it with (cnti + 1) new edges and cnti new nodes. The new nodes are x1, x2, ..., xcnti, and the new edges are [ui, x1], [x1, x2], [x2, x3], ..., [xcnti-1, xcnti], [xcnti, vi].
    In this new graph, you want to know how many nodes are reachable from the node 0, where a node is reachable if the distance is maxMoves or less.
    Given the original graph and maxMoves, return the number of nodes that are reachable from node 0 in the new graph.

    Example 1:

    >>> reachableNodes(edges = [[0,1,10],[0,2,1],[1,2,2]], maxMoves = 6, n = 3)
    >>> 13
    Explanation: The edge subdivisions are shown in the image above.
    The nodes that are reachable are highlighted in yellow.

    Example 2:

    >>> reachableNodes(edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], maxMoves = 10, n = 4)
    >>> 23

    Example 3:

    >>> reachableNodes(edges = [[1,2,4],[1,4,5],[1,3,1],[2,3,4],[3,4,5]], maxMoves = 17, n = 5)
    >>> 1
    Explanation: Node 0 is disconnected from the rest of the graph, so only node 0 is reachable.
    """


Prompt:
def projectionArea(grid: List[List[int]]) -> int:
    """
    You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes.
    Each value v = grid[i][j] represents a tower of v cubes placed on top of the cell (i, j).
    We view the projection of these cubes onto the xy, yz, and zx planes.
    A projection is like a shadow, that maps our 3-dimensional figure to a 2-dimensional plane. We are viewing the "shadow" when looking at the cubes from the top, the front, and the side.
    Return the total area of all three projections.

    Example 1:

    >>> projectionArea(grid = [[1,2],[3,4]])
    >>> 17
    Explanation: Here are the three projections ("shadows") of the shape made with each axis-aligned plane.

    Example 2:

    >>> projectionArea(grid = [[2]])
    >>> 5

    Example 3:

    >>> projectionArea(grid = [[1,0],[0,2]])
    >>> 8
    """


Prompt:
def uncommonFromSentences(s1: str, s2: str) -> List[str]:
    """
    A sentence is a string of single-space separated words where each word consists only of lowercase letters.
    A word is uncommon if it appears exactly once in one of the sentences, and does not appear in the other sentence.
    Given two sentences s1 and s2, return a list of all the uncommon words. You may return the answer in any order.

    Example 1:

    >>> uncommonFromSentences(s1 = "this apple is sweet", s2 = "this apple is sour")
    >>> ["sweet","sour"]
    Explanation:
    The word "sweet" appears only in s1, while the word "sour" appears only in s2.

    Example 2:

    >>> uncommonFromSentences(s1 = "apple apple", s2 = "banana")
    >>> ["banana"]
    """


Prompt:
def spiralMatrixIII(rows: int, cols: int, rStart: int, cStart: int) -> List[List[int]]:
    """
    You start at the cell (rStart, cStart) of an rows x cols grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.
    You will walk in a clockwise spiral shape to visit every position in this grid. Whenever you move outside the grid's boundary, we continue our walk outside the grid (but may return to the grid boundary later.). Eventually, we reach all rows * cols spaces of the grid.
    Return an array of coordinates representing the positions of the grid in the order you visited them.

    Example 1:

    >>> spiralMatrixIII(rows = 1, cols = 4, rStart = 0, cStart = 0)
    >>> [[0,0],[0,1],[0,2],[0,3]]

    Example 2:

    >>> spiralMatrixIII(rows = 5, cols = 6, rStart = 1, cStart = 4)
    >>> [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]
    """


Prompt:
def possibleBipartition(n: int, dislikes: List[List[int]]) -> bool:
    """
    We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group.
    Given the integer n and the array dislikes where dislikes[i] = [ai, bi] indicates that the person labeled ai does not like the person labeled bi, return true if it is possible to split everyone into two groups in this way.

    Example 1:

    >>> possibleBipartition(n = 4, dislikes = [[1,2],[1,3],[2,4]])
    >>> true
    Explanation: The first group has [1,4], and the second group has [2,3].

    Example 2:

    >>> possibleBipartition(n = 3, dislikes = [[1,2],[1,3],[2,3]])
    >>> false
    Explanation: We need at least 3 groups to divide them. We cannot put them in two groups.
    """


Prompt:
def superEggDrop(k: int, n: int) -> int:
    """
    You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.
    You know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.
    Each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.
    Return the minimum number of moves that you need to determine with certainty what the value of f is.

    Example 1:

    >>> superEggDrop(k = 1, n = 2)
    >>> 2
    Explanation:
    Drop the egg from floor 1. If it breaks, we know that f = 0.
    Otherwise, drop the egg from floor 2. If it breaks, we know that f = 1.
    If it does not break, then we know f = 2.
    Hence, we need at minimum 2 moves to determine with certainty what the value of f is.

    Example 2:

    >>> superEggDrop(k = 2, n = 6)
    >>> 3

    Example 3:

    >>> superEggDrop(k = 3, n = 14)
    >>> 4
    """


Prompt:
def fairCandySwap(aliceSizes: List[int], bobSizes: List[int]) -> List[int]:
    """
    Alice and Bob have a different total number of candies. You are given two integer arrays aliceSizes and bobSizes where aliceSizes[i] is the number of candies of the ith box of candy that Alice has and bobSizes[j] is the number of candies of the jth box of candy that Bob has.
    Since they are friends, they would like to exchange one candy box each so that after the exchange, they both have the same total amount of candy. The total amount of candy a person has is the sum of the number of candies in each box they have.
    Return an integer array answer where answer[0] is the number of candies in the box that Alice must exchange, and answer[1] is the number of candies in the box that Bob must exchange. If there are multiple answers, you may return any one of them. It is guaranteed that at least one answer exists.

    Example 1:

    >>> fairCandySwap(aliceSizes = [1,1], bobSizes = [2,2])
    >>> [1,2]

    Example 2:

    >>> fairCandySwap(aliceSizes = [1,2], bobSizes = [2,3])
    >>> [1,2]

    Example 3:

    >>> fairCandySwap(aliceSizes = [2], bobSizes = [1,3])
    >>> [2,3]
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def constructFromPrePost(preorder: List[int], postorder: List[int]) -> Optional[TreeNode]:
    """
    Given two integer arrays, preorder and postorder where preorder is the preorder traversal of a binary tree of distinct values and postorder is the postorder traversal of the same tree, reconstruct and return the binary tree.
    If there exist multiple answers, you can return any of them.

    Example 1:

    >>> __init__(preorder = [1,2,4,5,3,6,7], postorder = [4,5,2,6,7,3,1])
    >>> [1,2,3,4,5,6,7]

    Example 2:

    >>> __init__(preorder = [1], postorder = [1])
    >>> [1]
    """


Prompt:
def findAndReplacePattern(words: List[str], pattern: str) -> List[str]:
    """
    Given a list of strings words and a string pattern, return a list of words[i] that match pattern. You may return the answer in any order.
    A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.
    Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.

    Example 1:

    >>> findAndReplacePattern(words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb")
    >>> ["mee","aqq"]
    Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}.
    "ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, since a and b map to the same letter.

    Example 2:

    >>> findAndReplacePattern(words = ["a","b","c"], pattern = "a")
    >>> ["a","b","c"]
    """


Prompt:
def sumSubseqWidths(nums: List[int]) -> int:
    """
    The width of a sequence is the difference between the maximum and minimum elements in the sequence.
    Given an array of integers nums, return the sum of the widths of all the non-empty subsequences of nums. Since the answer may be very large, return it modulo 109 + 7.
    A subsequence is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7].

    Example 1:

    >>> sumSubseqWidths(nums = [2,1,3])
    >>> 6
    Explanation: The subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3].
    The corresponding widths are 0, 0, 0, 1, 1, 2, 2.
    The sum of these widths is 6.

    Example 2:

    >>> sumSubseqWidths(nums = [2])
    >>> 0
    """


Prompt:
def surfaceArea(grid: List[List[int]]) -> int:
    """
    You are given an n x n grid where you have placed some 1 x 1 x 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of cell (i, j).
    After placing these cubes, you have decided to glue any directly adjacent cubes to each other, forming several irregular 3D shapes.
    Return the total surface area of the resulting shapes.
    Note: The bottom face of each shape counts toward its surface area.

    Example 1:

    >>> surfaceArea(grid = [[1,2],[3,4]])
    >>> 34

    Example 2:

    >>> surfaceArea(grid = [[1,1,1],[1,0,1],[1,1,1]])
    >>> 32

    Example 3:

    >>> surfaceArea(grid = [[2,2,2],[2,1,2],[2,2,2]])
    >>> 46
    """


Prompt:
def numSpecialEquivGroups(words: List[str]) -> int:
    """
    You are given an array of strings of the same length words.
    In one move, you can swap any two even indexed characters or any two odd indexed characters of a string words[i].
    Two strings words[i] and words[j] are special-equivalent if after any number of moves, words[i] == words[j].

    For example, words[i] = "zzxy" and words[j] = "xyzz" are special-equivalent because we may make the moves "zzxy" -> "xzzy" -> "xyzz".

    A group of special-equivalent strings from words is a non-empty subset of words such that:

    Every pair of strings in the group are special equivalent, and
    The group is the largest size possible (i.e., there is not a string words[i] not in the group such that words[i] is special-equivalent to every string in the group).

    Return the number of groups of special-equivalent strings from words.

    Example 1:

    >>> numSpecialEquivGroups(words = ["abcd","cdab","cbad","xyzz","zzxy","zzyx"])
    >>> 3
    Explanation:
    One group is ["abcd", "cdab", "cbad"], since they are all pairwise special equivalent, and none of the other strings is all pairwise special equivalent to these.
    The other two groups are ["xyzz", "zzxy"] and ["zzyx"].
    Note that in particular, "zzxy" is not special equivalent to "zzyx".

    Example 2:

    >>> numSpecialEquivGroups(words = ["abc","acb","bac","bca","cab","cba"])
    >>> 3
    """


Prompt:
def isMonotonic(nums: List[int]) -> bool:
    """
    An array is monotonic if it is either monotone increasing or monotone decreasing.
    An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j].
    Given an integer array nums, return true if the given array is monotonic, or false otherwise.

    Example 1:

    >>> isMonotonic(nums = [1,2,2,3])
    >>> true

    Example 2:

    >>> isMonotonic(nums = [6,5,4,4])
    >>> true

    Example 3:

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


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def increasingBST(root: Optional[TreeNode]) -> Optional[TreeNode]:
    """
    Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.

    Example 1:

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

    Example 2:

    >>> __init__(root = [5,1,7])
    >>> [1,null,5,null,7]
    """


Prompt:
def subarrayBitwiseORs(arr: List[int]) -> int:
    """
    Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.
    The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray of one integer is that integer.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> subarrayBitwiseORs(arr = [0])
    >>> 1
    Explanation: There is only one possible result: 0.

    Example 2:

    >>> subarrayBitwiseORs(arr = [1,1,2])
    >>> 3
    Explanation: The possible subarrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2].
    These yield the results 1, 1, 2, 1, 3, 3.
    There are 3 unique values, so the answer is 3.

    Example 3:

    >>> subarrayBitwiseORs(arr = [1,2,4])
    >>> 6
    Explanation: The possible results are 1, 2, 3, 4, 6, and 7.
    """


Prompt:
def orderlyQueue(s: str, k: int) -> str:
    """
    You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.
    Return the lexicographically smallest string you could have after applying the mentioned step any number of moves.

    Example 1:

    >>> orderlyQueue(s = "cba", k = 1)
    >>> "acb"
    Explanation:
    In the first move, we move the 1st character 'c' to the end, obtaining the string "bac".
    In the second move, we move the 1st character 'b' to the end, obtaining the final result "acb".

    Example 2:

    >>> orderlyQueue(s = "baaca", k = 3)
    >>> "aaabc"
    Explanation:
    In the first move, we move the 1st character 'b' to the end, obtaining the string "aacab".
    In the second move, we move the 3rd character 'c' to the end, obtaining the final result "aaabc".
    """


Prompt:
def atMostNGivenDigitSet(digits: List[str], n: int) -> int:
    """
    Given an array of digits which is sorted in non-decreasing order. You can write numbers using each digits[i] as many times as we want. For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.
    Return the number of positive integers that can be generated that are less than or equal to a given integer n.

    Example 1:

    >>> atMostNGivenDigitSet(digits = ["1","3","5","7"], n = 100)
    >>> 20
    Explanation:
    The 20 numbers that can be written are:
    1, 3, 5, 7, 11, 13, 15, 17, 31, 33, 35, 37, 51, 53, 55, 57, 71, 73, 75, 77.

    Example 2:

    >>> atMostNGivenDigitSet(digits = ["1","4","9"], n = 1000000000)
    >>> 29523
    Explanation:
    We can write 3 one digit numbers, 9 two digit numbers, 27 three digit numbers,
    81 four digit numbers, 243 five digit numbers, 729 six digit numbers,
    2187 seven digit numbers, 6561 eight digit numbers, and 19683 nine digit numbers.
    In total, this is 29523 integers that can be written using the digits array.

    Example 3:

    >>> atMostNGivenDigitSet(digits = ["7"], n = 8)
    >>> 1
    """


Prompt:
def numPermsDISequence(s: str) -> int:
    """
    You are given a string s of length n where s[i] is either:

    'D' means decreasing, or
    'I' means increasing.

    A permutation perm of n + 1 integers of all the integers in the range [0, n] is called a valid permutation if for all valid i:

    If s[i] == 'D', then perm[i] > perm[i + 1], and
    If s[i] == 'I', then perm[i] < perm[i + 1].

    Return the number of valid permutations perm. Since the answer may be large, return it modulo 109 + 7.

    Example 1:

    >>> numPermsDISequence(s = "DID")
    >>> 5
    Explanation: The 5 valid permutations of (0, 1, 2, 3) are:
    (1, 0, 3, 2)
    (2, 0, 3, 1)
    (2, 1, 3, 0)
    (3, 0, 2, 1)
    (3, 1, 2, 0)

    Example 2:

    >>> numPermsDISequence(s = "D")
    >>> 1
    """


Prompt:
def totalFruit(fruits: List[int]) -> int:
    """
    You are visiting a farm that has a single row of fruit trees arranged from left to right. The trees are represented by an integer array fruits where fruits[i] is the type of fruit the ith tree produces.
    You want to collect as much fruit as possible. However, the owner has some strict rules that you must follow:

    You only have two baskets, and each basket can only hold a single type of fruit. There is no limit on the amount of fruit each basket can hold.
    Starting from any tree of your choice, you must pick exactly one fruit from every tree (including the start tree) while moving to the right. The picked fruits must fit in one of your baskets.
    Once you reach a tree with fruit that cannot fit in your baskets, you must stop.

    Given the integer array fruits, return the maximum number of fruits you can pick.

    Example 1:

    >>> totalFruit(fruits = [1,2,1])
    >>> 3
    Explanation: We can pick from all 3 trees.

    Example 2:

    >>> totalFruit(fruits = [0,1,2,2])
    >>> 3
    Explanation: We can pick from trees [1,2,2].
    If we had started at the first tree, we would only pick from trees [0,1].

    Example 3:

    >>> totalFruit(fruits = [1,2,3,2,2])
    >>> 4
    Explanation: We can pick from trees [2,3,2,2].
    If we had started at the first tree, we would only pick from trees [1,2].
    """


Prompt:
def sortArrayByParity(nums: List[int]) -> List[int]:
    """
    Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers.
    Return any array that satisfies this condition.

    Example 1:

    >>> sortArrayByParity(nums = [3,1,2,4])
    >>> [2,4,3,1]
    Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted.

    Example 2:

    >>> sortArrayByParity(nums = [0])
    >>> [0]
    """


Prompt:
def superpalindromesInRange(left: str, right: str) -> int:
    """
    Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.
    Given two positive integers left and right represented as strings, return the number of super-palindromes integers in the inclusive range [left, right].

    Example 1:

    >>> superpalindromesInRange(left = "4", right = "1000")
    >>> 4
    Explanation: 4, 9, 121, and 484 are superpalindromes.
    Note that 676 is not a superpalindrome: 26 * 26 = 676, but 26 is not a palindrome.

    Example 2:

    >>> superpalindromesInRange(left = "1", right = "2")
    >>> 1
    """


Prompt:
def sumSubarrayMins(arr: List[int]) -> int:
    """
    Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7.

    Example 1:

    >>> sumSubarrayMins(arr = [3,1,2,4])
    >>> 17
    Explanation:
    Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4].
    Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1.
    Sum is 17.

    Example 2:

    >>> sumSubarrayMins(arr = [11,81,94,43,3])
    >>> 444
    """


Prompt:
def smallestRangeI(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and an integer k.
    In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from the range [-k, k]. You can apply this operation at most once for each index i.
    The score of nums is the difference between the maximum and minimum elements in nums.
    Return the minimum score of nums after applying the mentioned operation at most once for each index in it.

    Example 1:

    >>> smallestRangeI(nums = [1], k = 0)
    >>> 0
    Explanation: The score is max(nums) - min(nums) = 1 - 1 = 0.

    Example 2:

    >>> smallestRangeI(nums = [0,10], k = 2)
    >>> 6
    Explanation: Change nums to be [2, 8]. The score is max(nums) - min(nums) = 8 - 2 = 6.

    Example 3:

    >>> smallestRangeI(nums = [1,3,6], k = 3)
    >>> 0
    Explanation: Change nums to be [4, 4, 4]. The score is max(nums) - min(nums) = 4 - 4 = 0.
    """