Prompt:
def isPalindrome(s: str) -> bool:
    """
    A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers.
    Given a string s, return true if it is a palindrome, or false otherwise.

    Example 1:

    >>> isPalindrome(s = "A man, a plan, a canal: Panama")
    >>> true
    Explanation: "amanaplanacanalpanama" is a palindrome.

    Example 2:

    >>> isPalindrome(s = "race a car")
    >>> false
    Explanation: "raceacar" is not a palindrome.

    Example 3:

    >>> isPalindrome(s = " ")
    >>> true
    Explanation: s is an empty string "" after removing non-alphanumeric characters.
    Since an empty string reads the same forward and backward, it is a palindrome.
    """


Prompt:
from typing import List
def ladderLength(beginWord: str, endWord: str, wordList: List[str]) -> int:
    """
    A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that:

    Every adjacent pair of words differs by a single letter.
    Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList.
    sk == endWord

    Given two words, beginWord and endWord, and a dictionary wordList, return the number of words in the shortest transformation sequence from beginWord to endWord, or 0 if no such sequence exists.

    Example 1:

    >>> ladderLength(beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"])
    >>> 5
    Explanation: One shortest transformation sequence is "hit" -> "hot" -> "dot" -> "dog" -> cog", which is 5 words long.

    Example 2:

    >>> ladderLength(beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"])
    >>> 0
    Explanation: The endWord "cog" is not in wordList, therefore there is no valid transformation sequence.
    """


Prompt:
from typing import List
def longestConsecutive(nums: List[int]) -> int:
    """
    Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
    You must write an algorithm that runs in O(n) time.

    Example 1:

    >>> longestConsecutive(nums = [100,4,200,1,3,2])
    >>> 4
    Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.

    Example 2:

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

    Example 3:

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


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def sumNumbers(root: Optional[TreeNode]) -> int:
"""
You are given the root of a binary tree containing digits from 0 to 9 only.
Each root-to-leaf path in the tree represents a number.

For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123.

Return the total sum of all root-to-leaf numbers. Test cases are generated so that the answer will fit in a 32-bit integer.
A leaf node is a node with no children.

Example 1:

>>> sumNumbers(root = [1,2,3])
>>> 25
Explanation:
The root-to-leaf path 1->2 represents the number 12.
The root-to-leaf path 1->3 represents the number 13.
Therefore, sum = 12 + 13 = 25.

Example 2:

>>> sumNumbers(root = [4,9,0,5,1])
>>> 1026
Explanation:
The root-to-leaf path 4->9->5 represents the number 495.
The root-to-leaf path 4->9->1 represents the number 491.
The root-to-leaf path 4->0 represents the number 40.
Therefore, sum = 495 + 491 + 40 = 1026.
"""


Prompt:
from typing import List
def solve(board: List[List[str]]) -> None:
        """
        Do not return anything, modify board in-place instead.
        """
    """
    You are given an m x n matrix board containing letters 'X' and 'O', capture regions that are surrounded:

    Connect: A cell is connected to adjacent cells horizontally or vertically.
    Region: To form a region connect every 'O' cell.
    Surround: The region is surrounded with 'X' cells if you can connect the region with 'X' cells and none of the region cells are on the edge of the board.

    To capture a surrounded region, replace all 'O's with 'X's in-place within the original board. You do not need to return anything.

    Example 1:

    >>> solve(board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]])
    >>> [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]
    Explanation:

    In the above diagram, the bottom region is not captured because it is on the edge of the board and cannot be surrounded.

    Example 2:

    >>> solve(board = [["X"]])
    >>> [["X"]]
    """


Prompt:
from typing import List
def partition(s: str) -> List[List[str]]:
    """
    Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.

    Example 1:
    >>> partition(s = "aab")
    >>> [["a","a","b"],["aa","b"]]
    Example 2:
    >>> partition(s = "a")
    >>> [["a"]]
    """


Prompt:
def minCut(s: str) -> int:
    """
    Given a string s, partition s such that every substring of the partition is a palindrome.
    Return the minimum cuts needed for a palindrome partitioning of s.

    Example 1:

    >>> minCut(s = "aab")
    >>> 1
    Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut.

    Example 2:

    >>> minCut(s = "a")
    >>> 0

    Example 3:

    >>> minCut(s = "ab")
    >>> 1
    """


Prompt:
from typing import List
def canCompleteCircuit(gas: List[int], cost: List[int]) -> int:
    """
    There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].
    You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.
    Given two integer arrays gas and cost, return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1. If there exists a solution, it is guaranteed to be unique.

    Example 1:

    >>> canCompleteCircuit(gas = [1,2,3,4,5], cost = [3,4,5,1,2])
    >>> 3
    Explanation:
    Start at station 3 (index 3) and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
    Travel to station 4. Your tank = 4 - 1 + 5 = 8
    Travel to station 0. Your tank = 8 - 2 + 1 = 7
    Travel to station 1. Your tank = 7 - 3 + 2 = 6
    Travel to station 2. Your tank = 6 - 4 + 3 = 5
    Travel to station 3. The cost is 5. Your gas is just enough to travel back to station 3.
    Therefore, return 3 as the starting index.

    Example 2:

    >>> canCompleteCircuit(gas = [2,3,4], cost = [3,4,3])
    >>> -1
    Explanation:
    You can't start at station 0 or 1, as there is not enough gas to travel to the next station.
    Let's start at station 2 and fill up with 4 unit of gas. Your tank = 0 + 4 = 4
    Travel to station 0. Your tank = 4 - 3 + 2 = 3
    Travel to station 1. Your tank = 3 - 3 + 3 = 3
    You cannot travel back to station 2, as it requires 4 unit of gas but you only have 3.
    Therefore, you can't travel around the circuit once no matter where you start.
    """


Prompt:
from typing import List
def candy(ratings: List[int]) -> int:
    """
    There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.
    You are giving candies to these children subjected to the following requirements:

    Each child must have at least one candy.
    Children with a higher rating get more candies than their neighbors.

    Return the minimum number of candies you need to have to distribute the candies to the children.

    Example 1:

    >>> candy(ratings = [1,0,2])
    >>> 5
    Explanation: You can allocate to the first, second and third child with 2, 1, 2 candies respectively.

    Example 2:

    >>> candy(ratings = [1,2,2])
    >>> 4
    Explanation: You can allocate to the first, second and third child with 1, 2, 1 candies respectively.
    The third child gets 1 candy because it satisfies the above two conditions.
    """


Prompt:
from typing import List
def singleNumber(nums: List[int]) -> int:
    """
    Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
    You must implement a solution with a linear runtime complexity and use only constant extra space.

    Example 1:

    >>> singleNumber(nums = [2,2,1])
    >>> 1

    Example 2:

    >>> singleNumber(nums = [4,1,2,1,2])
    >>> 4

    Example 3:

    >>> singleNumber(nums = [1])
    >>> 1
    """


Prompt:
from typing import List
def singleNumber(nums: List[int]) -> int:
    """
    Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it.
    You must implement a solution with a linear runtime complexity and use only constant extra space.

    Example 1:
    >>> singleNumber(nums = [2,2,3,2])
    >>> 3
    Example 2:
    >>> singleNumber(nums = [0,1,0,1,0,1,99])
    >>> 99
    """


Prompt:
from typing import List
def wordBreak(s: str, wordDict: List[str]) -> bool:
    """
    Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
    Note that the same word in the dictionary may be reused multiple times in the segmentation.

    Example 1:

    >>> wordBreak(s = "leetcode", wordDict = ["leet","code"])
    >>> true
    Explanation: Return true because "leetcode" can be segmented as "leet code".

    Example 2:

    >>> wordBreak(s = "applepenapple", wordDict = ["apple","pen"])
    >>> true
    Explanation: Return true because "applepenapple" can be segmented as "apple pen apple".
    Note that you are allowed to reuse a dictionary word.

    Example 3:

    >>> wordBreak(s = "catsandog", wordDict = ["cats","dog","sand","and","cat"])
    >>> false
    """


Prompt:
from typing import List
def wordBreak(s: str, wordDict: List[str]) -> List[str]:
    """
    Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order.
    Note that the same word in the dictionary may be reused multiple times in the segmentation.

    Example 1:

    >>> wordBreak(s = "catsanddog", wordDict = ["cat","cats","and","sand","dog"])
    >>> ["cats and dog","cat sand dog"]

    Example 2:

    >>> wordBreak(s = "pineapplepenapple", wordDict = ["apple","pen","applepen","pine","pineapple"])
    >>> ["pine apple pen apple","pineapple pen apple","pine applepen apple"]
    Explanation: Note that you are allowed to reuse a dictionary word.

    Example 3:

    >>> wordBreak(s = "catsandog", wordDict = ["cats","dog","sand","and","cat"])
    >>> []
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(x):
        self.val = x
        self.next = None

def hasCycle(head: Optional[ListNode]) -> bool:
"""
Given head, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.
Return true if there is a cycle in the linked list. Otherwise, return false.

Example 1:

>>> hasCycle(head = [3,2,0,-4], pos = 1)
>>> true
Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed).

Example 2:

>>> hasCycle(head = [1,2], pos = 0)
>>> true
Explanation: There is a cycle in the linked list, where the tail connects to the 0th node.

Example 3:

>>> hasCycle(head = [1], pos = -1)
>>> false
Explanation: There is no cycle in the linked list.
"""


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def reorderList(head: Optional[ListNode]) -> None:
    """
    Do not return anything, modify head in-place instead.
    """
