ShwStone/humaneval-leetcode huggingface dataset:
def palindromePartition(s: str, k: int) -> int:
    """
    You are given a string s containing lowercase letters and an integer k. You need to :
    
    First, change some characters of s to other lowercase English letters.
    Then divide s into k non-empty disjoint substrings such that each substring is a palindrome.
    
    Return the minimal number of characters that you need to change to divide the string.
    
    Example 1:
    
    >>> palindromePartition(s = "abc", k = 2)
    >>> 1
    Explanation: You can split the string into "ab" and "c", and change 1 character in "ab" to make it palindrome.
    
    Example 2:
    
    >>> palindromePartition(s = "aabbc", k = 3)
    >>> 0
    Explanation: You can split the string into "aa", "bb" and "c", all of them are palindrome.
    Example 3:
    
    >>> palindromePartition(s = "leetcode", k = 8)
    >>> 0
    """
def subtractProductAndSum(n: int) -> int:
    """
    Given an integer number n, return the difference between the product of its digits and the sum of its digits.
    
    Example 1:
    
    >>> subtractProductAndSum(n = 234)
    >>> 15
    Explanation:
    Product of digits = 2 * 3 * 4 = 24
    Sum of digits = 2 + 3 + 4 = 9
    Result = 24 - 9 = 15
    
    Example 2:
    
    >>> subtractProductAndSum(n = 4421)
    >>> 21
    Explanation:
    Product of digits = 4 * 4 * 2 * 1 = 32
    Sum of digits = 4 + 4 + 2 + 1 = 11
    Result = 32 - 11 = 21
    """
def groupThePeople(groupSizes: List[int]) -> List[List[int]]:
    """
    There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.
    You are given an integer array groupSizes, where groupSizes[i] is the size of the group that person i is in. For example, if groupSizes[1] = 3, then person 1 must be in a group of size 3.
    Return a list of groups such that each person i is in a group of size groupSizes[i].
    Each person should appear in exactly one group, and every person must be in a group. If there are multiple answers, return any of them. It is guaranteed that there will be at least one valid solution for the given input.
    
    Example 1:
    
    >>> groupThePeople(groupSizes = [3,3,3,3,3,1,3])
    >>> [[5],[0,1,2],[3,4,6]]
    Explanation:
    The first group is [5]. The size is 1, and groupSizes[5] = 1.
    The second group is [0,1,2]. The size is 3, and groupSizes[0] = groupSizes[1] = groupSizes[2] = 3.
    The third group is [3,4,6]. The size is 3, and groupSizes[3] = groupSizes[4] = groupSizes[6] = 3.
    Other possible solutions are [[2,1,6],[5],[0,4,3]] and [[5],[0,6,2],[4,3,1]].
    
    Example 2:
    
    >>> groupThePeople(groupSizes = [2,1,3,3,3,2])
    >>> [[1],[0,5],[2,3,4]]
    """
def smallestDivisor(nums: List[int], threshold: int) -> int:
    """
    Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.
    Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).
    The test cases are generated so that there will be an answer.
    
    Example 1:
    
    >>> smallestDivisor(nums = [1,2,5,9], threshold = 6)
    >>> 5
    Explanation: We can get a sum to 17 (1+2+5+9) if the divisor is 1.
    If the divisor is 4 we can get a sum of 7 (1+1+2+3) and if the divisor is 5 the sum will be 5 (1+1+1+2).
    
    Example 2:
    
    >>> smallestDivisor(nums = [44,22,33,11,1], threshold = 5)
    >>> 44
    """
def minFlips(mat: List[List[int]]) -> int:
    """
    Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighbors of it if they exist (Flip is changing 1 to 0 and 0 to 1). A pair of cells are called neighbors if they share one edge.
    Return the minimum number of steps required to convert mat to a zero matrix or -1 if you cannot.
    A binary matrix is a matrix with all cells equal to 0 or 1 only.
    A zero matrix is a matrix with all cells equal to 0.
    
    Example 1:
    
    
    >>> minFlips(mat = [[0,0],[0,1]])
    >>> 3
    Explanation: One possible solution is to flip (1, 0) then (0, 1) and finally (1, 1) as shown.
    
    Example 2:
    
    >>> minFlips(mat = [[0]])
    >>> 0
    Explanation: Given matrix is a zero matrix. We do not need to change it.
    
    Example 3:
    
    >>> minFlips(mat = [[1,0,0],[1,0,0]])
    >>> -1
    Explanation: Given matrix cannot be a zero matrix.
    """
