Prompt:
def minimumOperations(nums: List[int], start: int, goal: int) -> int:
    """
    You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:
    If 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:

    x + nums[i]
    x - nums[i]
    x ^ nums[i] (bitwise-XOR)

    Note that you can use each nums[i] any number of times in any order. Operations that set x to be out of the range 0 <= x <= 1000 are valid, but no more operations can be done afterward.
    Return the minimum number of operations needed to convert x = start into goal, and -1 if it is not possible.

    Example 1:

    >>> minimumOperations(nums = [2,4,12], start = 2, goal = 12)
    >>> 2
    Explanation: We can go from 2 → 14 → 12 with the following 2 operations.
    - 2 + 12 = 14
    - 14 - 2 = 12

    Example 2:

    >>> minimumOperations(nums = [3,5,7], start = 0, goal = -4)
    >>> 2
    Explanation: We can go from 0 → 3 → -4 with the following 2 operations.
    - 0 + 3 = 3
    - 3 - 7 = -4
    Note that the last operation sets x out of the range 0 <= x <= 1000, which is valid.

    Example 3:

    >>> minimumOperations(nums = [2,8,16], start = 0, goal = 1)
    >>> -1
    Explanation: There is no way to convert 0 into 1.
    """


Prompt:
def possiblyEquals(s1: str, s2: str) -> bool:
    """
    An original string, consisting of lowercase English letters, can be encoded by the following steps:

    Arbitrarily split it into a sequence of some number of non-empty substrings.
    Arbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).
    Concatenate the sequence as the encoded string.

    For example, one way to encode an original string "abcdefghijklmnop" might be:

    Split it as a sequence: ["ab", "cdefghijklmn", "o", "p"].
    Choose the second and third elements to be replaced by their lengths, respectively. The sequence becomes ["ab", "12", "1", "p"].
    Concatenate the elements of the sequence to get the encoded string: "ab121p".

    Given two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 (inclusive), return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.
    Note: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.

    Example 1:

    >>> possiblyEquals(s1 = "internationalization", s2 = "i18n")
    >>> true
    Explanation: It is possible that "internationalization" was the original string.
    - "internationalization"
      -> Split:       ["internationalization"]
      -> Do not replace any element
      -> Concatenate:  "internationalization", which is s1.
    - "internationalization"
      -> Split:       ["i", "nternationalizatio", "n"]
      -> Replace:     ["i", "18",                 "n"]
      -> Concatenate:  "i18n", which is s2

    Example 2:

    >>> possiblyEquals(s1 = "l123e", s2 = "44")
    >>> true
    Explanation: It is possible that "leetcode" was the original string.
    - "leetcode"
      -> Split:      ["l", "e", "et", "cod", "e"]
      -> Replace:    ["l", "1", "2",  "3",   "e"]
      -> Concatenate: "l123e", which is s1.
    - "leetcode"
      -> Split:      ["leet", "code"]
      -> Replace:    ["4",    "4"]
      -> Concatenate: "44", which is s2.

    Example 3:

    >>> possiblyEquals(s1 = "a5b", s2 = "c5b")
    >>> false
    Explanation: It is impossible.
    - The original string encoded as s1 must start with the letter 'a'.
    - The original string encoded as s2 must start with the letter 'c'.
    """


Prompt:
def numberOfCleanRooms(room: List[List[int]]) -> int:
    """
    A room is represented by a 0-indexed 2D binary matrix room where a 0 represents an empty space and a 1 represents a space with an object. The top left corner of the room will be empty in all test cases.
    A cleaning robot starts at the top left corner of the room and is facing right. The robot will continue heading straight until it reaches the edge of the room or it hits an object, after which it will turn 90 degrees clockwise and repeat this process. The starting space and all spaces that the robot visits are cleaned by it.
    Return the number of clean spaces in the room if the robot runs indefinitely.

    Example 1:

    >>> numberOfCleanRooms(room = [[0,0,0],[1,1,0],[0,0,0]])
    >>> 7
    Explanation:

    The robot cleans the spaces at (0, 0), (0, 1), and (0, 2).
    The robot is at the edge of the room, so it turns 90 degrees clockwise and now faces down.
    The robot cleans the spaces at (1, 2), and (2, 2).
    The robot is at the edge of the room, so it turns 90 degrees clockwise and now faces left.
    The robot cleans the spaces at (2, 1), and (2, 0).
    The robot has cleaned all 7 empty spaces, so return 7.

    Example 2:

    >>> numberOfCleanRooms(room = [[0,1,0],[1,0,0],[0,0,0]])
    >>> 1
    Explanation:

    The robot cleans the space at (0, 0).
    The robot hits an object, so it turns 90 degrees clockwise and now faces down.
    The robot hits an object, so it turns 90 degrees clockwise and now faces left.
    The robot is at the edge of the room, so it turns 90 degrees clockwise and now faces up.
    The robot is at the edge of the room, so it turns 90 degrees clockwise and now faces right.
    The robot is back at its starting position.
    The robot has cleaned 1 space, so return 1.

    Example 3:

    >>> numberOfCleanRooms(room = [[0,0,0],[0,0,0],[0,0,0]])
    >>> 8
    """


Prompt:
def countVowelSubstrings(word: str) -> int:
    """
    A substring is a contiguous (non-empty) sequence of characters within a string.
    A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.
    Given a string word, return the number of vowel substrings in word.

    Example 1:

    >>> countVowelSubstrings(word = "aeiouu")
    >>> 2
    Explanation: The vowel substrings of word are as follows (underlined):
    - "aeiouu"
    - "aeiouu"

    Example 2:

    >>> countVowelSubstrings(word = "unicornarihan")
    >>> 0
    Explanation: Not all 5 vowels are present, so there are no vowel substrings.

    Example 3:

    >>> countVowelSubstrings(word = "cuaieuouac")
    >>> 7
    Explanation: The vowel substrings of word are as follows (underlined):
    - "cuaieuouac"
    - "cuaieuouac"
    - "cuaieuouac"
    - "cuaieuouac"
    - "cuaieuouac"
    - "cuaieuouac"
    - "cuaieuouac"
    """


Prompt:
def countVowels(word: str) -> int:
    """
    Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.
    A substring is a contiguous (non-empty) sequence of characters within a string.
    Note: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.

    Example 1:

    >>> countVowels(word = "aba")
    >>> 6
    Explanation:
    All possible substrings are: "a", "ab", "aba", "b", "ba", and "a".
    - "b" has 0 vowels in it
    - "a", "ab", "ba", and "a" have 1 vowel each
    - "aba" has 2 vowels in it
    Hence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6.

    Example 2:

    >>> countVowels(word = "abc")
    >>> 3
    Explanation:
    All possible substrings are: "a", "ab", "abc", "b", "bc", and "c".
    - "a", "ab", and "abc" have 1 vowel each
    - "b", "bc", and "c" have 0 vowels each
    Hence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.

    Example 3:

    >>> countVowels(word = "ltcd")
    >>> 0
    Explanation: There are no vowels in any substring of "ltcd".
    """


Prompt:
def minimizedMaximum(n: int, quantities: List[int]) -> int:
    """
    You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.
    You need to distribute all products to the retail stores following these rules:

    A store can only be given at most one product type but can be given any amount of it.
    After distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.

    Return the minimum possible x.

    Example 1:

    >>> minimizedMaximum(n = 6, quantities = [11,6])
    >>> 3
    Explanation: One optimal way is:
    - The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3
    - The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3
    The maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.

    Example 2:

    >>> minimizedMaximum(n = 7, quantities = [15,10,10])
    >>> 5
    Explanation: One optimal way is:
    - The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5
    - The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5
    - The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5
    The maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.

    Example 3:

    >>> minimizedMaximum(n = 1, quantities = [100000])
    >>> 100000
    Explanation: The only optimal way is:
    - The 100000 products of type 0 are distributed to the only store.
    The maximum number of products given to any store is max(100000) = 100000.
    """


Prompt:
def maximalPathQuality(values: List[int], edges: List[List[int]], maxTime: int) -> int:
    """
    There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [uj, vj, timej] indicates that there is an undirected edge between the nodes uj and vj, and it takes timej seconds to travel between the two nodes. Finally, you are given an integer maxTime.
    A valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).
    Return the maximum quality of a valid path.
    Note: There are at most four edges connected to each node.

    Example 1:

    >>> maximalPathQuality(values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49)
    >>> 75
    Explanation:
    One possible path is 0 -> 1 -> 0 -> 3 -> 0. The total time taken is 10 + 10 + 10 + 10 = 40 <= 49.
    The nodes visited are 0, 1, and 3, giving a maximal path quality of 0 + 32 + 43 = 75.

    Example 2:

    >>> maximalPathQuality(values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30)
    >>> 25
    Explanation:
    One possible path is 0 -> 3 -> 0. The total time taken is 10 + 10 = 20 <= 30.
    The nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25.

    Example 3:

    >>> maximalPathQuality(values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50)
    >>> 7
    Explanation:
    One possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50.
    The nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.
    """


