Prompt:
from typing import List
def sequenceReconstruction(nums: List[int], sequences: List[List[int]]) -> bool:
    """
    You are given an integer array nums of length n where nums is a permutation of the integers in the range [1, n]. You are also given a 2D integer array sequences where sequences[i] is a subsequence of nums.
    Check if nums is the shortest possible and the only supersequence. The shortest supersequence is a sequence with the shortest length and has all sequences[i] as subsequences. There could be multiple valid supersequences for the given array sequences.

    For example, for sequences = [[1,2],[1,3]], there are two shortest supersequences, [1,2,3] and [1,3,2].
    While for sequences = [[1,2],[1,3],[1,2,3]], the only shortest supersequence possible is [1,2,3]. [1,2,3,4] is a possible supersequence but not the shortest.

    Return true if nums is the only shortest supersequence for sequences, or false otherwise.
    A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> sequenceReconstruction(nums = [1,2,3], sequences = [[1,2],[1,3]])
    >>> false
    Explanation: There are two possible supersequences: [1,2,3] and [1,3,2].
    The sequence [1,2] is a subsequence of both: [1,2,3] and [1,3,2].
    The sequence [1,3] is a subsequence of both: [1,2,3] and [1,3,2].
    Since nums is not the only shortest supersequence, we return false.

    Example 2:

    >>> sequenceReconstruction(nums = [1,2,3], sequences = [[1,2]])
    >>> false
    Explanation: The shortest possible supersequence is [1,2].
    The sequence [1,2] is a subsequence of it: [1,2].
    Since nums is not the shortest supersequence, we return false.

    Example 3:

    >>> sequenceReconstruction(nums = [1,2,3], sequences = [[1,2],[1,3],[2,3]])
    >>> true
    Explanation: The shortest possible supersequence is [1,2,3].
    The sequence [1,2] is a subsequence of it: [1,2,3].
    The sequence [1,3] is a subsequence of it: [1,2,3].
    The sequence [2,3] is a subsequence of it: [1,2,3].
    Since nums is the only shortest supersequence, we return true.
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def addTwoNumbers(l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
"""
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example 1:

>>> addTwoNumbers(l1 = [7,2,4,3], l2 = [5,6,4])
>>> [7,8,0,7]

Example 2:

>>> addTwoNumbers(l1 = [2,4,3], l2 = [5,6,4])
>>> [8,0,7]

Example 3:

>>> addTwoNumbers(l1 = [0], l2 = [0])
>>> [0]
"""


Prompt:
from typing import Any, List
def numberOfArithmeticSlices(nums: List[int]) -> int:
    """
    Given an integer array nums, return the number of all the arithmetic subsequences of nums.
    A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.

    For example, [1, 3, 5, 7, 9], [7, 7, 7, 7], and [3, -1, -5, -9] are arithmetic sequences.
    For example, [1, 1, 2, 5, 7] is not an arithmetic sequence.

    A subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.

    For example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].

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

    Example 1:

    >>> numberOfArithmeticSlices(nums = [2,4,6,8,10])
    >>> 7
    Explanation: All arithmetic subsequence slices are:
    [2,4,6]
    [4,6,8]
    [6,8,10]
    [2,4,6,8]
    [4,6,8,10]
    [2,4,6,8,10]
    [2,6,10]

    Example 2:

    >>> numberOfArithmeticSlices(nums = [7,7,7,7,7])
    >>> 16
    Explanation: Any subsequence of this array is arithmetic.
    """


Prompt:
from typing import List
def numberOfBoomerangs(points: List[List[int]]) -> int:
    """
    You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters).
    Return the number of boomerangs.

    Example 1:

    >>> numberOfBoomerangs(points = [[0,0],[1,0],[2,0]])
    >>> 2
    Explanation: The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]].

    Example 2:

    >>> numberOfBoomerangs(points = [[1,1],[2,2],[3,3]])
    >>> 2

    Example 3:

    >>> numberOfBoomerangs(points = [[1,1]])
    >>> 0
    """


Prompt:
from typing import List
def findDisappearedNumbers(nums: List[int]) -> List[int]:
    """
    Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.

    Example 1:
    >>> findDisappearedNumbers(nums = [4,3,2,7,8,2,3,1])
    >>> [5,6]
    Example 2:
    >>> findDisappearedNumbers(nums = [1,1])
    >>> [2]
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def deleteNode(root: Optional[TreeNode], key: int) -> Optional[TreeNode]:
"""
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Basically, the deletion can be divided into two stages:

Search for a node to remove.
If the node is found, delete the node.

Example 1:

>>> deleteNode(root = [5,3,6,2,4,null,7], key = 3)
>>> [5,4,6,2,null,null,7]
Explanation: Given key to delete is 3. So we find the node with value 3 and delete it.
One valid answer is [5,4,6,2,null,null,7], shown in the above BST.
Please notice that another valid answer is [5,2,6,null,4,null,7] and it's also accepted.

Example 2:

>>> deleteNode(root = [5,3,6,2,4,null,7], key = 0)
>>> [5,3,6,2,4,null,7]
Explanation: The tree does not contain a node with value = 0.

Example 3:

>>> deleteNode(root = [], key = 0)
>>> []
"""


Prompt:
def frequencySort(s: str) -> str:
    """
    Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string.
    Return the sorted string. If there are multiple answers, return any of them.

    Example 1:

    >>> frequencySort(s = "tree")
    >>> "eert"
    Explanation: 'e' appears twice while 'r' and 't' both appear once.
    So 'e' must appear before both 'r' and 't'. Therefore "eetr" is also a valid answer.

    Example 2:

    >>> frequencySort(s = "cccaaa")
    >>> "aaaccc"
    Explanation: Both 'c' and 'a' appear three times, so both "cccaaa" and "aaaccc" are valid answers.
    Note that "cacaca" is incorrect, as the same characters must be together.

    Example 3:

    >>> frequencySort(s = "Aabb")
    >>> "bbAa"
    Explanation: "bbaA" is also a valid answer, but "Aabb" is incorrect.
    Note that 'A' and 'a' are treated as two different characters.
    """


Prompt:
from typing import List
def findMinArrowShots(points: List[List[int]]) -> int:
    """
    There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [xstart, xend] denotes a balloon whose horizontal diameter stretches between xstart and xend. You do not know the exact y-coordinates of the balloons.
    Arrows can be shot up directly vertically (in the positive y-direction) from different points along the x-axis. A balloon with xstart and xend is burst by an arrow shot at x if xstart <= x <= xend. There is no limit to the number of arrows that can be shot. A shot arrow keeps traveling up infinitely, bursting any balloons in its path.
    Given the array points, return the minimum number of arrows that must be shot to burst all balloons.

    Example 1:

    >>> findMinArrowShots(points = [[10,16],[2,8],[1,6],[7,12]])
    >>> 2
    Explanation: The balloons can be burst by 2 arrows:
    - Shoot an arrow at x = 6, bursting the balloons [2,8] and [1,6].
    - Shoot an arrow at x = 11, bursting the balloons [10,16] and [7,12].

    Example 2:

    >>> findMinArrowShots(points = [[1,2],[3,4],[5,6],[7,8]])
    >>> 4
    Explanation: One arrow needs to be shot for each balloon for a total of 4 arrows.

    Example 3:

    >>> findMinArrowShots(points = [[1,2],[2,3],[3,4],[4,5]])
    >>> 2
    Explanation: The balloons can be burst by 2 arrows:
    - Shoot an arrow at x = 2, bursting the balloons [1,2] and [2,3].
    - Shoot an arrow at x = 4, bursting the balloons [3,4] and [4,5].
    """


Prompt:
from typing import List
def minMoves(nums: List[int]) -> int:
    """
    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.
    In one move, you can increment n - 1 elements of the array by 1.

    Example 1:

    >>> minMoves(nums = [1,2,3])
    >>> 3
    Explanation: Only three moves are needed (remember each move increments two elements):
    [1,2,3]  =>  [2,3,3]  =>  [3,4,3]  =>  [4,4,4]

    Example 2:

    >>> minMoves(nums = [1,1,1])
    >>> 0
    """