def findSpecialInteger(arr: List[int]) -> int:
    """
    Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.
    
    Example 1:
    
    >>> findSpecialInteger(arr = [1,2,2,6,6,6,6,7,10])
    >>> 6
    
    Example 2:
    
    >>> findSpecialInteger(arr = [1,1])
    >>> 1
    """
def removeCoveredIntervals(intervals: List[List[int]]) -> int:
    """
    Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list.
    The interval [a, b) is covered by the interval [c, d) if and only if c <= a and b <= d.
    Return the number of remaining intervals.
    
    Example 1:
    
    >>> removeCoveredIntervals(intervals = [[1,4],[3,6],[2,8]])
    >>> 2
    Explanation: Interval [3,6] is covered by [2,8], therefore it is removed.
    
    Example 2:
    
    >>> removeCoveredIntervals(intervals = [[1,4],[2,3]])
    >>> 1
    """
def minFallingPathSum(grid: List[List[int]]) -> int:
    """
    Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.
    A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column.
    
    Example 1:
    
    
    >>> minFallingPathSum(grid = [[1,2,3],[4,5,6],[7,8,9]])
    >>> 13
    Explanation:
    The possible falling paths are:
    [1,5,9], [1,5,7], [1,6,7], [1,6,8],
    [2,4,8], [2,4,9], [2,6,7], [2,6,8],
    [3,4,8], [3,4,9], [3,5,7], [3,5,9]
    The falling path with the smallest sum is [1,5,7], so the answer is 13.
    
    Example 2:
    
    >>> minFallingPathSum(grid = [[7]])
    >>> 7
    """
# class ListNode:
#     def __init__(val=0, next=None):
#         self.val = val
#         self.next = next
class Solution:
    def getDecimalValue(head: Optional[ListNode]) -> int:
    """
    Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number.
    Return the decimal value of the number in the linked list.
    The most significant bit is at the head of the linked list.
    
    Example 1:
    
    
    >>> __init__(head = [1,0,1])
    >>> 5
    Explanation: (101) in base 2 = (5) in base 10
    
    Example 2:
    
    >>> __init__(head = [0])
    >>> 0
    """
def sequentialDigits(low: int, high: int) -> List[int]:
    """
    An integer has sequential digits if and only if each digit in the number is one more than the previous digit.
    Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits.
    
    Example 1:
    >>> sequentialDigits(low = 100, high = 300)
    >>> [123,234]
    Example 2:
    >>> sequentialDigits(low = 1000, high = 13000)
    >>> [1234,2345,3456,4567,5678,6789,12345]
    """
def maxSideLength(mat: List[List[int]], threshold: int) -> int:
    """
    Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.
    
    Example 1:
    
    
    >>> maxSideLength(mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4)
    >>> 2
    Explanation: The maximum side length of square with sum less than 4 is 2 as shown.
    
    Example 2:
    
    >>> maxSideLength(mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1)
    >>> 0
    """
def shortestPath(grid: List[List[int]], k: int) -> int:
    """
    You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step.
    Return the minimum number of steps to walk from the upper left corner (0, 0) to the lower right corner (m - 1, n - 1) given that you can eliminate at most k obstacles. If it is not possible to find such walk return -1.
    
    Example 1:
    
    
    >>> shortestPath(grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1)
    >>> 6
    Explanation:
    The shortest path without eliminating any obstacle is 10.
    The shortest path with one obstacle elimination at position (3,2) is 6. Such path is (0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (3,2) -> (4,2).
    
    Example 2:
    
    
    >>> shortestPath(grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1)
    >>> -1
    Explanation: We need to eliminate at least two obstacles to find such a walk.
    """