Prompt:
def equalCountSubstrings(s: str, count: int) -> int:
    """
    You are given a 0-indexed string s consisting of only lowercase English letters, and an integer count. A substring of s is said to be an equal count substring if, for each unique letter in the substring, it appears exactly count times in the substring.
    Return the number of equal count substrings in s.
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    >>> equalCountSubstrings(s = "aaabcbbcc", count = 3)
    >>> 3
    Explanation:
    The substring that starts at index 0 and ends at index 2 is "aaa".
    The letter 'a' in the substring appears exactly 3 times.
    The substring that starts at index 3 and ends at index 8 is "bcbbcc".
    The letters 'b' and 'c' in the substring appear exactly 3 times.
    The substring that starts at index 0 and ends at index 8 is "aaabcbbcc".
    The letters 'a', 'b', and 'c' in the substring appear exactly 3 times.

    Example 2:

    >>> equalCountSubstrings(s = "abcd", count = 2)
    >>> 0
    Explanation:
    The number of times each letter appears in s is less than count.
    Therefore, no substrings in s are equal count substrings, so return 0.

    Example 3:

    >>> equalCountSubstrings(s = "a", count = 5)
    >>> 0
    Explanation:
    The number of times each letter appears in s is less than count.
    Therefore, no substrings in s are equal count substrings, so return 0
    """


Prompt:
def checkAlmostEquivalent(word1: str, word2: str) -> bool:
    """
    Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.
    Given two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.
    The frequency of a letter x is the number of times it occurs in the string.

    Example 1:

    >>> checkAlmostEquivalent(word1 = "aaaa", word2 = "bccb")
    >>> false
    Explanation: There are 4 'a's in "aaaa" but 0 'a's in "bccb".
    The difference is 4, which is more than the allowed 3.

    Example 2:

    >>> checkAlmostEquivalent(word1 = "abcdeef", word2 = "abaaacc")
    >>> true
    Explanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:
    - 'a' appears 1 time in word1 and 4 times in word2. The difference is 3.
    - 'b' appears 1 time in word1 and 1 time in word2. The difference is 0.
    - 'c' appears 1 time in word1 and 2 times in word2. The difference is 1.
    - 'd' appears 1 time in word1 and 0 times in word2. The difference is 1.
    - 'e' appears 2 times in word1 and 0 times in word2. The difference is 2.
    - 'f' appears 1 time in word1 and 0 times in word2. The difference is 1.

    Example 3:

    >>> checkAlmostEquivalent(word1 = "cccddabba", word2 = "babababab")
    >>> true
    Explanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:
    - 'a' appears 2 times in word1 and 4 times in word2. The difference is 2.
    - 'b' appears 2 times in word1 and 5 times in word2. The difference is 3.
    - 'c' appears 3 times in word1 and 0 times in word2. The difference is 3.
    - 'd' appears 2 times in word1 and 0 times in word2. The difference is 2.
    """


Prompt:
def maximumBeauty(items: List[List[int]], queries: List[int]) -> List[int]:
    """
    You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.
    You are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.
    Return an array answer of the same length as queries where answer[j] is the answer to the jth query.

    Example 1:

    >>> maximumBeauty(items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6])
    >>> [2,4,5,5,6,6]
    Explanation:
    - For queries[0]=1, [1,2] is the only item which has price <= 1. Hence, the answer for this query is 2.
    - For queries[1]=2, the items which can be considered are [1,2] and [2,4].
      The maximum beauty among them is 4.
    - For queries[2]=3 and queries[3]=4, the items which can be considered are [1,2], [3,2], [2,4], and [3,5].
      The maximum beauty among them is 5.
    - For queries[4]=5 and queries[5]=6, all items can be considered.
      Hence, the answer for them is the maximum beauty of all items, i.e., 6.

    Example 2:

    >>> maximumBeauty(items = [[1,2],[1,2],[1,3],[1,4]], queries = [1])
    >>> [4]
    Explanation:
    The price of every item is equal to 1, so we choose the item with the maximum beauty 4.
    Note that multiple items can have the same price and/or beauty.

    Example 3:

    >>> maximumBeauty(items = [[10,1000]], queries = [5])
    >>> [0]
    Explanation:
    No item has a price less than or equal to 5, so no item can be chosen.
    Hence, the answer to the query is 0.
    """


Prompt:
def maxTaskAssign(tasks: List[int], workers: List[int], pills: int, strength: int) -> int:
    """
    You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).
    Additionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.
    Given the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.

    Example 1:

    >>> maxTaskAssign(tasks = [3,2,1], workers = [0,3,3], pills = 1, strength = 1)
    >>> 3
    Explanation:
    We can assign the magical pill and tasks as follows:
    - Give the magical pill to worker 0.
    - Assign worker 0 to task 2 (0 + 1 >= 1)
    - Assign worker 1 to task 1 (3 >= 2)
    - Assign worker 2 to task 0 (3 >= 3)

    Example 2:

    >>> maxTaskAssign(tasks = [5,4], workers = [0,0,0], pills = 1, strength = 5)
    >>> 1
    Explanation:
    We can assign the magical pill and tasks as follows:
    - Give the magical pill to worker 0.
    - Assign worker 0 to task 0 (0 + 5 >= 5)

    Example 3:

    >>> maxTaskAssign(tasks = [10,15,30], workers = [0,10,10,10,10], pills = 3, strength = 10)
    >>> 2
    Explanation:
    We can assign the magical pills and tasks as follows:
    - Give the magical pill to worker 0 and worker 1.
    - Assign worker 0 to task 0 (0 + 10 >= 10)
    - Assign worker 1 to task 1 (10 + 10 >= 15)
    The last pill is not given because it will not make any worker strong enough for the last task.
    """