Prompt:
from typing import List
def fourSumCount(nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int:
    """
    Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:

    0 <= i, j, k, l < n
    nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0

    Example 1:

    >>> fourSumCount(nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2])
    >>> 2
    Explanation:
    The two tuples are:
    1. (0, 0, 0, 1) -> nums1[0] + nums2[0] + nums3[0] + nums4[1] = 1 + (-2) + (-1) + 2 = 0
    2. (1, 1, 0, 0) -> nums1[1] + nums2[1] + nums3[0] + nums4[0] = 2 + (-1) + (-1) + 0 = 0

    Example 2:

    >>> fourSumCount(nums1 = [0], nums2 = [0], nums3 = [0], nums4 = [0])
    >>> 1
    """


Prompt:
from typing import List
def findContentChildren(g: List[int], s: List[int]) -> int:
    """
    Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.
    Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number.

    Example 1:

    >>> findContentChildren(g = [1,2,3], s = [1,1])
    >>> 1
    Explanation: You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3.
    And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content.
    You need to output 1.

    Example 2:

    >>> findContentChildren(g = [1,2], s = [1,2,3])
    >>> 2
    Explanation: You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2.
    You have 3 cookies and their sizes are big enough to gratify all of the children,
    You need to output 2.
    """


Prompt:
from typing import List
def find132pattern(nums: List[int]) -> bool:
    """
    Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].
    Return true if there is a 132 pattern in nums, otherwise, return false.

    Example 1:

    >>> find132pattern(nums = [1,2,3,4])
    >>> false
    Explanation: There is no 132 pattern in the sequence.

    Example 2:

    >>> find132pattern(nums = [3,1,4,2])
    >>> true
    Explanation: There is a 132 pattern in the sequence: [1, 4, 2].

    Example 3:

    >>> find132pattern(nums = [-1,3,2,0])
    >>> true
    Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0].
    """


Prompt:
from typing import List
def circularArrayLoop(nums: List[int]) -> bool:
    """
    You are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move if you are located at index i:

    If nums[i] is positive, move nums[i] steps forward, and
    If nums[i] is negative, move nums[i] steps backward.

    Since the array is circular, you may assume that moving forward from the last element puts you on the first element, and moving backwards from the first element puts you on the last element.
    A cycle in the array consists of a sequence of indices seq of length k where:

    Following the movement rules above results in the repeating index sequence seq[0] -> seq[1] -> ... -> seq[k - 1] -> seq[0] -> ...
    Every nums[seq[j]] is either all positive or all negative.
    k > 1

    Return true if there is a cycle in nums, or false otherwise.

    Example 1:

    >>> circularArrayLoop(nums = [2,-1,1,2,2])
    >>> true
    Explanation: The graph shows how the indices are connected. White nodes are jumping forward, while red is jumping backward.
    We can see the cycle 0 --> 2 --> 3 --> 0 --> ..., and all of its nodes are white (jumping in the same direction).

    Example 2:

    >>> circularArrayLoop(nums = [-1,-2,-3,-4,-5,6])
    >>> false
    Explanation: The graph shows how the indices are connected. White nodes are jumping forward, while red is jumping backward.
    The only cycle is of size 1, so we return false.

    Example 3:

    >>> circularArrayLoop(nums = [1,-1,5,1,4])
    >>> true
    Explanation: The graph shows how the indices are connected. White nodes are jumping forward, while red is jumping backward.
    We can see the cycle 0 --> 1 --> 0 --> ..., and while it is of size > 1, it has a node jumping forward and a node jumping backward, so it is not a cycle.
    We can see the cycle 3 --> 4 --> 3 --> ..., and all of its nodes are white (jumping in the same direction).
    """


Prompt:
def poorPigs(buckets: int, minutesToDie: int, minutesToTest: int) -> int:
    """
    There are buckets buckets of liquid, where exactly one of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have minutesToTest minutes to determine which bucket is poisonous.
    You can feed the pigs according to these steps:

    Choose some live pigs to feed.
    For each pig, choose which buckets to feed it. The pig will consume all the chosen buckets simultaneously and will take no time. Each pig can feed from any number of buckets, and each bucket can be fed from by any number of pigs.
    Wait for minutesToDie minutes. You may not feed any other pigs during this time.
    After minutesToDie minutes have passed, any pigs that have been fed the poisonous bucket will die, and all others will survive.
    Repeat this process until you run out of time.

    Given buckets, minutesToDie, and minutesToTest, return the minimum number of pigs needed to figure out which bucket is poisonous within the allotted time.

    Example 1:

    >>> poorPigs(buckets = 4, minutesToDie = 15, minutesToTest = 15)
    >>> 2
    Explanation: We can determine the poisonous bucket as follows:
    At time 0, feed the first pig buckets 1 and 2, and feed the second pig buckets 2 and 3.
    At time 15, there are 4 possible outcomes:
    - If only the first pig dies, then bucket 1 must be poisonous.
    - If only the second pig dies, then bucket 3 must be poisonous.
    - If both pigs die, then bucket 2 must be poisonous.
    - If neither pig dies, then bucket 4 must be poisonous.

    Example 2:

    >>> poorPigs(buckets = 4, minutesToDie = 15, minutesToTest = 30)
    >>> 2
    Explanation: We can determine the poisonous bucket as follows:
    At time 0, feed the first pig bucket 1, and feed the second pig bucket 2.
    At time 15, there are 2 possible outcomes:
    - If either pig dies, then the poisonous bucket is the one it was fed.
    - If neither pig dies, then feed the first pig bucket 3, and feed the second pig bucket 4.
    At time 30, one of the two pigs must die, and the poisonous bucket is the one it was fed.
    """


Prompt:
def repeatedSubstringPattern(s: str) -> bool:
    """
    Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.

    Example 1:

    >>> repeatedSubstringPattern(s = "abab")
    >>> true
    Explanation: It is the substring "ab" twice.

    Example 2:

    >>> repeatedSubstringPattern(s = "aba")
    >>> false

    Example 3:

    >>> repeatedSubstringPattern(s = "abcabcabcabc")
    >>> true
    Explanation: It is the substring "abc" four times or the substring "abcabc" twice.
    """


Prompt:
def hammingDistance(x: int, y: int) -> int:
    """
    The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
    Given two integers x and y, return the Hamming distance between them.

    Example 1:

    >>> hammingDistance(x = 1, y = 4)
    >>> 2
    Explanation:
    1   (0 0 0 1)
    4   (0 1 0 0)
           ↑   ↑
    The above arrows point to positions where the corresponding bits are different.

    Example 2:

    >>> hammingDistance(x = 3, y = 1)
    >>> 1
    """


Prompt:
from typing import List
def minMoves2(nums: List[int]) -> int:
    """
    Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.
    In one move, you can increment or decrement an element of the array by 1.
    Test cases are designed so that the answer will fit in a 32-bit integer.

    Example 1:

    >>> minMoves2(nums = [1,2,3])
    >>> 2
    Explanation:
    Only two moves are needed (remember each move increments or decrements one element):
    [1,2,3]  =>  [2,2,3]  =>  [2,2,2]

    Example 2:

    >>> minMoves2(nums = [1,10,2,9])
    >>> 16
    """


Prompt:
from typing import List
def islandPerimeter(grid: List[List[int]]) -> int:
    """
    You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.
    Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).
    The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

    Example 1:

    >>> islandPerimeter(grid = [[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]])
    >>> 16
    Explanation: The perimeter is the 16 yellow stripes in the image above.

    Example 2:

    >>> islandPerimeter(grid = [[1]])
    >>> 4

    Example 3:

    >>> islandPerimeter(grid = [[1,0]])
    >>> 4
    """


Prompt:
def canIWin(maxChoosableInteger: int, desiredTotal: int) -> bool:
    """
    In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins.
    What if we change the game so that players cannot re-use integers?
    For example, two players might take turns drawing from a common pool of numbers from 1 to 15 without replacement until they reach a total >= 100.
    Given two integers maxChoosableInteger and desiredTotal, return true if the first player to move can force a win, otherwise, return false. Assume both players play optimally.

    Example 1:

    >>> canIWin(maxChoosableInteger = 10, desiredTotal = 11)
    >>> false
    Explanation:
    No matter which integer the first player choose, the first player will lose.
    The first player can choose an integer from 1 up to 10.
    If the first player choose 1, the second player can only choose integers from 2 up to 10.
    The second player will win by choosing 10 and get a total = 11, which is >= desiredTotal.
    Same with other integers chosen by the first player, the second player will always win.

    Example 2:

    >>> canIWin(maxChoosableInteger = 10, desiredTotal = 0)
    >>> true

    Example 3:

    >>> canIWin(maxChoosableInteger = 10, desiredTotal = 1)
    >>> true
    """


Prompt:
from typing import List
def minTransfers(transactions: List[List[int]]) -> int:
    """
    You are given an array of transactions transactions where transactions[i] = [fromi, toi, amounti] indicates that the person with ID = fromi gave amounti $ to the person with ID = toi.
    Return the minimum number of transactions required to settle the debt.

    Example 1:

    >>> minTransfers(transactions = [[0,1,10],[2,0,5]])
    >>> 2
    Explanation:
    Person #0 gave person #1 $10.
    Person #2 gave person #0 $5.
    Two transactions are needed. One way to settle the debt is person #1 pays person #0 and #2 $5 each.

    Example 2:

    >>> minTransfers(transactions = [[0,1,10],[1,0,1],[1,2,5],[2,0,5]])
    >>> 1
    Explanation:
    Person #0 gave person #1 $10.
    Person #1 gave person #0 $1.
    Person #1 gave person #2 $5.
    Person #2 gave person #0 $5.
    Therefore, person #1 only need to give person #0 $4, and all debt is settled.
    """


Prompt:
def getMaxRepetitions(s1: str, n1: int, s2: str, n2: int) -> int:
    """
    We define str = [s, n] as the string str which consists of the string s concatenated n times.

    For example, str == ["abc", 3] =="abcabcabc".

    We define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1.

    For example, s1 = "abc" can be obtained from s2 = "abdbec" based on our definition by removing the bolded underlined characters.

    You are given two strings s1 and s2 and two integers n1 and n2. You have the two strings str1 = [s1, n1] and str2 = [s2, n2].
    Return the maximum integer m such that str = [str2, m] can be obtained from str1.

    Example 1:
    >>> getMaxRepetitions(s1 = "acb", n1 = 4, s2 = "ab", n2 = 2)
    >>> 2
    Example 2:
    >>> getMaxRepetitions(s1 = "acb", n1 = 1, s2 = "acb", n2 = 1)
    >>> 1
    """


Prompt:
def findSubstringInWraproundString(s: str) -> int:
    """
    We define the string base to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so base will look like this:

    "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".

    Given a string s, return the number of unique non-empty substrings of s are present in base.

    Example 1:

    >>> findSubstringInWraproundString(s = "a")
    >>> 1
    Explanation: Only the substring "a" of s is in base.

    Example 2:

    >>> findSubstringInWraproundString(s = "cac")
    >>> 2
    Explanation: There are two substrings ("a", "c") of s in base.

    Example 3:

    >>> findSubstringInWraproundString(s = "zab")
    >>> 6
    Explanation: There are six substrings ("z", "a", "b", "za", "ab", and "zab") of s in base.
    """


Prompt:
def validIPAddress(queryIP: str) -> str:
    """
    Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.
    A valid IPv4 address is an IP in the form "x1.x2.x3.x4" where 0 <= xi <= 255 and xi cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1.0" are valid IPv4 addresses while "192.168.01.1", "192.168.1.00", and "192.168@1.1" are invalid IPv4 addresses.
    A valid IPv6 address is an IP in the form "x1:x2:x3:x4:x5:x6:x7:x8" where:

    1 <= xi.length <= 4
    xi is a hexadecimal string which may contain digits, lowercase English letter ('a' to 'f') and upper-case English letters ('A' to 'F').
    Leading zeros are allowed in xi.

    For example, "2001:0db8:85a3:0000:0000:8a2e:0370:7334" and "2001:db8:85a3:0:0:8A2E:0370:7334" are valid IPv6 addresses, while "2001:0db8:85a3::8A2E:037j:7334" and "02001:0db8:85a3:0000:0000:8a2e:0370:7334" are invalid IPv6 addresses.

    Example 1:

    >>> validIPAddress(queryIP = "172.16.254.1")
    >>> "IPv4"
    Explanation: This is a valid IPv4 address, return "IPv4".

    Example 2:

    >>> validIPAddress(queryIP = "2001:0db8:85a3:0:0:8A2E:0370:7334")
    >>> "IPv6"
    Explanation: This is a valid IPv6 address, return "IPv6".

    Example 3:

    >>> validIPAddress(queryIP = "256.256.256.256")
    >>> "Neither"
    Explanation: This is neither a IPv4 address nor a IPv6 address.
    """


Prompt:
from typing import List
def isConvex(points: List[List[int]]) -> bool:
    """
    You are given an array of points on the X-Y plane points where points[i] = [xi, yi]. The points form a polygon when joined sequentially.
    Return true if this polygon is convex and false otherwise.
    You may assume the polygon formed by given points is always a simple polygon. In other words, we ensure that exactly two edges intersect at each vertex and that edges otherwise don't intersect each other.

    Example 1:

    >>> isConvex(points = [[0,0],[0,5],[5,5],[5,0]])
    >>> true

    Example 2:

    >>> isConvex(points = [[0,0],[0,10],[10,10],[10,0],[5,5]])
    >>> false
    """


Prompt:
def encode(s: str) -> str:
    """
    Given a string s, encode the string such that its encoded length is the shortest.
    The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. k should be a positive integer.
    If an encoding process does not make the string shorter, then do not encode it. If there are several solutions, return any of them.

    Example 1:

    >>> encode(s = "aaa")
    >>> "aaa"
    Explanation: There is no way to encode it such that it is shorter than the input string, so we do not encode it.

    Example 2:

    >>> encode(s = "aaaaa")
    >>> "5[a]"
    Explanation: "5[a]" is shorter than "aaaaa" by 1 character.

    Example 3:

    >>> encode(s = "aaaaaaaaaa")
    >>> "10[a]"
    Explanation: "a9[a]" or "9[a]a" are also valid solutions, both of them have the same length = 5, which is the same as "10[a]".
    """


Prompt:
from typing import List
def findAllConcatenatedWordsInADict(words: List[str]) -> List[str]:
    """
    Given an array of strings words (without duplicates), return all the concatenated words in the given list of words.
    A concatenated word is defined as a string that is comprised entirely of at least two shorter words (not necessarily distinct) in the given array.

    Example 1:

    >>> findAllConcatenatedWordsInADict(words = ["cat","cats","catsdogcats","dog","dogcatsdog","hippopotamuses","rat","ratcatdogcat"])
    >>> ["catsdogcats","dogcatsdog","ratcatdogcat"]
    Explanation: "catsdogcats" can be concatenated by "cats", "dog" and "cats";
    "dogcatsdog" can be concatenated by "dog", "cats" and "dog";
    "ratcatdogcat" can be concatenated by "rat", "cat", "dog" and "cat".
    Example 2:

    >>> findAllConcatenatedWordsInADict(words = ["cat","dog","catdog"])
    >>> ["catdog"]
    """


Prompt:
from typing import List
def makesquare(matchsticks: List[int]) -> bool:
    """
    You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time.
    Return true if you can make this square and false otherwise.

    Example 1:

    >>> makesquare(matchsticks = [1,1,2,2,2])
    >>> true
    Explanation: You can form a square with length 2, one side of the square came two sticks with length 1.

    Example 2:

    >>> makesquare(matchsticks = [3,3,3,3,4])
    >>> false
    Explanation: You cannot find a way to form a square with all the matchsticks.
    """


Prompt:
from typing import List
def findMaxForm(strs: List[str], m: int, n: int) -> int:
    """
    You are given an array of binary strings strs and two integers m and n.
    Return the size of the largest subset of strs such that there are at most m 0's and n 1's in the subset.
    A set x is a subset of a set y if all elements of x are also elements of y.

    Example 1:

    >>> findMaxForm(strs = ["10","0001","111001","1","0"], m = 5, n = 3)
    >>> 4
    Explanation: The largest subset with at most 5 0's and 3 1's is {"10", "0001", "1", "0"}, so the answer is 4.
    Other valid but smaller subsets include {"0001", "1"} and {"10", "1", "0"}.
    {"111001"} is an invalid subset because it contains 4 1's, greater than the maximum of 3.

    Example 2:

    >>> findMaxForm(strs = ["10","0","1"], m = 1, n = 1)
    >>> 2
    Explanation: The largest subset is {"0", "1"}, so the answer is 2.
    """


Prompt:
from typing import List
def findRadius(houses: List[int], heaters: List[int]) -> int:
    """
    Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses.
    Every house can be warmed, as long as the house is within the heater's warm radius range.
    Given the positions of houses and heaters on a horizontal line, return the minimum radius standard of heaters so that those heaters could cover all houses.
    Notice that all the heaters follow your radius standard, and the warm radius will the same.

    Example 1:

    >>> findRadius(houses = [1,2,3], heaters = [2])
    >>> 1
    Explanation: The only heater was placed in the position 2, and if we use the radius 1 standard, then all the houses can be warmed.

    Example 2:

    >>> findRadius(houses = [1,2,3,4], heaters = [1,4])
    >>> 1
    Explanation: The two heaters were placed at positions 1 and 4. We need to use a radius 1 standard, then all the houses can be warmed.

    Example 3:

    >>> findRadius(houses = [1,5], heaters = [2])
    >>> 3
    """


Prompt:
def findComplement(num: int) -> int:
    """
    The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.

    For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2.

    Given an integer num, return its complement.

    Example 1:

    >>> findComplement(num = 5)
    >>> 2
    Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.

    Example 2:

    >>> findComplement(num = 1)
    >>> 0
    Explanation: The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.
    """


Prompt:
from typing import List
def totalHammingDistance(nums: List[int]) -> int:
    """
    The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
    Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums.

    Example 1:

    >>> totalHammingDistance(nums = [4,14,2])
    >>> 6
    Explanation: In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just
    showing the four bits relevant in this case).
    The answer will be:
    HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6.

    Example 2:

    >>> totalHammingDistance(nums = [4,14,4])
    >>> 4
    """


Prompt:
def largestPalindrome(n: int) -> int:
    """
    Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers. Since the answer can be very large, return it modulo 1337.

    Example 1:

    >>> largestPalindrome(n = 2)
    >>> 987
    Explanation: 99 x 91 = 9009, 9009 % 1337 = 987

    Example 2:

    >>> largestPalindrome(n = 1)
    >>> 9
    """


Prompt:
from typing import List
def medianSlidingWindow(nums: List[int], k: int) -> List[float]:
    """
    The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values.

    For examples, if arr = [2,3,4], the median is 3.
    For examples, if arr = [1,2,3,4], the median is (2 + 3) / 2 = 2.5.

    You are given an integer array nums and an integer k. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
    Return the median array for each window in the original array. Answers within 10-5 of the actual value will be accepted.

    Example 1:

    >>> medianSlidingWindow(nums = [1,3,-1,-3,5,3,6,7], k = 3)
    >>> [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000]
    Explanation:
    Window position                Median
    ---------------                -----
    [1  3  -1] -3  5  3  6  7        1
     1 [3  -1  -3] 5  3  6  7       -1
     1  3 [-1  -3  5] 3  6  7       -1
     1  3  -1 [-3  5  3] 6  7        3
     1  3  -1  -3 [5  3  6] 7        5
     1  3  -1  -3  5 [3  6  7]       6

    Example 2:

    >>> medianSlidingWindow(nums = [1,2,3,4,2,3,1,4,2], k = 3)
    >>> [2.00000,3.00000,3.00000,3.00000,2.00000,3.00000,2.00000]
    """


Prompt:
def magicalString(n: int) -> int:
    """
    A magical string s consists of only '1' and '2' and obeys the following rules:

    The string s is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string s itself.

    The first few elements of s is s = "1221121221221121122……". If we group the consecutive 1's and 2's in s, it will be "1 22 11 2 1 22 1 22 11 2 11 22 ......" and the occurrences of 1's or 2's in each group are "1 2 2 1 1 2 1 2 2 1 2 2 ......". You can see that the occurrence sequence is s itself.
    Given an integer n, return the number of 1's in the first n number in the magical string s.

    Example 1:

    >>> magicalString(n = 6)
    >>> 3
    Explanation: The first 6 elements of magical string s is "122112" and it contains three 1's, so return 3.

    Example 2:

    >>> magicalString(n = 1)
    >>> 1
    """


Prompt:
def licenseKeyFormatting(s: str, k: int) -> str:
    """
    You are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 groups by n dashes. You are also given an integer k.
    We want to reformat the string s such that each group contains exactly k characters, except for the first group, which could be shorter than k but still must contain at least one character. Furthermore, there must be a dash inserted between two groups, and you should convert all lowercase letters to uppercase.
    Return the reformatted license key.

    Example 1:

    >>> licenseKeyFormatting(s = "5F3Z-2e-9-w", k = 4)
    >>> "5F3Z-2E9W"
    Explanation: The string s has been split into two parts, each part has 4 characters.
    Note that the two extra dashes are not needed and can be removed.

    Example 2:

    >>> licenseKeyFormatting(s = "2-5g-3-J", k = 2)
    >>> "2-5G-3J"
    Explanation: The string s has been split into three parts, each part has 2 characters except the first part as it could be shorter as mentioned above.
    """


Prompt:
def smallestGoodBase(n: str) -> str:
    """
    Given an integer n represented as a string, return the smallest good base of n.
    We call k >= 2 a good base of n, if all digits of n base k are 1's.

    Example 1:

    >>> smallestGoodBase(n = "13")
    >>> "3"
    Explanation: 13 base 3 is 111.

    Example 2:

    >>> smallestGoodBase(n = "4681")
    >>> "8"
    Explanation: 4681 base 8 is 11111.

    Example 3:

    >>> smallestGoodBase(n = "1000000000000000000")
    >>> "999999999999999999"
    Explanation: 1000000000000000000 base 999999999999999999 is 11.
    """


Prompt:
from typing import List
def findPermutation(s: str) -> List[int]:
    """
    A permutation perm of n integers of all the integers in the range [1, n] can be represented as a string s of length n - 1 where:

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

    Given a string s, reconstruct the lexicographically smallest permutation perm and return it.

    Example 1:

    >>> findPermutation(s = "I")
    >>> [1,2]
    Explanation: [1,2] is the only legal permutation that can represented by s, where the number 1 and 2 construct an increasing relationship.

    Example 2:

    >>> findPermutation(s = "DI")
    >>> [2,1,3]
    Explanation: Both [2,1,3] and [3,1,2] can be represented as "DI", but since we want to find the smallest lexicographical permutation, you should return [2,1,3]
    """


Prompt:
from typing import List
def findMaxConsecutiveOnes(nums: List[int]) -> int:
    """
    Given a binary array nums, return the maximum number of consecutive 1's in the array.

    Example 1:

    >>> findMaxConsecutiveOnes(nums = [1,1,0,1,1,1])
    >>> 3
    Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.

    Example 2:

    >>> findMaxConsecutiveOnes(nums = [1,0,1,1,0,1])
    >>> 2
    """


Prompt:
from typing import List
def predictTheWinner(nums: List[int]) -> bool:
    """
    You are given an integer array nums. Two players are playing a game with this array: player 1 and player 2.
    Player 1 and player 2 take turns, with player 1 starting first. Both players start the game with a score of 0. At each turn, the player takes one of the numbers from either end of the array (i.e., nums[0] or nums[nums.length - 1]) which reduces the size of the array by 1. The player adds the chosen number to their score. The game ends when there are no more elements in the array.
    Return true if Player 1 can win the game. If the scores of both players are equal, then player 1 is still the winner, and you should also return true. You may assume that both players are playing optimally.

    Example 1:

    >>> predictTheWinner(nums = [1,5,2])
    >>> false
    Explanation: Initially, player 1 can choose between 1 and 2.
    If he chooses 2 (or 1), then player 2 can choose from 1 (or 2) and 5. If player 2 chooses 5, then player 1 will be left with 1 (or 2).
    So, final score of player 1 is 1 + 2 = 3, and player 2 is 5.
    Hence, player 1 will never be the winner and you need to return false.

    Example 2:

    >>> predictTheWinner(nums = [1,5,233,7])
    >>> true
    Explanation: Player 1 first chooses 1. Then player 2 has to choose between 5 and 7. No matter which number player 2 choose, player 1 can choose 233.
    Finally, player 1 has more score (234) than player 2 (12), so you need to return True representing player1 can win.
    """


Prompt:
from typing import List
def findMaxConsecutiveOnes(nums: List[int]) -> int:
    """
    Given a binary array nums, return the maximum number of consecutive 1's in the array if you can flip at most one 0.

    Example 1:

    >>> findMaxConsecutiveOnes(nums = [1,0,1,1,0])
    >>> 4
    Explanation:
    - If we flip the first zero, nums becomes [1,1,1,1,0] and we have 4 consecutive ones.
    - If we flip the second zero, nums becomes [1,0,1,1,1] and we have 3 consecutive ones.
    The max number of consecutive ones is 4.

    Example 2:

    >>> findMaxConsecutiveOnes(nums = [1,0,1,1,0,1])
    >>> 4
    Explanation:
    - If we flip the first zero, nums becomes [1,1,1,1,0,1] and we have 4 consecutive ones.
    - If we flip the second zero, nums becomes [1,0,1,1,1,1] and we have 4 consecutive ones.
    The max number of consecutive ones is 4.
    """


Prompt:
def findMinStep(board: str, hand: str) -> int:
    """
    You are playing a variation of the game Zuma.
    In this variation of Zuma, there is a single row of colored balls on a board, where each ball can be colored red 'R', yellow 'Y', blue 'B', green 'G', or white 'W'. You also have several colored balls in your hand.
    Your goal is to clear all of the balls from the board. On each turn:

    Pick any ball from your hand and insert it in between two balls in the row or on either end of the row.
    If there is a group of three or more consecutive balls of the same color, remove the group of balls from the board.

    If this removal causes more groups of three or more of the same color to form, then continue removing each group until there are none left.

    If there are no more balls on the board, then you win the game.
    Repeat this process until you either win or do not have any more balls in your hand.

    Given a string board, representing the row of balls on the board, and a string hand, representing the balls in your hand, return the minimum number of balls you have to insert to clear all the balls from the board. If you cannot clear all the balls from the board using the balls in your hand, return -1.

    Example 1:

    >>> findMinStep(board = "WRRBBW", hand = "RB")
    >>> -1
    Explanation: It is impossible to clear all the balls. The best you can do is:
    - Insert 'R' so the board becomes WRRRBBW. WRRRBBW -> WBBW.
    - Insert 'B' so the board becomes WBBBW. WBBBW -> WW.
    There are still balls remaining on the board, and you are out of balls to insert.
    Example 2:

    >>> findMinStep(board = "WWRRBBWW", hand = "WRBRW")
    >>> 2
    Explanation: To make the board empty:
    - Insert 'R' so the board becomes WWRRRBBWW. WWRRRBBWW -> WWBBWW.
    - Insert 'B' so the board becomes WWBBBWW. WWBBBWW -> WWWW -> empty.
    2 balls from your hand were needed to clear the board.

    Example 3:

    >>> findMinStep(board = "G", hand = "GGGGG")
    >>> 2
    Explanation: To make the board empty:
    - Insert 'G' so the board becomes GG.
    - Insert 'G' so the board becomes GGG. GGG -> empty.
    2 balls from your hand were needed to clear the board.
    """


Prompt:
from typing import List
def hasPath(maze: List[List[int]], start: List[int], destination: List[int]) -> bool:
    """
    There is a ball in a maze with empty spaces (represented as 0) and walls (represented as 1). The ball can go through the empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.
    Given the m x n maze, the ball's start position and the destination, where start = [startrow, startcol] and destination = [destinationrow, destinationcol], return true if the ball can stop at the destination, otherwise return false.
    You may assume that the borders of the maze are all walls (see examples).

    Example 1:

    >>> hasPath(maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]], start = [0,4], destination = [4,4])
    >>> true
    Explanation: One possible way is : left -> down -> left -> down -> right -> down -> right.

    Example 2:

    >>> hasPath(maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]], start = [0,4], destination = [3,2])
    >>> false
    Explanation: There is no way for the ball to stop at the destination. Notice that you can pass through the destination but you cannot stop there.

    Example 3:

    >>> hasPath(maze = [[0,0,0,0,0],[1,1,0,0,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,0,0,0]], start = [4,3], destination = [0,1])
    >>> false
    """


Prompt:
from typing import List
def findSubsequences(nums: List[int]) -> List[List[int]]:
    """
    Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order.

    Example 1:

    >>> findSubsequences(nums = [4,6,7,7])
    >>> [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]]

    Example 2:

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


Prompt:
from typing import List
def constructRectangle(area: int) -> List[int]:
    """
    A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

    The area of the rectangular web page you designed must equal to the given target area.
    The width W should not be larger than the length L, which means L >= W.
    The difference between length L and width W should be as small as possible.

    Return an array [L, W] where L and W are the length and width of the web page you designed in sequence.

    Example 1:

    >>> constructRectangle(area = 4)
    >>> [2,2]
    Explanation: The target area is 4, and all the possible ways to construct it are [1,4], [2,2], [4,1].
    But according to requirement 2, [1,4] is illegal; according to requirement 3,  [4,1] is not optimal compared to [2,2]. So the length L is 2, and the width W is 2.

    Example 2:

    >>> constructRectangle(area = 37)
    >>> [37,1]

    Example 3:

    >>> constructRectangle(area = 122122)
    >>> [427,286]
    """


Prompt:
from typing import List
def reversePairs(nums: List[int]) -> int:
    """
    Given an integer array nums, return the number of reverse pairs in the array.
    A reverse pair is a pair (i, j) where:

    0 <= i < j < nums.length and
    nums[i] > 2 * nums[j].

    Example 1:

    >>> reversePairs(nums = [1,3,2,3,1])
    >>> 2
    Explanation: The reverse pairs are:
    (1, 4) --> nums[1] = 3, nums[4] = 1, 3 > 2 * 1
    (3, 4) --> nums[3] = 3, nums[4] = 1, 3 > 2 * 1

    Example 2:

    >>> reversePairs(nums = [2,4,3,5,1])
    >>> 3
    Explanation: The reverse pairs are:
    (1, 4) --> nums[1] = 4, nums[4] = 1, 4 > 2 * 1
    (2, 4) --> nums[2] = 3, nums[4] = 1, 3 > 2 * 1
    (3, 4) --> nums[3] = 5, nums[4] = 1, 5 > 2 * 1
    """


Prompt:
from typing import List
def findTargetSumWays(nums: List[int], target: int) -> int:
    """
    You are given an integer array nums and an integer target.
    You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.

    For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them to build the expression "+2-1".

    Return the number of different expressions that you can build, which evaluates to target.

    Example 1:

    >>> findTargetSumWays(nums = [1,1,1,1,1], target = 3)
    >>> 5
    Explanation: There are 5 ways to assign symbols to make the sum of nums be target 3.
    -1 + 1 + 1 + 1 + 1 = 3
    +1 - 1 + 1 + 1 + 1 = 3
    +1 + 1 - 1 + 1 + 1 = 3
    +1 + 1 + 1 - 1 + 1 = 3
    +1 + 1 + 1 + 1 - 1 = 3

    Example 2:

    >>> findTargetSumWays(nums = [1], target = 1)
    >>> 1
    """


Prompt:
from typing import List
def findPoisonedDuration(timeSeries: List[int], duration: int) -> int:
    """
    Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe is poisoned during the inclusive time interval [t, t + duration - 1]. If Teemo attacks again before the poison effect ends, the timer for it is reset, and the poison effect will end duration seconds after the new attack.
    You are given a non-decreasing integer array timeSeries, where timeSeries[i] denotes that Teemo attacks Ashe at second timeSeries[i], and an integer duration.
    Return the total number of seconds that Ashe is poisoned.

    Example 1:

    >>> findPoisonedDuration(timeSeries = [1,4], duration = 2)
    >>> 4
    Explanation: Teemo's attacks on Ashe go as follows:
    - At second 1, Teemo attacks, and Ashe is poisoned for seconds 1 and 2.
    - At second 4, Teemo attacks, and Ashe is poisoned for seconds 4 and 5.
    Ashe is poisoned for seconds 1, 2, 4, and 5, which is 4 seconds in total.

    Example 2:

    >>> findPoisonedDuration(timeSeries = [1,2], duration = 2)
    >>> 3
    Explanation: Teemo's attacks on Ashe go as follows:
    - At second 1, Teemo attacks, and Ashe is poisoned for seconds 1 and 2.
    - At second 2 however, Teemo attacks again and resets the poison timer. Ashe is poisoned for seconds 2 and 3.
    Ashe is poisoned for seconds 1, 2, and 3, which is 3 seconds in total.
    """


Prompt:
from typing import List
def nextGreaterElement(nums1: List[int], nums2: List[int]) -> List[int]:
    """
    The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.
    You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2.
    For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and determine the next greater element of nums2[j] in nums2. If there is no next greater element, then the answer for this query is -1.
    Return an array ans of length nums1.length such that ans[i] is the next greater element as described above.

    Example 1:

    >>> nextGreaterElement(nums1 = [4,1,2], nums2 = [1,3,4,2])
    >>> [-1,3,-1]
    Explanation: The next greater element for each value of nums1 is as follows:
    - 4 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1.
    - 1 is underlined in nums2 = [1,3,4,2]. The next greater element is 3.
    - 2 is underlined in nums2 = [1,3,4,2]. There is no next greater element, so the answer is -1.

    Example 2:

    >>> nextGreaterElement(nums1 = [2,4], nums2 = [1,2,3,4])
    >>> [3,-1]
    Explanation: The next greater element for each value of nums1 is as follows:
    - 2 is underlined in nums2 = [1,2,3,4]. The next greater element is 3.
    - 4 is underlined in nums2 = [1,2,3,4]. There is no next greater element, so the answer is -1.
    """


Prompt:
from typing import List
def findDiagonalOrder(mat: List[List[int]]) -> List[int]:
    """
    Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.

    Example 1:

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

    Example 2:

    >>> findDiagonalOrder(mat = [[1,2],[3,4]])
    >>> [1,2,3,4]
    """


Prompt:
from typing import List
def findShortestWay(maze: List[List[int]], ball: List[int], hole: List[int]) -> str:
    """
    There is a ball in a maze with empty spaces (represented as 0) and walls (represented as 1). The ball can go through the empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction. There is also a hole in this maze. The ball will drop into the hole if it rolls onto the hole.
    Given the m x n maze, the ball's position ball and the hole's position hole, where ball = [ballrow, ballcol] and hole = [holerow, holecol], return a string instructions of all the instructions that the ball should follow to drop in the hole with the shortest distance possible. If there are multiple valid instructions, return the lexicographically minimum one. If the ball can't drop in the hole, return "impossible".
    If there is a way for the ball to drop in the hole, the answer instructions should contain the characters 'u' (i.e., up), 'd' (i.e., down), 'l' (i.e., left), and 'r' (i.e., right).
    The distance is the number of empty spaces traveled by the ball from the start position (excluded) to the destination (included).
    You may assume that the borders of the maze are all walls (see examples).

    Example 1:

    >>> findShortestWay(maze = [[0,0,0,0,0],[1,1,0,0,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,0,0,0]], ball = [4,3], hole = [0,1])
    >>> "lul"
    Explanation: There are two shortest ways for the ball to drop into the hole.
    The first way is left -> up -> left, represented by "lul".
    The second way is up -> left, represented by 'ul'.
    Both ways have shortest distance 6, but the first way is lexicographically smaller because 'l' < 'u'. So the output is "lul".

    Example 2:

    >>> findShortestWay(maze = [[0,0,0,0,0],[1,1,0,0,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,0,0,0]], ball = [4,3], hole = [3,0])
    >>> "impossible"
    Explanation: The ball cannot reach the hole.

    Example 3:

    >>> findShortestWay(maze = [[0,0,0,0,0,0,0],[0,0,1,0,0,1,0],[0,0,0,0,1,0,0],[0,0,0,0,0,0,1]], ball = [0,4], hole = [3,5])
    >>> "dldr"
    """


Prompt:
from typing import List
def findWords(words: List[str]) -> List[str]:
    """
    Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.
    Note that the strings are case-insensitive, both lowercased and uppercased of the same letter are treated as if they are at the same row.
    In the American keyboard:

    the first row consists of the characters "qwertyuiop",
    the second row consists of the characters "asdfghjkl", and
    the third row consists of the characters "zxcvbnm".

    Example 1:

    >>> findWords(words = ["Hello","Alaska","Dad","Peace"])
    >>> ["Alaska","Dad"]
    Explanation:
    Both "a" and "A" are in the 2nd row of the American keyboard due to case insensitivity.

    Example 2:

    >>> findWords(words = ["omk"])
    >>> []

    Example 3:

    >>> findWords(words = ["adsdf","sfd"])
    >>> ["adsdf","sfd"]
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def findMode(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary search tree (BST) with duplicates, return all the mode(s) (i.e., the most frequently occurred element) in it.
If the tree has more than one mode, return them in any order.
Assume a BST is defined as follows:

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

Example 1:

>>> findMode(root = [1,null,2,2])
>>> [2]

Example 2:

>>> findMode(root = [0])
>>> [0]
"""


Prompt:
from typing import List
def findMaximizedCapital(k: int, w: int, profits: List[int], capital: List[int]) -> int:
    """
    Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCode design the best way to maximize its total capital after finishing at most k distinct projects.
    You are given n projects where the ith project has a pure profit profits[i] and a minimum capital of capital[i] is needed to start it.
    Initially, you have w capital. When you finish a project, you will obtain its pure profit and the profit will be added to your total capital.
    Pick a list of at most k distinct projects from given projects to maximize your final capital, and return the final maximized capital.
    The answer is guaranteed to fit in a 32-bit signed integer.

    Example 1:

    >>> findMaximizedCapital(k = 2, w = 0, profits = [1,2,3], capital = [0,1,1])
    >>> 4
    Explanation: Since your initial capital is 0, you can only start the project indexed 0.
    After finishing it you will obtain profit 1 and your capital becomes 1.
    With capital 1, you can either start the project indexed 1 or the project indexed 2.
    Since you can choose at most 2 projects, you need to finish the project indexed 2 to get the maximum capital.
    Therefore, output the final maximized capital, which is 0 + 1 + 3 = 4.

    Example 2:

    >>> findMaximizedCapital(k = 3, w = 0, profits = [1,2,3], capital = [0,1,2])
    >>> 6
    """


Prompt:
from typing import List
def nextGreaterElements(nums: List[int]) -> List[int]:
    """
    Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.
    The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its next greater number. If it doesn't exist, return -1 for this number.

    Example 1:

    >>> nextGreaterElements(nums = [1,2,1])
    >>> [2,-1,2]
    Explanation: The first 1's next greater number is 2;
    The number 2 can't find next greater number.
    The second 1's next greater number needs to search circularly, which is also 2.

    Example 2:

    >>> nextGreaterElements(nums = [1,2,3,4,3])
    >>> [2,3,4,-1,4]
    """


Prompt:
def convertToBase7(num: int) -> str:
    """
    Given an integer num, return a string of its base 7 representation.

    Example 1:
    >>> convertToBase7(num = 100)
    >>> "202"
    Example 2:
    >>> convertToBase7(num = -7)
    >>> "-10"
    """


Prompt:
from typing import List
def shortestDistance(maze: List[List[int]], start: List[int], destination: List[int]) -> int:
    """
    There is a ball in a maze with empty spaces (represented as 0) and walls (represented as 1). The ball can go through the empty spaces by rolling up, down, left or right, but it won't stop rolling until hitting a wall. When the ball stops, it could choose the next direction.
    Given the m x n maze, the ball's start position and the destination, where start = [startrow, startcol] and destination = [destinationrow, destinationcol], return the shortest distance for the ball to stop at the destination. If the ball cannot stop at destination, return -1.
    The distance is the number of empty spaces traveled by the ball from the start position (excluded) to the destination (included).
    You may assume that the borders of the maze are all walls (see examples).

    Example 1:

    >>> shortestDistance(maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]], start = [0,4], destination = [4,4])
    >>> 12
    Explanation: One possible way is : left -> down -> left -> down -> right -> down -> right.
    The length of the path is 1 + 1 + 3 + 1 + 2 + 2 + 2 = 12.

    Example 2:

    >>> shortestDistance(maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]], start = [0,4], destination = [3,2])
    >>> -1
    Explanation: There is no way for the ball to stop at the destination. Notice that you can pass through the destination but you cannot stop there.

    Example 3:

    >>> shortestDistance(maze = [[0,0,0,0,0],[1,1,0,0,1],[0,0,0,0,0],[0,1,0,0,1],[0,1,0,0,0]], start = [4,3], destination = [0,1])
    >>> -1
    """


Prompt:
from typing import List
def findRelativeRanks(score: List[int]) -> List[str]:
    """
    You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition. All the scores are guaranteed to be unique.
    The athletes are placed based on their scores, where the 1st place athlete has the highest score, the 2nd place athlete has the 2nd highest score, and so on. The placement of each athlete determines their rank:

    The 1st place athlete's rank is "Gold Medal".
    The 2nd place athlete's rank is "Silver Medal".
    The 3rd place athlete's rank is "Bronze Medal".
    For the 4th place to the nth place athlete, their rank is their placement number (i.e., the xth place athlete's rank is "x").

    Return an array answer of size n where answer[i] is the rank of the ith athlete.

    Example 1:

    >>> findRelativeRanks(score = [5,4,3,2,1])
    >>> ["Gold Medal","Silver Medal","Bronze Medal","4","5"]
    Explanation: The placements are [1st, 2nd, 3rd, 4th, 5th].
    Example 2:

    >>> findRelativeRanks(score = [10,3,8,9,4])
    >>> ["Gold Medal","5","Bronze Medal","Silver Medal","4"]
    Explanation: The placements are [1st, 5th, 3rd, 2nd, 4th].
    """


Prompt:
def checkPerfectNumber(num: int) -> bool:
    """
    A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly.
    Given an integer n, return true if n is a perfect number, otherwise return false.

    Example 1:

    >>> checkPerfectNumber(num = 28)
    >>> true
    Explanation: 28 = 1 + 2 + 4 + 7 + 14
    1, 2, 4, 7, and 14 are all divisors of 28.

    Example 2:

    >>> checkPerfectNumber(num = 7)
    >>> false
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def findFrequentTreeSum(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order.
The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself).

Example 1:

>>> findFrequentTreeSum(root = [5,2,-3])
>>> [2,-3,4]

Example 2:

>>> findFrequentTreeSum(root = [5,2,-5])
>>> [2]
"""


Prompt:
def fib(n: int) -> int:
    """
    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

    F(0) = 0, F(1) = 1
    F(n) = F(n - 1) + F(n - 2), for n > 1.

    Given n, calculate F(n).

    Example 1:

    >>> fib(n = 2)
    >>> 1
    Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1.

    Example 2:

    >>> fib(n = 3)
    >>> 2
    Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2.

    Example 3:

    >>> fib(n = 4)
    >>> 3
    Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3.
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def findBottomLeftValue(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the leftmost value in the last row of the tree.

Example 1:

>>> findBottomLeftValue(root = [2,1,3])
>>> 1

Example 2:

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


Prompt:
def findRotateSteps(ring: str, key: str) -> int:
    """
    In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to spell a specific keyword to open the door.
    Given a string ring that represents the code engraved on the outer ring and another string key that represents the keyword that needs to be spelled, return the minimum number of steps to spell all the characters in the keyword.
    Initially, the first character of the ring is aligned at the "12:00" direction. You should spell all the characters in key one by one by rotating ring clockwise or anticlockwise to make each character of the string key aligned at the "12:00" direction and then by pressing the center button.
    At the stage of rotating the ring to spell the key character key[i]:

    You can rotate the ring clockwise or anticlockwise by one place, which counts as one step. The final purpose of the rotation is to align one of ring's characters at the "12:00" direction, where this character must equal key[i].
    If the character key[i] has been aligned at the "12:00" direction, press the center button to spell, which also counts as one step. After the pressing, you could begin to spell the next character in the key (next stage). Otherwise, you have finished all the spelling.

    Example 1:

    >>> findRotateSteps(ring = "godding", key = "gd")
    >>> 4
    Explanation:
    For the first key character 'g', since it is already in place, we just need 1 step to spell this character.
    For the second key character 'd', we need to rotate the ring "godding" anticlockwise by two steps to make it become "ddinggo".
    Also, we need 1 more step for spelling.
    So the final output is 4.

    Example 2:

    >>> findRotateSteps(ring = "godding", key = "godding")
    >>> 13
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def largestValues(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed).

Example 1:

>>> largestValues(root = [1,3,2,5,3,null,9])
>>> [1,3,9]

Example 2:

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


Prompt:
def longestPalindromeSubseq(s: str) -> int:
    """
    Given a string s, find the longest palindromic subsequence's length in s.
    A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> longestPalindromeSubseq(s = "bbbab")
    >>> 4
    Explanation: One possible longest palindromic subsequence is "bbbb".

    Example 2:

    >>> longestPalindromeSubseq(s = "cbbd")
    >>> 2
    Explanation: One possible longest palindromic subsequence is "bb".
    """


Prompt:
from typing import List
def findMinMoves(machines: List[int]) -> int:
    """
    You have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.
    For each move, you could choose any m (1 <= m <= n) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at the same time.
    Given an integer array machines representing the number of dresses in each washing machine from left to right on the line, return the minimum number of moves to make all the washing machines have the same number of dresses. If it is not possible to do it, return -1.

    Example 1:

    >>> findMinMoves(machines = [1,0,5])
    >>> 3
    Explanation:
    1st move:    1     0 <-- 5    =>    1     1     4
    2nd move:    1 <-- 1 <-- 4    =>    2     1     3
    3rd move:    2     1 <-- 3    =>    2     2     2

    Example 2:

    >>> findMinMoves(machines = [0,3,0])
    >>> 2
    Explanation:
    1st move:    0 <-- 3     0    =>    1     2     0
    2nd move:    1     2 --> 0    =>    1     1     1

    Example 3:

    >>> findMinMoves(machines = [0,2,0])
    >>> -1
    Explanation:
    It's impossible to make all three washing machines have the same number of dresses.
    """


Prompt:
from typing import List
def change(amount: int, coins: List[int]) -> int:
    """
    You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
    Return the number of combinations that make up that amount. If that amount of money cannot be made up by any combination of the coins, return 0.
    You may assume that you have an infinite number of each kind of coin.
    The answer is guaranteed to fit into a signed 32-bit integer.

    Example 1:

    >>> change(amount = 5, coins = [1,2,5])
    >>> 4
    Explanation: there are four ways to make up the amount:
    5=5
    5=2+2+1
    5=2+1+1+1
    5=1+1+1+1+1

    Example 2:

    >>> change(amount = 3, coins = [2])
    >>> 0
    Explanation: the amount of 3 cannot be made up just with coins of 2.

    Example 3:

    >>> change(amount = 10, coins = [10])
    >>> 1
    """


Prompt:
def detectCapitalUse(word: str) -> bool:
    """
    We define the usage of capitals in a word to be right when one of the following cases holds:

    All letters in this word are capitals, like "USA".
    All letters in this word are not capitals, like "leetcode".
    Only the first letter in this word is capital, like "Google".

    Given a string word, return true if the usage of capitals in it is right.

    Example 1:
    >>> detectCapitalUse(word = "USA")
    >>> true
    Example 2:
    >>> detectCapitalUse(word = "FlaG")
    >>> false
    """


Prompt:
def findLUSlength(a: str, b: str) -> int:
    """
    Given two strings a and b, return the length of the longest uncommon subsequence between a and b. If no such uncommon subsequence exists, return -1.
    An uncommon subsequence between two strings is a string that is a subsequence of exactly one of them.

    Example 1:

    >>> findLUSlength(a = "aba", b = "cdc")
    >>> 3
    Explanation: One longest uncommon subsequence is "aba" because "aba" is a subsequence of "aba" but not "cdc".
    Note that "cdc" is also a longest uncommon subsequence.

    Example 2:

    >>> findLUSlength(a = "aaa", b = "bbb")
    >>> 3
    Explanation: The longest uncommon subsequences are "aaa" and "bbb".

    Example 3:

    >>> findLUSlength(a = "aaa", b = "aaa")
    >>> -1
    Explanation: Every subsequence of string a is also a subsequence of string b. Similarly, every subsequence of string b is also a subsequence of string a. So the answer would be -1.
    """


Prompt:
from typing import List
def findLUSlength(strs: List[str]) -> int:
    """
    Given an array of strings strs, return the length of the longest uncommon subsequence between them. If the longest uncommon subsequence does not exist, return -1.
    An uncommon subsequence between an array of strings is a string that is a subsequence of one string but not the others.
    A subsequence of a string s is a string that can be obtained after deleting any number of characters from s.

    For example, "abc" is a subsequence of "aebdc" because you can delete the underlined characters in "aebdc" to get "abc". Other subsequences of "aebdc" include "aebdc", "aeb", and "" (empty string).

    Example 1:
    >>> findLUSlength(strs = ["aba","cdc","eae"])
    >>> 3
    Example 2:
    >>> findLUSlength(strs = ["aaa","aaa","aa"])
    >>> -1
    """


Prompt:
from typing import List
def checkSubarraySum(nums: List[int], k: int) -> bool:
    """
    Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise.
    A good subarray is a subarray where:

    its length is at least two, and
    the sum of the elements of the subarray is a multiple of k.

    Note that:

    A subarray is a contiguous part of the array.
    An integer x is a multiple of k if there exists an integer n such that x = n * k. 0 is always a multiple of k.

    Example 1:

    >>> checkSubarraySum(nums = [23,2,4,6,7], k = 6)
    >>> true
    Explanation: [2, 4] is a continuous subarray of size 2 whose elements sum up to 6.

    Example 2:

    >>> checkSubarraySum(nums = [23,2,6,4,7], k = 6)
    >>> true
    Explanation: [23, 2, 6, 4, 7] is an continuous subarray of size 5 whose elements sum up to 42.
    42 is a multiple of 6 because 42 = 7 * 6 and 7 is an integer.

    Example 3:

    >>> checkSubarraySum(nums = [23,2,6,4,7], k = 13)
    >>> false
    """


Prompt:
from typing import List
def findLongestWord(s: str, dictionary: List[str]) -> str:
    """
    Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.

    Example 1:

    >>> findLongestWord(s = "abpcplea", dictionary = ["ale","apple","monkey","plea"])
    >>> "apple"

    Example 2:

    >>> findLongestWord(s = "abpcplea", dictionary = ["a","b","c"])
    >>> "a"
    """


Prompt:
from typing import List
def findMaxLength(nums: List[int]) -> int:
    """
    Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

    Example 1:

    >>> findMaxLength(nums = [0,1])
    >>> 2
    Explanation: [0, 1] is the longest contiguous subarray with an equal number of 0 and 1.

    Example 2:

    >>> findMaxLength(nums = [0,1,0])
    >>> 2
    Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.

    Example 3:

    >>> findMaxLength(nums = [0,1,1,1,1,1,0,0,0])
    >>> 6
    Explanation: [1,1,1,0,0,0] is the longest contiguous subarray with equal number of 0 and 1.
    """


Prompt:
def countArrangement(n: int) -> int:
    """
    Suppose you have n integers labeled 1 through n. A permutation of those n integers perm (1-indexed) is considered a beautiful arrangement if for every i (1 <= i <= n), either of the following is true:

    perm[i] is divisible by i.
    i is divisible by perm[i].

    Given an integer n, return the number of the beautiful arrangements that you can construct.

    Example 1:

    >>> countArrangement(n = 2)
    >>> 2
    Explanation:
    The first beautiful arrangement is [1,2]:
        - perm[1] = 1 is divisible by i = 1
        - perm[2] = 2 is divisible by i = 2
    The second beautiful arrangement is [2,1]:
        - perm[1] = 2 is divisible by i = 1
        - i = 2 is divisible by perm[2] = 1

    Example 2:

    >>> countArrangement(n = 1)
    >>> 1
    """


Prompt:
from typing import List
def wordsAbbreviation(words: List[str]) -> List[str]:
    """
    Given an array of distinct strings words, return the minimal possible abbreviations for every word.
    The following are the rules for a string abbreviation:

    The initial abbreviation for each word is: the first character, then the number of characters in between, followed by the last character.
    If more than one word shares the same abbreviation, then perform the following operation:

    Increase the prefix (characters in the first part) of each of their abbreviations by 1.

    For example, say you start with the words ["abcdef","abndef"] both initially abbreviated as "a4f". Then, a sequence of operations would be ["a4f","a4f"] -> ["ab3f","ab3f"] -> ["abc2f","abn2f"].

    This operation is repeated until every abbreviation is unique.

    At the end, if an abbreviation did not make a word shorter, then keep it as the original word.

    Example 1:
    >>> wordsAbbreviation(words = ["like","god","internal","me","internet","interval","intension","face","intrusion"])
    >>> ["l2e","god","internal","me","i6t","interval","inte4n","f2e","intr4n"]
    Example 2:
    >>> wordsAbbreviation(words = ["aa","aaa"])
    >>> ["aa","aaa"]
    """


Prompt:
from typing import List
def updateBoard(board: List[List[str]], click: List[int]) -> List[List[str]]:
    """
    Let's play the minesweeper game (Wikipedia, online game)!
    You are given an m x n char matrix board representing the game board where:

    'M' represents an unrevealed mine,
    'E' represents an unrevealed empty square,
    'B' represents a revealed blank square that has no adjacent mines (i.e., above, below, left, right, and all 4 diagonals),
    digit ('1' to '8') represents how many mines are adjacent to this revealed square, and
    'X' represents a revealed mine.

    You are also given an integer array click where click = [clickr, clickc] represents the next click position among all the unrevealed squares ('M' or 'E').
    Return the board after revealing this position according to the following rules:

    If a mine 'M' is revealed, then the game is over. You should change it to 'X'.
    If an empty square 'E' with no adjacent mines is revealed, then change it to a revealed blank 'B' and all of its adjacent unrevealed squares should be revealed recursively.
    If an empty square 'E' with at least one adjacent mine is revealed, then change it to a digit ('1' to '8') representing the number of adjacent mines.
    Return the board when no more squares will be revealed.

    Example 1:

    >>> updateBoard(board = [["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]], click = [3,0])
    >>> [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]

    Example 2:

    >>> updateBoard(board = [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]], click = [1,2])
    >>> [["B","1","E","1","B"],["B","1","X","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def getMinimumDifference(root: Optional[TreeNode]) -> int:
"""
Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree.

Example 1:

>>> getMinimumDifference(root = [4,2,6,1,3])
>>> 1

Example 2:

>>> getMinimumDifference(root = [1,0,48,null,null,12,49])
>>> 1
"""


Prompt:
from typing import List
def findLonelyPixel(picture: List[List[str]]) -> int:
    """
    Given an m x n picture consisting of black 'B' and white 'W' pixels, return the number of black lonely pixels.
    A black lonely pixel is a character 'B' that located at a specific position where the same row and same column don't have any other black pixels.

    Example 1:

    >>> findLonelyPixel(picture = [["W","W","B"],["W","B","W"],["B","W","W"]])
    >>> 3
    Explanation: All the three 'B's are black lonely pixels.

    Example 2:

    >>> findLonelyPixel(picture = [["B","B","B"],["B","B","W"],["B","B","B"]])
    >>> 0
    """


Prompt:
from typing import List
def findPairs(nums: List[int], k: int) -> int:
    """
    Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
    A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:

    0 <= i, j < nums.length
    i != j
    |nums[i] - nums[j]| == k

    Notice that |val| denotes the absolute value of val.

    Example 1:

    >>> findPairs(nums = [3,1,4,1,5], k = 2)
    >>> 2
    Explanation: There are two 2-diff pairs in the array, (1, 3) and (3, 5).
    Although we have two 1s in the input, we should only return the number of unique pairs.

    Example 2:

    >>> findPairs(nums = [1,2,3,4,5], k = 1)
    >>> 4
    Explanation: There are four 1-diff pairs in the array, (1, 2), (2, 3), (3, 4) and (4, 5).

    Example 3:

    >>> findPairs(nums = [1,3,1,5,4], k = 0)
    >>> 1
    Explanation: There is one 0-diff pair in the array, (1, 1).
    """


Prompt:
from typing import List
def findBlackPixel(picture: List[List[str]], target: int) -> int:
    """
    Given an m x n picture consisting of black 'B' and white 'W' pixels and an integer target, return the number of black lonely pixels.
    A black lonely pixel is a character 'B' that located at a specific position (r, c) where:

    Row r and column c both contain exactly target black pixels.
    For all rows that have a black pixel at column c, they should be exactly the same as row r.

    Example 1:

    >>> findBlackPixel(picture = [["W","B","W","B","B","W"],["W","B","W","B","B","W"],["W","B","W","B","B","W"],["W","W","B","W","B","W"]], target = 3)
    >>> 6
    Explanation: All the green 'B' are the black pixels we need (all 'B's at column 1 and 3).
    Take 'B' at row r = 0 and column c = 1 as an example:
     - Rule 1, row r = 0 and column c = 1 both have exactly target = 3 black pixels.
     - Rule 2, the rows have black pixel at column c = 1 are row 0, row 1 and row 2. They are exactly the same as row r = 0.

    Example 2:

    >>> findBlackPixel(picture = [["W","W","B"],["W","W","B"],["W","W","B"]], target = 1)
    >>> 0
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def str2tree(s: str) -> Optional[TreeNode]:
"""
You need to construct a binary tree from a string consisting of parenthesis and integers.
The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root's value and a pair of parenthesis contains a child binary tree with the same structure.
You always start to construct the left child node of the parent first if it exists.

Example 1:

>>> str2tree(s = "4(2(3)(1))(6(5))")
>>> [4,2,6,3,1,5]

Example 2:

>>> str2tree(s = "4(2(3)(1))(6(5)(7))")
>>> [4,2,6,3,1,5,7]

Example 3:

>>> str2tree(s = "-4(2(3)(1))(6(5)(7))")
>>> [-4,2,6,3,1,5,7]
"""


Prompt:
def complexNumberMultiply(num1: str, num2: str) -> str:
    """
    A complex number can be represented as a string on the form "real+imaginaryi" where:

    real is the real part and is an integer in the range [-100, 100].
    imaginary is the imaginary part and is an integer in the range [-100, 100].
    i2 == -1.

    Given two complex numbers num1 and num2 as strings, return a string of the complex number that represents their multiplications.

    Example 1:

    >>> complexNumberMultiply(num1 = "1+1i", num2 = "1+1i")
    >>> "0+2i"
    Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i.

    Example 2:

    >>> complexNumberMultiply(num1 = "1+-1i", num2 = "1+-1i")
    >>> "0+-2i"
    Explanation: (1 - i) * (1 - i) = 1 + i2 - 2 * i = -2i, and you need convert it to the form of 0+-2i.
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def convertBST(root: Optional[TreeNode]) -> Optional[TreeNode]:
"""
Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.
As a reminder, a binary search tree is a tree that satisfies these constraints:

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

Example 1:

>>> convertBST(root = [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8])
>>> [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8]

Example 2:

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


Prompt:
from typing import List
def findMinDifference(timePoints: List[str]) -> int:
    """
    Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list.

    Example 1:
    >>> findMinDifference(timePoints = ["23:59","00:00"])
    >>> 1
    Example 2:
    >>> findMinDifference(timePoints = ["00:00","23:59","00:00"])
    >>> 0
    """


Prompt:
from typing import List
def singleNonDuplicate(nums: List[int]) -> int:
    """
    You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
    Return the single element that appears only once.
    Your solution must run in O(log n) time and O(1) space.

    Example 1:
    >>> singleNonDuplicate(nums = [1,1,2,3,3,4,4,8,8])
    >>> 2
    Example 2:
    >>> singleNonDuplicate(nums = [3,3,7,7,10,11,11])
    >>> 10
    """


Prompt:
def reverseStr(s: str, k: int) -> str:
    """
    Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string.
    If there are fewer than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and leave the other as original.

    Example 1:
    >>> reverseStr(s = "abcdefg", k = 2)
    >>> "bacdfeg"
    Example 2:
    >>> reverseStr(s = "abcd", k = 2)
    >>> "bacd"
    """


Prompt:
from typing import List
def updateMatrix(mat: List[List[int]]) -> List[List[int]]:
    """
    Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
    The distance between two cells sharing a common edge is 1.

    Example 1:

    >>> updateMatrix(mat = [[0,0,0],[0,1,0],[0,0,0]])
    >>> [[0,0,0],[0,1,0],[0,0,0]]

    Example 2:

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


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def diameterOfBinaryTree(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the length of the diameter of the tree.
The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
The length of a path between two nodes is represented by the number of edges between them.

Example 1:

>>> diameterOfBinaryTree(root = [1,2,3,4,5])
>>> 3
Explanation: 3 is the length of the path [4,2,1,3] or [5,2,1,3].

Example 2:

>>> diameterOfBinaryTree(root = [1,2])
>>> 1
"""


Prompt:
def findContestMatch(n: int) -> str:
    """
    During the NBA playoffs, we always set the rather strong team to play with the rather weak team, like making the rank 1 team play with the rank nth team, which is a good strategy to make the contest more interesting.
    Given n teams, return their final contest matches in the form of a string.
    The n teams are labeled from 1 to n, which represents their initial rank (i.e., Rank 1 is the strongest team and Rank n is the weakest team).
    We will use parentheses '(', and ')' and commas ',' to represent the contest team pairing. We use the parentheses for pairing and the commas for partition. During the pairing process in each round, you always need to follow the strategy of making the rather strong one pair with the rather weak one.

    Example 1:

    >>> findContestMatch(n = 4)
    >>> "((1,4),(2,3))"
    Explanation:
    In the first round, we pair the team 1 and 4, the teams 2 and 3 together, as we need to make the strong team and weak team together.
    And we got (1, 4),(2, 3).
    In the second round, the winners of (1, 4) and (2, 3) need to play again to generate the final winner, so you need to add the paratheses outside them.
    And we got the final answer ((1,4),(2,3)).

    Example 2:

    >>> findContestMatch(n = 8)
    >>> "(((1,8),(4,5)),((2,7),(3,6)))"
    Explanation:
    First round: (1, 8),(2, 7),(3, 6),(4, 5)
    Second round: ((1, 8),(4, 5)),((2, 7),(3, 6))
    Third round: (((1, 8),(4, 5)),((2, 7),(3, 6)))
    Since the third round will generate the final winner, you need to output the answer (((1,8),(4,5)),((2,7),(3,6))).
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def boundaryOfBinaryTree(root: Optional[TreeNode]) -> List[int]:
"""
The boundary of a binary tree is the concatenation of the root, the left boundary, the leaves ordered from left-to-right, and the reverse order of the right boundary.
The left boundary is the set of nodes defined by the following:

The root node's left child is in the left boundary. If the root does not have a left child, then the left boundary is empty.
If a node in the left boundary and has a left child, then the left child is in the left boundary.
If a node is in the left boundary, has no left child, but has a right child, then the right child is in the left boundary.
The leftmost leaf is not in the left boundary.

The right boundary is similar to the left boundary, except it is the right side of the root's right subtree. Again, the leaf is not part of the right boundary, and the right boundary is empty if the root does not have a right child.
The leaves are nodes that do not have any children. For this problem, the root is not a leaf.
Given the root of a binary tree, return the values of its boundary.

Example 1:

>>> boundaryOfBinaryTree(root = [1,null,2,3,4])
>>> [1,3,4,2]
Explanation:
- The left boundary is empty because the root does not have a left child.
- The right boundary follows the path starting from the root's right child 2 -> 4.
  4 is a leaf, so the right boundary is [2].
- The leaves from left to right are [3,4].
Concatenating everything results in [1] + [] + [3,4] + [2] = [1,3,4,2].

Example 2:

>>> boundaryOfBinaryTree(root = [1,2,3,4,5,6,null,null,null,7,8,9,10])
>>> [1,2,4,7,8,9,10,6,3]
Explanation:
- The left boundary follows the path starting from the root's left child 2 -> 4.
  4 is a leaf, so the left boundary is [2].
- The right boundary follows the path starting from the root's right child 3 -> 6 -> 10.
  10 is a leaf, so the right boundary is [3,6], and in reverse order is [6,3].
- The leaves from left to right are [4,7,8,9,10].
Concatenating everything results in [1] + [2] + [4,7,8,9,10] + [6,3] = [1,2,4,7,8,9,10,6,3].
"""


Prompt:
from typing import List
def removeBoxes(boxes: List[int]) -> int:
    """
    You are given several boxes with different colors represented by different positive numbers.
    You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (i.e., composed of k boxes, k >= 1), remove them and get k * k points.
    Return the maximum points you can get.

    Example 1:

    >>> removeBoxes(boxes = [1,3,2,2,2,3,4,3,1])
    >>> 23
    Explanation:
    [1, 3, 2, 2, 2, 3, 4, 3, 1]
    ----> [1, 3, 3, 4, 3, 1] (3*3=9 points)
    ----> [1, 3, 3, 3, 1] (1*1=1 points)
    ----> [1, 1] (3*3=9 points)
    ----> [] (2*2=4 points)

    Example 2:

    >>> removeBoxes(boxes = [1,1,1])
    >>> 9

    Example 3:

    >>> removeBoxes(boxes = [1])
    >>> 1
    """


Prompt:
from typing import List
def findCircleNum(isConnected: List[List[int]]) -> int:
    """
    There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c.
    A province is a group of directly or indirectly connected cities and no other cities outside of the group.
    You are given an n x n matrix isConnected where isConnected[i][j] = 1 if the ith city and the jth city are directly connected, and isConnected[i][j] = 0 otherwise.
    Return the total number of provinces.

    Example 1:

    >>> findCircleNum(isConnected = [[1,1,0],[1,1,0],[0,0,1]])
    >>> 2

    Example 2:

    >>> findCircleNum(isConnected = [[1,0,0],[0,1,0],[0,0,1]])
    >>> 3
    """


Prompt:
from typing import List
def splitArray(nums: List[int]) -> bool:
    """
    Given an integer array nums of length n, return true if there is a triplet (i, j, k) which satisfies the following conditions:

    0 < i, i + 1 < j, j + 1 < k < n - 1
    The sum of subarrays (0, i - 1), (i + 1, j - 1), (j + 1, k - 1) and (k + 1, n - 1) is equal.

    A subarray (l, r) represents a slice of the original array starting from the element indexed l to the element indexed r.

    Example 1:

    >>> splitArray(nums = [1,2,1,2,1,2,1])
    >>> true
    Explanation:
    i = 1, j = 3, k = 5.
    sum(0, i - 1) = sum(0, 0) = 1
    sum(i + 1, j - 1) = sum(2, 2) = 1
    sum(j + 1, k - 1) = sum(4, 4) = 1
    sum(k + 1, n - 1) = sum(6, 6) = 1

    Example 2:

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


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def longestConsecutive(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the length of the longest consecutive path in the tree.
A consecutive path is a path where the values of the consecutive nodes in the path differ by one. This path can be either increasing or decreasing.

For example, [1,2,3,4] and [4,3,2,1] are both considered valid, but the path [1,2,4,3] is not valid.

On the other hand, the path can be in the child-Parent-child order, where not necessarily be parent-child order.

Example 1:

>>> longestConsecutive(root = [1,2,3])
>>> 2
Explanation: The longest consecutive path is [1, 2] or [2, 1].

Example 2:

>>> longestConsecutive(root = [2,1,3])
>>> 3
Explanation: The longest consecutive path is [1, 2, 3] or [3, 2, 1].
"""


Prompt:
def checkRecord(s: str) -> bool:
    """
    You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

    'A': Absent.
    'L': Late.
    'P': Present.

    The student is eligible for an attendance award if they meet both of the following criteria:

    The student was absent ('A') for strictly fewer than 2 days total.
    The student was never late ('L') for 3 or more consecutive days.

    Return true if the student is eligible for an attendance award, or false otherwise.

    Example 1:

    >>> checkRecord(s = "PPALLP")
    >>> true
    Explanation: The student has fewer than 2 absences and was never late 3 or more consecutive days.

    Example 2:

    >>> checkRecord(s = "PPALLL")
    >>> false
    Explanation: The student was late 3 consecutive days in the last 3 days, so is not eligible for the award.
    """


Prompt:
from typing import Any
def checkRecord(n: int) -> int:
    """
    An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:

    'A': Absent.
    'L': Late.
    'P': Present.

    Any student is eligible for an attendance award if they meet both of the following criteria:

    The student was absent ('A') for strictly fewer than 2 days total.
    The student was never late ('L') for 3 or more consecutive days.

    Given an integer n, return the number of possible attendance records of length n that make a student eligible for an attendance award. The answer may be very large, so return it modulo 109 + 7.

    Example 1:

    >>> checkRecord(n = 2)
    >>> 8
    Explanation: There are 8 records with length 2 that are eligible for an award:
    "PP", "AP", "PA", "LP", "PL", "AL", "LA", "LL"
    Only "AA" is not eligible because there are 2 absences (there need to be fewer than 2).

    Example 2:

    >>> checkRecord(n = 1)
    >>> 3

    Example 3:

    >>> checkRecord(n = 10101)
    >>> 183236316
    """


Prompt:
from typing import List
def optimalDivision(nums: List[int]) -> str:
    """
    You are given an integer array nums. The adjacent integers in nums will perform the float division.

    For example, for nums = [2,3,4], we will evaluate the expression "2/3/4".

    However, you can add any number of parenthesis at any position to change the priority of operations. You want to add these parentheses such the value of the expression after the evaluation is maximum.
    Return the corresponding expression that has the maximum value in string format.
    Note: your expression should not contain redundant parenthesis.

    Example 1:

    >>> optimalDivision(nums = [1000,100,10,2])
    >>> "1000/(100/10/2)"
    Explanation: 1000/(100/10/2) = 1000/((100/10)/2) = 200
    However, the bold parenthesis in "1000/((100/10)/2)" are redundant since they do not influence the operation priority.
    So you should return "1000/(100/10/2)".
    Other cases:
    1000/(100/10)/2 = 50
    1000/(100/(10/2)) = 50
    1000/100/10/2 = 0.5
    1000/100/(10/2) = 2

    Example 2:

    >>> optimalDivision(nums = [2,3,4])
    >>> "2/(3/4)"
    Explanation: (2/(3/4)) = 8/3 = 2.667
    It can be shown that after trying all possibilities, we cannot get an expression with evaluation greater than 2.667
    """


Prompt:
from typing import List
def leastBricks(wall: List[List[int]]) -> int:
    """
    There is a rectangular brick wall in front of you with n rows of bricks. The ith row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.
    Draw a vertical line from the top to the bottom and cross the least bricks. If your line goes through the edge of a brick, then the brick is not considered as crossed. You cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks.
    Given the 2D array wall that contains the information about the wall, return the minimum number of crossed bricks after drawing such a vertical line.

    Example 1:

    >>> leastBricks(wall = [[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]])
    >>> 2

    Example 2:

    >>> leastBricks(wall = [[1],[1],[1]])
    >>> 3
    """


Prompt:
from typing import List
def splitLoopedString(strs: List[str]) -> str:
    """
    You are given an array of strings strs. You could concatenate these strings together into a loop, where for each string, you could choose to reverse it or not. Among all the possible loops
    Return the lexicographically largest string after cutting the loop, which will make the looped string into a regular one.
    Specifically, to find the lexicographically largest string, you need to experience two phases:

    Concatenate all the strings into a loop, where you can reverse some strings or not and connect them in the same order as given.
    Cut and make one breakpoint in any place of the loop, which will make the looped string into a regular one starting from the character at the cutpoint.

    And your job is to find the lexicographically largest one among all the possible regular strings.

    Example 1:

    >>> splitLoopedString(strs = ["abc","xyz"])
    >>> "zyxcba"
    Explanation: You can get the looped string "-abcxyz-", "-abczyx-", "-cbaxyz-", "-cbazyx-", where '-' represents the looped status.
    The answer string came from the fourth looped one, where you could cut from the middle character 'a' and get "zyxcba".

    Example 2:

    >>> splitLoopedString(strs = ["abc"])
    >>> "cba"
    """


Prompt:
def nextGreaterElement(n: int) -> int:
    """
    Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1.
    Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, return -1.

    Example 1:
    >>> nextGreaterElement(n = 12)
    >>> 21
    Example 2:
    >>> nextGreaterElement(n = 21)
    >>> -1
    """


Prompt:
def reverseWords(s: str) -> str:
    """
    Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.

    Example 1:

    >>> reverseWords(s = "Let's take LeetCode contest")
    >>> "s'teL ekat edoCteeL tsetnoc"

    Example 2:

    >>> reverseWords(s = "Mr Ding")
    >>> "rM gniD"
    """


Prompt:
from typing import List
def subarraySum(nums: List[int], k: int) -> int:
    """
    Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:
    >>> subarraySum(nums = [1,1,1], k = 2)
    >>> 2
    Example 2:
    >>> subarraySum(nums = [1,2,3], k = 3)
    >>> 2
    """