def findNumbers(nums: List[int]) -> int:
    """
    Given an array nums of integers, return how many of them contain an even number of digits.
    
    Example 1:
    
    >>> findNumbers(nums = [12,345,2,6,7896])
    >>> 2
    Explanation:
    12 contains 2 digits (even number of digits).
    345 contains 3 digits (odd number of digits).
    2 contains 1 digit (odd number of digits).
    6 contains 1 digit (odd number of digits).
    7896 contains 4 digits (even number of digits).
    Therefore only 12 and 7896 contain an even number of digits.
    
    Example 2:
    
    >>> findNumbers(nums = [555,901,482,1771])
    >>> 1
    Explanation:
    Only 1771 contains an even number of digits.
    """
def isPossibleDivide(nums: List[int], k: int) -> bool:
    """
    Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
    Return true if it is possible. Otherwise, return false.
    
    Example 1:
    
    >>> isPossibleDivide(nums = [1,2,3,3,4,4,5,6], k = 4)
    >>> true
    Explanation: Array can be divided into [1,2,3,4] and [3,4,5,6].
    
    Example 2:
    
    >>> isPossibleDivide(nums = [3,2,1,2,3,4,3,4,5,9,10,11], k = 3)
    >>> true
    Explanation: Array can be divided into [1,2,3] , [2,3,4] , [3,4,5] and [9,10,11].
    
    Example 3:
    
    >>> isPossibleDivide(nums = [1,2,3,4], k = 3)
    >>> false
    Explanation: Each array should be divided in subarrays of size 3.
    """
def maxFreq(s: str, maxLetters: int, minSize: int, maxSize: int) -> int:
    """
    Given a string s, return the maximum number of occurrences of any substring under the following rules:
    
    The number of unique characters in the substring must be less than or equal to maxLetters.
    The substring size must be between minSize and maxSize inclusive.
    
    
    Example 1:
    
    >>> maxFreq(s = "aababcaab", maxLetters = 2, minSize = 3, maxSize = 4)
    >>> 2
    Explanation: Substring "aab" has 2 occurrences in the original string.
    It satisfies the conditions, 2 unique letters and size 3 (between minSize and maxSize).
    
    Example 2:
    
    >>> maxFreq(s = "aaaa", maxLetters = 1, minSize = 3, maxSize = 3)
    >>> 2
    Explanation: Substring "aaa" occur 2 times in the string. It can overlap.
    """
def maxCandies(status: List[int], candies: List[int], keys: List[List[int]], containedBoxes: List[List[int]], initialBoxes: List[int]) -> int:
    """
    You have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where:
    
    status[i] is 1 if the ith box is open and 0 if the ith box is closed,
    candies[i] is the number of candies in the ith box,
    keys[i] is a list of the labels of the boxes you can open after opening the ith box.
    containedBoxes[i] is a list of the boxes you found inside the ith box.
    
    You are given an integer array initialBoxes that contains the labels of the boxes you initially have. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.
    Return the maximum number of candies you can get following the rules above.
    
    Example 1:
    
    >>> maxCandies(status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0])
    >>> 16
    Explanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2.
    Box 1 is closed and you do not have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.
    In box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.
    Total number of candies collected = 7 + 4 + 5 = 16 candy.
    
    Example 2:
    
    >>> maxCandies(status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0])
    >>> 6
    Explanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys.
    The total number of candies will be 6.
    """
def replaceElements(arr: List[int]) -> List[int]:
    """
    Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1.
    After doing so, return the array.
    
    Example 1:
    
    >>> replaceElements(arr = [17,18,5,4,6,1])
    >>> [18,6,6,6,1,-1]
    Explanation:
    - index 0 --> the greatest element to the right of index 0 is index 1 (18).
    - index 1 --> the greatest element to the right of index 1 is index 4 (6).
    - index 2 --> the greatest element to the right of index 2 is index 4 (6).
    - index 3 --> the greatest element to the right of index 3 is index 4 (6).
    - index 4 --> the greatest element to the right of index 4 is index 5 (1).
    - index 5 --> there are no elements to the right of index 5, so we put -1.
    
    Example 2:
    
    >>> replaceElements(arr = [400])
    >>> [-1]
    Explanation: There are no elements to the right of index 0.
    """