Prompt:
def timeRequiredToBuy(tickets: List[int], k: int) -> int:
    """
    There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.
    You are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i].
    Each person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.
    Return the time taken for the person initially at position k (0-indexed) to finish buying tickets.

    Example 1:

    >>> timeRequiredToBuy(tickets = [2,3,2], k = 2)
    >>> 6
    Explanation:

    The queue starts as [2,3,2], where the kth person is underlined.
    After the person at the front has bought a ticket, the queue becomes [3,2,1] at 1 second.
    Continuing this process, the queue becomes [2,1,2] at 2 seconds.
    Continuing this process, the queue becomes [1,2,1] at 3 seconds.
    Continuing this process, the queue becomes [2,1] at 4 seconds. Note: the person at the front left the queue.
    Continuing this process, the queue becomes [1,1] at 5 seconds.
    Continuing this process, the queue becomes [1] at 6 seconds. The kth person has bought all their tickets, so return 6.

    Example 2:

    >>> timeRequiredToBuy(tickets = [5,1,1,1], k = 0)
    >>> 8
    Explanation:

    The queue starts as [5,1,1,1], where the kth person is underlined.
    After the person at the front has bought a ticket, the queue becomes [1,1,1,4] at 1 second.
    Continuing this process for 3 seconds, the queue becomes [4] at 4 seconds.
    Continuing this process for 4 seconds, the queue becomes [] at 8 seconds. The kth person has bought all their tickets, so return 8.
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def reverseEvenLengthGroups(head: Optional[ListNode]) -> Optional[ListNode]:
    """
    You are given the head of a linked list.
    The nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words,

    The 1st node is assigned to the first group.
    The 2nd and the 3rd nodes are assigned to the second group.
    The 4th, 5th, and 6th nodes are assigned to the third group, and so on.

    Note that the length of the last group may be less than or equal to 1 + the length of the second to last group.
    Reverse the nodes in each group with an even length, and return the head of the modified linked list.

    Example 1:

    >>> __init__(head = [5,2,6,3,9,1,7,3,8,4])
    >>> [5,6,2,3,9,1,4,8,3,7]
    Explanation:
    - The length of the first group is 1, which is odd, hence no reversal occurs.
    - The length of the second group is 2, which is even, hence the nodes are reversed.
    - The length of the third group is 3, which is odd, hence no reversal occurs.
    - The length of the last group is 4, which is even, hence the nodes are reversed.

    Example 2:

    >>> __init__(head = [1,1,0,6])
    >>> [1,0,1,6]
    Explanation:
    - The length of the first group is 1. No reversal occurs.
    - The length of the second group is 2. The nodes are reversed.
    - The length of the last group is 1. No reversal occurs.

    Example 3:

    >>> __init__(head = [1,1,0,6,5])
    >>> [1,0,1,5,6]
    Explanation:
    - The length of the first group is 1. No reversal occurs.
    - The length of the second group is 2. The nodes are reversed.
    - The length of the last group is 2. The nodes are reversed.
    """


Prompt:
def decodeCiphertext(encodedText: str, rows: int) -> str:
    """
    A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.
    originalText is placed first in a top-left to bottom-right manner.

    The blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.
    encodedText is then formed by appending all characters of the matrix in a row-wise fashion.

    The characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.
    For example, if originalText = "cipher" and rows = 3, then we encode it in the following manner:

    The blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = "ch ie pr".
    Given the encoded string encodedText and number of rows rows, return the original string originalText.
    Note: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.

    Example 1:

    >>> decodeCiphertext(encodedText = "ch   ie   pr", rows = 3)
    >>> "cipher"
    Explanation: This is the same example described in the problem description.

    Example 2:

    >>> decodeCiphertext(encodedText = "iveo    eed   l te   olc", rows = 4)
    >>> "i love leetcode"
    Explanation: The figure above denotes the matrix that was used to encode originalText.
    The blue arrows show how we can find originalText from encodedText.

    Example 3:

    >>> decodeCiphertext(encodedText = "coding", rows = 1)
    >>> "coding"
    Explanation: Since there is only 1 row, both originalText and encodedText are the same.
    """


Prompt:
def friendRequests(n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:
    """
    You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.
    You are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people.
    Initially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [uj, vj] is a friend request between person uj and person vj.
    A friend request is successful if uj and vj can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, uj and vj become direct friends for all future friend requests.
    Return a boolean array result, where each result[j] is true if the jth friend request is successful or false if it is not.
    Note: If uj and vj are already direct friends, the request is still successful.

    Example 1:

    >>> friendRequests(n = 3, restrictions = [[0,1]], requests = [[0,2],[2,1]])
    >>> [true,false]
    Explanation:
    Request 0: Person 0 and person 2 can be friends, so they become direct friends.
    Request 1: Person 2 and person 1 cannot be friends since person 0 and person 1 would be indirect friends (1--2--0).

    Example 2:

    >>> friendRequests(n = 3, restrictions = [[0,1]], requests = [[1,2],[0,2]])
    >>> [true,false]
    Explanation:
    Request 0: Person 1 and person 2 can be friends, so they become direct friends.
    Request 1: Person 0 and person 2 cannot be friends since person 0 and person 1 would be indirect friends (0--2--1).

    Example 3:

    >>> friendRequests(n = 5, restrictions = [[0,1],[1,2],[2,3]], requests = [[0,4],[1,2],[3,1],[3,4]])
    >>> [true,false,true,false]
    Explanation:
    Request 0: Person 0 and person 4 can be friends, so they become direct friends.
    Request 1: Person 1 and person 2 cannot be friends since they are directly restricted.
    Request 2: Person 3 and person 1 can be friends, so they become direct friends.
    Request 3: Person 3 and person 4 cannot be friends since person 0 and person 1 would be indirect friends (0--4--3--1).
    """


Prompt:
def numberOfPaths(n: int, corridors: List[List[int]]) -> int:
    """
    A maze consists of n rooms numbered from 1 to n, and some rooms are connected by corridors. You are given a 2D integer array corridors where corridors[i] = [room1i, room2i] indicates that there is a corridor connecting room1i and room2i, allowing a person in the maze to go from room1i to room2i and vice versa.
    The designer of the maze wants to know how confusing the maze is. The confusion score of the maze is the number of different cycles of length 3.

    For example, 1 → 2 → 3 → 1 is a cycle of length 3, but 1 → 2 → 3 → 4 and 1 → 2 → 3 → 2 → 1 are not.

    Two cycles are considered to be different if one or more of the rooms visited in the first cycle is not in the second cycle.
    Return the confusion score of the maze.

    Example 1:

    >>> numberOfPaths(n = 5, corridors = [[1,2],[5,2],[4,1],[2,4],[3,1],[3,4]])
    >>> 2
    Explanation:
    One cycle of length 3 is 4 → 1 → 3 → 4, denoted in red.
    Note that this is the same cycle as 3 → 4 → 1 → 3 or 1 → 3 → 4 → 1 because the rooms are the same.
    Another cycle of length 3 is 1 → 2 → 4 → 1, denoted in blue.
    Thus, there are two different cycles of length 3.

    Example 2:

    >>> numberOfPaths(n = 4, corridors = [[1,2],[3,4]])
    >>> 0
    Explanation:
    There are no cycles of length 3.
    """


Prompt:
def maxDistance(colors: List[int]) -> int:
    """
    There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.
    Return the maximum distance between two houses with different colors.
    The distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.

    Example 1:

    >>> maxDistance(colors = [1,1,1,6,1,1,1])
    >>> 3
    Explanation: In the above image, color 1 is blue, and color 6 is red.
    The furthest two houses with different colors are house 0 and house 3.
    House 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.
    Note that houses 3 and 6 can also produce the optimal answer.

    Example 2:

    >>> maxDistance(colors = [1,8,3,8,3])
    >>> 4
    Explanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.
    The furthest two houses with different colors are house 0 and house 4.
    House 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.

    Example 3:

    >>> maxDistance(colors = [0,1])
    >>> 1
    Explanation: The furthest two houses with different colors are house 0 and house 1.
    House 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.
    """


Prompt:
def wateringPlants(plants: List[int], capacity: int) -> int:
    """
    You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.
    Each plant needs a specific amount of water. You will water the plants in the following way:

    Water the plants in order from left to right.
    After watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.
    You cannot refill the watering can early.

    You are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.
    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.

    Example 1:

    >>> wateringPlants(plants = [2,2,3,3], capacity = 5)
    >>> 14
    Explanation: Start at the river with a full watering can:
    - Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.
    - Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.
    - Since you cannot completely water plant 2, walk back to the river to refill (2 steps).
    - Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.
    - Since you cannot completely water plant 3, walk back to the river to refill (3 steps).
    - Walk to plant 3 (4 steps) and water it.
    Steps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.

    Example 2:

    >>> wateringPlants(plants = [1,1,1,4,2,3], capacity = 4)
    >>> 30
    Explanation: Start at the river with a full watering can:
    - Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).
    - Water plant 3 (4 steps). Return to river (4 steps).
    - Water plant 4 (5 steps). Return to river (5 steps).
    - Water plant 5 (6 steps).
    Steps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.

    Example 3:

    >>> wateringPlants(plants = [7,7,7,7,7,7,7], capacity = 8)
    >>> 49
    Explanation: You have to refill before watering each plant.
    Steps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.
    """


Prompt:
def kMirror(k: int, n: int) -> int:
    """
    A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.

    For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.
    On the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.

    Given the base k and the number n, return the sum of the n smallest k-mirror numbers.

    Example 1:

    >>> kMirror(k = 2, n = 5)
    >>> 25
    Explanation:
    The 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:
      base-10    base-2
        1          1
        3          11
        5          101
        7          111
        9          1001
    Their sum = 1 + 3 + 5 + 7 + 9 = 25.

    Example 2:

    >>> kMirror(k = 3, n = 7)
    >>> 499
    Explanation:
    The 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:
      base-10    base-3
        1          1
        2          2
        4          11
        8          22
        121        11111
        151        12121
        212        21212
    Their sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.

    Example 3:

    >>> kMirror(k = 7, n = 17)
    >>> 20379000
    Explanation: The 17 smallest 7-mirror numbers are:
    1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596
    """


Prompt:
def numberOfSubstrings(s: str) -> int:
    """
    You are given a 0-indexed string s consisting of only lowercase English letters. Return the number of substrings in s that begin and end with the same character.
    A substring is a contiguous non-empty sequence of characters within a string.

    Example 1:

    >>> numberOfSubstrings(s = "abcba")
    >>> 7
    Explanation:
    The substrings of length 1 that start and end with the same letter are: "a", "b", "c", "b", and "a".
    The substring of length 3 that starts and ends with the same letter is: "bcb".
    The substring of length 5 that starts and ends with the same letter is: "abcba".

    Example 2:

    >>> numberOfSubstrings(s = "abacad")
    >>> 9
    Explanation:
    The substrings of length 1 that start and end with the same letter are: "a", "b", "a", "c", "a", and "d".
    The substrings of length 3 that start and end with the same letter are: "aba" and "aca".
    The substring of length 5 that starts and ends with the same letter is: "abaca".

    Example 3:

    >>> numberOfSubstrings(s = "a")
    >>> 1
    Explanation:
    The substring of length 1 that starts and ends with the same letter is: "a".
    """


Prompt:
def countWords(words1: List[str], words2: List[str]) -> int:
    """
    Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.

    Example 1:

    >>> countWords(words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing","leetcode","is"])
    >>> 2
    Explanation:
    - "leetcode" appears exactly once in each of the two arrays. We count this string.
    - "amazing" appears exactly once in each of the two arrays. We count this string.
    - "is" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.
    - "as" appears once in words1, but does not appear in words2. We do not count this string.
    Thus, there are 2 strings that appear exactly once in each of the two arrays.

    Example 2:

    >>> countWords(words1 = ["b","bb","bbb"], words2 = ["a","aa","aaa"])
    >>> 0
    Explanation: There are no strings that appear in each of the two arrays.

    Example 3:

    >>> countWords(words1 = ["a","ab"], words2 = ["a","a","a","ab"])
    >>> 1
    Explanation: The only string that appears exactly once in each of the two arrays is "ab".
    """


Prompt:
def minimumBuckets(hamsters: str) -> int:
    """
    You are given a 0-indexed string hamsters where hamsters[i] is either:

    'H' indicating that there is a hamster at index i, or
    '.' indicating that index i is empty.

    You will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to its left or to its right. More formally, a hamster at index i can be fed if you place a food bucket at index i - 1 and/or at index i + 1.
    Return the minimum number of food buckets you should place at empty indices to feed all the hamsters or -1 if it is impossible to feed all of them.

    Example 1:

    >>> minimumBuckets(hamsters = "H..H")
    >>> 2
    Explanation: We place two food buckets at indices 1 and 2.
    It can be shown that if we place only one food bucket, one of the hamsters will not be fed.

    Example 2:

    >>> minimumBuckets(hamsters = ".H.H.")
    >>> 1
    Explanation: We place one food bucket at index 2.

    Example 3:

    >>> minimumBuckets(hamsters = ".HHH.")
    >>> -1
    Explanation: If we place a food bucket at every empty index as shown, the hamster at index 2 will not be able to eat.
    """


Prompt:
def minCost(startPos: List[int], homePos: List[int], rowCosts: List[int], colCosts: List[int]) -> int:
    """
    There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).
    The robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.

    If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].
    If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].

    Return the minimum total cost for this robot to return home.

    Example 1:

    >>> minCost(startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7])
    >>> 18
    Explanation: One optimal path is that:
    Starting from (1, 0)
    -> It goes down to (2, 0). This move costs rowCosts[2] = 3.
    -> It goes right to (2, 1). This move costs colCosts[1] = 2.
    -> It goes right to (2, 2). This move costs colCosts[2] = 6.
    -> It goes right to (2, 3). This move costs colCosts[3] = 7.
    The total cost is 3 + 2 + 6 + 7 = 18
    Example 2:

    >>> minCost(startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26])
    >>> 0
    Explanation: The robot is already at its home. Since no moves occur, the total cost is 0.
    """


Prompt:
def countPyramids(grid: List[List[int]]) -> int:
    """
    A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.
    A pyramidal plot of land can be defined as a set of cells with the following criteria:

    The number of cells in the set has to be greater than 1 and all cells must be fertile.
    The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).

    An inverse pyramidal plot of land can be defined as a set of cells with similar criteria:

    The number of cells in the set has to be greater than 1 and all cells must be fertile.
    The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).

    Some examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.

    Given a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.

    Example 1:

    >>> countPyramids(grid = [[0,1,1,0],[1,1,1,1]])
    >>> 2
    Explanation: The 2 possible pyramidal plots are shown in blue and red respectively.
    There are no inverse pyramidal plots in this grid.
    Hence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.

    Example 2:

    >>> countPyramids(grid = [[1,1,1],[1,1,1]])
    >>> 2
    Explanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red.
    Hence the total number of plots is 1 + 1 = 2.

    Example 3:

    >>> countPyramids(grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]])
    >>> 13
    Explanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.
    There are 6 inverse pyramidal plots, 2 of which are shown in the last figure.
    The total number of plots is 7 + 6 = 13.
    """


Prompt:
def targetIndices(nums: List[int], target: int) -> List[int]:
    """
    You are given a 0-indexed integer array nums and a target element target.
    A target index is an index i such that nums[i] == target.
    Return a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.

    Example 1:

    >>> targetIndices(nums = [1,2,5,2,3], target = 2)
    >>> [1,2]
    Explanation: After sorting, nums is [1,2,2,3,5].
    The indices where nums[i] == 2 are 1 and 2.

    Example 2:

    >>> targetIndices(nums = [1,2,5,2,3], target = 3)
    >>> [3]
    Explanation: After sorting, nums is [1,2,2,3,5].
    The index where nums[i] == 3 is 3.

    Example 3:

    >>> targetIndices(nums = [1,2,5,2,3], target = 5)
    >>> [4]
    Explanation: After sorting, nums is [1,2,2,3,5].
    The index where nums[i] == 5 is 4.
    """


Prompt:
def getAverages(nums: List[int], k: int) -> List[int]:
    """
    You are given a 0-indexed array nums of n integers, and an integer k.
    The k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.
    Build and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.
    The average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.

    For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.

    Example 1:

    >>> getAverages(nums = [7,4,3,9,1,8,5,2,6], k = 3)
    >>> [-1,-1,-1,5,4,4,-1,-1,-1]
    Explanation:
    - avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.
    - The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.
      Using integer division, avg[3] = 37 / 7 = 5.
    - For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.
    - For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.
    - avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.

    Example 2:

    >>> getAverages(nums = [100000], k = 0)
    >>> [100000]
    Explanation:
    - The sum of the subarray centered at index 0 with radius 0 is: 100000.
      avg[0] = 100000 / 1 = 100000.

    Example 3:

    >>> getAverages(nums = [8], k = 100000)
    >>> [-1]
    Explanation:
    - avg[0] is -1 because there are less than k elements before and after index 0.
    """


Prompt:
def minimumDeletions(nums: List[int]) -> int:
    """
    You are given a 0-indexed array of distinct integers nums.
    There is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.
    A deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.
    Return the minimum number of deletions it would take to remove both the minimum and maximum element from the array.

    Example 1:

    >>> minimumDeletions(nums = [2,10,7,5,4,1,8,6])
    >>> 5
    Explanation:
    The minimum element in the array is nums[5], which is 1.
    The maximum element in the array is nums[1], which is 10.
    We can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.
    This results in 2 + 3 = 5 deletions, which is the minimum number possible.

    Example 2:

    >>> minimumDeletions(nums = [0,-4,19,1,8,-2,-3,5])
    >>> 3
    Explanation:
    The minimum element in the array is nums[1], which is -4.
    The maximum element in the array is nums[2], which is 19.
    We can remove both the minimum and maximum by removing 3 elements from the front.
    This results in only 3 deletions, which is the minimum number possible.

    Example 3:

    >>> minimumDeletions(nums = [101])
    >>> 1
    Explanation:
    There is only one element in the array, which makes it both the minimum and maximum element.
    We can remove it with 1 deletion.
    """


Prompt:
def findAllPeople(n: int, meetings: List[List[int]], firstPerson: int) -> List[int]:
    """
    You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.
    Person 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.
    The secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.
    Return a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.

    Example 1:

    >>> findAllPeople(n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1)
    >>> [0,1,2,3,5]
    Explanation:
    At time 0, person 0 shares the secret with person 1.
    At time 5, person 1 shares the secret with person 2.
    At time 8, person 2 shares the secret with person 3.
    At time 10, person 1 shares the secret with person 5.
    Thus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.

    Example 2:

    >>> findAllPeople(n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3)
    >>> [0,1,3]
    Explanation:
    At time 0, person 0 shares the secret with person 3.
    At time 2, neither person 1 nor person 2 know the secret.
    At time 3, person 3 shares the secret with person 0 and person 1.
    Thus, people 0, 1, and 3 know the secret after all the meetings.

    Example 3:

    >>> findAllPeople(n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1)
    >>> [0,1,2,3,4]
    Explanation:
    At time 0, person 0 shares the secret with person 1.
    At time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.
    Note that person 2 can share the secret at the same time as receiving it.
    At time 2, person 3 shares the secret with person 4.
    Thus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.
    """


Prompt:
def minimumCost(n: int, highways: List[List[int]], discounts: int) -> int:
    """
    A series of highways connect n cities numbered from 0 to n - 1. You are given a 2D integer array highways where highways[i] = [city1i, city2i, tolli] indicates that there is a highway that connects city1i and city2i, allowing a car to go from city1i to city2i and vice versa for a cost of tolli.
    You are also given an integer discounts which represents the number of discounts you have. You can use a discount to travel across the ith highway for a cost of tolli / 2 (integer division). Each discount may only be used once, and you can only use at most one discount per highway.
    Return the minimum total cost to go from city 0 to city n - 1, or -1 if it is not possible to go from city 0 to city n - 1.

    Example 1:

    >>> minimumCost(n = 5, highways = [[0,1,4],[2,1,3],[1,4,11],[3,2,3],[3,4,2]], discounts = 1)
    >>> 9
    Explanation:
    Go from 0 to 1 for a cost of 4.
    Go from 1 to 4 and use a discount for a cost of 11 / 2 = 5.
    The minimum cost to go from 0 to 4 is 4 + 5 = 9.

    Example 2:

    >>> minimumCost(n = 4, highways = [[1,3,17],[1,2,7],[3,2,5],[0,1,6],[3,0,20]], discounts = 20)
    >>> 8
    Explanation:
    Go from 0 to 1 and use a discount for a cost of 6 / 2 = 3.
    Go from 1 to 2 and use a discount for a cost of 7 / 2 = 3.
    Go from 2 to 3 and use a discount for a cost of 5 / 2 = 2.
    The minimum cost to go from 0 to 3 is 3 + 3 + 2 = 8.

    Example 3:

    >>> minimumCost(n = 4, highways = [[0,1,3],[2,3,2]], discounts = 0)
    >>> -1
    Explanation:
    It is impossible to go from 0 to 3 so return -1.
    """


Prompt:
def findEvenNumbers(digits: List[int]) -> List[int]:
    """
    You are given an integer array digits, where each element is a digit. The array may contain duplicates.
    You need to find all the unique integers that follow the given requirements:

    The integer consists of the concatenation of three elements from digits in any arbitrary order.
    The integer does not have leading zeros.
    The integer is even.

    For example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.
    Return a sorted array of the unique integers.

    Example 1:

    >>> findEvenNumbers(digits = [2,1,3,0])
    >>> [102,120,130,132,210,230,302,310,312,320]
    Explanation: All the possible integers that follow the requirements are in the output array.
    Notice that there are no odd integers or integers with leading zeros.

    Example 2:

    >>> findEvenNumbers(digits = [2,2,8,8,2])
    >>> [222,228,282,288,822,828,882]
    Explanation: The same digit can be used as many times as it appears in digits.
    In this example, the digit 8 is used twice each time in 288, 828, and 882.

    Example 3:

    >>> findEvenNumbers(digits = [3,7,5])
    >>> []
    Explanation: No even integers can be formed using the given digits.
    """


Prompt:
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def deleteMiddle(head: Optional[ListNode]) -> Optional[ListNode]:
    """
    You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.
    The middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.

    For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.

    Example 1:

    >>> __init__(head = [1,3,4,7,1,2,6])
    >>> [1,3,4,1,2,6]
    Explanation:
    The above figure represents the given linked list. The indices of the nodes are written below.
    Since n = 7, node 3 with value 7 is the middle node, which is marked in red.
    We return the new list after removing this node.

    Example 2:

    >>> __init__(head = [1,2,3,4])
    >>> [1,2,4]
    Explanation:
    The above figure represents the given linked list.
    For n = 4, node 2 with value 3 is the middle node, which is marked in red.

    Example 3:

    >>> __init__(head = [2,1])
    >>> [2]
    Explanation:
    The above figure represents the given linked list.
    For n = 2, node 1 with value 1 is the middle node, which is marked in red.
    Node 0 with value 2 is the only node remaining after removing node 1.
    """


Prompt:
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def getDirections(root: Optional[TreeNode], startValue: int, destValue: int) -> str:
    """
    You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.
    Find the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:

    'L' means to go from a node to its left child node.
    'R' means to go from a node to its right child node.
    'U' means to go from a node to its parent node.

    Return the step-by-step directions of the shortest path from node s to node t.

    Example 1:

    >>> __init__(root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6)
    >>> "UURL"
    Explanation: The shortest path is: 3 → 1 → 5 → 2 → 6.

    Example 2:

    >>> __init__(root = [2,1], startValue = 2, destValue = 1)
    >>> "L"
    Explanation: The shortest path is: 2 → 1.
    """


Prompt:
def validArrangement(pairs: List[List[int]]) -> List[List[int]]:
    """
    You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.
    Return any valid arrangement of pairs.
    Note: The inputs will be generated such that there exists a valid arrangement of pairs.

    Example 1:

    >>> validArrangement(pairs = [[5,1],[4,5],[11,9],[9,4]])
    >>> [[11,9],[9,4],[4,5],[5,1]]
    Explanation:
    This is a valid arrangement since endi-1 always equals starti.
    end0 = 9 == 9 = start1
    end1 = 4 == 4 = start2
    end2 = 5 == 5 = start3

    Example 2:

    >>> validArrangement(pairs = [[1,3],[3,2],[2,1]])
    >>> [[1,3],[3,2],[2,1]]
    Explanation:
    This is a valid arrangement since endi-1 always equals starti.
    end0 = 3 == 3 = start1
    end1 = 2 == 2 = start2
    The arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.

    Example 3:

    >>> validArrangement(pairs = [[1,2],[1,3],[2,1]])
    >>> [[1,2],[2,1],[1,3]]
    Explanation:
    This is a valid arrangement since endi-1 always equals starti.
    end0 = 2 == 2 = start1
    end1 = 1 == 1 = start2
    """


Prompt:
def largestEvenSum(nums: List[int], k: int) -> int:
    """
    You are given an integer array nums and an integer k. Find the largest even sum of any subsequence of nums that has a length of k.
    Return this sum, or -1 if such a sum does not exist.
    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> largestEvenSum(nums = [4,1,5,3,1], k = 3)
    >>> 12
    Explanation:
    The subsequence with the largest possible even sum is [4,5,3]. It has a sum of 4 + 5 + 3 = 12.

    Example 2:

    >>> largestEvenSum(nums = [4,6,2], k = 3)
    >>> 12
    Explanation:
    The subsequence with the largest possible even sum is [4,6,2]. It has a sum of 4 + 6 + 2 = 12.

    Example 3:

    >>> largestEvenSum(nums = [1,3,5], k = 1)
    >>> -1
    Explanation:
    No subsequence of nums with length 1 has an even sum.
    """


Prompt:
def maxSubsequence(nums: List[int], k: int) -> List[int]:
    """
    You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.
    Return any such subsequence as an integer array of length k.
    A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.

    Example 1:

    >>> maxSubsequence(nums = [2,1,3,3], k = 2)
    >>> [3,3]
    Explanation:
    The subsequence has the largest sum of 3 + 3 = 6.
    Example 2:

    >>> maxSubsequence(nums = [-1,-2,3,4], k = 3)
    >>> [-1,3,4]
    Explanation:
    The subsequence has the largest sum of -1 + 3 + 4 = 6.

    Example 3:

    >>> maxSubsequence(nums = [3,4,3,3], k = 2)
    >>> [3,4]
    Explanation:
    The subsequence has the largest sum of 3 + 4 = 7.
    Another possible subsequence is [4, 3].
    """


Prompt:
def goodDaysToRobBank(security: List[int], time: int) -> List[int]:
    """
    You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.
    The ith day is a good day to rob the bank if:

    There are at least time days before and after the ith day,
    The number of guards at the bank for the time days before i are non-increasing, and
    The number of guards at the bank for the time days after i are non-decreasing.

    More formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].
    Return a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.

    Example 1:

    >>> goodDaysToRobBank(security = [5,3,3,3,5,6,2], time = 2)
    >>> [2,3]
    Explanation:
    On day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].
    On day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].
    No other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.

    Example 2:

    >>> goodDaysToRobBank(security = [1,1,1,1,1], time = 0)
    >>> [0,1,2,3,4]
    Explanation:
    Since time equals 0, every day is a good day to rob the bank, so return every day.

    Example 3:

    >>> goodDaysToRobBank(security = [1,2,3,4,5,6], time = 2)
    >>> []
    Explanation:
    No day has 2 days before it that have a non-increasing number of guards.
    Thus, no day is a good day to rob the bank, so return an empty list.
    """


Prompt:
def maximumDetonation(bombs: List[List[int]]) -> int:
    """
    You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.
    The bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.
    You may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.
    Given the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.

    Example 1:

    >>> maximumDetonation(bombs = [[2,1,3],[6,1,4]])
    >>> 2
    Explanation:
    The above figure shows the positions and ranges of the 2 bombs.
    If we detonate the left bomb, the right bomb will not be affected.
    But if we detonate the right bomb, both bombs will be detonated.
    So the maximum bombs that can be detonated is max(1, 2) = 2.

    Example 2:

    >>> maximumDetonation(bombs = [[1,1,5],[10,10,5]])
    >>> 1
    Explanation:
    Detonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.

    Example 3:

    >>> maximumDetonation(bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]])
    >>> 5
    Explanation:
    The best bomb to detonate is bomb 0 because:
    - Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.
    - Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.
    - Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.
    Thus all 5 bombs are detonated.
    """


Prompt:
def countPoints(rings: str) -> int:
    """
    There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.
    You are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:

    The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').
    The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').

    For example, "R3G2B1" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.
    Return the number of rods that have all three colors of rings on them.

    Example 1:

    >>> countPoints(rings = "B0B6G0R6R0R6G9")
    >>> 1
    Explanation:
    - The rod labeled 0 holds 3 rings with all colors: red, green, and blue.
    - The rod labeled 6 holds 3 rings, but it only has red and blue.
    - The rod labeled 9 holds only a green ring.
    Thus, the number of rods with all three colors is 1.

    Example 2:

    >>> countPoints(rings = "B0R0G0R9R0B0G0")
    >>> 1
    Explanation:
    - The rod labeled 0 holds 6 rings with all colors: red, green, and blue.
    - The rod labeled 9 holds only a red ring.
    Thus, the number of rods with all three colors is 1.

    Example 3:

    >>> countPoints(rings = "G4")
    >>> 0
    Explanation:
    Only one ring is given. Thus, no rods have all three colors.
    """


Prompt:
def subArrayRanges(nums: List[int]) -> int:
    """
    You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.
    Return the sum of all subarray ranges of nums.
    A subarray is a contiguous non-empty sequence of elements within an array.

    Example 1:

    >>> subArrayRanges(nums = [1,2,3])
    >>> 4
    Explanation: The 6 subarrays of nums are the following:
    [1], range = largest - smallest = 1 - 1 = 0
    [2], range = 2 - 2 = 0
    [3], range = 3 - 3 = 0
    [1,2], range = 2 - 1 = 1
    [2,3], range = 3 - 2 = 1
    [1,2,3], range = 3 - 1 = 2
    So the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.
    Example 2:

    >>> subArrayRanges(nums = [1,3,3])
    >>> 4
    Explanation: The 6 subarrays of nums are the following:
    [1], range = largest - smallest = 1 - 1 = 0
    [3], range = 3 - 3 = 0
    [3], range = 3 - 3 = 0
    [1,3], range = 3 - 1 = 2
    [3,3], range = 3 - 3 = 0
    [1,3,3], range = 3 - 1 = 2
    So the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.

    Example 3:

    >>> subArrayRanges(nums = [4,-2,-3,4,1])
    >>> 59
    Explanation: The sum of all subarray ranges of nums is 59.
    """


Prompt:
def minimumRefill(plants: List[int], capacityA: int, capacityB: int) -> int:
    """
    Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.
    Each plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:

    Alice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.
    It takes the same amount of time to water each plant regardless of how much water it needs.
    Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.
    In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.

    Given a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.

    Example 1:

    >>> minimumRefill(plants = [2,2,3,3], capacityA = 5, capacityB = 5)
    >>> 1
    Explanation:
    - Initially, Alice and Bob have 5 units of water each in their watering cans.
    - Alice waters plant 0, Bob waters plant 3.
    - Alice and Bob now have 3 units and 2 units of water respectively.
    - Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.
    So, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.

    Example 2:

    >>> minimumRefill(plants = [2,2,3,3], capacityA = 3, capacityB = 4)
    >>> 2
    Explanation:
    - Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.
    - Alice waters plant 0, Bob waters plant 3.
    - Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.
    - Since neither of them have enough water for their current plants, they refill their cans and then water the plants.
    So, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.

    Example 3:

    >>> minimumRefill(plants = [5], capacityA = 10, capacityB = 8)
    >>> 0
    Explanation:
    - There is only one plant.
    - Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.
    So, the total number of times they have to refill is 0.
    """


Prompt:
def maxTotalFruits(fruits: List[List[int]], startPos: int, k: int) -> int:
    """
    Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.
    You are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.
    Return the maximum total number of fruits you can harvest.

    Example 1:

    >>> maxTotalFruits(fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4)
    >>> 9
    Explanation:
    The optimal way is to:
    - Move right to position 6 and harvest 3 fruits
    - Move right to position 8 and harvest 6 fruits
    You moved 3 steps and harvested 3 + 6 = 9 fruits in total.

    Example 2:

    >>> maxTotalFruits(fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4)
    >>> 14
    Explanation:
    You can move at most k = 4 steps, so you cannot reach position 0 nor 10.
    The optimal way is to:
    - Harvest the 7 fruits at the starting position 5
    - Move left to position 4 and harvest 1 fruit
    - Move right to position 6 and harvest 2 fruits
    - Move right to position 7 and harvest 4 fruits
    You moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.

    Example 3:

    >>> maxTotalFruits(fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2)
    >>> 0
    Explanation:
    You can move at most k = 2 steps and cannot reach any position with fruits.
    """


Prompt:
def shareCandies(candies: List[int], k: int) -> int:
    """
    You are given a 0-indexed integer array candies, where candies[i] represents the flavor of the ith candy. Your mom wants you to share these candies with your little sister by giving her k consecutive candies, but you want to keep as many flavors of candies as possible.
    Return the maximum number of unique flavors of candy you can keep after sharing  with your sister.

    Example 1:

    >>> shareCandies(candies = [1,2,2,3,4,3], k = 3)
    >>> 3
    Explanation:
    Give the candies in the range [1, 3] (inclusive) with flavors [2,2,3].
    You can eat candies with flavors [1,4,3].
    There are 3 unique flavors, so return 3.

    Example 2:

    >>> shareCandies(candies = [2,2,2,2,3,3], k = 2)
    >>> 2
    Explanation:
    Give the candies in the range [3, 4] (inclusive) with flavors [2,3].
    You can eat candies with flavors [2,2,2,3].
    There are 2 unique flavors, so return 2.
    Note that you can also share the candies with flavors [2,2] and eat the candies with flavors [2,2,3,3].

    Example 3:

    >>> shareCandies(candies = [2,4,5], k = 0)
    >>> 3
    Explanation:
    You do not have to give any candies.
    You can eat the candies with flavors [2,4,5].
    There are 3 unique flavors, so return 3.
    """


Prompt:
def firstPalindrome(words: List[str]) -> str:
    """
    Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string "".
    A string is palindromic if it reads the same forward and backward.

    Example 1:

    >>> firstPalindrome(words = ["abc","car","ada","racecar","cool"])
    >>> "ada"
    Explanation: The first string that is palindromic is "ada".
    Note that "racecar" is also palindromic, but it is not the first.

    Example 2:

    >>> firstPalindrome(words = ["notapalindrome","racecar"])
    >>> "racecar"
    Explanation: The first and only string that is palindromic is "racecar".

    Example 3:

    >>> firstPalindrome(words = ["def","ghi"])
    >>> ""
    Explanation: There are no palindromic strings, so the empty string is returned.
    """


Prompt:
def addSpaces(s: str, spaces: List[int]) -> str:
    """
    You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.

    For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain "Enjoy Your Coffee".

    Return the modified string after the spaces have been added.

    Example 1:

    >>> addSpaces(s = "LeetcodeHelpsMeLearn", spaces = [8,13,15])
    >>> "Leetcode Helps Me Learn"
    Explanation:
    The indices 8, 13, and 15 correspond to the underlined characters in "LeetcodeHelpsMeLearn".
    We then place spaces before those characters.

    Example 2:

    >>> addSpaces(s = "icodeinpython", spaces = [1,5,7,9])
    >>> "i code in py thon"
    Explanation:
    The indices 1, 5, 7, and 9 correspond to the underlined characters in "icodeinpython".
    We then place spaces before those characters.

    Example 3:

    >>> addSpaces(s = "spacing", spaces = [0,1,2,3,4,5,6])
    >>> " s p a c i n g"
    Explanation:
    We are also able to place spaces before the first character of the string.
    """


Prompt:
def getDescentPeriods(prices: List[int]) -> int:
    """
    You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.
    A smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.
    Return the number of smooth descent periods.

    Example 1:

    >>> getDescentPeriods(prices = [3,2,1,4])
    >>> 7
    Explanation: There are 7 smooth descent periods:
    [3], [2], [1], [4], [3,2], [2,1], and [3,2,1]
    Note that a period with one day is a smooth descent period by the definition.

    Example 2:

    >>> getDescentPeriods(prices = [8,6,7,7])
    >>> 4
    Explanation: There are 4 smooth descent periods: [8], [6], [7], and [7]
    Note that [8,6] is not a smooth descent period as 8 - 6 ≠ 1.

    Example 3:

    >>> getDescentPeriods(prices = [1])
    >>> 1
    Explanation: There is 1 smooth descent period: [1]
    """


Prompt:
def kIncreasing(arr: List[int], k: int) -> int:
    """
    You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.
    The array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.

    For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because:

    arr[0] <= arr[2] (4 <= 5)
    arr[1] <= arr[3] (1 <= 2)
    arr[2] <= arr[4] (5 <= 6)
    arr[3] <= arr[5] (2 <= 2)

    However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).

    In one operation, you can choose an index i and change arr[i] into any positive integer.
    Return the minimum number of operations required to make the array K-increasing for the given k.

    Example 1:

    >>> kIncreasing(arr = [5,4,3,2,1], k = 1)
    >>> 4
    Explanation:
    For k = 1, the resultant array has to be non-decreasing.
    Some of the K-increasing arrays that can be formed are [5,6,7,8,9], [1,1,1,1,1], [2,2,3,4,4]. All of them require 4 operations.
    It is suboptimal to change the array to, for example, [6,7,8,9,10] because it would take 5 operations.
    It can be shown that we cannot make the array K-increasing in less than 4 operations.

    Example 2:

    >>> kIncreasing(arr = [4,1,5,2,6,2], k = 2)
    >>> 0
    Explanation:
    This is the same example as the one in the problem description.
    Here, for every index i where 2 <= i <= 5, arr[i-2] <= arr[i].
    Since the given array is already K-increasing, we do not need to perform any operations.
    Example 3:

    >>> kIncreasing(arr = [4,1,5,2,6,2], k = 3)
    >>> 2
    Explanation:
    Indices 3 and 5 are the only ones not satisfying arr[i-3] <= arr[i] for 3 <= i <= 5.
    One of the ways we can make the array K-increasing is by changing arr[3] to 4 and arr[5] to 5.
    The array will now be [4,1,5,4,6,5].
    Note that there can be other ways to make the array K-increasing, but none of them require less than 2 operations.
    """


Prompt:
def elementInNums(nums: List[int], queries: List[List[int]]) -> List[int]:
    """
    You are given a 0-indexed integer array nums. Initially on minute 0, the array is unchanged. Every minute, the leftmost element in nums is removed until no elements remain. Then, every minute, one element is appended to the end of nums, in the order they were removed in, until the original array is restored. This process repeats indefinitely.

    For example, the array [0,1,2] would change as follows: [0,1,2] → [1,2] → [2] → [] → [0] → [0,1] → [0,1,2] → [1,2] → [2] → [] → [0] → [0,1] → [0,1,2] → ...

    You are also given a 2D integer array queries of size n where queries[j] = [timej, indexj]. The answer to the jth query is:

    nums[indexj] if indexj < nums.length at minute timej
    -1 if indexj >= nums.length at minute timej

    Return an integer array ans of size n where ans[j] is the answer to the jth query.

    Example 1:

    >>> elementInNums(nums = [0,1,2], queries = [[0,2],[2,0],[3,2],[5,0]])
    >>> [2,2,-1,0]
    Explanation:
    Minute 0: [0,1,2] - All elements are in the nums.
    Minute 1: [1,2]   - The leftmost element, 0, is removed.
    Minute 2: [2]     - The leftmost element, 1, is removed.
    Minute 3: []      - The leftmost element, 2, is removed.
    Minute 4: [0]     - 0 is added to the end of nums.
    Minute 5: [0,1]   - 1 is added to the end of nums.

    At minute 0, nums[2] is 2.
    At minute 2, nums[0] is 2.
    At minute 3, nums[2] does not exist.
    At minute 5, nums[0] is 0.

    Example 2:

    >>> elementInNums(nums = [2], queries = [[0,0],[1,0],[2,0],[3,0]])
    >>> [2,-1,2,-1]
    Minute 0: [2] - All elements are in the nums.
    Minute 1: []  - The leftmost element, 2, is removed.
    Minute 2: [2] - 2 is added to the end of nums.
    Minute 3: []  - The leftmost element, 2, is removed.

    At minute 0, nums[0] is 2.
    At minute 1, nums[0] does not exist.
    At minute 2, nums[0] is 2.
    At minute 3, nums[0] does not exist.
    """


Prompt:
def mostWordsFound(sentences: List[str]) -> int:
    """
    A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
    You are given an array of strings sentences, where each sentences[i] represents a single sentence.
    Return the maximum number of words that appear in a single sentence.

    Example 1:

    >>> mostWordsFound(sentences = ["alice and bob love leetcode", "i think so too", "this is great thanks very much"])
    >>> 6
    Explanation:
    - The first sentence, "alice and bob love leetcode", has 5 words in total.
    - The second sentence, "i think so too", has 4 words in total.
    - The third sentence, "this is great thanks very much", has 6 words in total.
    Thus, the maximum number of words in a single sentence comes from the third sentence, which has 6 words.

    Example 2:

    >>> mostWordsFound(sentences = ["please wait", "continue to fight", "continue to win"])
    >>> 3
    Explanation: It is possible that multiple sentences contain the same number of words.
    In this example, the second and third sentences (underlined) have the same number of words.
    """


Prompt:
def findAllRecipes(recipes: List[str], ingredients: List[List[str]], supplies: List[str]) -> List[str]:
    """
    You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can also be an ingredient for other recipes, i.e., ingredients[i] may contain a string that is in recipes.
    You are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.
    Return a list of all the recipes that you can create. You may return the answer in any order.
    Note that two recipes may contain each other in their ingredients.

    Example 1:

    >>> findAllRecipes(recipes = ["bread"], ingredients = [["yeast","flour"]], supplies = ["yeast","flour","corn"])
    >>> ["bread"]
    Explanation:
    We can create "bread" since we have the ingredients "yeast" and "flour".

    Example 2:

    >>> findAllRecipes(recipes = ["bread","sandwich"], ingredients = [["yeast","flour"],["bread","meat"]], supplies = ["yeast","flour","meat"])
    >>> ["bread","sandwich"]
    Explanation:
    We can create "bread" since we have the ingredients "yeast" and "flour".
    We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".

    Example 3:

    >>> findAllRecipes(recipes = ["bread","sandwich","burger"], ingredients = [["yeast","flour"],["bread","meat"],["sandwich","meat","bread"]], supplies = ["yeast","flour","meat"])
    >>> ["bread","sandwich","burger"]
    Explanation:
    We can create "bread" since we have the ingredients "yeast" and "flour".
    We can create "sandwich" since we have the ingredient "meat" and can create the ingredient "bread".
    We can create "burger" since we have the ingredient "meat" and can create the ingredients "bread" and "sandwich".
    """


Prompt:
def canBeValid(s: str, locked: str) -> bool:
    """
    A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:

    It is ().
    It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.
    It can be written as (A), where A is a valid parentheses string.

    You are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,

    If locked[i] is '1', you cannot change s[i].
    But if locked[i] is '0', you can change s[i] to either '(' or ')'.

    Return true if you can make s a valid parentheses string. Otherwise, return false.

    Example 1:

    >>> canBeValid(s = "))()))", locked = "010100")
    >>> true
    Explanation: locked[1] == '1' and locked[3] == '1', so we cannot change s[1] or s[3].
    We change s[0] and s[4] to '(' while leaving s[2] and s[5] unchanged to make s valid.
    Example 2:

    >>> canBeValid(s = "()()", locked = "0000")
    >>> true
    Explanation: We do not need to make any changes because s is already valid.

    Example 3:

    >>> canBeValid(s = ")", locked = "0")
    >>> false
    Explanation: locked permits us to change s[0].
    Changing s[0] to either '(' or ')' will not make s valid.

    Example 4:

    >>> canBeValid(s = "(((())(((())", locked = "111111010111")
    >>> true
    Explanation: locked permits us to change s[6] and s[8].
    We change s[6] and s[8] to ')' to make s valid.
    """


Prompt:
def abbreviateProduct(left: int, right: int) -> str:
    """
    You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].
    Since the product may be very large, you will abbreviate it following these steps:

    Count all trailing zeros in the product and remove them. Let us denote this count as C.

    For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.

    Denote the remaining number of digits in the product as d. If d > 10, then express the product as ... where  denotes the first 5 digits of the product, and  denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged.

    For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.

    Finally, represent the product as a string "...eC".

    For example, 12345678987600000 will be represented as "12345...89876e5".

    Return a string denoting the abbreviated product of all integers in the inclusive range [left, right].

    Example 1:

    >>> abbreviateProduct(left = 1, right = 4)
    >>> "24e0"
    Explanation: The product is 1 × 2 × 3 × 4 = 24.
    There are no trailing zeros, so 24 remains the same. The abbreviation will end with "e0".
    Since the number of digits is 2, which is less than 10, we do not have to abbreviate it further.
    Thus, the final representation is "24e0".

    Example 2:

    >>> abbreviateProduct(left = 2, right = 11)
    >>> "399168e2"
    Explanation: The product is 39916800.
    There are 2 trailing zeros, which we remove to get 399168. The abbreviation will end with "e2".
    The number of digits after removing the trailing zeros is 6, so we do not abbreviate it further.
    Hence, the abbreviated product is "399168e2".

    Example 3:

    >>> abbreviateProduct(left = 371, right = 375)
    >>> "7219856259e3"
    Explanation: The product is 7219856259000.
    """


Prompt:
def isSameAfterReversals(num: int) -> bool:
    """
    Reversing an integer means to reverse all its digits.

    For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.

    Given an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.

    Example 1:

    >>> isSameAfterReversals(num = 526)
    >>> true
    Explanation: Reverse num to get 625, then reverse 625 to get 526, which equals num.

    Example 2:

    >>> isSameAfterReversals(num = 1800)
    >>> false
    Explanation: Reverse num to get 81, then reverse 81 to get 18, which does not equal num.

    Example 3:

    >>> isSameAfterReversals(num = 0)
    >>> true
    Explanation: Reverse num to get 0, then reverse 0 to get 0, which equals num.
    """


Prompt:
def executeInstructions(n: int, startPos: List[int], s: str) -> List[int]:
    """
    There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).
    You are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).
    The robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:

    The next instruction will move the robot off the grid.
    There are no more instructions left to execute.

    Return an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.

    Example 1:

    >>> executeInstructions(n = 3, startPos = [0,1], s = "RRDDLU")
    >>> [1,5,4,3,1,0]
    Explanation: Starting from startPos and beginning execution from the ith instruction:
    - 0th: "RRDDLU". Only one instruction "R" can be executed before it moves off the grid.
    - 1st:  "RDDLU". All five instructions can be executed while it stays in the grid and ends at (1, 1).
    - 2nd:   "DDLU". All four instructions can be executed while it stays in the grid and ends at (1, 0).
    - 3rd:    "DLU". All three instructions can be executed while it stays in the grid and ends at (0, 0).
    - 4th:     "LU". Only one instruction "L" can be executed before it moves off the grid.
    - 5th:      "U". If moving up, it would move off the grid.

    Example 2:

    >>> executeInstructions(n = 2, startPos = [1,1], s = "LURD")
    >>> [4,1,0,0]
    Explanation:
    - 0th: "LURD".
    - 1st:  "URD".
    - 2nd:   "RD".
    - 3rd:    "D".

    Example 3:

    >>> executeInstructions(n = 1, startPos = [0,0], s = "LRUD")
    >>> [0,0,0,0]
    Explanation: No matter which instruction the robot begins execution from, it would move off the grid.
    """


Prompt:
def getDistances(arr: List[int]) -> List[int]:
    """
    You are given a 0-indexed array of n integers arr.
    The interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.
    Return an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].
    Note: |x| is the absolute value of x.

    Example 1:

    >>> getDistances(arr = [2,1,3,1,2,3,3])
    >>> [4,2,7,2,4,4,5]
    Explanation:
    - Index 0: Another 2 is found at index 4. |0 - 4| = 4
    - Index 1: Another 1 is found at index 3. |1 - 3| = 2
    - Index 2: Two more 3s are found at indices 5 and 6. |2 - 5| + |2 - 6| = 7
    - Index 3: Another 1 is found at index 1. |3 - 1| = 2
    - Index 4: Another 2 is found at index 0. |4 - 0| = 4
    - Index 5: Two more 3s are found at indices 2 and 6. |5 - 2| + |5 - 6| = 4
    - Index 6: Two more 3s are found at indices 2 and 5. |6 - 2| + |6 - 5| = 5

    Example 2:

    >>> getDistances(arr = [10,5,10,10])
    >>> [5,0,3,4]
    Explanation:
    - Index 0: Two more 10s are found at indices 2 and 3. |0 - 2| + |0 - 3| = 5
    - Index 1: There is only one 5 in the array, so its sum of intervals to identical elements is 0.
    - Index 2: Two more 10s are found at indices 0 and 3. |2 - 0| + |2 - 3| = 3
    - Index 3: Two more 10s are found at indices 0 and 2. |3 - 0| + |3 - 2| = 4
    """


Prompt:
def recoverArray(nums: List[int]) -> List[int]:
    """
    Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:

    lower[i] = arr[i] - k, for every index i where 0 <= i < n
    higher[i] = arr[i] + k, for every index i where 0 <= i < n

    Unfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.
    Given an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.
    Note: The test cases are generated such that there exists at least one valid array arr.

    Example 1:

    >>> recoverArray(nums = [2,10,6,4,8,12])
    >>> [3,7,11]
    Explanation:
    If arr = [3,7,11] and k = 1, we get lower = [2,6,10] and higher = [4,8,12].
    Combining lower and higher gives us [2,6,10,4,8,12], which is a permutation of nums.
    Another valid possibility is that arr = [5,7,9] and k = 3. In that case, lower = [2,4,6] and higher = [8,10,12].

    Example 2:

    >>> recoverArray(nums = [1,1,3,3])
    >>> [2,2]
    Explanation:
    If arr = [2,2] and k = 1, we get lower = [1,1] and higher = [3,3].
    Combining lower and higher gives us [1,1,3,3], which is equal to nums.
    Note that arr cannot be [1,3] because in that case, the only possible way to obtain [1,1,3,3] is with k = 0.
    This is invalid since k must be positive.

    Example 3:

    >>> recoverArray(nums = [5,435])
    >>> [220]
    Explanation:
    The only possible combination is arr = [220] and k = 215. Using them, we get lower = [5] and higher = [435].
    """


Prompt:
def minimumOperations(grid: List[List[int]]) -> int:
    """
    You are given a 0-indexed binary matrix grid. In one operation, you can flip any 1 in grid to be 0.
    A binary matrix is well-isolated if there is no 1 in the matrix that is 4-directionally connected (i.e., horizontal and vertical) to another 1.
    Return the minimum number of operations to make grid well-isolated.

    Example 1:

    >>> minimumOperations(grid = [[1,1,0],[0,1,1],[1,1,1]])
    >>> 3
    Explanation: Use 3 operations to change grid[0][1], grid[1][2], and grid[2][1] to 0.
    After, no more 1's are 4-directionally connected and grid is well-isolated.

    Example 2:

    >>> minimumOperations(grid = [[0,0,0],[0,0,0],[0,0,0]])
    >>> 0
    Explanation: There are no 1's in grid and it is well-isolated.
    No operations were done so return 0.

    Example 3:

    >>> minimumOperations(grid = [[0,1],[1,0]])
    >>> 0
    Explanation: None of the 1's are 4-directionally connected and grid is well-isolated.
    No operations were done so return 0.
    """


Prompt:
def checkString(s: str) -> bool:
    """
    Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.

    Example 1:

    >>> checkString(s = "aaabbb")
    >>> true
    Explanation:
    The 'a's are at indices 0, 1, and 2, while the 'b's are at indices 3, 4, and 5.
    Hence, every 'a' appears before every 'b' and we return true.

    Example 2:

    >>> checkString(s = "abab")
    >>> false
    Explanation:
    There is an 'a' at index 2 and a 'b' at index 1.
    Hence, not every 'a' appears before every 'b' and we return false.

    Example 3:

    >>> checkString(s = "bbb")
    >>> true
    Explanation:
    There are no 'a's, hence, every 'a' appears before every 'b' and we return true.
    """


Prompt:
def numberOfBeams(bank: List[str]) -> int:
    """
    Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.
    There is one laser beam between any two security devices if both conditions are met:

    The two devices are located on two different rows: r1 and r2, where r1 < r2.
    For each row i where r1 < i < r2, there are no security devices in the ith row.

    Laser beams are independent, i.e., one beam does not interfere nor join with another.
    Return the total number of laser beams in the bank.

    Example 1:

    >>> numberOfBeams(bank = ["011001","000000","010100","001000"])
    >>> 8
    Explanation: Between each of the following device pairs, there is one beam. In total, there are 8 beams:
     * bank[0][1] -- bank[2][1]
     * bank[0][1] -- bank[2][3]
     * bank[0][2] -- bank[2][1]
     * bank[0][2] -- bank[2][3]
     * bank[0][5] -- bank[2][1]
     * bank[0][5] -- bank[2][3]
     * bank[2][1] -- bank[3][2]
     * bank[2][3] -- bank[3][2]
    Note that there is no beam between any device on the 0th row with any on the 3rd row.
    This is because the 2nd row contains security devices, which breaks the second condition.

    Example 2:

    >>> numberOfBeams(bank = ["000","111","000"])
    >>> 0
    Explanation: There does not exist two devices located on two different rows.
    """


Prompt:
def asteroidsDestroyed(mass: int, asteroids: List[int]) -> bool:
    """
    You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.
    You can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.
    Return true if all asteroids can be destroyed. Otherwise, return false.

    Example 1:

    >>> asteroidsDestroyed(mass = 10, asteroids = [3,9,19,5,21])
    >>> true
    Explanation: One way to order the asteroids is [9,19,5,3,21]:
    - The planet collides with the asteroid with a mass of 9. New planet mass: 10 + 9 = 19
    - The planet collides with the asteroid with a mass of 19. New planet mass: 19 + 19 = 38
    - The planet collides with the asteroid with a mass of 5. New planet mass: 38 + 5 = 43
    - The planet collides with the asteroid with a mass of 3. New planet mass: 43 + 3 = 46
    - The planet collides with the asteroid with a mass of 21. New planet mass: 46 + 21 = 67
    All asteroids are destroyed.

    Example 2:

    >>> asteroidsDestroyed(mass = 5, asteroids = [4,9,23,4])
    >>> false
    Explanation:
    The planet cannot ever gain enough mass to destroy the asteroid with a mass of 23.
    After the planet destroys the other asteroids, it will have a mass of 5 + 4 + 9 + 4 = 22.
    This is less than 23, so a collision would not destroy the last asteroid.
    """


Prompt:
def maximumInvitations(favorite: List[int]) -> int:
    """
    A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.
    The employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.
    Given a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.

    Example 1:

    >>> maximumInvitations(favorite = [2,2,1,2])
    >>> 3
    Explanation:
    The above figure shows how the company can invite employees 0, 1, and 2, and seat them at the round table.
    All employees cannot be invited because employee 2 cannot sit beside employees 0, 1, and 3, simultaneously.
    Note that the company can also invite employees 1, 2, and 3, and give them their desired seats.
    The maximum number of employees that can be invited to the meeting is 3.

    Example 2:

    >>> maximumInvitations(favorite = [1,2,0])
    >>> 3
    Explanation:
    Each employee is the favorite person of at least one other employee, and the only way the company can invite them is if they invite every employee.
    The seating arrangement will be the same as that in the figure given in example 1:
    - Employee 0 will sit between employees 2 and 1.
    - Employee 1 will sit between employees 0 and 2.
    - Employee 2 will sit between employees 1 and 0.
    The maximum number of employees that can be invited to the meeting is 3.

    Example 3:

    >>> maximumInvitations(favorite = [3,0,1,4,1])
    >>> 4
    Explanation:
    The above figure shows how the company will invite employees 0, 1, 3, and 4, and seat them at the round table.
    Employee 2 cannot be invited because the two spots next to their favorite employee 1 are taken.
    So the company leaves them out of the meeting.
    The maximum number of employees that can be invited to the meeting is 4.
    """


Prompt:
def removeOnes(grid: List[List[int]]) -> bool:
    """
    You are given an m x n binary matrix grid.
    In one operation, you can choose any row or column and flip each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's).
    Return true if it is possible to remove all 1's from grid using any number of operations or false otherwise.

    Example 1:

    >>> removeOnes(grid = [[0,1,0],[1,0,1],[0,1,0]])
    >>> true
    Explanation: One possible way to remove all 1's from grid is to:
    - Flip the middle row
    - Flip the middle column

    Example 2:

    >>> removeOnes(grid = [[1,1,0],[0,0,0],[0,0,0]])
    >>> false
    Explanation: It is impossible to remove all 1's from grid.

    Example 3:

    >>> removeOnes(grid = [[0]])
    >>> true
    Explanation: There are no 1's in grid.
    """