"""
You are given the head of a singly linked-list. The list can be represented as:

L0 → L1 → … → Ln - 1 → Ln

Reorder the list to be on the following form:

L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → …

You may not modify the values in the list's nodes. Only nodes themselves may be changed.

Example 1:

>>> reorderList(head = [1,2,3,4])
>>> [1,4,2,3]

Example 2:

>>> reorderList(head = [1,2,3,4,5])
>>> [1,5,2,4,3]
"""


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def preorderTraversal(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary tree, return the preorder traversal of its nodes' values.

Example 1:

>>> preorderTraversal(root = [1,null,2,3])
>>> [1,2,3]
Explanation:

Example 2:

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

Example 3:

>>> preorderTraversal(root = [])
>>> []

Example 4:

>>> preorderTraversal(root = [1])
>>> [1]
"""


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def postorderTraversal(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary tree, return the postorder traversal of its nodes' values.

Example 1:

>>> postorderTraversal(root = [1,null,2,3])
>>> [3,2,1]
Explanation:

Example 2:

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

Example 3:

>>> postorderTraversal(root = [])
>>> []

Example 4:

>>> postorderTraversal(root = [1])
>>> [1]
"""


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def insertionSortList(head: Optional[ListNode]) -> Optional[ListNode]:
"""
Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head.
The steps of the insertion sort algorithm:

Insertion sort iterates, consuming one input element each repetition and growing a sorted output list.
At each iteration, insertion sort removes one element from the input data, finds the location it belongs within the sorted list and inserts it there.
It repeats until no input elements remain.

The following is a graphical example of the insertion sort algorithm. The partially sorted list (black) initially contains only the first element in the list. One element (red) is removed from the input data and inserted in-place into the sorted list with each iteration.

Example 1:

>>> insertionSortList(head = [4,2,1,3])
>>> [1,2,3,4]

Example 2:

>>> insertionSortList(head = [-1,5,3,4,0])
>>> [-1,0,3,4,5]
"""


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def sortList(head: Optional[ListNode]) -> Optional[ListNode]:
"""
Given the head of a linked list, return the list after sorting it in ascending order.

Example 1:

>>> sortList(head = [4,2,1,3])
>>> [1,2,3,4]

Example 2:

>>> sortList(head = [-1,5,3,4,0])
>>> [-1,0,3,4,5]

Example 3:

>>> sortList(head = [])
>>> []
"""


Prompt:
from typing import List
def maxPoints(points: List[List[int]]) -> int:
    """
    Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.

    Example 1:

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

    Example 2:

    >>> maxPoints(points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]])
    >>> 4
    """


Prompt:
from typing import List
def evalRPN(tokens: List[str]) -> int:
    """
    You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
    Evaluate the expression. Return an integer that represents the value of the expression.
    Note that:

    The valid operators are '+', '-', '*', and '/'.
    Each operand may be an integer or another expression.
    The division between two integers always truncates toward zero.
    There will not be any division by zero.
    The input represents a valid arithmetic expression in a reverse polish notation.
    The answer and all the intermediate calculations can be represented in a 32-bit integer.

    Example 1:

    >>> evalRPN(tokens = ["2","1","+","3","*"])
    >>> 9
    Explanation: ((2 + 1) * 3) = 9

    Example 2:

    >>> evalRPN(tokens = ["4","13","5","/","+"])
    >>> 6
    Explanation: (4 + (13 / 5)) = 6

    Example 3:

    >>> evalRPN(tokens = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"])
    >>> 22
    Explanation: ((10 * (6 / ((9 + 3) * -11))) + 17) + 5
    = ((10 * (6 / (12 * -11))) + 17) + 5
    = ((10 * (6 / -132)) + 17) + 5
    = ((10 * 0) + 17) + 5
    = (0 + 17) + 5
    = 17 + 5
    = 22
    """


Prompt:
def reverseWords(s: str) -> str:
    """
    Given an input string s, reverse the order of the words.
    A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space.
    Return a string of the words in reverse order concatenated by a single space.
    Note that s may contain leading or trailing spaces or multiple spaces between two words. The returned string should only have a single space separating the words. Do not include any extra spaces.

    Example 1:

    >>> reverseWords(s = "the sky is blue")
    >>> "blue is sky the"

    Example 2:

    >>> reverseWords(s = "  hello world  ")
    >>> "world hello"
    Explanation: Your reversed string should not contain leading or trailing spaces.

    Example 3:

    >>> reverseWords(s = "a good   example")
    >>> "example good a"
    Explanation: You need to reduce multiple spaces between two words to a single space in the reversed string.
    """


Prompt:
from typing import List
def maxProduct(nums: List[int]) -> int:
    """
    Given an integer array nums, find a subarray that has the largest product, and return the product.
    The test cases are generated so that the answer will fit in a 32-bit integer.

    Example 1:

    >>> maxProduct(nums = [2,3,-2,4])
    >>> 6
    Explanation: [2,3] has the largest product 6.

    Example 2:

    >>> maxProduct(nums = [-2,0,-1])
    >>> 0
    Explanation: The result cannot be 2, because [-2,-1] is not a subarray.
    """


Prompt:
from typing import List
def findMin(nums: List[int]) -> int:
    """
    Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

    [4,5,6,7,0,1,2] if it was rotated 4 times.
    [0,1,2,4,5,6,7] if it was rotated 7 times.

    Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
    Given the sorted rotated array nums of unique elements, return the minimum element of this array.
    You must write an algorithm that runs in O(log n) time.

    Example 1:

    >>> findMin(nums = [3,4,5,1,2])
    >>> 1
    Explanation: The original array was [1,2,3,4,5] rotated 3 times.

    Example 2:

    >>> findMin(nums = [4,5,6,7,0,1,2])
    >>> 0
    Explanation: The original array was [0,1,2,4,5,6,7] and it was rotated 4 times.

    Example 3:

    >>> findMin(nums = [11,13,15,17])
    >>> 11
    Explanation: The original array was [11,13,15,17] and it was rotated 4 times.
    """


Prompt:
from typing import List
def findMin(nums: List[int]) -> int:
    """
    Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:

    [4,5,6,7,0,1,4] if it was rotated 4 times.
    [0,1,4,4,5,6,7] if it was rotated 7 times.

    Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]].
    Given the sorted rotated array nums that may contain duplicates, return the minimum element of this array.
    You must decrease the overall operation steps as much as possible.

    Example 1:
    >>> findMin(nums = [1,3,5])
    >>> 1
    Example 2:
    >>> findMin(nums = [2,2,2,0,1])
    >>> 0
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def upsideDownBinaryTree(root: Optional[TreeNode]) -> Optional[TreeNode]:
"""
Given the root of a binary tree, turn the tree upside down and return the new root.
You can turn a binary tree upside down with the following steps:

The original left child becomes the new root.
The original root becomes the new right child.
The original right child becomes the new left child.

The mentioned steps are done level by level. It is guaranteed that every right node has a sibling (a left node with the same parent) and has no children.

Example 1:

>>> upsideDownBinaryTree(root = [1,2,3,4,5])
>>> [4,5,2,null,null,3,1]

Example 2:

>>> upsideDownBinaryTree(root = [])
>>> []

Example 3:

>>> upsideDownBinaryTree(root = [1])
>>> [1]
"""


Prompt:
def lengthOfLongestSubstringTwoDistinct(s: str) -> int:
    """
    Given a string s, return the length of the longest substring that contains at most two distinct characters.

    Example 1:

    >>> lengthOfLongestSubstringTwoDistinct(s = "eceba")
    >>> 3
    Explanation: The substring is "ece" which its length is 3.

    Example 2:

    >>> lengthOfLongestSubstringTwoDistinct(s = "ccaabbb")
    >>> 5
    Explanation: The substring is "aabbb" which its length is 5.
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(x):
        self.val = x
        self.next = None

def getIntersectionNode(headA: ListNode, headB: ListNode) -> Optional[ListNode]:
"""
Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null.
For example, the following two linked lists begin to intersect at node c1:

The test cases are generated such that there are no cycles anywhere in the entire linked structure.
Note that the linked lists must retain their original structure after the function returns.
Custom Judge:
The inputs to the judge are given as follows (your program is not given these inputs):

intersectVal - The value of the node where the intersection occurs. This is 0 if there is no intersected node.
listA - The first linked list.
listB - The second linked list.
skipA - The number of nodes to skip ahead in listA (starting from the head) to get to the intersected node.
skipB - The number of nodes to skip ahead in listB (starting from the head) to get to the intersected node.

The judge will then create the linked structure based on these inputs and pass the two heads, headA and headB to your program. If you correctly return the intersected node, then your solution will be accepted.

Example 1:

>>> getIntersectionNode(intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8,4,5], skipA = 2, skipB = 3)
>>> Intersected at '8'
Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect).
From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,6,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B.
- Note that the intersected node's value is not 1 because the nodes with value 1 in A and B (2nd node in A and 3rd node in B) are different node references. In other words, they point to two different locations in memory, while the nodes with value 8 in A and B (3rd node in A and 4th node in B) point to the same location in memory.

Example 2:

>>> getIntersectionNode(intersectVal = 2, listA = [1,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1)
>>> Intersected at '2'
Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect).
From the head of A, it reads as [1,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B.

Example 3:

>>> getIntersectionNode(intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2)
>>> No intersection
Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values.
Explanation: The two lists do not intersect, so return null.
"""


Prompt:
def isOneEditDistance(s: str, t: str) -> bool:
    """
    Given two strings s and t, return true if they are both one edit distance apart, otherwise return false.
    A string s is said to be one distance apart from a string t if you can:

    Insert exactly one character into s to get t.
    Delete exactly one character from s to get t.
    Replace exactly one character of s with a different character to get t.

    Example 1:

    >>> isOneEditDistance(s = "ab", t = "acb")
    >>> true
    Explanation: We can insert 'c' into s to get t.

    Example 2:

    >>> isOneEditDistance(s = "", t = "")
    >>> false
    Explanation: We cannot get t from s by only one step.
    """


Prompt:
from typing import List
def findPeakElement(nums: List[int]) -> int:
    """
    A peak element is an element that is strictly greater than its neighbors.
    Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.
    You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array.
    You must write an algorithm that runs in O(log n) time.

    Example 1:

    >>> findPeakElement(nums = [1,2,3,1])
    >>> 2
    Explanation: 3 is a peak element and your function should return the index number 2.
    Example 2:

    >>> findPeakElement(nums = [1,2,1,3,5,6,4])
    >>> 5
    Explanation: Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.
    """


Prompt:
from typing import List
def findMissingRanges(nums: List[int], lower: int, upper: int) -> List[List[int]]:
    """
    You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are within the inclusive range.
    A number x is considered missing if x is in the range [lower, upper] and x is not in nums.
    Return the shortest sorted list of ranges that exactly covers all the missing numbers. That is, no element of nums is included in any of the ranges, and each missing number is covered by one of the ranges.

    Example 1:

    >>> findMissingRanges(nums = [0,1,3,50,75], lower = 0, upper = 99)
    >>> [[2,2],[4,49],[51,74],[76,99]]
    Explanation: The ranges are:
    [2,2]
    [4,49]
    [51,74]
    [76,99]

    Example 2:

    >>> findMissingRanges(nums = [-1], lower = -1, upper = -1)
    >>> []
    Explanation: There are no missing ranges since there are no missing numbers.
    """


Prompt:
from typing import List
def maximumGap(nums: List[int]) -> int:
    """
    Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0.
    You must write an algorithm that runs in linear time and uses linear extra space.

    Example 1:

    >>> maximumGap(nums = [3,6,9,1])
    >>> 3
    Explanation: The sorted form of the array is [1,3,6,9], either (3,6) or (6,9) has the maximum difference 3.

    Example 2:

    >>> maximumGap(nums = [10])
    >>> 0
    Explanation: The array contains less than 2 elements, therefore return 0.
    """


Prompt:
def compareVersion(version1: str, version2: str) -> int:
    """
    Given two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revision is its integer conversion ignoring leading zeros.
    To compare version strings, compare their revision values in left-to-right order. If one of the version strings has fewer revisions, treat the missing revision values as 0.
    Return the following:

    If version1 < version2, return -1.
    If version1 > version2, return 1.
    Otherwise, return 0.

    Example 1:

    >>> compareVersion(version1 = "1.2", version2 = "1.10")
    >>> -1
    Explanation:
    version1's second revision is "2" and version2's second revision is "10": 2 < 10, so version1 < version2.

    Example 2:

    >>> compareVersion(version1 = "1.01", version2 = "1.001")
    >>> 0
    Explanation:
    Ignoring leading zeroes, both "01" and "001" represent the same integer "1".

    Example 3:

    >>> compareVersion(version1 = "1.0", version2 = "1.0.0.0")
    >>> 0
    Explanation:
    version1 has less revisions, which means every missing revision are treated as "0".
    """


Prompt:
def fractionToDecimal(numerator: int, denominator: int) -> str:
    """
    Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
    If the fractional part is repeating, enclose the repeating part in parentheses.
    If multiple answers are possible, return any of them.
    It is guaranteed that the length of the answer string is less than 104 for all the given inputs.

    Example 1:

    >>> fractionToDecimal(numerator = 1, denominator = 2)
    >>> "0.5"

    Example 2:

    >>> fractionToDecimal(numerator = 2, denominator = 1)
    >>> "2"

    Example 3:

    >>> fractionToDecimal(numerator = 4, denominator = 333)
    >>> "0.(012)"
    """


Prompt:
from typing import List
def twoSum(numbers: List[int], target: int) -> List[int]:
    """
    Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length.
    Return the indices of the two numbers, index1 and index2, added by one as an integer array [index1, index2] of length 2.
    The tests are generated such that there is exactly one solution. You may not use the same element twice.
    Your solution must use only constant extra space.

    Example 1:

    >>> twoSum(numbers = [2,7,11,15], target = 9)
    >>> [1,2]
    Explanation: The sum of 2 and 7 is 9. Therefore, index1 = 1, index2 = 2. We return [1, 2].

    Example 2:

    >>> twoSum(numbers = [2,3,4], target = 6)
    >>> [1,3]
    Explanation: The sum of 2 and 4 is 6. Therefore index1 = 1, index2 = 3. We return [1, 3].

    Example 3:

    >>> twoSum(numbers = [-1,0], target = -1)
    >>> [1,2]
    Explanation: The sum of -1 and 0 is -1. Therefore index1 = 1, index2 = 2. We return [1, 2].
    """


Prompt:
def convertToTitle(columnNumber: int) -> str:
    """
    Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.
    For example:

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28
    ...

    Example 1:

    >>> convertToTitle(columnNumber = 1)
    >>> "A"

    Example 2:

    >>> convertToTitle(columnNumber = 28)
    >>> "AB"

    Example 3:

    >>> convertToTitle(columnNumber = 701)
    >>> "ZY"
    """


Prompt:
from typing import List
def majorityElement(nums: List[int]) -> int:
    """
    Given an array nums of size n, return the majority element.
    The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.

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


Prompt:
def titleToNumber(columnTitle: str) -> int:
    """
    Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number.
    For example:

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28
    ...

    Example 1:

    >>> titleToNumber(columnTitle = "A")
    >>> 1

    Example 2:

    >>> titleToNumber(columnTitle = "AB")
    >>> 28

    Example 3:

    >>> titleToNumber(columnTitle = "ZY")
    >>> 701
    """


Prompt:
def trailingZeroes(n: int) -> int:
    """
    Given an integer n, return the number of trailing zeroes in n!.
    Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1.

    Example 1:

    >>> trailingZeroes(n = 3)
    >>> 0
    Explanation: 3! = 6, no trailing zero.

    Example 2:

    >>> trailingZeroes(n = 5)
    >>> 1
    Explanation: 5! = 120, one trailing zero.

    Example 3:

    >>> trailingZeroes(n = 0)
    >>> 0
    """


Prompt:
from typing import List
def calculateMinimumHP(dungeon: List[List[int]]) -> int:
    """
    The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left room and must fight his way through dungeon to rescue the princess.
    The knight has an initial health point represented by a positive integer. If at any point his health point drops to 0 or below, he dies immediately.
    Some of the rooms are guarded by demons (represented by negative integers), so the knight loses health upon entering these rooms; other rooms are either empty (represented as 0) or contain magic orbs that increase the knight's health (represented by positive integers).
    To reach the princess as quickly as possible, the knight decides to move only rightward or downward in each step.
    Return the knight's minimum initial health so that he can rescue the princess.
    Note that any room can contain threats or power-ups, even the first room the knight enters and the bottom-right room where the princess is imprisoned.

    Example 1:

    >>> calculateMinimumHP(dungeon = [[-2,-3,3],[-5,-10,1],[10,30,-5]])
    >>> 7
    Explanation: The initial health of the knight must be at least 7 if he follows the optimal path: RIGHT-> RIGHT -> DOWN -> DOWN.

    Example 2:

    >>> calculateMinimumHP(dungeon = [[0]])
    >>> 1
    """


Prompt:
from typing import List
def largestNumber(nums: List[int]) -> str:
    """
    Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.
    Since the result may be very large, so you need to return a string instead of an integer.

    Example 1:

    >>> largestNumber(nums = [10,2])
    >>> "210"

    Example 2:

    >>> largestNumber(nums = [3,30,34,5,9])
    >>> "9534330"
    """


Prompt:
from typing import List
def reverseWords(s: List[str]) -> None:
        """
        Do not return anything, modify s in-place instead.
        """
    """
    Given a character array s, reverse the order of the words.
    A word is defined as a sequence of non-space characters. The words in s will be separated by a single space.
    Your code must solve the problem in-place, i.e. without allocating extra space.

    Example 1:
    >>> reverseWords(s = ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"])
    >>> ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"]
    Example 2:
    >>> reverseWords(s = ["a"])
    >>> ["a"]
    """


Prompt:
from typing import List
def findRepeatedDnaSequences(s: str) -> List[str]:
    """
    The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.

    For example, "ACGAATTCCG" is a DNA sequence.

    When studying DNA, it is useful to identify repeated sequences within the DNA.
    Given a string s that represents a DNA sequence, return all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in any order.

    Example 1:
    >>> findRepeatedDnaSequences(s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT")
    >>> ["AAAAACCCCC","CCCCCAAAAA"]
    Example 2:
    >>> findRepeatedDnaSequences(s = "AAAAAAAAAAAAA")
    >>> ["AAAAAAAAAA"]
    """


Prompt:
from typing import List
def maxProfit(k: int, prices: List[int]) -> int:
    """
    You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.
    Find the maximum profit you can achieve. You may complete at most k transactions: i.e. you may buy at most k times and sell at most k times.
    Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

    Example 1:

    >>> maxProfit(k = 2, prices = [2,4,1])
    >>> 2
    Explanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2.

    Example 2:

    >>> maxProfit(k = 2, prices = [3,2,6,5,0,3])
    >>> 7
    Explanation: Buy on day 2 (price = 2) and sell on day 3 (price = 6), profit = 6-2 = 4. Then buy on day 5 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.
    """


Prompt:
from typing import List
def rotate(nums: List[int], k: int) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
    """
    Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

    Example 1:

    >>> rotate(nums = [1,2,3,4,5,6,7], k = 3)
    >>> [5,6,7,1,2,3,4]
    Explanation:
    rotate 1 steps to the right: [7,1,2,3,4,5,6]
    rotate 2 steps to the right: [6,7,1,2,3,4,5]
    rotate 3 steps to the right: [5,6,7,1,2,3,4]

    Example 2:

    >>> rotate(nums = [-1,-100,3,99], k = 2)
    >>> [3,99,-1,-100]
    Explanation:
    rotate 1 steps to the right: [99,-1,-100,3]
    rotate 2 steps to the right: [3,99,-1,-100]
    """


Prompt:
def reverseBits(n: int) -> int:
    """
    Reverse bits of a given 32 bits unsigned integer.
    Note:

    Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
    In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.

    Example 1:

    >>> reverseBits(n = 00000010100101000001111010011100)
    >>> 964176192 (00111001011110000010100101000000)
    Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.

    Example 2:

    >>> reverseBits(n = 11111111111111111111111111111101)
    >>> 3221225471 (10111111111111111111111111111111)
    Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111.
    """


Prompt:
def hammingWeight(n: int) -> int:
    """
    Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).

    Example 1:

    >>> hammingWeight(n = 11)
    >>> 3
    Explanation:
    The input binary string 1011 has a total of three set bits.

    Example 2:

    >>> hammingWeight(n = 128)
    >>> 1
    Explanation:
    The input binary string 10000000 has a total of one set bit.

    Example 3:

    >>> hammingWeight(n = 2147483645)
    >>> 30
    Explanation:
    The input binary string 1111111111111111111111111111101 has a total of thirty set bits.
    """


Prompt:
from typing import List
def rob(nums: List[int]) -> int:
    """
    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
    Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

    Example 1:

    >>> rob(nums = [1,2,3,1])
    >>> 4
    Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
    Total amount you can rob = 1 + 3 = 4.

    Example 2:

    >>> rob(nums = [2,7,9,3,1])
    >>> 12
    Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (money = 1).
    Total amount you can rob = 2 + 9 + 1 = 12.
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def rightSideView(root: Optional[TreeNode]) -> List[int]:
"""
Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

Example 1:

>>> rightSideView(root = [1,2,3,null,5,null,4])
>>> [1,3,4]
Explanation:

Example 2:

>>> rightSideView(root = [1,2,3,4,null,null,null,5])
>>> [1,3,4,5]
Explanation:

Example 3:

>>> rightSideView(root = [1,null,3])
>>> [1,3]

Example 4:

>>> rightSideView(root = [])
>>> []
"""


Prompt:
from typing import List
def numIslands(grid: List[List[str]]) -> int:
    """
    Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.
    An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

    Example 1:

      ["1","1","1","1","0"],
      ["1","1","0","1","0"],
      ["1","1","0","0","0"],
      ["0","0","0","0","0"]
    ]
    >>> numIslands(grid = [)
    >>> 1

    Example 2:

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


Prompt:
def rangeBitwiseAnd(left: int, right: int) -> int:
    """
    Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.

    Example 1:

    >>> rangeBitwiseAnd(left = 5, right = 7)
    >>> 4

    Example 2:

    >>> rangeBitwiseAnd(left = 0, right = 0)
    >>> 0

    Example 3:

    >>> rangeBitwiseAnd(left = 1, right = 2147483647)
    >>> 0
    """


Prompt:
def isHappy(n: int) -> bool:
    """
    Write an algorithm to determine if a number n is happy.
    A happy number is a number defined by the following process:

    Starting with any positive integer, replace the number by the sum of the squares of its digits.
    Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1.
    Those numbers for which this process ends in 1 are happy.

    Return true if n is a happy number, and false if not.

    Example 1:

    >>> isHappy(n = 19)
    >>> true
    Explanation:
    12 + 92 = 82
    82 + 22 = 68
    62 + 82 = 100
    12 + 02 + 02 = 1

    Example 2:

    >>> isHappy(n = 2)
    >>> false
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def removeElements(head: Optional[ListNode], val: int) -> Optional[ListNode]:
"""
Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.

Example 1:

>>> removeElements(head = [1,2,6,3,4,5,6], val = 6)
>>> [1,2,3,4,5]

Example 2:

>>> removeElements(head = [], val = 1)
>>> []

Example 3:

>>> removeElements(head = [7,7,7,7], val = 7)
>>> []
"""


Prompt:
def countPrimes(n: int) -> int:
    """
    Given an integer n, return the number of prime numbers that are strictly less than n.

    Example 1:

    >>> countPrimes(n = 10)
    >>> 4
    Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.

    Example 2:

    >>> countPrimes(n = 0)
    >>> 0

    Example 3:

    >>> countPrimes(n = 1)
    >>> 0
    """


Prompt:
def isIsomorphic(s: str, t: str) -> bool:
    """
    Given two strings s and t, determine if they are isomorphic.
    Two strings s and t are isomorphic if the characters in s can be replaced to get t.
    All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.

    Example 1:

    >>> isIsomorphic(s = "egg", t = "add")
    >>> true
    Explanation:
    The strings s and t can be made identical by:

    Mapping 'e' to 'a'.
    Mapping 'g' to 'd'.

    Example 2:

    >>> isIsomorphic(s = "foo", t = "bar")
    >>> false
    Explanation:
    The strings s and t can not be made identical as 'o' needs to be mapped to both 'a' and 'r'.

    Example 3:

    >>> isIsomorphic(s = "paper", t = "title")
    >>> true
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def reverseList(head: Optional[ListNode]) -> Optional[ListNode]:
"""
Given the head of a singly linked list, reverse the list, and return the reversed list.

Example 1:

>>> reverseList(head = [1,2,3,4,5])
>>> [5,4,3,2,1]

Example 2:

>>> reverseList(head = [1,2])
>>> [2,1]

Example 3:

>>> reverseList(head = [])
>>> []
"""


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

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

    Return true if you can finish all courses. Otherwise, return false.

    Example 1:

    >>> canFinish(numCourses = 2, prerequisites = [[1,0]])
    >>> true
    Explanation: There are a total of 2 courses to take.
    To take course 1 you should have finished course 0. So it is possible.

    Example 2:

    >>> canFinish(numCourses = 2, prerequisites = [[1,0],[0,1]])
    >>> false
    Explanation: There are a total of 2 courses to take.
    To take course 1 you should have finished course 0, and to take course 0 you should also have finished course 1. So it is impossible.
    """


Prompt:
from typing import List
def minSubArrayLen(target: int, nums: List[int]) -> int:
    """
    Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.

    Example 1:

    >>> minSubArrayLen(target = 7, nums = [2,3,1,2,4,3])
    >>> 2
    Explanation: The subarray [4,3] has the minimal length under the problem constraint.

    Example 2:

    >>> minSubArrayLen(target = 4, nums = [1,4,4])
    >>> 1

    Example 3:

    >>> minSubArrayLen(target = 11, nums = [1,1,1,1,1,1,1,1])
    >>> 0
    """


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

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

    Return the ordering of courses you should take to finish all courses. If there are many valid answers, return any of them. If it is impossible to finish all courses, return an empty array.

    Example 1:

    >>> findOrder(numCourses = 2, prerequisites = [[1,0]])
    >>> [0,1]
    Explanation: There are a total of 2 courses to take. To take course 1 you should have finished course 0. So the correct course order is [0,1].

    Example 2:

    >>> findOrder(numCourses = 4, prerequisites = [[1,0],[2,0],[3,1],[3,2]])
    >>> [0,2,1,3]
    Explanation: There are a total of 4 courses to take. To take course 3 you should have finished both courses 1 and 2. Both courses 1 and 2 should be taken after you finished course 0.
    So one correct course order is [0,1,2,3]. Another correct ordering is [0,2,1,3].

    Example 3:

    >>> findOrder(numCourses = 1, prerequisites = [])
    >>> [0]
    """


Prompt:
from typing import List
def findWords(board: List[List[str]], words: List[str]) -> List[str]:
    """
    Given an m x n board of characters and a list of strings words, return all words on the board.
    Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word.

    Example 1:

    >>> findWords(board = [["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]], words = ["oath","pea","eat","rain"])
    >>> ["eat","oath"]

    Example 2:

    >>> findWords(board = [["a","b"],["c","d"]], words = ["abcb"])
    >>> []
    """


Prompt:
from typing import List
def rob(nums: List[int]) -> int:
    """
    You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically contact the police if two adjacent houses were broken into on the same night.
    Given an integer array nums representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police.

    Example 1:

    >>> rob(nums = [2,3,2])
    >>> 3
    Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), because they are adjacent houses.

    Example 2:

    >>> rob(nums = [1,2,3,1])
    >>> 4
    Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
    Total amount you can rob = 1 + 3 = 4.

    Example 3:

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


Prompt:
def shortestPalindrome(s: str) -> str:
    """
    You are given a string s. You can convert s to a palindrome by adding characters in front of it.
    Return the shortest palindrome you can find by performing this transformation.

    Example 1:
    >>> shortestPalindrome(s = "aacecaaa")
    >>> "aaacecaaa"
    Example 2:
    >>> shortestPalindrome(s = "abcd")
    >>> "dcbabcd"
    """


Prompt:
from typing import List
def findKthLargest(nums: List[int], k: int) -> int:
    """
    Given an integer array nums and an integer k, return the kth largest element in the array.
    Note that it is the kth largest element in the sorted order, not the kth distinct element.
    Can you solve it without sorting?

    Example 1:
    >>> findKthLargest(nums = [3,2,1,5,6,4], k = 2)
    >>> 5
    Example 2:
    >>> findKthLargest(nums = [3,2,3,1,2,4,5,5,6], k = 4)
    >>> 4
    """


Prompt:
from typing import List
def combinationSum3(k: int, n: int) -> List[List[int]]:
    """
    Find all valid combinations of k numbers that sum up to n such that the following conditions are true:

    Only numbers 1 through 9 are used.
    Each number is used at most once.

    Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in any order.

    Example 1:

    >>> combinationSum3(k = 3, n = 7)
    >>> [[1,2,4]]
    Explanation:
    1 + 2 + 4 = 7
    There are no other valid combinations.
    Example 2:

    >>> combinationSum3(k = 3, n = 9)
    >>> [[1,2,6],[1,3,5],[2,3,4]]
    Explanation:
    1 + 2 + 6 = 9
    1 + 3 + 5 = 9
    2 + 3 + 4 = 9
    There are no other valid combinations.

    Example 3:

    >>> combinationSum3(k = 4, n = 1)
    >>> []
    Explanation: There are no valid combinations.
    Using 4 different numbers in the range [1,9], the smallest sum we can get is 1+2+3+4 = 10 and since 10 > 1, there are no valid combination.
    """


Prompt:
from typing import List
def containsDuplicate(nums: List[int]) -> bool:
    """
    Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

    Example 1:

    >>> containsDuplicate(nums = [1,2,3,1])
    >>> true
    Explanation:
    The element 1 occurs at the indices 0 and 3.

    Example 2:

    >>> containsDuplicate(nums = [1,2,3,4])
    >>> false
    Explanation:
    All elements are distinct.

    Example 3:

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


Prompt:
from typing import Any, List
def getSkyline(buildings: List[List[int]]) -> List[List[int]]:
    """
    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively.
    The geometric information of each building is given in the array buildings where buildings[i] = [lefti, righti, heighti]:

    lefti is the x coordinate of the left edge of the ith building.
    righti is the x coordinate of the right edge of the ith building.
    heighti is the height of the ith building.

    You may assume all buildings are perfect rectangles grounded on an absolutely flat surface at height 0.
    The skyline should be represented as a list of "key points" sorted by their x-coordinate in the form [[x1,y1],[x2,y2],...]. Each key point is the left endpoint of some horizontal segment in the skyline except the last point in the list, which always has a y-coordinate 0 and is used to mark the skyline's termination where the rightmost building ends. Any ground between the leftmost and rightmost buildings should be part of the skyline's contour.
    Note: There must be no consecutive horizontal lines of equal height in the output skyline. For instance, [...,[2 3],[4 5],[7 5],[11 5],[12 7],...] is not acceptable; the three lines of height 5 should be merged into one in the final output as such: [...,[2 3],[4 5],[12 7],...]

    Example 1:

    >>> getSkyline(buildings = [[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]])
    >>> [[2,10],[3,15],[7,12],[12,0],[15,10],[20,8],[24,0]]
    Explanation:
    Figure A shows the buildings of the input.
    Figure B shows the skyline formed by those buildings. The red points in figure B represent the key points in the output list.

    Example 2:

    >>> getSkyline(buildings = [[0,2,3],[2,5,3]])
    >>> [[0,3],[5,0]]
    """


Prompt:
from typing import List
def containsNearbyDuplicate(nums: List[int], k: int) -> bool:
    """
    Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.

    Example 1:

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

    Example 2:

    >>> containsNearbyDuplicate(nums = [1,0,1,1], k = 1)
    >>> true

    Example 3:

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


Prompt:
from typing import List
def containsNearbyAlmostDuplicate(nums: List[int], indexDiff: int, valueDiff: int) -> bool:
    """
    You are given an integer array nums and two integers indexDiff and valueDiff.
    Find a pair of indices (i, j) such that:

    i != j,
    abs(i - j) <= indexDiff.
    abs(nums[i] - nums[j]) <= valueDiff, and

    Return true if such pair exists or false otherwise.

    Example 1:

    >>> containsNearbyAlmostDuplicate(nums = [1,2,3,1], indexDiff = 3, valueDiff = 0)
    >>> true
    Explanation: We can choose (i, j) = (0, 3).
    We satisfy the three conditions:
    i != j --> 0 != 3
    abs(i - j) <= indexDiff --> abs(0 - 3) <= 3
    abs(nums[i] - nums[j]) <= valueDiff --> abs(1 - 1) <= 0

    Example 2:

    >>> containsNearbyAlmostDuplicate(nums = [1,5,9,1,5,9], indexDiff = 2, valueDiff = 3)
    >>> false
    Explanation: After trying all the possible pairs (i, j), we cannot satisfy the three conditions, so we return false.
    """


Prompt:
from typing import List
def maximalSquare(matrix: List[List[str]]) -> int:
    """
    Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

    Example 1:

    >>> maximalSquare(matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]])
    >>> 4

    Example 2:

    >>> maximalSquare(matrix = [["0","1"],["1","0"]])
    >>> 1

    Example 3:

    >>> maximalSquare(matrix = [["0"]])
    >>> 0
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def countNodes(root: Optional[TreeNode]) -> int:
"""
Given the root of a complete binary tree, return the number of the nodes in the tree.
According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.
Design an algorithm that runs in less than O(n) time complexity.

Example 1:

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

Example 2:

>>> countNodes(root = [])
>>> 0

Example 3:

>>> countNodes(root = [1])
>>> 1
"""


Prompt:
def computeArea(ax1: int, ay1: int, ax2: int, ay2: int, bx1: int, by1: int, bx2: int, by2: int) -> int:
    """
    Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.
    The first rectangle is defined by its bottom-left corner (ax1, ay1) and its top-right corner (ax2, ay2).
    The second rectangle is defined by its bottom-left corner (bx1, by1) and its top-right corner (bx2, by2).

    Example 1:

    >>> computeArea(ax1 = -3, ay1 = 0, ax2 = 3, ay2 = 4, bx1 = 0, by1 = -1, bx2 = 9, by2 = 2)
    >>> 45

    Example 2:

    >>> computeArea(ax1 = -2, ay1 = -2, ax2 = 2, ay2 = 2, bx1 = -2, by1 = -2, bx2 = 2, by2 = 2)
    >>> 16
    """


Prompt:
def calculate(s: str) -> int:
    """
    Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.
    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    Example 1:

    >>> calculate(s = "1 + 1")
    >>> 2

    Example 2:

    >>> calculate(s = " 2-1 + 2 ")
    >>> 3

    Example 3:

    >>> calculate(s = "(1+(4+5+2)-3)+(6+8)")
    >>> 23
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def invertTree(root: Optional[TreeNode]) -> Optional[TreeNode]:
"""
Given the root of a binary tree, invert the tree, and return its root.

Example 1:

>>> invertTree(root = [4,2,7,1,3,6,9])
>>> [4,7,2,9,6,3,1]

Example 2:

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

Example 3:

>>> invertTree(root = [])
>>> []
"""


Prompt:
def calculate(s: str) -> int:
    """
    Given a string s which represents an expression, evaluate this expression and return its value.
    The integer division should truncate toward zero.
    You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1].
    Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().

    Example 1:
    >>> calculate(s = "3+2*2")
    >>> 7
    Example 2:
    >>> calculate(s = " 3/2 ")
    >>> 1
    Example 3:
    >>> calculate(s = " 3+5 / 2 ")
    >>> 5
    """


Prompt:
from typing import List
def summaryRanges(nums: List[int]) -> List[str]:
    """
    You are given a sorted unique integer array nums.
    A range [a,b] is the set of all integers from a to b (inclusive).
    Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is in one of the ranges but not in nums.
    Each range [a,b] in the list should be output as:

    "a->b" if a != b
    "a" if a == b

    Example 1:

    >>> summaryRanges(nums = [0,1,2,4,5,7])
    >>> ["0->2","4->5","7"]
    Explanation: The ranges are:
    [0,2] --> "0->2"
    [4,5] --> "4->5"
    [7,7] --> "7"

    Example 2:

    >>> summaryRanges(nums = [0,2,3,4,6,8,9])
    >>> ["0","2->4","6","8->9"]
    Explanation: The ranges are:
    [0,0] --> "0"
    [2,4] --> "2->4"
    [6,6] --> "6"
    [8,9] --> "8->9"
    """


Prompt:
from typing import List
def majorityElement(nums: List[int]) -> List[int]:
    """
    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

    Example 1:

    >>> majorityElement(nums = [3,2,3])
    >>> [3]

    Example 2:

    >>> majorityElement(nums = [1])
    >>> [1]

    Example 3:

    >>> majorityElement(nums = [1,2])
    >>> [1,2]
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def kthSmallest(root: Optional[TreeNode], k: int) -> int:
"""
Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

Example 1:

>>> kthSmallest(root = [3,1,4,null,2], k = 1)
>>> 1

Example 2:

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


Prompt:
def isPowerOfTwo(n: int) -> bool:
    """
    Given an integer n, return true if it is a power of two. Otherwise, return false.
    An integer n is a power of two, if there exists an integer x such that n == 2x.

    Example 1:

    >>> isPowerOfTwo(n = 1)
    >>> true
    Explanation: 20 = 1

    Example 2:

    >>> isPowerOfTwo(n = 16)
    >>> true
    Explanation: 24 = 16

    Example 3:

    >>> isPowerOfTwo(n = 3)
    >>> false
    """


Prompt:
def countDigitOne(n: int) -> int:
    """
    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.

    Example 1:

    >>> countDigitOne(n = 13)
    >>> 6

    Example 2:

    >>> countDigitOne(n = 0)
    >>> 0
    """


Prompt:
from typing import Optional
class ListNode:
    def __init__(val=0, next=None):
        self.val = val
        self.next = next
def isPalindrome(head: Optional[ListNode]) -> bool:
"""
Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

Example 1:

>>> isPalindrome(head = [1,2,2,1])
>>> true

Example 2:

>>> isPalindrome(head = [1,2])
>>> false
"""


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

def lowestCommonAncestor(root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
"""
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).”

Example 1:

>>> lowestCommonAncestor(root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1)
>>> 3
Explanation: The LCA of nodes 5 and 1 is 3.

Example 2:

>>> lowestCommonAncestor(root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4)
>>> 5
Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition.

Example 3:

>>> lowestCommonAncestor(root = [1,2], p = 1, q = 2)
>>> 1
"""


Prompt:
from typing import List
def productExceptSelf(nums: List[int]) -> List[int]:
    """
    Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
    The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
    You must write an algorithm that runs in O(n) time and without using the division operation.

    Example 1:
    >>> productExceptSelf(nums = [1,2,3,4])
    >>> [24,12,8,6]
    Example 2:
    >>> productExceptSelf(nums = [-1,1,0,-3,3])
    >>> [0,0,9,0,0]
    """


Prompt:
from typing import List
def maxSlidingWindow(nums: List[int], k: int) -> List[int]:
    """
    You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
    Return the max sliding window.

    Example 1:

    >>> maxSlidingWindow(nums = [1,3,-1,-3,5,3,6,7], k = 3)
    >>> [3,3,5,5,6,7]
    Explanation:
    Window position                Max
    ---------------               -----
    [1  3  -1] -3  5  3  6  7       3
     1 [3  -1  -3] 5  3  6  7       3
     1  3 [-1  -3  5] 3  6  7       5
     1  3  -1 [-3  5  3] 6  7       5
     1  3  -1  -3 [5  3  6] 7       6
     1  3  -1  -3  5 [3  6  7]      7

    Example 2:

    >>> maxSlidingWindow(nums = [1], k = 1)
    >>> [1]
    """


Prompt:
from typing import List
def searchMatrix(matrix: List[List[int]], target: int) -> bool:
    """
    Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties:

    Integers in each row are sorted in ascending from left to right.
    Integers in each column are sorted in ascending from top to bottom.

    Example 1:

    >>> searchMatrix(matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 5)
    >>> true

    Example 2:

    >>> searchMatrix(matrix = [[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]], target = 20)
    >>> false
    """


Prompt:
from typing import List
def diffWaysToCompute(expression: str) -> List[int]:
    """
    Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order.
    The test cases are generated such that the output values fit in a 32-bit integer and the number of different results does not exceed 104.

    Example 1:

    >>> diffWaysToCompute(expression = "2-1-1")
    >>> [0,2]
    Explanation:
    ((2-1)-1) = 0
    (2-(1-1)) = 2

    Example 2:

    >>> diffWaysToCompute(expression = "2*3-4*5")
    >>> [-34,-14,-10,-10,10]
    Explanation:
    (2*(3-(4*5))) = -34
    ((2*3)-(4*5)) = -14
    ((2*(3-4))*5) = -10
    (2*((3-4)*5)) = -10
    (((2*3)-4)*5) = 10
    """


Prompt:
def isAnagram(s: str, t: str) -> bool:
    """
    Given two strings s and t, return true if t is an anagram of s, and false otherwise.

    Example 1:

    >>> isAnagram(s = "anagram", t = "nagaram")
    >>> true

    Example 2:

    >>> isAnagram(s = "rat", t = "car")
    >>> false
    """


Prompt:
from typing import List
def shortestDistance(wordsDict: List[str], word1: str, word2: str) -> int:
    """
    Given an array of strings wordsDict and two different strings that already exist in the array word1 and word2, return the shortest distance between these two words in the list.

    Example 1:

    >>> shortestDistance(wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "coding", word2 = "practice")
    >>> 3

    Example 2:

    >>> shortestDistance(wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "coding")
    >>> 1
    """


Prompt:
from typing import List
def shortestWordDistance(wordsDict: List[str], word1: str, word2: str) -> int:
    """
    Given an array of strings wordsDict and two strings that already exist in the array word1 and word2, return the shortest distance between the occurrence of these two words in the list.
    Note that word1 and word2 may be the same. It is guaranteed that they represent two individual words in the list.

    Example 1:
    >>> shortestWordDistance(wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "coding")
    >>> 1
    Example 2:
    >>> shortestWordDistance(wordsDict = ["practice", "makes", "perfect", "coding", "makes"], word1 = "makes", word2 = "makes")
    >>> 3
    """


Prompt:
def isStrobogrammatic(num: str) -> bool:
    """
    Given a string num which represents an integer, return true if num is a strobogrammatic number.
    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    Example 1:

    >>> isStrobogrammatic(num = "69")
    >>> true

    Example 2:

    >>> isStrobogrammatic(num = "88")
    >>> true

    Example 3:

    >>> isStrobogrammatic(num = "962")
    >>> false
    """


Prompt:
from typing import List
def findStrobogrammatic(n: int) -> List[str]:
    """
    Given an integer n, return all the strobogrammatic numbers that are of length n. You may return the answer in any order.
    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    Example 1:
    >>> findStrobogrammatic(n = 2)
    >>> ["11","69","88","96"]
    Example 2:
    >>> findStrobogrammatic(n = 1)
    >>> ["0","1","8"]
    """


Prompt:
def strobogrammaticInRange(low: str, high: str) -> int:
    """
    Given two strings low and high that represent two integers low and high where low <= high, return the number of strobogrammatic numbers in the range [low, high].
    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).

    Example 1:
    >>> strobogrammaticInRange(low = "50", high = "100")
    >>> 3
    Example 2:
    >>> strobogrammaticInRange(low = "0", high = "0")
    >>> 1
    """


Prompt:
from typing import List
def groupStrings(strings: List[str]) -> List[List[str]]:
    """
    Perform the following shift operations on a string:

    Right shift: Replace every letter with the successive letter of the English alphabet, where 'z' is replaced by 'a'. For example, "abc" can be right-shifted to "bcd" or "xyz" can be right-shifted to "yza".
    Left shift: Replace every letter with the preceding letter of the English alphabet, where 'a' is replaced by 'z'. For example, "bcd" can be left-shifted to "abc" or "yza" can be left-shifted to "xyz".

    We can keep shifting the string in both directions to form an endless shifting sequence.

    For example, shift "abc" to form the sequence: ... <-> "abc" <-> "bcd" <-> ... <-> "xyz" <-> "yza" <-> .... <-> "zab" <-> "abc" <-> ...

    You are given an array of strings strings, group together all strings[i] that belong to the same shifting sequence. You may return the answer in any order.

    Example 1:

    >>> groupStrings(strings = ["abc","bcd","acef","xyz","az","ba","a","z"])
    >>> [["acef"],["a","z"],["abc","bcd","xyz"],["az","ba"]]

    Example 2:

    >>> groupStrings(strings = ["a"])
    >>> [["a"]]
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def countUnivalSubtrees(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the number of uni-value subtrees.
A uni-value subtree means all nodes of the subtree have the same value.

Example 1:

>>> countUnivalSubtrees(root = [5,1,5,5,5,null,5])
>>> 4

Example 2:

>>> countUnivalSubtrees(root = [])
>>> 0

Example 3:

>>> countUnivalSubtrees(root = [5,5,5,5,5,null,5])
>>> 6
"""


Prompt:
from typing import List
def canAttendMeetings(intervals: List[List[int]]) -> bool:
    """
    Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.

    Example 1:
    >>> canAttendMeetings(intervals = [[0,30],[5,10],[15,20]])
    >>> false
    Example 2:
    >>> canAttendMeetings(intervals = [[7,10],[2,4]])
    >>> true
    """


Prompt:
from typing import List
def minMeetingRooms(intervals: List[List[int]]) -> int:
    """
    Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.

    Example 1:
    >>> minMeetingRooms(intervals = [[0,30],[5,10],[15,20]])
    >>> 2
    Example 2:
    >>> minMeetingRooms(intervals = [[7,10],[2,4]])
    >>> 1
    """


Prompt:
from typing import List
def getFactors(n: int) -> List[List[int]]:
    """
    Numbers can be regarded as the product of their factors.

    For example, 8 = 2 x 2 x 2 = 2 x 4.

    Given an integer n, return all possible combinations of its factors. You may return the answer in any order.
    Note that the factors should be in the range [2, n - 1].

    Example 1:

    >>> getFactors(n = 1)
    >>> []

    Example 2:

    >>> getFactors(n = 12)
    >>> [[2,6],[3,4],[2,2,3]]

    Example 3:

    >>> getFactors(n = 37)
    >>> []
    """


Prompt:
from typing import List
def verifyPreorder(preorder: List[int]) -> bool:
    """
    Given an array of unique integers preorder, return true if it is the correct preorder traversal sequence of a binary search tree.

    Example 1:

    >>> verifyPreorder(preorder = [5,2,1,3,6])
    >>> true

    Example 2:

    >>> verifyPreorder(preorder = [5,2,6,1,3])
    >>> false
    """


Prompt:
from typing import List
def minCost(costs: List[List[int]]) -> int:
    """
    There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.
    The cost of painting each house with a certain color is represented by an n x 3 cost matrix costs.

    For example, costs[0][0] is the cost of painting house 0 with the color red; costs[1][2] is the cost of painting house 1 with color green, and so on...

    Return the minimum cost to paint all houses.

    Example 1:

    >>> minCost(costs = [[17,2,17],[16,16,5],[14,3,19]])
    >>> 10
    Explanation: Paint house 0 into blue, paint house 1 into green, paint house 2 into blue.
    Minimum cost: 2 + 5 + 3 = 10.

    Example 2:

    >>> minCost(costs = [[7,6,2]])
    >>> 2
    """


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def binaryTreePaths(root: Optional[TreeNode]) -> List[str]:
"""
Given the root of a binary tree, return all root-to-leaf paths in any order.
A leaf is a node with no children.

Example 1:

>>> binaryTreePaths(root = [1,2,3,null,5])
>>> ["1->2->5","1->3"]

Example 2:

>>> binaryTreePaths(root = [1])
>>> ["1"]
"""


Prompt:
def addDigits(num: int) -> int:
    """
    Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.

    Example 1:

    >>> addDigits(num = 38)
    >>> 2
    Explanation: The process is
    38 --> 3 + 8 --> 11
    11 --> 1 + 1 --> 2
    Since 2 has only one digit, return it.

    Example 2:

    >>> addDigits(num = 0)
    >>> 0
    """


Prompt:
from typing import List
def threeSumSmaller(nums: List[int], target: int) -> int:
    """
    Given an array of n integers nums and an integer target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] < target.

    Example 1:

    >>> threeSumSmaller(nums = [-2,0,1,3], target = 2)
    >>> 2
    Explanation: Because there are two triplets which sums are less than 2:
    [-2,0,1]
    [-2,0,3]

    Example 2:

    >>> threeSumSmaller(nums = [], target = 0)
    >>> 0

    Example 3:

    >>> threeSumSmaller(nums = [0], target = 0)
    >>> 0
    """


Prompt:
from typing import List
def singleNumber(nums: List[int]) -> List[int]:
    """
    Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order.
    You must write an algorithm that runs in linear runtime complexity and uses only constant extra space.

    Example 1:

    >>> singleNumber(nums = [1,2,1,3,2,5])
    >>> [3,5]
    Explanation:  [5, 3] is also a valid answer.

    Example 2:

    >>> singleNumber(nums = [-1,0])
    >>> [-1,0]

    Example 3:

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


Prompt:
from typing import List
def validTree(n: int, edges: List[List[int]]) -> bool:
    """
    You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and a list of edges where edges[i] = [ai, bi] indicates that there is an undirected edge between nodes ai and bi in the graph.
    Return true if the edges of the given graph make up a valid tree, and false otherwise.

    Example 1:

    >>> validTree(n = 5, edges = [[0,1],[0,2],[0,3],[1,4]])
    >>> true

    Example 2:

    >>> validTree(n = 5, edges = [[0,1],[1,2],[2,3],[1,3],[1,4]])
    >>> false
    """


Prompt:
def isUgly(n: int) -> bool:
    """
    An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.
    Given an integer n, return true if n is an ugly number.

    Example 1:

    >>> isUgly(n = 6)
    >>> true
    Explanation: 6 = 2 × 3

    Example 2:

    >>> isUgly(n = 1)
    >>> true
    Explanation: 1 has no prime factors.

    Example 3:

    >>> isUgly(n = 14)
    >>> false
    Explanation: 14 is not ugly since it includes the prime factor 7.
    """


Prompt:
def nthUglyNumber(n: int) -> int:
    """
    An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
    Given an integer n, return the nth ugly number.

    Example 1:

    >>> nthUglyNumber(n = 10)
    >>> 12
    Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers.

    Example 2:

    >>> nthUglyNumber(n = 1)
    >>> 1
    Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5.
    """


Prompt:
from typing import List
def minCostII(costs: List[List[int]]) -> int:
    """
    There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.
    The cost of painting each house with a certain color is represented by an n x k cost matrix costs.

    For example, costs[0][0] is the cost of painting house 0 with color 0; costs[1][2] is the cost of painting house 1 with color 2, and so on...

    Return the minimum cost to paint all houses.

    Example 1:

    >>> minCostII(costs = [[1,5,3],[2,9,4]])
    >>> 5
    Explanation:
    Paint house 0 into color 0, paint house 1 into color 2. Minimum cost: 1 + 4 = 5;
    Or paint house 0 into color 2, paint house 1 into color 0. Minimum cost: 3 + 2 = 5.

    Example 2:

    >>> minCostII(costs = [[1,3],[2,4]])
    >>> 5
    """


Prompt:
def canPermutePalindrome(s: str) -> bool:
    """
    Given a string s, return true if a permutation of the string could form a palindrome and false otherwise.

    Example 1:

    >>> canPermutePalindrome(s = "code")
    >>> false

    Example 2:

    >>> canPermutePalindrome(s = "aab")
    >>> true

    Example 3:

    >>> canPermutePalindrome(s = "carerac")
    >>> true
    """


Prompt:
from typing import List
def generatePalindromes(s: str) -> List[str]:
    """
    Given a string s, return all the palindromic permutations (without duplicates) of it.
    You may return the answer in any order. If s has no palindromic permutation, return an empty list.

    Example 1:
    >>> generatePalindromes(s = "aabb")
    >>> ["abba","baab"]
    Example 2:
    >>> generatePalindromes(s = "abc")
    >>> []
    """


Prompt:
from typing import List
def missingNumber(nums: List[int]) -> int:
    """
    Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.

    Example 1:

    >>> missingNumber(nums = [3,0,1])
    >>> 2
    Explanation:
    n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums.

    Example 2:

    >>> missingNumber(nums = [0,1])
    >>> 2
    Explanation:
    n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range since it does not appear in nums.

    Example 3:

    >>> missingNumber(nums = [9,6,4,2,3,5,7,0,1])
    >>> 8
    Explanation:
    n = 9 since there are 9 numbers, so all numbers are in the range [0,9]. 8 is the missing number in the range since it does not appear in nums.
    """


Prompt:
from typing import List
def alienOrder(words: List[str]) -> str:
    """
    There is a new alien language that uses the English alphabet. However, the order of the letters is unknown to you.
    You are given a list of strings words from the alien language's dictionary. Now it is claimed that the strings in words are sorted lexicographically by the rules of this new language.
    If this claim is incorrect, and the given arrangement of string in words cannot correspond to any order of letters, return "".
    Otherwise, return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new language's rules. If there are multiple solutions, return any of them.

    Example 1:

    >>> alienOrder(words = ["wrt","wrf","er","ett","rftt"])
    >>> "wertf"

    Example 2:

    >>> alienOrder(words = ["z","x"])
    >>> "zx"

    Example 3:

    >>> alienOrder(words = ["z","x","z"])
    >>> ""
    Explanation: The order is invalid, so return "".
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def closestValue(root: Optional[TreeNode], target: float) -> int:
"""
Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target. If there are multiple answers, print the smallest.

Example 1:

>>> closestValue(root = [4,2,5,1,3], target = 3.714286)
>>> 4

Example 2:

>>> closestValue(root = [1], target = 4.428571)
>>> 1
"""


Prompt:
from typing import List, Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def closestKValues(root: Optional[TreeNode], target: float, k: int) -> List[int]:
"""
Given the root of a binary search tree, a target value, and an integer k, return the k values in the BST that are closest to the target. You may return the answer in any order.
You are guaranteed to have only one unique set of k values in the BST that are closest to the target.

Example 1:

>>> closestKValues(root = [4,2,5,1,3], target = 3.714286, k = 2)
>>> [4,3]

Example 2:

>>> closestKValues(root = [1], target = 0.000000, k = 1)
>>> [1]
"""


Prompt:
def numberToWords(num: int) -> str:
    """
    Convert a non-negative integer num to its English words representation.

    Example 1:

    >>> numberToWords(num = 123)
    >>> "One Hundred Twenty Three"

    Example 2:

    >>> numberToWords(num = 12345)
    >>> "Twelve Thousand Three Hundred Forty Five"

    Example 3:

    >>> numberToWords(num = 1234567)
    >>> "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"
    """


Prompt:
from typing import List
def hIndex(citations: List[int]) -> int:
    """
    Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.
    According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h papers that have each been cited at least h times.

    Example 1:

    >>> hIndex(citations = [3,0,6,1,5])
    >>> 3
    Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively.
    Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.

    Example 2:

    >>> hIndex(citations = [1,3,1])
    >>> 1
    """


Prompt:
from typing import List
def hIndex(citations: List[int]) -> int:
    """
    Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in ascending order, return the researcher's h-index.
    According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h papers that have each been cited at least h times.
    You must write an algorithm that runs in logarithmic time.

    Example 1:

    >>> hIndex(citations = [0,1,3,5,6])
    >>> 3
    Explanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had received 0, 1, 3, 5, 6 citations respectively.
    Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3.

    Example 2:

    >>> hIndex(citations = [1,2,100])
    >>> 2
    """


Prompt:
def numWays(n: int, k: int) -> int:
    """
    You are painting a fence of n posts with k different colors. You must paint the posts following these rules:

    Every post must be painted exactly one color.
    There cannot be three or more consecutive posts with the same color.

    Given the two integers n and k, return the number of ways you can paint the fence.

    Example 1:

    >>> numWays(n = 3, k = 2)
    >>> 6
    Explanation: All the possibilities are shown.
    Note that painting all the posts red or all the posts green is invalid because there cannot be three posts in a row with the same color.

    Example 2:

    >>> numWays(n = 1, k = 1)
    >>> 1

    Example 3:

    >>> numWays(n = 7, k = 2)
    >>> 42
    """


Prompt:
# def isBadVersion(version: int) -> bool:

def firstBadVersion(n: int) -> int:
"""
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.
You are given an API bool isBadVersion(version) which returns whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.

Example 1:

>>> isBadVersion(n = 5, bad = 4)
>>> 4
Explanation:
call isBadVersion(3) -> false
call isBadVersion(5) -> true
call isBadVersion(4) -> true
Then 4 is the first bad version.

Example 2:

>>> isBadVersion(n = 1, bad = 1)
>>> 1
"""


Prompt:
def numSquares(n: int) -> int:
    """
    Given an integer n, return the least number of perfect square numbers that sum to n.
    A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not.

    Example 1:

    >>> numSquares(n = 12)
    >>> 3
    Explanation: 12 = 4 + 4 + 4.

    Example 2:

    >>> numSquares(n = 13)
    >>> 2
    Explanation: 13 = 4 + 9.
    """


Prompt:
from typing import List
def wiggleSort(nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
    """
    Given an integer array nums, reorder it such that nums[0] <= nums[1] >= nums[2] <= nums[3]....
    You may assume the input array always has a valid answer.

    Example 1:

    >>> wiggleSort(nums = [3,5,2,1,6,4])
    >>> [3,5,1,6,2,4]
    Explanation: [1,6,2,5,3,4] is also accepted.

    Example 2:

    >>> wiggleSort(nums = [6,6,5,6,3,8])
    >>> [6,6,5,6,3,8]
    """


Prompt:
from typing import List
def addOperators(num: str, target: int) -> List[str]:
    """
    Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that the resultant expression evaluates to the target value.
    Note that operands in the returned expressions should not contain leading zeros.

    Example 1:

    >>> addOperators(num = "123", target = 6)
    >>> ["1*2*3","1+2+3"]
    Explanation: Both "1*2*3" and "1+2+3" evaluate to 6.

    Example 2:

    >>> addOperators(num = "232", target = 8)
    >>> ["2*3+2","2+3*2"]
    Explanation: Both "2*3+2" and "2+3*2" evaluate to 8.

    Example 3:

    >>> addOperators(num = "3456237490", target = 9191)
    >>> []
    Explanation: There are no expressions that can be created from "3456237490" to evaluate to 9191.
    """


Prompt:
from typing import List
def moveZeroes(nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
    """
    Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
    Note that you must do this in-place without making a copy of the array.

    Example 1:
    >>> moveZeroes(nums = [0,1,0,3,12])
    >>> [1,3,12,0,0]
    Example 2:
    >>> moveZeroes(nums = [0])
    >>> [0]
    """


Prompt:
from typing import List
def wallsAndGates(rooms: List[List[int]]) -> None:
        """
        Do not return anything, modify rooms in-place instead.
        """
    """
    You are given an m x n grid rooms initialized with these three possible values.

    -1 A wall or an obstacle.
    0 A gate.
    INF Infinity means an empty room. We use the value 231 - 1 = 2147483647 to represent INF as you may assume that the distance to a gate is less than 2147483647.

    Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with INF.

    Example 1:

    >>> wallsAndGates(rooms = [[2147483647,-1,0,2147483647],[2147483647,2147483647,2147483647,-1],[2147483647,-1,2147483647,-1],[0,-1,2147483647,2147483647]])
    >>> [[3,-1,0,1],[2,2,1,-1],[1,-1,2,-1],[0,-1,3,4]]

    Example 2:

    >>> wallsAndGates(rooms = [[-1]])
    >>> [[-1]]
    """


Prompt:
from typing import List
def findDuplicate(nums: List[int]) -> int:
    """
    Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.
    There is only one repeated number in nums, return this repeated number.
    You must solve the problem without modifying the array nums and using only constant extra space.

    Example 1:

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

    Example 2:

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

    Example 3:

    >>> findDuplicate(nums = [3,3,3,3,3])
    >>> 3
    """


Prompt:
from typing import Any, List
def gameOfLife(board: List[List[int]]) -> None:
        """
        Do not return anything, modify board in-place instead.
        """
    """
    According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
    The board is made up of an m x n grid of cells, where each cell has an initial state: live (represented by a 1) or dead (represented by a 0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article):

    Any live cell with fewer than two live neighbors dies as if caused by under-population.
    Any live cell with two or three live neighbors lives on to the next generation.
    Any live cell with more than three live neighbors dies, as if by over-population.
    Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

    The next state of the board is determined by applying the above rules simultaneously to every cell in the current state of the m x n grid board. In this process, births and deaths occur simultaneously.
    Given the current state of the board, update the board to reflect its next state.
    Note that you do not need to return anything.

    Example 1:

    >>> gameOfLife(board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]])
    >>> [[0,0,0],[1,0,1],[0,1,1],[0,1,0]]

    Example 2:

    >>> gameOfLife(board = [[1,1],[1,0]])
    >>> [[1,1],[1,1]]
    """


Prompt:
def wordPattern(pattern: str, s: str) -> bool:
    """
    Given a pattern and a string s, find if s follows the same pattern.
    Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Specifically:

    Each letter in pattern maps to exactly one unique word in s.
    Each unique word in s maps to exactly one letter in pattern.
    No two letters map to the same word, and no two words map to the same letter.

    Example 1:

    >>> wordPattern(pattern = "abba", s = "dog cat cat dog")
    >>> true
    Explanation:
    The bijection can be established as:

    'a' maps to "dog".
    'b' maps to "cat".

    Example 2:

    >>> wordPattern(pattern = "abba", s = "dog cat cat fish")
    >>> false

    Example 3:

    >>> wordPattern(pattern = "aaaa", s = "dog cat cat dog")
    >>> false
    """


Prompt:
def wordPatternMatch(pattern: str, s: str) -> bool:
    """
    Given a pattern and a string s, return true if s matches the pattern.
    A string s matches a pattern if there is some bijective mapping of single characters to non-empty strings such that if each character in pattern is replaced by the string it maps to, then the resulting string is s. A bijective mapping means that no two characters map to the same string, and no character maps to two different strings.

    Example 1:

    >>> wordPatternMatch(pattern = "abab", s = "redblueredblue")
    >>> true
    Explanation: One possible mapping is as follows:
    'a' -> "red"
    'b' -> "blue"
    Example 2:

    >>> wordPatternMatch(pattern = "aaaa", s = "asdasdasdasd")
    >>> true
    Explanation: One possible mapping is as follows:
    'a' -> "asd"

    Example 3:

    >>> wordPatternMatch(pattern = "aabb", s = "xyzabcxzyabc")
    >>> false
    """


Prompt:
def canWinNim(n: int) -> bool:
    """
    You are playing the following Nim Game with your friend:

    Initially, there is a heap of stones on the table.
    You and your friend will alternate taking turns, and you go first.
    On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.
    The one who removes the last stone is the winner.

    Given n, the number of stones in the heap, return true if you can win the game assuming both you and your friend play optimally, otherwise return false.

    Example 1:

    >>> canWinNim(n = 4)
    >>> false
    Explanation: These are the possible outcomes:
    1. You remove 1 stone. Your friend removes 3 stones, including the last stone. Your friend wins.
    2. You remove 2 stones. Your friend removes 2 stones, including the last stone. Your friend wins.
    3. You remove 3 stones. Your friend removes the last stone. Your friend wins.
    In all outcomes, your friend wins.

    Example 2:

    >>> canWinNim(n = 1)
    >>> true

    Example 3:

    >>> canWinNim(n = 2)
    >>> true
    """


Prompt:
from typing import List
def generatePossibleNextMoves(currentState: str) -> List[str]:
    """
    You are playing a Flip Game with your friend.
    You are given a string currentState that contains only '+' and '-'. You and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move, and therefore the other person will be the winner.
    Return all possible states of the string currentState after one valid move. You may return the answer in any order. If there is no valid move, return an empty list [].

    Example 1:

    >>> generatePossibleNextMoves(currentState = "++++")
    >>> ["--++","+--+","++--"]

    Example 2:

    >>> generatePossibleNextMoves(currentState = "+")
    >>> []
    """


Prompt:
def canWin(currentState: str) -> bool:
    """
    You are playing a Flip Game with your friend.
    You are given a string currentState that contains only '+' and '-'. You and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move, and therefore the other person will be the winner.
    Return true if the starting player can guarantee a win, and false otherwise.

    Example 1:

    >>> canWin(currentState = "++++")
    >>> true
    Explanation: The starting player can guarantee a win by flipping the middle "++" to become "+--+".

    Example 2:

    >>> canWin(currentState = "+")
    >>> false
    """


Prompt:
from typing import List
def minTotalDistance(grid: List[List[int]]) -> int:
    """
    Given an m x n binary grid grid where each 1 marks the home of one friend, return the minimal total travel distance.
    The total travel distance is the sum of the distances between the houses of the friends and the meeting point.
    The distance is calculated using Manhattan Distance, where distance(p1, p2) = |p2.x - p1.x| + |p2.y - p1.y|.

    Example 1:

    >>> minTotalDistance(grid = [[1,0,0,0,1],[0,0,0,0,0],[0,0,1,0,0]])
    >>> 6
    Explanation: Given three friends living at (0,0), (0,4), and (2,2).
    The point (0,2) is an ideal meeting point, as the total travel distance of 2 + 2 + 2 = 6 is minimal.
    So return 6.

    Example 2:

    >>> minTotalDistance(grid = [[1,1]])
    >>> 1
    """


Prompt:
from typing import Optional
class TreeNode:
    def __init__(val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
def longestConsecutive(root: Optional[TreeNode]) -> int:
"""
Given the root of a binary tree, return the length of the longest consecutive sequence path.
A consecutive sequence path is a path where the values increase by one along the path.
Note that the path can start at any node in the tree, and you cannot go from a node to its parent in the path.

Example 1:

>>> longestConsecutive(root = [1,null,3,2,4,null,null,null,5])
>>> 3
Explanation: Longest consecutive sequence path is 3-4-5, so return 3.

Example 2:

>>> longestConsecutive(root = [2,null,3,2,null,1])
>>> 2
Explanation: Longest consecutive sequence path is 2-3, not 3-2-1, so return 2.
"""