def findBestValue(arr: List[int], target: int) -> int:
    """
    Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value, the sum of the array gets as close as possible (in absolute difference) to target.
    In case of a tie, return the minimum such integer.
    Notice that the answer is not neccesarilly a number from arr.
    
    Example 1:
    
    >>> findBestValue(arr = [4,9,3], target = 10)
    >>> 3
    Explanation: When using 3 arr converts to [3, 3, 3] which sums 9 and that's the optimal answer.
    
    Example 2:
    
    >>> findBestValue(arr = [2,3,5], target = 10)
    >>> 5
    
    Example 3:
    
    >>> findBestValue(arr = [60864,25176,27249,21296,20204], target = 56803)
    >>> 11361
    """
def pathsWithMaxScore(board: List[str]) -> List[int]:
    """
    You are given a square board of characters. You can move on the board starting at the bottom right square marked with the character 'S'.\r
    \r
    You need to reach the top left square marked with the character 'E'. The rest of the squares are labeled either with a numeric character 1, 2, ..., 9 or with an obstacle 'X'. In one move you can go up, left or up-left (diagonally) only if there is no obstacle there.\r
    \r
    Return a list of two integers: the first integer is the maximum sum of numeric characters you can collect, and the second is the number of such paths that you can take to get that maximum sum, taken modulo 10^9 + 7.\r
    \r
    In case there is no path, return [0, 0].\r
    \r
     \r
    Example 1:\r
    >>> pathsWithMaxScore(board = ["E23","2X2","12S"]\r)
    >>> [7,1]\r
    Example 2:\r
    >>> pathsWithMaxScore(board = ["E12","1X1","21S"]\r)
    >>> [4,2]\r
    Example 3:\r
    >>> pathsWithMaxScore(board = ["E11","XXX","11S"]\r)
    >>> [0,0]\r
    \r
     \r
    """
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def deepestLeavesSum(root: Optional[TreeNode]) -> int:
    """
    Given the root of a binary tree, return the sum of values of its deepest leaves.
    
    Example 1:
    
    
    >>> __init__(root = [1,2,3,4,5,null,6,7,null,null,null,null,8])
    >>> 15
    
    Example 2:
    
    >>> __init__(root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5])
    >>> 19
    """
def sumZero(n: int) -> List[int]:
    """
    Given an integer n, return any array containing n unique integers such that they add up to 0.
    
    Example 1:
    
    >>> sumZero(n = 5)
    >>> [-7,-1,1,3,4]
    Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].
    
    Example 2:
    
    >>> sumZero(n = 3)
    >>> [-1,0,1]
    
    Example 3:
    
    >>> sumZero(n = 1)
    >>> [0]
    """
# class TreeNode:
#     def __init__(val=0, left=None, right=None):
#         self.val = val
#         self.left = left
#         self.right = right
class Solution:
    def getAllElements(root1: Optional[TreeNode], root2: Optional[TreeNode]) -> List[int]:
    """
    Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.
    
    Example 1:
    
    
    >>> __init__(root1 = [2,1,4], root2 = [1,0,3])
    >>> [0,1,1,2,3,4]
    
    Example 2:
    
    
    >>> __init__(root1 = [1,null,8], root2 = [8,1])
    >>> [1,1,8,8]
    """
def canReach(arr: List[int], start: int) -> bool:
    """
    Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0.
    Notice that you can not jump outside of the array at any time.
    
    Example 1:
    
    >>> canReach(arr = [4,2,3,0,3,1,2], start = 5)
    >>> true
    Explanation:
    All possible ways to reach at index 3 with value 0 are:
    index 5 -> index 4 -> index 1 -> index 3
    index 5 -> index 6 -> index 4 -> index 1 -> index 3
    
    Example 2:
    
    >>> canReach(arr = [4,2,3,0,3,1,2], start = 0)
    >>> true
    Explanation:
    One possible way to reach at index 3 with value 0 is:
    index 0 -> index 4 -> index 1 -> index 3
    
    Example 3:
    
    >>> canReach(arr = [3,0,2,1,2], start = 2)
    >>> false
    Explanation: There is no way to reach at index 1 with value 0.
    """
def isSolvable(words: List[str], result: str) -> bool:
    """
    Given an equation, represented by words on the left side and the result on the right side.
    You need to check if the equation is solvable under the following rules:
    
    Each character is decoded as one digit (0 - 9).
    No two characters can map to the same digit.
    Each words[i] and result are decoded as one number without leading zeros.
    Sum of numbers on the left side (words) will equal to the number on the right side (result).
    
    Return true if the equation is solvable, otherwise return false.
    
    Example 1:
    
    >>> isSolvable(words = ["SEND","MORE"], result = "MONEY")
    >>> true
    Explanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'
    Such that: "SEND" + "MORE" = "MONEY" ,  9567 + 1085 = 10652
    Example 2:
    
    >>> isSolvable(words = ["SIX","SEVEN","SEVEN"], result = "TWENTY")
    >>> true
    Explanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4
    Such that: "SIX" + "SEVEN" + "SEVEN" = "TWENTY" ,  650 + 68782 + 68782 = 138214
    Example 3:
    
    >>> isSolvable(words = ["LEET","CODE"], result = "POINT")
    >>> false
    Explanation: There is no possible mapping to satisfy the equation, so we return false.
    Note that two different characters cannot map to the same digit.
    """
def freqAlphabets(s: str) -> str:
    """
    You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:
    
    Characters ('a' to 'i') are represented by ('1' to '9') respectively.
    Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.
    
    Return the string formed after mapping.
    The test cases are generated so that a unique mapping will always exist.
    
    Example 1:
    
    >>> freqAlphabets(s = "10#11#12")
    >>> "jkab"
    Explanation: "j" -> "10#" , "k" -> "11#" , "a" -> "1" , "b" -> "2".
    
    Example 2:
    
    >>> freqAlphabets(s = "1326#")
    >>> "acz"
    """
def xorQueries(arr: List[int], queries: List[List[int]]) -> List[int]:
    """
    You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].
    For each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).
    Return an array answer where answer[i] is the answer to the ith query.
    
    Example 1:
    
    >>> xorQueries(arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]])
    >>> [2,7,14,8]
    Explanation:
    The binary representation of the elements in the array are:
    1 = 0001
    3 = 0011
    4 = 0100
    8 = 1000
    The XOR values for queries are:
    [0,1] = 1 xor 3 = 2
    [1,2] = 3 xor 4 = 7
    [0,3] = 1 xor 3 xor 4 xor 8 = 14
    [3,3] = 8
    
    Example 2:
    
    >>> xorQueries(arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]])
    >>> [8,0,4,4]
    """
def watchedVideosByFriends(watchedVideos: List[List[str]], friends: List[List[int]], id: int, level: int) -> List[str]:
    """
    There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.
    Level 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest.
    
    Example 1:
    
    
    >>> watchedVideosByFriends(watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1)
    >>> ["B","C"]
    Explanation:
    You have id = 0 (green color in the figure) and your friends are (yellow color in the figure):
    Person with id = 1 -> watchedVideos = ["C"]
    Person with id = 2 -> watchedVideos = ["B","C"]
    The frequencies of watchedVideos by your friends are:
    B -> 1
    C -> 2
    
    Example 2:
    
    
    >>> watchedVideosByFriends(watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2)
    >>> ["D"]
    Explanation:
    You have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).
    """
def minInsertions(s: str) -> int:
    """
    Given a string s. In one step you can insert any character at any index of the string.
    Return the minimum number of steps to make s palindrome.
    A Palindrome String is one that reads the same backward as well as forward.
    
    Example 1:
    
    >>> minInsertions(s = "zzazz")
    >>> 0
    Explanation: The string "zzazz" is already palindrome we do not need any insertions.
    
    Example 2:
    
    >>> minInsertions(s = "mbadm")
    >>> 2
    Explanation: String can be "mbdadbm" or "mdbabdm".
    
    Example 3:
    
    >>> minInsertions(s = "leetcode")
    >>> 5
    Explanation: Inserting 5 characters the string becomes "leetcodocteel".
    """