{ "2062": { "problem_id": 2062, "description": "A substring is a contiguous (non-empty) sequence of characters within a string.\nA vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.\nGiven a string word, return the number of vowel substrings in word.\n", "provided_code_snippet": "class Solution:\r\n def countVowelSubstrings(self, word: str) -> int:", "solution": "class Solution:\n def countVowelSubstrings(self, word: str) -> int:\n ans = 0 \n freq = defaultdict(int)\n for i, x in enumerate(word): \n if x in \"aeiou\": \n if not i or word[i-1] not in \"aeiou\": \n jj = j = i # set anchor\n freq.clear()\n freq[x] += 1\n while len(freq) == 5 and all(freq.values()): \n freq[word[j]] -= 1\n j += 1\n ans += j - jj\n return ans", "submission_passed": false, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "int return", "one argument", "short" ] }, { "researcher_id": 2, "tags": [ "ambiguous terms", "Given and Return", "speaking method name", "starts with definitions" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "all", "for loop", "medium long", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "prediction", "function_input" ] }, "2063": { "problem_id": 2063, "description": "Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.\nA substring is a contiguous (non-empty) sequence of characters within a string.\nNote: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.\n", "provided_code_snippet": "class Solution:\r\n def countVowels(self, word: str) -> int:", "solution": "class Solution:\n def countVowels(self, word: str) -> int:\n count = 0\n sz = len(word)\n \n for pos in range(sz):\n if word[pos] in 'aeiou':\n count += (sz - pos) * (pos + 1)\n \n return count", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "definition after description", "int return", "note", "one argument", "short", "warning" ] }, { "researcher_id": 2, "tags": [ "ambiguous terms", "definitions in between", "Given and Return", "Note about solution (datatypes)", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "math", "short" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "prediction", "function_input" ] }, "2064": { "problem_id": 2064, "description": "You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.\nYou need to distribute all products to the retail stores following these rules:\n\t- A store can only be given at most one product type but can be given any amount of it.\n\t- After distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.\nReturn the minimum possible x.\n", "provided_code_snippet": "class Solution:\r\n def minimizedMaximum(self, n: int, quantities: List[int]) -> int:", "solution": "class Solution:\n def minimizedMaximum(self, n: int, quantities: List[int]) -> int:\n lo, hi = 1, max(quantities)\n while lo < hi: \n mid = lo + hi >> 1\n if sum(ceil(qty/mid) for qty in quantities) <= n: hi = mid \n else: lo = mid + 1\n return lo", "submission_passed": true, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "business", "int return", "list argument", "list of rules", "medium long", "story", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "Let and Return", "List of rules to consider", "optimization problem", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "bit operation", "math function", "short", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "problem_theme", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2065": { "problem_id": 2065, "description": "There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [uj, vj, timej] indicates that there is an undirected edge between the nodes uj and vj, and it takes timej seconds to travel between the two nodes. Finally, you are given an integer maxTime.\nA valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).\nReturn the maximum quality of a valid path.\nNote: There are at most four edges connected to each node.\n", "provided_code_snippet": "class Solution:\r\n def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:", "solution": "class Solution:\n def maximalPathQuality(self, values: List[int], edges: List[List[int]], maxTime: int) -> int:\n\n def dfs(node:int, prev_qual:int, prev_time:int, prev_mask:int)-> None:\n \n if node == 0: \n self.maxQuality = max(self.maxQuality, prev_qual)\n \n for nxt, wgt in graph[node]:\n if wgt > prev_time: continue\n\n if prev_mask & (1<< nxt): qual = prev_qual\n else: qual = prev_qual + values[nxt]\n\n mask = prev_mask | (1<< nxt)\n time = prev_time - wgt\n\n dfs(nxt, qual, time, mask)\n\n return\n\n\n self.maxQuality = 0\n graph = defaultdict(list)\n\n for u, v, wgt in edges:\n graph[u].append((v, wgt))\n graph[v].append((u, wgt))\n \n dfs(0, values[0], maxTime, 1)\n return self.maxQuality", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "graph", "list argument", "long", "math", "note", "three arguments" ] }, { "researcher_id": 2, "tags": [ "2D array", ">3 parameters", "array", "complex sentences (where, if, which)", "definitions in between", "Given and Return", "Note with extra constraints", "routing", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "bit operation", "for loop", "long" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "data_structure", "prediction", "sentences", "function_input" ] }, "2068": { "problem_id": 2068, "description": "Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.\nGiven two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.\nThe frequency of a letter x is the number of times it occurs in the string.\n", "provided_code_snippet": "class Solution:\r\n def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:", "solution": "def checkAlmostEquivalent(self, word1: str, word2: str) -> bool:\n return all(v <= 3 for v in ((Counter(list(word1)) - Counter(list(word2))) + (Counter(list(word2)) - Counter(list(word1)))).values())", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "bool return", "condition", "definition", "definition after description", "medium long", "string argument", "two arguments" ] }, { "researcher_id": 2, "tags": [ "complex sentences (where, if, which)", "definitions at the end", "Given and Return", "Sentence with >25 words", "speaking method name", "starts with definitions" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "all", "counter", "short" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "prediction", "sentences", "problem_type", "function_input" ] }, "2070": { "problem_id": 2070, "description": "You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.\nYou are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.\nReturn an array answer of the same length as queries where answer[j] is the answer to the jth query.\n", "provided_code_snippet": "class Solution:\r\n def maximumBeauty(self, items: List[List[int]], queries: List[int]) -> List[int]:", "solution": "class Solution:\n def maximumBeauty(self, items: List[List[int]], queries: List[int]) -> List[int]:\n\n # Ex: items = [[1,2],[3,2],[2,4],[5,6],[3,5]]\n\t\t\t\t\t\t\t\t\t\t\t\t\t# queries = [1,2,3,4,5,6]\n\n price, beauty = zip(*sorted(items)) # sorted(items = [[1,2],[2,4],[3,2],[3, 5],[5, 6]]\n # price = [1,2,3,3,5], beauty = [2,4,2,5,6]\n\n beauty = list(accumulate(beauty,lambda x,y: max(x,y)))\n\t\t\n # beauty = [2,4,4,5,6] \n return [0 if q < price[0] else \n beauty[bisect_right(price, q)-1] for q in queries]\n\t\t\t\t\n # q price[i] beauty[i]\n # \\u2013\\u2013\\u2013\\u2013 \\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013 \\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\n # 1 [ /1\\\\ ,2,3,3,5] [ /2\\\\ ,4,4,5,6]\n # 2 [1, /2\\\\, 3,3,5] [2, /4\\\\ ,4,5,6]\n # 3 [1,2,3, /3\\\\ 5] [2,4,4, /5\\\\ ,6]\n # 4 [1,2,3, /3\\\\ ,5] [2,4,4, /5\\\\ ,6]\n # 5 [1,2,3,3, /5\\\\ ] [2,4,4,5, /6\\\\ ]\n # 6 [1,2,3,3, /5\\\\ ] [2,4,4,5, /6\\\\ ]\n\n # return [2,4,5,5,6,6]", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "condition", "list argument", "list return", "medium long", "optimisation", "two arguments" ] }, { "researcher_id": 2, "tags": [ "2D array", "array", "complex sentences (where, if, which)", "Given and Return", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "accumulate", "bisect", "for loop", "list comprehension", "short", "zip" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2071": { "problem_id": 2071, "description": "You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).\nAdditionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.\nGiven the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.\n", "provided_code_snippet": "class Solution:\r\n def maxTaskAssign(self, tasks: List[int], workers: List[int], pills: int, strength: int) -> int:", "solution": "class Solution:\n def maxTaskAssign(self, tasks: List[int], workers: List[int], pills: int, strength: int) -> int:\n # workers sorted in reverse order, tasks sorted in normal order\n def can_assign(n):\n task_i = 0\n task_temp = deque()\n n_pills = pills\n for i in range(n-1,-1,-1):\n while task_i < n and tasks[task_i] <= workers[i]+strength:\n task_temp.append(tasks[task_i])\n task_i += 1\n \n if len(task_temp) == 0:\n return False\n if workers[i] >= task_temp[0]:\n task_temp.popleft()\n elif n_pills > 0:\n task_temp.pop()\n n_pills -= 1\n else:\n return False\n return True\n \n tasks.sort()\n workers.sort(reverse = True)\n \n l = 0\n r = min(len(tasks), len(workers))\n res = -1\n while l <= r:\n m = (l+r)//2\n if can_assign(m):\n res = m\n l = m+1\n else:\n r = m-1\n return res", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "business", "condition", "four arguments", "int return", "list argument", "long", "story", "variables unclear" ] }, { "researcher_id": 2, "tags": [ ">3 parameters", "array", "Given and Return", "Sentence with >25 words", "speaking method name", "whitespace in variable names" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "for loop", "long", "math function", "multiple cases", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "problem_theme", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2073": { "problem_id": 2073, "description": "There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.\nYou are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i].\nEach person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.\nReturn the time taken for the person at position k (0-indexed) to finish buying tickets.\n", "provided_code_snippet": "class Solution:\r\n def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:", "solution": "class Solution:\n def timeRequiredToBuy(self, tickets: List[int], k: int) -> int:\n total = 0\n\n for i, x in enumerate(tickets):\n if i <= k:\n total += min(tickets[i], tickets[k])\n else:\n total += min(tickets[i], tickets[k] - 1)\n\n return total", "submission_passed": false, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "business", "input late", "int return", "list argument", "story", "time", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "Given and Return", "Sentence with >25 words", "sentence with \"where\"", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "for loop", "math function", "medium long" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "description_order", "problem_theme", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2074": { "problem_id": 2074, "description": "You are given the head of a linked list.\nThe nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words,\n\t- The 1st node is assigned to the first group.\n\t- The 2nd and the 3rd nodes are assigned to the second group.\n\t- The 4th, 5th, and 6th nodes are assigned to the third group, and so on.\nNote that the length of the last group may be less than or equal to 1 + the length of the second to last group.\nReverse the nodes in each group with an even length, and return the head of the modified linked list.\n", "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n# def __init__(self, val=0, next=None):\r\n# self.val = val\r\n# self.next = next\r\nclass Solution:\r\n def reverseEvenLengthGroups(self, head: Optional[ListNode]) -> Optional[ListNode]:", "solution": "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# self.next = next\nclass Solution:\n def reverseEvenLengthGroups(self, head: Optional[ListNode]) -> Optional[ListNode]:\n connector = None\n curr = head\n group_count = 1\n count = 1\n\n def reverse_between(pre, n):\n start = pre.next\n then = start.next\n after = start\n\n for _ in range(n - 1):\n start.next = then.next\n then.next = pre.next\n pre.next = then\n then = start.next\n\n return after\n\n while curr:\n if group_count == count or not curr.next:\n if count % 2 == 0:\n curr = reverse_between(connector, count)\n connector = curr\n group_count += 1\n count = 0\n\n count += 1\n curr = curr.next\n\n return head", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "data structure", "list of rules", "medium long", "one argument", "predicted to be unsolved" ] }, { "researcher_id": 2, "tags": [ "coded data type definition", "examples", "Given and Return", "linked list", "Note with extra constraints", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "for loop", "long", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_building_block", "data_structure", "prediction", "function_input" ] }, "2075": { "problem_id": 2075, "description": "A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.\noriginalText is placed first in a top-left to bottom-right manner.\nThe blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.\nencodedText is then formed by appending all characters of the matrix in a row-wise fashion.\nThe characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.\nFor example, if originalText = \"cipher\" and rows = 3, then we encode it in the following manner:\nThe blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = \"ch ie pr\".\nGiven the encoded string encodedText and number of rows rows, return the original string originalText.\nNote: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.\n", "provided_code_snippet": "class Solution:\r\n def decodeCiphertext(self, encodedText: str, rows: int) -> str:", "solution": "class Solution:\n def decodeCiphertext(self, encodedText: str, rows: int) -> str:\n cols, res = len(encodedText) // rows, \"\"\n for i in range(cols):\n for j in range(i, len(encodedText), cols + 1):\n res += encodedText[j]\n return res.rstrip()", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "encoding", "image", "long", "missing reference", "note", "string manipulation", "string return", "two arguments" ] }, { "researcher_id": 2, "tags": [ "complex sentences (where, if, which)", "example", "Given and Return", "image missing", "matrix", "Note with extra constraints", "Sentence with >25 words" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "nested loop", "short" ] } ], "categories": [ "problem_domain", "input/output_wording", "length_of_problem", "description_building_block", "image", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2076": { "problem_id": 2076, "description": "You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.\nYou are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people.\nInitially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [uj, vj] is a friend request between person uj and person vj.\nA friend request is successful if uj and vj can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, uj and vj become direct friends for all future friend requests.\nReturn a boolean array result, where each result[j] is true if the jth friend request is successful or false if it is not.\nNote: If uj and vj are already direct friends, the request is still successful.\n", "provided_code_snippet": "class Solution:\r\n def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]:", "solution": "class Solution:\n def friendRequests(self, n: int, restrictions: List[List[int]], requests: List[List[int]]) -> List[bool]: \n result = [False for _ in requests]\n \n connected_components = [{i} for i in range(n)]\n \n connected_comp_dict = {}\n for i in range(n):\n connected_comp_dict[i] = i\n \n banned_by_comps = [set() for i in range(n)]\n for res in restrictions:\n banned_by_comps[res[0]].add(res[1])\n banned_by_comps[res[1]].add(res[0])\n for i,r in enumerate(requests):\n n1, n2 = r[0], r[1]\n c1, c2 = connected_comp_dict[n1], connected_comp_dict[n2]\n if c1 == c2:\n result[i] = True\n else:\n if not (connected_components[c1].intersection(banned_by_comps[c2]) or connected_components[c2].intersection(banned_by_comps[c1])):\n connected_components[c1].update(connected_components[c2])\n banned_by_comps[c1].update(banned_by_comps[c2])\n for node in connected_components[c2]:\n connected_comp_dict[node] = c1\n result[i] = True\n \n return result", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "list argument", "list return", "long", "note", "story", "three arguments" ] }, { "researcher_id": 2, "tags": [ "2D array", ">3 parameters", "ambiguous terms", "bloating of question", "complex sentences (where, if, which)", "Given and Return", "Note with extra constraints", "Sentence with >25 words" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "list comprehension", "long", "nested loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2078": { "problem_id": 2078, "description": "There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.\nReturn the maximum distance between two houses with different colors.\nThe distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.\n", "provided_code_snippet": "class Solution:\r\n def maxDistance(self, colors: List[int]) -> int:", "solution": "class Solution:\n def maxDistance(self, colors: List[int]) -> int:\n p, res = inf, 0\n for i, c in enumerate(colors):\n if (c != colors[0]):\n res = i\n p = min(p, i)\n else:\n res = max(res, i - p)\n return res", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "definition after description", "int return", "list argument", "math", "one argument", "optimisation", "short", "story" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "definitions at the end", "Given and Return" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "math function", "short" ] } ], "categories": [ "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2079": { "problem_id": 2079, "description": "You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.\nEach plant needs a specific amount of water. You will water the plants in the following way:\n\t- Water the plants in order from left to right.\n\t- After watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.\n\t- You cannot refill the watering can early.\nYou are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.\n", "provided_code_snippet": "class Solution:\r\n def wateringPlants(self, plants: List[int], capacity: int) -> int:", "solution": "class Solution:\n def wateringPlants(self, plants: List[int], capacity: int) -> int:\n ans = 0\n can = capacity\n for i, x in enumerate(plants): \n if can < x: \n ans += 2*i\n can = capacity\n ans += 1\n can -= x\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "gardening", "int return", "list argument", "list of rules", "medium long", "story", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "Given and Return", "List of rules to consider", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "for loop", "short" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "problem_theme", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2081": { "problem_id": 2081, "description": "A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.\n\t- For example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.\n\t- On the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.\nGiven the base k and the number n, return the sum of the n smallest k-mirror numbers.\n", "provided_code_snippet": "class Solution:\r\n def kMirror(self, k: int, n: int) -> int:", "solution": "class Solution:\n def kMirror(self, k: int, n: int) -> int:\n \n def fn(x):\n \n n = len(x)//2\n for i in range(n, len(x)): \n if int(x[i])+1 < k: \n x[i] = x[~i] = str(int(x[i])+1)\n for ii in range(n, i): x[ii] = x[~ii] = '0'\n return x\n return [\"1\"] + [\"0\"]*(len(x)-1) + [\"1\"]\n \n x = [\"0\"]\n ans = 0\n for _ in range(n): \n while True: \n x = fn(x)\n val = int(\"\".join(x), k)\n if str(val)[::-1] == str(val): break\n ans += val\n return ans", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "base", "example", "int return", "math", "two arguments" ] }, { "researcher_id": 2, "tags": [ "example", "Given and Return", "speaking method name", "starts with definitions" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "bit operation", "for loop", "medium long", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "description_order", "description_building_block", "output", "prediction", "function_input" ] }, "2085": { "problem_id": 2085, "description": "Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.\n", "provided_code_snippet": "class Solution:\r\n def countWords(self, words1: List[str], words2: List[str]) -> int:", "solution": "class Solution:\n def countWords(self, words1: List[str], words2: List[str]) -> int:\n freq1, freq2 = Counter(words1), Counter(words2)\n return len({w for w, v in freq1.items() if v == 1} & {w for w, v in freq2.items() if v == 1})", "submission_passed": false, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "int return", "list argument", "short", "two arguments" ] }, { "researcher_id": 2, "tags": [ "ambiguous method name", "array", "Given and Return", "very short" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "bit operation", "counter", "list comprehension", "short" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "output", "data_structure", "prediction", "function_input" ] }, "2086": { "problem_id": 2086, "description": "You are given a 0-indexed string hamsters where hamsters[i] is either:\n\t- 'H' indicating that there is a hamster at index i, or\n\t- '.' indicating that index i is empty.\nYou will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to its left or to its right. More formally, a hamster at index i can be fed if you place a food bucket at index i - 1 and/or at index i + 1.\nReturn the minimum number of food buckets you should place at empty indices to feed all the hamsters or -1 if it is impossible to feed all of them.\n", "provided_code_snippet": "class Solution:\r\n def minimumBuckets(self, hamsters: str) -> int:", "solution": "class Solution:\n def minimumBuckets(self, street: str) -> int:\n street = list(street)\n ans = 0 \n for i, ch in enumerate(street): \n if ch == 'H' and (i == 0 or street[i-1] != '#'): \n if i+1 < len(street) and street[i+1] == '.': street[i+1] = '#'\n elif i and street[i-1] == '.': street[i-1] = '#'\n else: return -1\n ans += 1\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "condition", "int return", "list of rules", "medium long", "one argument", "optimisation", "story", "string argument", "variables unclear" ] }, { "researcher_id": 2, "tags": [ "complex sentences (where, if, which)", "formal clarification", "Given and Return", "List of rules to consider", "speaking method name", "string encoding" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "medium long", "multiple cases" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2087": { "problem_id": 2087, "description": "There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).\nThe robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.\n\t- If the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].\n\t- If the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].\nReturn the minimum total cost for this robot to return home.\n", "provided_code_snippet": "class Solution:\r\n def minCost(self, startPos: List[int], homePos: List[int], rowCosts: List[int], colCosts: List[int]) -> int:", "solution": "class Solution:\n def minCost(self, startPos: List[int], homePos: List[int], rowCosts: List[int], colCosts: List[int]) -> int:\n src_x,src_y = startPos[0],startPos[1]\n end_x,end_y = homePos[0], homePos[1]\n \n if src_x < end_x:\n rc = sum(rowCosts[src_x+1:end_x+1])\n elif src_x > end_x:\n rc = sum(rowCosts[end_x:src_x])\n else:\n rc=0\n \n if src_y < end_y:\n cc = sum(colCosts[src_y+1:end_y+1])\n elif src_y > end_y:\n cc = sum(colCosts[end_y:src_y])\n else:\n cc=0\n \n return cc+rc", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "four arguments", "list argument", "medium long", "spatial", "story" ] }, { "researcher_id": 2, "tags": [ ">3 parameters", "array", "complex sentences (where, if, which)", "Given and Return", "List of rules to consider", "matrix" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "math function", "medium long", "multiple cases" ] } ], "categories": [ "problem_domain", "input/output_wording", "length_of_problem", "description_building_block", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2088": { "problem_id": 2088, "description": "A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.\nA pyramidal plot of land can be defined as a set of cells with the following criteria:\n\t1. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n\t2. The apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).\nAn inverse pyramidal plot of land can be defined as a set of cells with similar criteria:\n\t3. The number of cells in the set has to be greater than 1 and all cells must be fertile.\n\t4. The apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).\nSome examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.\nGiven a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.\n", "provided_code_snippet": "class Solution:\r\n def countPyramids(self, grid: List[List[int]]) -> int:", "solution": "class Solution:\n def countPyramids(self, grid: List[List[int]], ans = 0) -> int:\n\n def count()-> None:\n nonlocal ans\n prev_row = grid[0]\n\n for row in grid[1:]:\n curr_row = row[::]\n\n for j in range(1, len(grid[0])-1):\n \n if curr_row[j] == 0: continue\n\n curr_row[j] = min(prev_row[j-1:j+2])\n ans+= curr_row[j]\n curr_row[j]+= 1\n\n prev_row = curr_row\n\n return\n\n\n count()\n grid = grid[::-1]\n count()\n\n return ans", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "definition", "geometry", "int return", "list argument", "list of rules", "long", "math", "missing reference", "one argument", "spatial" ] }, { "researcher_id": 2, "tags": [ "complex sentences (where, if, which)", "example", "image missing", "List of rules to consider", "matrix" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "for loop", "medium long", "nested loop", "nonlocal" ] } ], "categories": [ "problem_domain", "length_of_problem", "description_building_block", "image", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2089": { "problem_id": 2089, "description": "You are given a 0-indexed integer array nums and a target element target.\nA target index is an index i such that nums[i] == target.\nReturn a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.\n", "provided_code_snippet": "class Solution:\r\n def targetIndices(self, nums: List[int], target: int) -> List[int]:", "solution": "class Solution:\n def targetIndices(self, nums: List[int], target: int) -> List[int]:\n lessThanEqual = 0\n onlyLess = 0\n for i in nums:\n if i <= target:\n lessThanEqual += 1\n if i < target:\n onlyLess += 1\n return list(range(onlyLess, lessThanEqual))", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "condition", "definition", "list argument", "list return", "output constraint", "short", "sorting", "two arguments", "variables unclear" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "definitions in between", "Given and Return" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "short" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2090": { "problem_id": 2090, "description": "You are given a 0-indexed array nums of n integers, and an integer k.\nThe k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.\nBuild and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.\nThe average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.\n\t- For example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.\n", "provided_code_snippet": "class Solution:\r\n def getAverages(self, nums: List[int], k: int) -> List[int]:", "solution": "class Solution:\n def getAverages(self, nums: List[int], k: int) -> List[int]:\n n = len(nums)\n windowSize = 2 * k + 1\n ans = [-1] * n\n \n if n < windowSize:\n return ans\n \n prefixSum = [0] * (n + 1)\n for i in range(n):\n prefixSum[i + 1] = prefixSum[i] + nums[i]\n \n for i in range(k, n - k):\n ans[i] = (prefixSum[i + k + 1] - prefixSum[i - k]) // windowSize\n \n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "definition after description", "example", "list argument", "list return", "math", "medium long", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "definitions in between", "example", "Given and Return", "Note with extra constraints", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "medium long" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2091": { "problem_id": 2091, "description": "You are given a 0-indexed array of distinct integers nums.\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n", "provided_code_snippet": "class Solution:\r\n def minimumDeletions(self, nums: List[int]) -> int:", "solution": "class Solution:\n def minimumDeletions(self, nums: List[int]) -> int:\n minp, maxp, minel, maxel, L = 0, 0, float('inf'), float('-inf'), len(nums)\n for i, n in enumerate(nums):\n if n > maxel:\n maxel = n\n maxp = i\n if n < minel:\n minel = n\n minp = i\n \n left, right = min(minp, maxp), max(minp, maxp)\n\n return min(right + 1, L - left, left + 1 + (L - right))", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "int return", "list argument", "medium long", "one argument", "predicted to be solved" ] }, { "researcher_id": 2, "tags": [ "array", "definitions in between", "Given and Return", "implicit constraint" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "math function", "medium long" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2092": { "problem_id": 2092, "description": "You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.\nPerson 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.\nThe secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.\nReturn a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.\n", "provided_code_snippet": "class Solution:\r\n def findAllPeople(self, n: int, meetings: List[List[int]], firstPerson: int) -> List[int]:", "solution": "class Solution:\n def findAllPeople(self, n: int, meetings: List[List[int]], firstPerson: int) -> List[int]:\n can = {0, firstPerson}\n for _, grp in groupby(sorted(meetings, key=lambda x: x[2]), key=lambda x: x[2]): \n queue = set()\n graph = defaultdict(list)\n for x, y, _ in grp: \n graph[x].append(y)\n graph[y].append(x)\n if x in can: queue.add(x)\n if y in can: queue.add(y)\n \n queue = deque(queue)\n while queue: \n x = queue.popleft()\n for y in graph[x]: \n if y not in can: \n can.add(y)\n queue.append(y)\n return can", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "list return", "medium long", "story", "three arguments", "variables unclear" ] }, { "researcher_id": 2, "tags": [ "2D array", ">3 parameters", "complex sentences (where, if, which)", "formal clarification", "Given and Return", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "lambda", "medium long", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2094": { "problem_id": 2094, "description": "You are given an integer array digits, where each element is a digit. The array may contain duplicates.\nYou need to find all the unique integers that follow the given requirements:\n\t- The integer consists of the concatenation of three elements from digits in any arbitrary order.\n\t- The integer does not have leading zeros.\n\t- The integer is even.\nFor example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.\nReturn a sorted array of the unique integers.\n", "provided_code_snippet": "class Solution:\r\n def findEvenNumbers(self, digits: List[int]) -> List[int]:", "solution": "class Solution:\n def findEvenNumbers(self, digits: List[int]) -> List[int]:\n res, cnt = [], Counter(digits)\n for i in range(1, 10):\n for j in range(0, 10):\n for k in range(0, 10, 2):\n if cnt[i] > 0 and cnt[j] > (i == j) and cnt[k] > (k == i) + (k == j):\n res.append(i * 100 + j * 10 + k)\n return res", "submission_passed": false, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "example", "list argument", "list of rules", "list return", "medium long", "one argument", "string manipulation" ] }, { "researcher_id": 2, "tags": [ "array", "example", "List of rules to consider", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "counter", "for loop", "math", "nested loop", "short" ] } ], "categories": [ "impreciseness", "problem_domain", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2096": { "problem_id": 2096, "description": "You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.\nFind the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:\n\t- 'L' means to go from a node to its left child node.\n\t- 'R' means to go from a node to its right child node.\n\t- 'U' means to go from a node to its parent node.\nReturn the step-by-step directions of the shortest path from node s to node t.\n", "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n# def __init__(self, val=0, left=None, right=None):\r\n# self.val = val\r\n# self.left = left\r\n# self.right = right\r\nclass Solution:\r\n def getDirections(self, root: Optional[TreeNode], startValue: int, destValue: int) -> str:", "solution": "class Solution:\n def getDirections(self, root: Optional[TreeNode], startValue: int, destValue: int) -> str:\n def find(n: TreeNode, val: int, path: List[str]) -> bool:\n if n.val == val:\n return True\n if n.left and find(n.left, val, path):\n path += \"L\"\n elif n.right and find(n.right, val, path):\n path += \"R\"\n return path\n s, d = [], []\n find(root, startValue, s)\n find(root, destValue, d)\n while len(s) and len(d) and s[-1] == d[-1]:\n s.pop()\n d.pop()\n return \"\".join(\"U\" * len(s)) + \"\".join(reversed(d))", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "data structure", "graph", "list of rules", "string return", "three arguments" ] }, { "researcher_id": 2, "tags": [ ">3 parameters", "coded data type definition", "Given and Return", "List of rules to consider", "Sentence with >25 words", "tree" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "medium long", "multiple cases", "while loop" ] } ], "categories": [ "input/output_wording", "description_building_block", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2097": { "problem_id": 2097, "description": "You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.\nReturn any valid arrangement of pairs.\nNote: The inputs will be generated such that there exists a valid arrangement of pairs.\n", "provided_code_snippet": "class Solution:\r\n def validArrangement(self, pairs: List[List[int]]) -> List[List[int]]:", "solution": "class Solution:\n def validArrangement(self, pairs: List[List[int]]) -> List[List[int]]:\n graph = defaultdict(list)\n degree = defaultdict(int) # net out degree \n for x, y in pairs: \n graph[x].append(y)\n degree[x] += 1\n degree[y] -= 1\n \n for k in degree: \n if degree[k] == 1: \n x = k\n break \n \n ans = []\n\n def fn(x): \n \n while graph[x]: fn(graph[x].pop()) \n ans.append(x)\n \n fn(x)\n ans.reverse()\n return [[ans[i], ans[i+1]] for i in range(len(ans)-1)]", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "list argument", "list return", "math", "note", "one argument", "short" ] }, { "researcher_id": 2, "tags": [ "2D array", "complex sentences (where, if, which)", "implicit constraint", "Note with extra constraints", "very short" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "list comprehension", "long", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2099": { "problem_id": 2099, "description": "You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.\nReturn any such subsequence as an integer array of length k.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n", "provided_code_snippet": "class Solution:\r\n def maxSubsequence(self, nums: List[int], k: int) -> List[int]:", "solution": "def maxSubsequence(self, nums: List[int], k: int) -> List[int]:\n val_and_index = sorted([(num, i) for i, num in enumerate(nums)])\n return [num for num, i in sorted(val_and_index[-k :], key=lambda x: x[1])]", "submission_passed": false, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "definition after description", "list argument", "list return", "short", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "definitions at the end", "Given and Return", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "lambda", "list comprehension", "short" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2100": { "problem_id": 2100, "description": "You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.\nThe ith day is a good day to rob the bank if:\n\t- There are at least time days before and after the ith day,\n\t- The number of guards at the bank for the time days before i are non-increasing, and\n\t- The number of guards at the bank for the time days after i are non-decreasing.\nMore formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].\nReturn a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.\n", "provided_code_snippet": "class Solution:\r\n def goodDaysToRobBank(self, security: List[int], time: int) -> List[int]:", "solution": "class Solution:\n def goodDaysToRobBank(self, security: List[int], time: int) -> List[int]:\n suffix = [0]*len(security)\n for i in range(len(security)-2, 0, -1): \n if security[i] <= security[i+1]: suffix[i] = suffix[i+1] + 1\n \n ans = []\n prefix = 0\n for i in range(len(security)-time): \n if i and security[i-1] >= security[i]: prefix += 1\n else: prefix = 0\n if prefix >= time and suffix[i] >= time: ans.append(i)\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "further clarification", "list argument", "list of rules", "list return", "medium long", "story", "two arguments", "variables unclear" ] }, { "researcher_id": 2, "tags": [ "complex sentences (where, if, which)", "crime and violence", "formal clarification", "Given and Return", "List of rules to consider" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "medium long" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_building_block", "problem_theme", "output", "prediction", "sentences", "problem_type", "function_input" ] }, "2101": { "problem_id": 2101, "description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n", "provided_code_snippet": "class Solution:\r\n def maximumDetonation(self, bombs: List[List[int]]) -> int:", "solution": "class Solution:\n def maximumDetonation(self, bombs: List[List[int]]) -> int:\n\n def is_connected(a,b):\n x1, y1, r1 = bombs[a]\n x2, y2, r2 = bombs[b]\n dist = math.sqrt((x1-x2)**2 + (y1-y2)**2)\n return dist <= r1\n\n\n conn = collections.defaultdict(list)\n for i in range(len(bombs)):\n for j in range(len(bombs)):\n if i != j:\n if is_connected(i,j):\n conn[i].append(j)\n\n # 1. BFS\n # q = collections.deque()\n # maxCount = float('-inf')\n\n # for node in range(len(bombs)):\n # if conn[node]:\n # q.append(node)\n # visited = set()\n # visited.add(node)\n # count = 0\n # while q:\n # curr = q.popleft()\n # count+=1\n # maxCount = max(maxCount, count)\n # for child in conn[curr]:\n # if child not in visited:\n # visited.add(child)\n # q.append(child)\n\n # return maxCount if maxCount != float('-inf') else 1\n\n\n # 2. DFS\n\n # stack = []\n # maxCount = float('-inf')\n\n # for node in range(len(bombs)):\n # if conn[node]:\n # visited = set()\n # stack.append(node)\n # visited.add(node)\n # count = 0\n # while stack:\n\n # curr = stack.pop()\n # count+=1\n # maxCount = max(maxCount, count)\n\n # for child in conn[curr]:\n # if child not in visited:\n # visited.add(child)\n # stack.append(child)\n # return maxCount if maxCount != float('-inf') else 1\n\n\n # 3. DFS recursive \n \n def dfs(node):\n\n if node in visited:\n return 0\n\n visited.add(node)\n \n ans = 1\n\n if node in conn:\n for child in conn[node]:\n if child in visited:\n continue\n ans += dfs(child)\n \n return ans \n\n maxCount = 1\n for node in conn:\n visited = set()\n maxCount = max(maxCount, dfs(node))\n return maxCount", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "geometry", "int return", "list argument", "math", "medium long", "spatial", "story" ] }, { "researcher_id": 2, "tags": [ "2D array", "crime and violence", "definitions in between", "Given and Return" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "for loop", "long", "math function", "nested loop" ] } ], "categories": [ "problem_domain", "input/output_wording", "length_of_problem", "description_order", "problem_theme", "output", "data_structure", "prediction", "problem_type", "function_input" ] }, "2103": { "problem_id": 2103, "description": "There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.\nYou are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:\n\t- The first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').\n\t- The second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').\nFor example, \"R3G2B1\" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.\nReturn the number of rods that have all three colors of rings on them.\n", "provided_code_snippet": "class Solution:\r\n def countPoints(self, rings: str) -> int:", "solution": "class Solution:\n def countPoints(self, r: str) -> int:\n ans = 0\n for i in range(10):\n i = str(i)\n if 'R'+i in r and 'G'+i in r and 'B'+i in r:\n ans += 1\n return ans", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "example", "int return", "list of rules", "medium long", "string argument", "string manipulation" ] }, { "researcher_id": 2, "tags": [ "ambiguous method name", "example", "Given and Return", "List of rules to consider", "string encoding" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "for loop", "short" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2104": { "problem_id": 2104, "description": "You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.\nReturn the sum of all subarray ranges of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def subArrayRanges(self, nums: List[int]) -> int:", "solution": "class Solution:\n def subArrayRanges(self, nums: List[int]) -> int:\n n = len(nums)\n \n # the answer will be sum{ Max(subarray) - Min(subarray) } over all possible subarray\n # which decomposes to sum{Max(subarray)} - sum{Min(subarray)} over all possible subarray\n # so totalsum = maxsum - minsum\n # we calculate minsum and maxsum in two different loops\n minsum = maxsum = 0\n \n # first calculate sum{ Min(subarray) } over all subarrays\n # sum{ Min(subarray) } = sum(f(i) * nums[i]) ; i=0..n-1\n # where f(i) is number of subarrays where nums[i] is the minimum value\n # f(i) = (i - index of the previous smaller value) * (index of the next smaller value - i) * nums[i]\n # we can claculate these indices in linear time using a monotonically increasing stack.\n stack = []\n for next_smaller in range(n + 1):\n\t\t\t# we pop from the stack in order to satisfy the monotonically increasing order property\n\t\t\t# if we reach the end of the iteration and there are elements present in the stack, we pop all of them\n while stack and (next_smaller == n or nums[stack[-1]] > nums[next_smaller]):\n i = stack.pop()\n prev_smaller = stack[-1] if stack else -1\n minsum += nums[i] * (next_smaller - i) * (i - prev_smaller)\n stack.append(next_smaller)\n \n # then calculate sum{ Max(subarray) } over all subarrays\n # sum{ Max(subarray) } = sum(f'(i) * nums[i]) ; i=0..n-1\n # where f'(i) is number of subarrays where nums[i] is the maximum value\n # f'(i) = (i - index of the previous larger value) - (index of the next larger value - i) * nums[i]\n # this time we use a monotonically decreasing stack.\n stack = []\n for next_larger in range(n + 1):\n\t\t\t# we pop from the stack in order to satisfy the monotonically decreasing order property\n\t\t\t# if we reach the end of the iteration and there are elements present in the stack, we pop all of them\n while stack and (next_larger == n or nums[stack[-1]] < nums[next_larger]):\n i = stack.pop()\n prev_larger = stack[-1] if stack else -1\n maxsum += nums[i] * (next_larger - i) * (i - prev_larger)\n stack.append(next_larger)\n \n return maxsum - minsum", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "definition after description", "int return", "list argument", "one argument", "short" ] }, { "researcher_id": 2, "tags": [ "ambiguous method name", "array", "definitions at the end", "definitions in between", "Given and Return" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "for loop", "math", "medium long", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2105": { "problem_id": 2105, "description": "Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.\nEach plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:\n\t- Alice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.\n\t- It takes the same amount of time to water each plant regardless of how much water it needs.\n\t- Alice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.\n\t- In case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.\n", "provided_code_snippet": "class Solution:\r\n def minimumRefill(self, plants: List[int], capacityA: int, capacityB: int) -> int:", "solution": "class Solution:\n def minimumRefill(self, plants: List[int], capacityA: int, capacityB: int) -> int:\n ans = 0 \n lo, hi = 0, len(plants)-1\n canA, canB = capacityA, capacityB\n while lo < hi: \n if canA < plants[lo]: ans += 1; canA = capacityA\n canA -= plants[lo]\n if canB < plants[hi]: ans += 1; canB = capacityB\n canB -= plants[hi]\n lo, hi = lo+1, hi-1\n if lo == hi and max(canA, canB) < plants[lo]: ans += 1\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "condition", "gardening", "input late", "int return", "list argument", "list of rules", "long", "optimisation", "spatial", "story", "three arguments" ] }, { "researcher_id": 2, "tags": [ ">3 parameters", "array", "complex sentences (where, if, which)", "Given and Return", "List of rules to consider", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "medium long", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "problem_theme", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2106": { "problem_id": 2106, "description": "Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.\nYou are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.\nReturn the maximum total number of fruits you can harvest.\n", "provided_code_snippet": "class Solution:\r\n def maxTotalFruits(self, fruits: List[List[int]], startPos: int, k: int) -> int:", "solution": "class Solution:\n def maxTotalFruits(self, fruits: List[List[int]], startPos: int, k: int) -> int:\n return self.max_fruits_sliding_window(fruits, startPos, k)\n \n def max_fruits_sliding_window(self, fruits, start_pos, k):\n # the sliding window approach is very intuitive to come up with\n # basically, create a window and slide it over the fruits array\n # when the window is valid, calculate the max fruits.\n # Then increase the end of the window, while calculating max fruits at every step\n # but when window becomes invalid, shrink from start to make it valid\n # The main thing is how to make sure window is valid? Here we are not interested in the width of the window\n # but rather the number of steps from the start position\n # first make sure you reach the start position cuz thats where you need to start\n # then the no of steps = steps in window - min(steps in either direction from start pos)\n # visualize the question, the most optimal walk is go in one direction, then switch. Going back and forth wont help\n # but to maximize steps, we need to go in shorter direction first, so not to waste steps coming back to start\n # thats why the steps needed is (window steps) - min(abs distance of both ends of window from start)\n # time: O(N)\n\n max_fruits, f = 0, 0\n start = 0\n for end, [p, a] in enumerate(fruits): # end is the index in fruits, and each fruit has position and amount\n f += a # accumulate fruits\n if p < start:\n continue # wait till window reaches the start\n\n # length of window = end - start + 1, but steps needed is end - start\n # since we are going from start to one end of window then going to another, we subtract that amount of steps needed to go from start to min end of window\n # but remember here steps is related to position, so use position\n while start <= end and p - fruits[start][0] + min(abs(start_pos - p), abs(start_pos - fruits[start][0])) > k:\n f -= fruits[start][1] # remove fruit at start of window in fruits\n start += 1\n\n max_fruits = max(max_fruits, f)\n\n return max_fruits", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "gardening", "int return", "medium long", "spatial", "story", "three arguments" ] }, { "researcher_id": 2, "tags": [ "2D array", ">3 parameters", "Given and Return", "implicit constraint", "optimization problem" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "math", "math function", "short", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "problem_theme", "output", "data_structure", "prediction", "problem_type", "function_input" ] }, "2108": { "problem_id": 2108, "description": "Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string \"\".\nA string is palindromic if it reads the same forward and backward.\n", "provided_code_snippet": "class Solution:\r\n def firstPalindrome(self, words: List[str]) -> str:", "solution": "class Solution:\n def firstPalindrome(self, words: List[str]) -> str:\n return next((s for s in words if all(s[i]==s[-(i+1)] for i in range(len(s)//2))), \"\")\n``` \n# Python 1-liner check s==s[::-1]", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "condition", "definition", "definition after description", "list argument", "one argument", "short", "string return" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "definitions at the end", "Given and Return", "speaking method name", "very short" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "all", "for loop", "list comprehension" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2109": { "problem_id": 2109, "description": "You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.\n\t- For example, given s = \"EnjoyYourCoffee\" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at indices 5 and 9 respectively. Thus, we obtain \"Enjoy Your Coffee\".\nReturn the modified string after the spaces have been added.\n", "provided_code_snippet": "class Solution:\r\n def addSpaces(self, s: str, spaces: List[int]) -> str:", "solution": "def addSpaces(self, s: str, spaces: List[int]) -> str:\n ans = []\n i = len(s) - 1\n while i >= 0:\n ans.append(s[i])\n if spaces and i == spaces[-1]:\n ans.append(' ')\n spaces.pop()\n i -= 1 \n return ''.join(ans[:: -1])", "submission_passed": true, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "example", "list argument", "short", "string argument", "string manipulation", "string return", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "example", "Given and Return", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "short", "while loop" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2110": { "problem_id": 2110, "description": "You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.\nA smooth descent period of a stock consists of one or more contiguous days such that the price on each day is lower than the price on the preceding day by exactly 1. The first day of the period is exempted from this rule.\nReturn the number of smooth descent periods.\n", "provided_code_snippet": "class Solution:\r\n def getDescentPeriods(self, prices: List[int]) -> int:", "solution": "def getDescentPeriods(self, prices: List[int]) -> int:\n ans = cnt = 0\n prev = -math.inf\n for cur in prices:\n if prev - cur == 1:\n cnt += 1\n else:\n cnt = 1\n ans += cnt\n prev = cur\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "int return", "list argument", "short", "story", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "definitions in between", "Given and Return", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "for loop", "math" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "problem_type", "function_input" ] }, "2111": { "problem_id": 2111, "description": "You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.\nThe array arr is called K-increasing if arr[i-k] <= arr[i] holds for every index i, where k <= i <= n-1.\n\t- For example, arr = [4, 1, 5, 2, 6, 2] is K-increasing for k = 2 because:\t\t\t- arr[0] <= arr[2] (4 <= 5)\n\t\t- arr[1] <= arr[3] (1 <= 2)\n\t\t- arr[2] <= arr[4] (5 <= 6)\n\t\t- arr[3] <= arr[5] (2 <= 2)\n\t\t\n\t- However, the same arr is not K-increasing for k = 1 (because arr[0] > arr[1]) or k = 3 (because arr[0] > arr[3]).\nIn one operation, you can choose an index i and change arr[i] into any positive integer.\nReturn the minimum number of operations required to make the array K-increasing for the given k.\n", "provided_code_snippet": "class Solution:\r\n def kIncreasing(self, arr: List[int], k: int) -> int:", "solution": "class Solution:\n def kIncreasing(self, arr: List[int], k: int) -> int:\n \n def fn(sub): \n \n vals = []\n for x in sub: \n k = bisect_right(vals, x)\n if k == len(vals): vals.append(x)\n else: vals[k] = x\n return len(sub) - len(vals)\n \n return sum(fn(arr[i:len(arr):k]) for i in range(k))", "submission_passed": false, "difficulty": "Hard", "problem_tags": [ { "researcher_id": 1, "tags": [ "example", "int return", "list argument", "math", "medium long", "two arguments" ] }, { "researcher_id": 2, "tags": [ "array", "definitions in between", "example", "Given and Return" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "bisect", "for loop", "list comprehension", "math function", "short" ] } ], "categories": [ "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2114": { "problem_id": 2114, "description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\nYou are given an array of strings sentences, where each sentences[i] represents a single sentence.\nReturn the maximum number of words that appear in a single sentence.\n", "provided_code_snippet": "class Solution:\r\n def mostWordsFound(self, sentences: List[str]) -> int:", "solution": "class Solution:\n def mostWordsFound(self, ss: List[str]) -> int:\n return max(s.count(\" \") for s in ss) + 1", "submission_passed": true, "difficulty": "Easy", "problem_tags": [ { "researcher_id": 1, "tags": [ "definition", "int return", "list argument", "short", "string manipulation" ] }, { "researcher_id": 2, "tags": [ "array", "complex sentences (where, if, which)", "Given and Return", "speaking method name", "starts with definitions", "very short" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "easy", "math function", "short" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "sentences", "function_input" ] }, "2115": { "problem_id": 2115, "description": "You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. Ingredients to a recipe may need to be created from other recipes, i.e., ingredients[i] may contain a string that is in recipes.\nYou are also given a string array supplies containing all the ingredients that you initially have, and you have an infinite supply of all of them.\nReturn a list of all the recipes that you can create. You may return the answer in any order.\nNote that two recipes may contain each other in their ingredients.\n", "provided_code_snippet": "class Solution:\r\n def findAllRecipes(self, recipes: List[str], ingredients: List[List[str]], supplies: List[str]) -> List[str]:", "solution": "def findAllRecipes(self, recipes: List[str], ingredients: List[List[str]], supplies: List[str]) -> List[str]:\n \n ans = []\n seen = set(supplies)\n dq = deque([(r, ing) for r, ing in zip(recipes, ingredients)])\n \n # dummy value for prev_size, just to make sure \n # the initial value of prev_size < len(seen) \n prev_size = len(seen) - 1 \n \n # Keep searching if we have any new finding(s).\n while len(seen) > prev_size:\n prev_size = len(seen)\n for _ in range(len(dq)):\n r, ing = dq.popleft()\n if all(i in seen for i in ing):\n ans.append(r)\n seen.add(r)\n else:\n dq.append((r, ing))\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "2d array", "list argument", "list return", "medium long", "note", "story", "three arguments" ] }, { "researcher_id": 2, "tags": [ "2D array", ">3 parameters", "array", "Given and Return", "Note with extra constraints", "Sentence with >25 words", "speaking method name" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "all", "for loop", "list comprehension", "medium long", "nested loop", "while loop" ] } ], "categories": [ "impreciseness", "input/output_wording", "length_of_problem", "description_building_block", "output", "data_structure", "prediction", "sentences", "problem_type", "function_input" ] }, "2116": { "problem_id": 2116, "description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\t- It is ().\n\t- It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\n\t- It can be written as (A), where A is a valid parentheses string.\nYou are given a parentheses string s and a string locked, both of length n. locked is a binary string consisting only of '0's and '1's. For each index i of locked,\n\t- If locked[i] is '1', you cannot change s[i].\n\t- But if locked[i] is '0', you can change s[i] to either '(' or ')'.\nReturn true if you can make s a valid parentheses string. Otherwise, return false.\n", "provided_code_snippet": "class Solution:\r\n def canBeValid(self, s: str, locked: str) -> bool:", "solution": "class Solution:\n def canBeValid(self, s: str, locked: str) -> bool:\n def validate(s: str, locked: str, op: str) -> bool:\n bal, wild = 0, 0\n for i in range(len(s)):\n if locked[i] == \"1\":\n bal += 1 if s[i] == op else -1\n else:\n wild += 1\n if wild + bal < 0:\n return False\n return bal <= wild\n return len(s) % 2 == 0 and validate(s, locked, '(') and validate(s[::-1], locked[::-1], ')')", "submission_passed": false, "difficulty": "Medium", "problem_tags": [ { "researcher_id": 1, "tags": [ "bool return", "definition", "list of rules", "math", "medium long", "string argument", "two arguments" ] }, { "researcher_id": 2, "tags": [ "Given and Return", "List of rules to consider", "speaking method name", "starts with definitions", "string encoding" ] } ], "solution_tags": [ { "researcher_id": 1, "tags": [ "additional function def", "for loop", "medium long" ] } ], "categories": [ "impreciseness", "problem_domain", "input/output_wording", "length_of_problem", "description_order", "description_building_block", "output", "data_structure", "prediction", "function_input" ] }, "2117": { "problem_id": 2117, "description": "You are given two positive integers left and right with left <= right. Calculate the product of all integers in the inclusive range [left, right].\nSince the product may be very large, you will abbreviate it following these steps:\n\t- Count all trailing zeros in the product and remove them. Let us denote this count as C.\t\t\t- For example, there are 3 trailing zeros in 1000, and there are 0 trailing zeros in 546.\n\t\t\n\t- Denote the remaining number of digits in the product as d. If d > 10, then express the product as
... where 
 denotes the first 5 digits of the product, and  denotes the last 5 digits of the product after removing all trailing zeros. If d <= 10, we keep it unchanged.\t\t\t- For example, we express 1234567654321 as 12345...54321, but 1234567 is represented as 1234567.\n\t\t\n\t- Finally, represent the product as a string \"
...eC\".\t\t\t- For example, 12345678987600000 will be represented as \"12345...89876e5\".\n\t\t\nReturn a string denoting the abbreviated product of all integers in the inclusive range [left, right].\n",
        "provided_code_snippet": "class Solution:\r\n    def abbreviateProduct(self, left: int, right: int) -> str:",
        "solution": "class Solution:\n    def abbreviateProduct(self, left: int, right: int) -> str:\n        ans = prefix = suffix = 1\n        trailing = 0 \n        flag = False \n        for x in range(left, right+1): \n            if not flag: \n                ans *= x\n                while ans % 10 == 0: ans //= 10 \n                if ans >= 1e10: flag = True \n            prefix *= x\n            suffix *= x\n            while prefix >= 1e12: prefix //= 10 \n            while suffix % 10 == 0: \n                trailing += 1\n                suffix //= 10 \n            if suffix >= 1e10: suffix %= 10_000_000_000\n        while prefix >= 100000: prefix //= 10 \n        suffix %= 100000\n        if flag: return f\"{prefix}...{suffix:>05}e{trailing}\"\n        return f\"{ans}e{trailing}\"",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "example",
                    "list of rules",
                    "medium long",
                    "output constraint",
                    "string return",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "complex sentences (where, if, which)",
                    "example",
                    "Given and Return",
                    "List of rules to consider"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "for loop",
                    "math",
                    "medium long",
                    "nested loop",
                    "while loop"
                ]
            }
        ],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2119": {
        "problem_id": 2119,
        "description": "Reversing an integer means to reverse all its digits.\n\t- For example, reversing 2021 gives 1202. Reversing 12300 gives 321 as the leading zeros are not retained.\nGiven an integer num, reverse num to get reversed1, then reverse reversed1 to get reversed2. Return true if reversed2 equals num. Otherwise return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def isSameAfterReversals(self, num: int) -> bool:",
        "solution": "class Solution:\n    def isSameAfterReversals(self, num: int) -> bool:\n        return not num or num % 10",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "chain of operations",
                    "definition",
                    "one argument",
                    "string manipulation"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "complex sentences (where, if, which)",
                    "example",
                    "Given and Return",
                    "speaking method name",
                    "starts with definitions",
                    "very short"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "easy",
                    "short"
                ]
            }
        ],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2120": {
        "problem_id": 2120,
        "description": "There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1). You are given the integer n and an integer array startPos where startPos = [startrow, startcol] indicates that a robot is initially at cell (startrow, startcol).\nYou are also given a 0-indexed string s of length m where s[i] is the ith instruction for the robot: 'L' (move left), 'R' (move right), 'U' (move up), and 'D' (move down).\nThe robot can begin executing from any ith instruction in s. It executes the instructions one by one towards the end of s but it stops if either of these conditions is met:\n\t- The next instruction will move the robot off the grid.\n\t- There are no more instructions left to execute.\nReturn an array answer of length m where answer[i] is the number of instructions the robot can execute if the robot begins executing from the ith instruction in s.\n",
        "provided_code_snippet": "class Solution:\r\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:",
        "solution": "class Solution:\n    def executeInstructions(self, n: int, startPos: List[int], s: str) -> List[int]:\n        row,col,res=startPos[0],startPos[1],[]\n        for i in range(len(s)):\n            startPos[0],startPos[1],arr,count=row,col,s[i:],0\n            for j in arr:\n                if j==\"R\":\n                    if startPos[1]+1==n:break\n                    else:\n                        startPos[1]+=1\n                        count+=1\n                elif j==\"L\":\n                    if startPos[1]-1==-1:break\n                    else:\n                        startPos[1]-=1\n                        count+=1\n                elif j==\"U\":\n                    if startPos[0]-1==-1:break\n                    else:\n                        startPos[0]-=1\n                        count+=1\n                elif j==\"D\":\n                    if startPos[0]+1==n:break\n                    else:\n                        startPos[0]+=1\n                        count+=1\n            res.append(count)\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "list argument",
                    "list of rules",
                    "list return",
                    "medium long",
                    "spatial",
                    "story",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "List of rules to consider",
                    "matrix",
                    "string encoding"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "for loop",
                    "multiple cases",
                    "nested loop"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2121": {
        "problem_id": 2121,
        "description": "You are given a 0-indexed array of n integers arr.\nThe interval between two elements in arr is defined as the absolute difference between their indices. More formally, the interval between arr[i] and arr[j] is |i - j|.\nReturn an array intervals of length n where intervals[i] is the sum of intervals between arr[i] and each element in arr with the same value as arr[i].\nNote: |x| is the absolute value of x.\n",
        "provided_code_snippet": "class Solution:\r\n    def getDistances(self, arr: List[int]) -> List[int]:",
        "solution": "def getDistances(self, arr: List[int]) -> List[int]:\n    m, res = {}, [0] * len(arr)\n    for i, v in enumerate(arr):\n        if v not in m: m[v] = list()\n        m[v].append(i)\n    \n    for x in m:\n        l = m[x]\n        pre = [0] * (len(l) + 1)\n        for i in range(len(l)):\n            pre[i + 1] = pre[i] + l[i]\n        for i, v in enumerate(l):\n            res[v] = (v * (i + 1) - pre[i + 1]) + ((pre[len(l)] - pre[i]) - v * (len(l) - (i)))\n    return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "further clarification",
                    "list argument",
                    "list return",
                    "math",
                    "note",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions in between",
                    "formal clarification",
                    "Given and Return",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "for loop",
                    "math",
                    "medium long",
                    "nested loop"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2122": {
        "problem_id": 2122,
        "description": "Alice had a 0-indexed array arr consisting of n positive integers. She chose an arbitrary positive integer k and created two new 0-indexed integer arrays lower and higher in the following manner:\n\t1. lower[i] = arr[i] - k, for every index i where 0 <= i < n\n\t2. higher[i] = arr[i] + k, for every index i where 0 <= i < n\nUnfortunately, Alice lost all three arrays. However, she remembers the integers that were present in the arrays lower and higher, but not the array each integer belonged to. Help Alice and recover the original array.\nGiven an array nums consisting of 2n integers, where exactly n of the integers were present in lower and the remaining in higher, return the original array arr. In case the answer is not unique, return any valid array.\nNote: The test cases are generated such that there exists at least one valid array arr.\n",
        "provided_code_snippet": "class Solution:\r\n    def recoverArray(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def recoverArray(self, nums: List[int]) -> List[int]:\n        nums.sort()\n        cnt = Counter(nums)\n        for i in range(1, len(nums)): \n            diff = nums[i] - nums[0]\n            if diff and diff&1 == 0: \n                ans = []\n                freq = cnt.copy()\n                for k, v in freq.items(): \n                    if v: \n                        if freq[k+diff] < v: break \n                        ans.extend([k+diff//2]*v)\n                        freq[k+diff] -= v\n                else: return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "list argument",
                    "list of rules",
                    "list return",
                    "math",
                    "note",
                    "one argument",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bit operation",
                    "counter",
                    "for loop",
                    "medium long",
                    "nested loop"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2124": {
        "problem_id": 2124,
        "description": "Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def checkString(self, s: str) -> bool:",
        "solution": "def checkString(self, s: str) -> bool:\n        for i, c in enumerate(s):\n            if i > 0 and s[i - 1] == 'b' and c == 'a':\n                return False\n        return True",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "one argument",
                    "short",
                    "string argument"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "easy",
                    "for loop",
                    "short"
                ]
            }
        ],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2125": {
        "problem_id": 2125,
        "description": "Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is an m x n 2D matrix. bank[i] represents the ith row, consisting of '0's and '1's. '0' means the cell is empty, while'1' means the cell has a security device.\nThere is one laser beam between any two security devices if both conditions are met:\n\t- The two devices are located on two different rows: r1 and r2, where r1 < r2.\n\t- For each row i where r1 < i < r2, there are no security devices in the ith row.\nLaser beams are independent, i.e., one beam does not interfere nor join with another.\nReturn the total number of laser beams in the bank.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfBeams(self, bank: List[str]) -> int:",
        "solution": "class Solution:\n    def numberOfBeams(self, bank):\n        ans, temp = 0, 0\n        for s in bank:\n            n = s.count('1')\n            if n == 0:\n                continue\n            ans += temp * n\n            temp = n\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "list argument",
                    "list of rules",
                    "one argument",
                    "spatial",
                    "story",
                    "string manipulation"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "List of rules to consider",
                    "matrix",
                    "string encoding"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "for loop",
                    "short"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2126": {
        "problem_id": 2126,
        "description": "You are given an integer mass, which represents the original mass of a planet. You are further given an integer array asteroids, where asteroids[i] is the mass of the ith asteroid.\nYou can arrange for the planet to collide with the asteroids in any arbitrary order. If the mass of the planet is greater than or equal to the mass of the asteroid, the asteroid is destroyed and the planet gains the mass of the asteroid. Otherwise, the planet is destroyed.\nReturn true if all asteroids can be destroyed. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def asteroidsDestroyed(self, mass: int, asteroids: List[int]) -> bool:",
        "solution": "def asteroidsDestroyed(self, mass: int, asteroids: List[int]) -> bool:\n        for a in sorted(asteroids):\n            if mass < a:\n                return False\n            mass += a\n        return True",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "condition",
                    "sorting",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "easy",
                    "for loop",
                    "short"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "output",
            "data_structure",
            "prediction",
            "problem_type"
        ]
    },
    "2127": {
        "problem_id": 2127,
        "description": "A company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seating any number of employees.\nThe employees are numbered from 0 to n - 1. Each employee has a favorite person and they will attend the meeting only if they can sit next to their favorite person at the table. The favorite person of an employee is not themself.\nGiven a 0-indexed integer array favorite, where favorite[i] denotes the favorite person of the ith employee, return the maximum number of employees that can be invited to the meeting.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumInvitations(self, favorite: List[int]) -> int:",
        "solution": "class Solution:\n    def maximumInvitations(self, favorite: List[int]) -> int:\n        n = len(favorite)\n        graph = [[] for _ in range(n)]\n        for i, x in enumerate(favorite): graph[x].append(i)\n        \n        def bfs(x, seen): \n            \n            ans = 0 \n            queue = deque([x])\n            while queue: \n                for _ in range(len(queue)): \n                    u = queue.popleft()\n                    for v in graph[u]: \n                        if v not in seen: \n                            seen.add(v)\n                            queue.append(v)\n                ans += 1\n            return ans \n        \n        ans = 0 \n        seen = [False]*n\n        for i, x in enumerate(favorite): \n            if favorite[x] == i and not seen[i]: \n                seen[i] = seen[x] = True \n                ans += bfs(i, {i, x}) + bfs(x, {i, x})\n                \n        dp = [0]*n\n        for i, x in enumerate(favorite): \n            if dp[i] == 0: \n                ii, val = i, 0\n                memo = {}\n                while ii not in memo: \n                    if dp[ii]: \n                        cycle = dp[ii]\n                        break\n                    memo[ii] = val\n                    val += 1\n                    ii = favorite[ii]\n                else: cycle = val - memo[ii]\n                for k in memo: dp[k] = cycle\n        return max(ans, max(dp))",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "business",
                    "int return",
                    "list argument",
                    "one argument",
                    "optimisation",
                    "short",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "additional function def",
                    "for loop",
                    "long",
                    "nested loop",
                    "while loop"
                ]
            }
        ],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "problem_theme",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2129": {
        "problem_id": 2129,
        "description": "You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:\n\t- If the length of the word is 1 or 2 letters, change all letters to lowercase.\n\t- Otherwise, change the first letter to uppercase and the remaining letters to lowercase.\nReturn the capitalized title.\n",
        "provided_code_snippet": "class Solution:\r\n    def capitalizeTitle(self, title: str) -> str:",
        "solution": "def capitalizeTitle(self, title: str) -> str:\n        ans = []\n        for s in title.split():\n            if len(s) < 3:\n                ans.append(s.lower())\n            else:\n                ans.append(s.capitalize())\n        return ' '.join(ans)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "list of rules",
                    "one argument",
                    "short",
                    "string argument",
                    "string manipulation",
                    "string return"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "List of rules to consider",
                    "speaking method name"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "for loop",
                    "short"
                ]
            }
        ],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2130": {
        "problem_id": 2130,
        "description": "In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) - 1.\n\t- For example, if n = 4, then node 0 is the twin of node 3, and node 1 is the twin of node 2. These are the only nodes with twins for n = 4.\nThe twin sum is defined as the sum of a node and its twin.\nGiven the head of a linked list with even length, return the maximum twin sum of the linked list.\n",
        "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\r\nclass Solution:\r\n    def pairSum(self, head: Optional[ListNode]) -> int:",
        "solution": "def pairSum(self, head: Optional[ListNode]) -> int:\n\tslow, fast = head, head\n\tmaxVal = 0\n\n\t# Get middle of linked list\n\twhile fast and fast.next:\n\t\tfast = fast.next.next\n\t\tslow = slow.next\n\n\t# Reverse second part of linked list\n\tcurr, prev = slow, None\n\n\twhile curr:       \n\t\tcurr.next, prev, curr = prev, curr, curr.next   \n\n\t# Get max sum of pairs\n\twhile prev:\n\t\tmaxVal = max(maxVal, head.val + prev.val)\n\t\tprev = prev.next\n\t\thead = head.next\n\n\treturn maxVal",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "data structure",
                    "definition",
                    "example",
                    "input late",
                    "int return",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "coded data type definition",
                    "complex sentences (where, if, which)",
                    "definitions in between",
                    "example",
                    "Given and Return",
                    "linked list"
                ]
            }
        ],
        "solution_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "long",
                    "math function",
                    "while loop"
                ]
            }
        ],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2131": {
        "problem_id": 2131,
        "description": "You are given an array of strings words. Each element of words consists of two lowercase English letters.\nCreate the longest possible palindrome by selecting some elements from words and concatenating them in any order. Each element can be selected at most once.\nReturn the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0.\nA palindrome is a string that reads the same forward and backward.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestPalindrome(self, words: List[str]) -> int:",
        "solution": "def longestPalindrome(self, words: List[str]) -> int:\n        pairs, sym, nonPaired = 0, 0, Counter()\n        for w in words:\n            if nonPaired[w[:: -1]] > 0:\n                pairs += 1\n                nonPaired[w[:: -1]] -= 1\n                sym -= 1 if w[0] == w[1] else 0\n            else:\n                nonPaired[w] += 1    \n                sym += 1 if w[0] == w[1] else 0\n        return pairs * 4 + (2 if sym > 0 else 0)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "condition",
                    "definition",
                    "definition after description",
                    "int return",
                    "list argument",
                    "one argument",
                    "short",
                    "string manipulation"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions at the end",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2132": {
        "problem_id": 2132,
        "description": "You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).\nYou are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:\n\t1. Cover all the empty cells.\n\t2. Do not cover any of the occupied cells.\n\t3. We can put as many stamps as we want.\n\t4. Stamps can overlap with each other.\n\t5. Stamps are not allowed to be rotated.\n\t6. Stamps must stay completely inside the grid.\nReturn true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def possibleToStamp(self, grid: List[List[int]], stampHeight: int, stampWidth: int) -> bool:",
        "solution": "class Solution:\n    def possibleToStamp(self, grid: List[List[int]], stampHeight: int, stampWidth: int) -> bool:\n        m = len(grid)\n        n = len(grid[0])\n        s = 0\n        for i in range(m):\n            for j in range(n):\n                s += grid[i][j]\n        if s == m*n:return True\n\n        if stampHeight > m or stampWidth > n:\n            return False\n            \n        mark = [[0 for i in range(n)] for j in range(m)]\n        psum = [[0 for i in range(n+1)] for j in range(m+1)]\n        for i in range(m):\n            for j in range(n):\n                psum[i+1][j+1] = grid[i][j] + psum[i][j+1]+psum[i+1][j] - psum[i][j]\n                possible = False\n                if i+1 >= stampHeight and j+1 >= stampWidth:\n                    if psum[i+1][j+1] - psum[i+1][j+1-stampWidth] - psum[i+1 -stampHeight][j+1] + psum[i+1 -stampHeight][j+1-stampWidth] == 0:\n                        possible = True\n                mark[i][j] = int(possible)\n        psum2 = [[0 for i in range(n+1)] for j in range(m+1)]\n        for i in range(m-1,-1,-1):\n            for j in range(n-1,-1,-1):\n                psum2[i][j] = mark[i][j] + psum2[i][j+1]+psum2[i+1][j] - psum2[i+1][j+1]\n                if grid[i][j] == 1:\n                    continue\n                possible = False\n                seen = psum2[i][j]\n                if i + stampHeight <= m:\n                    seen -= psum2[i+stampHeight][j]\n                if j + stampWidth <= n:\n                    seen -= psum2[i][j+stampWidth]\n                if  i + stampHeight <= m and j + stampWidth <= n:\n                    seen += psum2[i+stampHeight][j+stampWidth]\n                if seen < 1:return False\n\n\n        return True",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "bool return",
                    "list argument",
                    "list of rules",
                    "medium long",
                    "story",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    ">3 parameters",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "List of rules to consider",
                    "matrix"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2133": {
        "problem_id": 2133,
        "description": "An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).\nGiven an n x n integer matrix matrix, return true if the matrix is valid. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def checkValid(self, matrix: List[List[int]]) -> bool:",
        "solution": "def checkValid(self, matrix: List[List[int]]) -> bool:\n        n = len(matrix)\n        for row, col in zip(matrix, zip(*matrix)):\n            if len(set(row)) != n or len(set(col)) != n:\n                return False\n        return True",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "bool return",
                    "definition",
                    "short",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "matrix",
                    "starts with definitions",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction"
        ]
    },
    "2134": {
        "problem_id": 2134,
        "description": "A swap is defined as taking two distinct positions in an array and swapping the values in them.\nA circular array is defined as an array where we consider the first element and the last element to be adjacent.\nGiven a binary circular array nums, return the minimum number of swaps required to group all 1's present in the array together at any location.\n",
        "provided_code_snippet": "class Solution:\r\n    def minSwaps(self, nums: List[int]) -> int:",
        "solution": "def minSwaps(self, nums: List[int]) -> int:\n\tones, n = nums.count(1), len(nums)\n\tx, onesInWindow = 0, 0\n\tfor i in range(n * 2):\n\t\tif i >= ones and nums[i % n - ones]: x -= 1\n\t\tif nums[i % n] == 1: x += 1\n\t\tonesInWindow = max(x, onesInWindow)\n\treturn ones - onesInWindow",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "input late",
                    "int return",
                    "list argument",
                    "one argument",
                    "short",
                    "sorting"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "starts with definitions",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2135": {
        "problem_id": 2135,
        "description": "You are given two 0-indexed arrays of strings startWords and targetWords. Each string consists of lowercase English letters only.\nFor each string in targetWords, check if it is possible to choose a string from startWords and perform a conversion operation on it to be equal to that from targetWords.\nThe conversion operation is described in the following two steps:\n\t- Append any lowercase letter that is not present in the string to its end.\t\t\t- For example, if the string is \"abc\", the letters 'd', 'e', or 'y' can be added to it, but not 'a'. If 'd' is added, the resulting string will be \"abcd\".\n\t\t\n\t- Rearrange the letters of the new string in any arbitrary order.\t\t\t- For example, \"abcd\" can be rearranged to \"acbd\", \"bacd\", \"cbda\", and so on. Note that it can also be rearranged to \"abcd\" itself.\n\t\t\nReturn the number of strings in targetWords that can be obtained by performing the operations on any string of startWords.\nNote that you will only be verifying if the string in targetWords can be obtained from a string in startWords by performing the operations. The strings in startWords do not actually change during this process.\n",
        "provided_code_snippet": "class Solution:\r\n    def wordCount(self, startWords: List[str], targetWords: List[str]) -> int:",
        "solution": "class Solution:\n    def wordCount(self, startWords: List[str], targetWords: List[str]) -> int:\n        seen = set()\n        for word in startWords: \n            m = 0\n            for ch in word: m ^= 1 << ord(ch)-97\n            seen.add(m)\n            \n        ans = 0 \n        for word in targetWords: \n            m = 0 \n            for ch in word: m ^= 1 << ord(ch)-97\n            for ch in word: \n                if m ^ (1 << ord(ch)-97) in seen: \n                    ans += 1\n                    break \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "chain of operations",
                    "int return",
                    "list argument",
                    "list of rules",
                    "medium long",
                    "note",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "ambiguous language",
                    "array",
                    "example",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2136": {
        "problem_id": 2136,
        "description": "You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:\n\t- plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.\n\t- growTime[i] is the number of full days it takes the ith seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.\nFrom the beginning of day 0, you can plant the seeds in any order.\nReturn the earliest possible day where all seeds are blooming.\n",
        "provided_code_snippet": "class Solution:\r\n    def earliestFullBloom(self, plantTime: List[int], growTime: List[int]) -> int:",
        "solution": "class Solution:\n    def earliestFullBloom(self, plantTime: List[int], growTime: List[int]) -> int:\n        res = 0\n        for grow, plant in sorted(zip(growTime, plantTime)):\n            res = max(res, grow) + plant\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "gardening",
                    "int return",
                    "list argument",
                    "list of rules",
                    "medium long",
                    "optimisation",
                    "story",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "List of rules to consider",
                    "Sentence with >25 words",
                    "you have and return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "problem_theme",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2138": {
        "problem_id": 2138,
        "description": "A string s can be partitioned into groups of size k using the following procedure:\n\t- The first group consists of the first k characters of the string, the second group consists of the next k characters of the string, and so on. Each character can be a part of exactly one group.\n\t- For the last group, if the string does not have k characters remaining, a character fill is used to complete the group.\nNote that the partition is done so that after removing the fill character from the last group (if it exists) and concatenating all the groups in order, the resultant string should be s.\nGiven the string s, the size of each group k and the character fill, return a string array denoting the composition of every group s has been divided into, using the above procedure.\n",
        "provided_code_snippet": "class Solution:\r\n    def divideString(self, s: str, k: int, fill: str) -> List[str]:",
        "solution": "def divideString(self, s: str, k: int, fill: str) -> List[str]:\n        l=[]\n        if len(s)%k!=0:\n            s+=fill*(k-len(s)%k)\n        for i in range(0,len(s),k):\n            l.append(s[i:i+k])\n        return l",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "input late",
                    "list of rules",
                    "list return",
                    "medium long",
                    "string argument",
                    "three arguments",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2139": {
        "problem_id": 2139,
        "description": "You are playing a game with integers. You start with the integer 1 and you want to reach the integer target.\nIn one move, you can either:\n\t- Increment the current integer by one (i.e., x = x + 1).\n\t- Double the current integer (i.e., x = 2 * x).\nYou can use the increment operation any number of times, however, you can only use the double operation at most maxDoubles times.\nGiven the two integers target and maxDoubles, return the minimum number of moves needed to reach target starting with 1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minMoves(self, target: int, maxDoubles: int) -> int:",
        "solution": "class Solution:\n    def minMoves(self, target: int, maxDoubles: int) -> int:\n        moves = 0\n        while maxDoubles > 0 and target > 1:\n            if target % 2 == 1:\n                target -= 1\n            else:\n                target //= 2\n                maxDoubles -= 1\n            moves += 1\n        moves += target - 1\n        return moves",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "input late",
                    "int return",
                    "list of rules",
                    "medium long",
                    "optimisation",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "List of rules to consider"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2140": {
        "problem_id": 2140,
        "description": "You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].\nThe array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question i will earn you pointsi points but you will be unable to solve each of the next brainpoweri questions. If you skip question i, you get to make the decision on the next question.\n\t- For example, given questions = [[3, 2], [4, 3], [4, 4], [2, 5]]:\t\t\t- If question 0 is solved, you will earn 3 points but you will be unable to solve questions 1 and 2.\n\t\t- If instead, question 0 is skipped and question 1 is solved, you will earn 4 points but you will be unable to solve questions 2 and 3.\n\t\t\nReturn the maximum points you can earn for the exam.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostPoints(self, questions: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def mostPoints(self, q: List[List[int]]) -> int:\n        @cache\n        def dfs(i: int) -> int:\n            return 0 if i >= len(q) else max(dfs(i + 1), q[i][0] + dfs(i + 1 + q[i][1]))\n        return dfs(0)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "example",
                    "int return",
                    "list argument",
                    "one argument",
                    "optimisation",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    "complex sentences (where, if, which)",
                    "example",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2141": {
        "problem_id": 2141,
        "description": "You have n computers. You are given the integer n and a 0-indexed integer array batteries where the ith battery can run a computer for batteries[i] minutes. You are interested in running all n computers simultaneously using the given batteries.\nInitially, you can insert at most one battery into each computer. After that and at any integer time moment, you can remove a battery from a computer and insert another battery any number of times. The inserted battery can be a totally new battery or a battery from another computer. You may assume that the removing and inserting processes take no time.\nNote that the batteries cannot be recharged.\nReturn the maximum number of minutes you can run all the n computers simultaneously.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxRunTime(self, n: int, batteries: List[int]) -> int:",
        "solution": "class Solution:\n    def maxRunTime(self, n: int, batteries: List[int]) -> int:\n        batteries.sort()\n        extra = sum(batteries[:-n])\n        batteries = batteries[-n:]\n        \n        ans = prefix = 0 \n        for i, x in enumerate(batteries): \n            prefix += x \n            if i+1 < len(batteries) and batteries[i+1]*(i+1) - prefix > extra: return (prefix + extra) // (i+1)\n        return (prefix + extra) // n",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "list argument",
                    "medium long",
                    "optimisation",
                    "story",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2144": {
        "problem_id": 2144,
        "description": "A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.\nThe customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought.\n\t- For example, if there are 4 candies with costs 1, 2, 3, and 4, and the customer buys candies with costs 2 and 3, they can take the candy with cost 1 for free, but not the candy with cost 4.\nGiven a 0-indexed integer array cost, where cost[i] denotes the cost of the ith candy, return the minimum cost of buying all the candies.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumCost(self, cost: List[int]) -> int:",
        "solution": "class Solution:\n    minimumCost = lambda self, cost: sum(c for i, c in enumerate(sorted(cost, reverse=True)) if i % 3 != 2)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "business",
                    "example",
                    "int return",
                    "list argument",
                    "medium long",
                    "one argument",
                    "optimisation",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "example",
                    "Given and Return",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "problem_theme",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2145": {
        "problem_id": 2145,
        "description": "You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1). More formally, call the hidden sequence hidden, then we have that differences[i] = hidden[i + 1] - hidden[i].\nYou are further given two integers lower and upper that describe the inclusive range of values [lower, upper] that the hidden sequence can contain.\n\t- For example, given differences = [1, -3, 4], lower = 1, upper = 6, the hidden sequence is a sequence of length 4 whose elements are in between 1 and 6 (inclusive).\t\t\t- [3, 4, 1, 5] and [4, 5, 2, 6] are possible hidden sequences.\n\t\t- [5, 6, 3, 7] is not possible since it contains an element greater than 6.\n\t\t- [1, 2, 3, 4] is not possible since the differences are not correct.\n\t\t\nReturn the number of possible hidden sequences there are. If there are no possible sequences, return 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfArrays(self, differences: List[int], lower: int, upper: int) -> int:",
        "solution": "def numberOfArrays(self, differences: List[int], lower: int, upper: int) -> int:\n\tlo, up = lower, upper\n\tfor diff in differences:\n\t\tlo, up = max(lower, lo + diff), min(upper, up + diff)\n\t\tif lo > upper or up < lower: return 0\n\n\treturn up - lo + 1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "condition",
                    "definition",
                    "example",
                    "int return",
                    "list argument",
                    "medium long",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    ">3 parameters",
                    "array",
                    "example",
                    "formal clarification",
                    "Given and Return",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2146": {
        "problem_id": 2146,
        "description": "You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop. The integers in the grid represent the following:\n\t- 0 represents a wall that you cannot pass through.\n\t- 1 represents an empty cell that you can freely move to and from.\n\t- All other positive integers represent the price of an item in that cell. You may also freely move to and from these item cells.\nIt takes 1 step to travel between adjacent grid cells.\nYou are also given integer arrays pricing and start where pricing = [low, high] and start = [row, col] indicates that you start at the position (row, col) and are interested only in items with a price in the range of [low, high] (inclusive). You are further given an integer k.\nYou are interested in the positions of the k highest-ranked items whose prices are within the given price range. The rank is determined by the first of these criteria that is different:\n\t- Distance, defined as the length of the shortest path from the start (shorter distance has a higher rank).\n\t- Price (lower price has a higher rank, but it must be in the price range).\n\t- The row number (smaller row number has a higher rank).\n\t- The column number (smaller column number has a higher rank).\nReturn the k highest-ranked items within the price range sorted by their rank (highest to lowest). If there are fewer than k reachable items within the price range, return all of them.\n",
        "provided_code_snippet": "class Solution:\r\n    def highestRankedKItems(self, grid: List[List[int]], pricing: List[int], start: List[int], k: int) -> List[List[int]]:",
        "solution": "def highestRankedKItems(self, grid: List[List[int]], pricing: List[int], start: List[int], k: int) -> List[List[int]]:\n        R, C = map(len, (grid, grid[0]))\n        ans, (x, y), (low, high) = [], start, pricing\n        heap = [(0, grid[x][y], x, y)]\n        seen = {(x, y)}\n        while heap and len(ans) < k:\n            distance, price, r, c = heapq.heappop(heap)\n            if low <= price <= high:\n                ans.append([r, c])\n            for i, j in (r, c + 1), (r, c - 1), (r + 1, c), (r - 1, c):\n                if R > i >= 0 <= j < C and grid[i][j] > 0 and (i, j) not in seen: \n                    seen.add((i, j))\n                    heapq.heappush(heap, (distance + 1, grid[i][j], i, j))\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "condition",
                    "four arguments",
                    "list argument",
                    "list of rules",
                    "list return",
                    "long",
                    "predicted to be unsolved"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    ">3 parameters",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "List of rules to consider"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2147": {
        "problem_id": 2147,
        "description": "Along a long library corridor, there is a line of seats and decorative plants. You are given a 0-indexed string corridor of length n consisting of letters 'S' and 'P' where each 'S' represents a seat and each 'P' represents a plant.\nOne room divider has already been installed to the left of index 0, and another to the right of index n - 1. Additional room dividers can be installed. For each position between indices i - 1 and i (1 <= i <= n - 1), at most one divider can be installed.\nDivide the corridor into non-overlapping sections, where each section has exactly two seats with any number of plants. There may be multiple ways to perform the division. Two ways are different if there is a position with a room divider installed in the first way but not in the second way.\nReturn the number of ways to divide the corridor. Since the answer may be very large, return it modulo 109 + 7. If there is no way, return 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfWays(self, corridor: str) -> int:",
        "solution": "class Solution:\n    def numberOfWays(self, corridor):\n        seat, res, plant = 0, 1, 0\n        for i in corridor:\n            if i=='S':\n                seat += 1\n            else:\n                if seat == 2:\n                    plant += 1\n            if seat == 3:\n                res = res*(plant+1) % (10**9 + 7)\n                seat , plant = 1 , 0\n        if seat != 2:\n            return 0\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "math",
                    "medium long",
                    "one argument",
                    "output constraint",
                    "story",
                    "string argument"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "string encoding"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2148": {
        "problem_id": 2148,
        "description": "Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def countElements(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def countElements(self, nums: List[int]) -> int:\n        mn = min(nums)\n        mx = max(nums)\n        return sum(1 for i in nums if mn < i < mx)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2149": {
        "problem_id": 2149,
        "description": "You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.\nYou should return the array of nums such that the the array follows the given conditions:\n\t1. Every consecutive pair of integers have opposite signs.\n\t2. For all integers with the same sign, the order in which they were present in nums is preserved.\n\t3. The rearranged array begins with a positive integer.\nReturn the modified array after rearranging the elements to satisfy the aforementioned conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def rearrangeArray(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def rearrangeArray(self, nums: List[int]) -> List[int]:\n        v1, v2, ans = [], [], []\n        \n        for num in nums:\n            if num > 0:\n                v1.append(num)\n            else:\n                v2.append(num)\n        \n        ind1, ind2 = 0, 0\n        \n        while ind2 < len(nums) // 2:\n            ans.append(v1[ind1])\n            ind1 += 1\n            ans.append(v2[ind2])\n            ind2 += 1\n        \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2150": {
        "problem_id": 2150,
        "description": "You are given an integer array nums. A number x is lonely when it appears only once, and no adjacent numbers (i.e. x + 1 and x - 1) appear in the array.\nReturn all lonely numbers in nums. You may return the answer in any order.\n",
        "provided_code_snippet": "class Solution:\r\n    def findLonely(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def findLonely(self, nums: List[int]) -> List[int]:\n        m = Counter(nums)\n        return [n for n in nums if m[n] == 1 and m[n - 1] + m[n + 1] == 0]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "list argument",
                    "list return",
                    "math",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2151": {
        "problem_id": 2151,
        "description": "There are two types of persons:\n\t- The good person: The person who always tells the truth.\n\t- The bad person: The person who might tell the truth and might lie.\nYou are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other. More specifically, statements[i][j] could be one of the following:\n\t- 0 which represents a statement made by person i that person j is a bad person.\n\t- 1 which represents a statement made by person i that person j is a good person.\n\t- 2 represents that no statement is made by person i about person j.\nAdditionally, no person ever makes a statement about themselves. Formally, we have that statements[i][i] = 2 for all 0 <= i < n.\nReturn the maximum number of people who can be good based on the statements made by the n people.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumGood(self, statements: List[List[int]]) -> int:",
        "solution": "class Solution:        \n    def maximumGood(self, statements: List[List[int]]) -> int:\n        \n        n = len(statements)\n        res = 0\n        \n        def checkGood(person, mask):\n            if (mask>>person) & 1:\n                return True\n            return False\n        \n        def validateStatement(mask):\n            for i in range(n):\n                if checkGood(i, mask):\n                    for j in range(n):\n                        statement = statements[i][j]\n                        \n                        if (statement==0 and checkGood(j, mask)) or (statement==1 and not checkGood(j, mask)):\n                            return False\n            return True\n        \n        for i in range(1,1< int:",
        "solution": "def findFinalValue(self, nums: List[int], original: int) -> int:\n        nums = set(nums)\n        while original in nums:\n            original *= 2\n        return original",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2155": {
        "problem_id": 2155,
        "description": "You are given a 0-indexed binary array nums of length n. nums can be divided at index i (where 0 <= i <= n) into two arrays (possibly empty) numsleft and numsright:\n\t- numsleft has all the elements of nums between index 0 and i - 1 (inclusive), while numsright has all the elements of nums between index i and n - 1 (inclusive).\n\t- If i == 0, numsleft is empty, while numsright has all the elements of nums.\n\t- If i == n, numsleft has all the elements of nums, while numsright is empty.\nThe division score of an index i is the sum of the number of 0's in numsleft and the number of 1's in numsright.\nReturn all distinct indices that have the highest possible division score. You may return the answer in any order.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxScoreIndices(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def maxScoreIndices(self, nums: List[int]) -> List[int]:\n        cnt_1 = 0\n        for num in nums:\n            if num == 1: cnt_1 += 1\n        \n        cnt_0, max_division = 0, cnt_1\n        d = collections.defaultdict(list)\n        d[cnt_1].append(0)\n        for i, num in enumerate(nums):\n            cnt_0 += int(num == 0)\n            cnt_1 -= int(num == 1)\n            d[cnt_0 + cnt_1].append(i + 1)\n            max_division = max(max_division, cnt_0 + cnt_1)\n        return d[max_division]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2156": {
        "problem_id": 2156,
        "description": "The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function:\n\t- hash(s, p, m) = (val(s[0]) * p0 + val(s[1]) * p1 + ... + val(s[k-1]) * pk-1) mod m.\nWhere val(s[i]) represents the index of s[i] in the alphabet from val('a') = 1 to val('z') = 26.\nYou are given a string s and the integers power, modulo, k, and hashValue. Return sub, the first substring of s of length k such that hash(sub, power, modulo) == hashValue.\nThe test cases will be generated such that an answer always exists.\nA substring is a contiguous non-empty sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def subStrHash(self, s: str, power: int, modulo: int, k: int, hashValue: int) -> str:",
        "solution": "class Solution:\n    def subStrHash(self, s: str, power: int, modulo: int, k: int, hashValue: int) -> str:\n        \n        n = len(s)\n\n        # lambda for finding the value of a character\n        val = lambda v: ord(v) - ord(\"a\") + 1\n\n        # preprocess the powers w/ modulo to prevent overflow\n        powers = [pow(power, i, modulo) for i in range(k)]\n        \n        # initalize our index for our substring and hash value\n        idx = n-k\n        hash_val = 0\n\n        # preprocess the hash value from the n-k to n-1\n        for i in range(k):\n            hash_val += val(s[n-k+i]) * powers[i]\n\n        for i in range(n-k-1, -1, -1):\n            # the rolling hash part\n            # update the hash value by subtracting the hash with the rightmost value times the highest power\n            # then add the value of the incoming character * p1 to ensure the hash value gets updated\n            hash_val = ((hash_val - val(s[i+k]) * powers[k-1]) * power + val(s[i])) % modulo\n                        # removing last char in window         # adding incoming char\n\n            # since we're reversing, the last visited instance of this if statement will be the first instance\n            if hash_val == hashValue:\n                idx = i\n        \n        return s[idx:idx+k]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2157": {
        "problem_id": 2157,
        "description": "You are given a 0-indexed array of strings words. Each string consists of lowercase English letters only. No letter occurs more than once in any string of words.\nTwo strings s1 and s2 are said to be connected if the set of letters of s2 can be obtained from the set of letters of s1 by any one of the following operations:\n\t- Adding exactly one letter to the set of the letters of s1.\n\t- Deleting exactly one letter from the set of the letters of s1.\n\t- Replacing exactly one letter from the set of the letters of s1 with any letter, including itself.\nThe array words can be divided into one or more non-intersecting groups. A string belongs to a group if any one of the following is true:\n\t- It is connected to at least one other string of the group.\n\t- It is the only string present in the group.\nNote that the strings in words should be grouped in such a manner that a string belonging to a group cannot be connected to a string present in any other group. It can be proved that such an arrangement is always unique.\nReturn an array ans of size 2 where:\n\t- ans[0] is the maximum number of groups words can be divided into, and\n\t- ans[1] is the size of the largest group.\n",
        "provided_code_snippet": "class Solution:\r\n    def groupStrings(self, words: List[str]) -> List[int]:",
        "solution": "class UnionFind: \n    def __init__(self, n): \n        self.parent = list(range(n))\n        self.rank = [1] * n \n        \n    def find(self, p): \n        if p != self.parent[p]: \n            self.parent[p] = self.find(self.parent[p])\n        return self.parent[p]\n    \n    def union(self, p, q): \n        prt, qrt = self.find(p), self.find(q)\n        if prt == qrt: return False \n        if self.rank[prt] > self.rank[qrt]: prt, qrt = qrt, prt\n        self.parent[prt] = self.parent[qrt]\n        self.rank[qrt] += self.rank[prt]\n        return True \n\n\nclass Solution:\n    def groupStrings(self, words: List[str]) -> List[int]:\n        n = len(words)\n        uf = UnionFind(n)\n        seen = {}\n        for i, word in enumerate(words): \n            m = reduce(or_, (1< int:",
        "solution": "class Solution:\n    def minimumSum(self, num: int) -> int:\n        num = sorted(str(num),reverse=True)\n        n = len(num)    \n        res = 0\n        even_iteration = False\n        position = 0\n        for i in range(n):\n            res += int(num[i])*(10**position)\n            if even_iteration:\n                position += 1\n                even_iteration = False\n            else:\n                even_iteration = True\n        return res",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2161": {
        "problem_id": 2161,
        "description": "You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:\n\t- Every element less than pivot appears before every element greater than pivot.\n\t- Every element equal to pivot appears in between the elements less than and greater than pivot.\n\t- The relative order of the elements less than pivot and the elements greater than pivot is maintained.\t\t\t- More formally, consider every pi, pj where pi is the new position of the ith element and pj is the new position of the jth element. For elements less than pivot, if i < j and nums[i] < pivot and nums[j] < pivot, then pi < pj. Similarly for elements greater than pivot, if i < j and nums[i] > pivot and nums[j] > pivot, then pi < pj.\n\t\t\nReturn nums after the rearrangement.\n",
        "provided_code_snippet": "class Solution:\r\n    def pivotArray(self, nums: List[int], pivot: int) -> List[int]:",
        "solution": "class Solution:\n    def pivotArray(self, nums: List[int], pivot: int) -> List[int]:\n        lst,val,tmp=[],[],[]\n        for i in nums:\n            if i==pivot:val.append(i)\n            elif i int:",
        "solution": "class Solution:\n    def minCostSetTime(self, startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int:\n        def count_cost(minutes, seconds): # Calculates cost for certain configuration of minutes and seconds\n            time = f'{minutes // 10}{minutes % 10}{seconds // 10}{seconds % 10}' # mm:ss\n            time = time.lstrip('0') # since 0's are prepended we remove the 0's to the left to minimize cost\n            t = [int(i) for i in time]\n            current = startAt\n            cost = 0\n            for i in t:\n                if i != current:\n                    current = i\n                    cost += moveCost\n                cost += pushCost\n            return cost\n        ans = float('inf')\n        for m in range(100): # Check which [mm:ss] configuration works out\n            for s in range(100):\n                if m * 60 + s == targetSeconds: \n                    ans = min(ans, count_cost(m, s))\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2163": {
        "problem_id": 2163,
        "description": "You are given a 0-indexed integer array nums consisting of 3 * n elements.\nYou are allowed to remove any subsequence of elements of size exactly n from nums. The remaining 2 * n elements will be divided into two equal parts:\n\t- The first n elements belonging to the first part and their sum is sumfirst.\n\t- The next n elements belonging to the second part and their sum is sumsecond.\nThe difference in sums of the two parts is denoted as sumfirst - sumsecond.\n\t- For example, if sumfirst = 3 and sumsecond = 2, their difference is 1.\n\t- Similarly, if sumfirst = 2 and sumsecond = 3, their difference is -1.\nReturn the minimum difference possible between the sums of the two parts after the removal of n elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumDifference(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumDifference(self, nums: List[int]) -> int:\n        n = len(nums) // 3\n\n        # calculate max_sum using min_heap for second part\n        min_heap = nums[(2 * n) :]\n        heapq.heapify(min_heap)\n\n        max_sum = [0] * (n + 2)\n        max_sum[n + 1] = sum(min_heap)\n        for i in range((2 * n) - 1, n - 1, -1):\n            # push current\n            heapq.heappush(min_heap, nums[i])\n            # popout minimum from heap\n            val = heapq.heappop(min_heap)\n            # max_sum for this partition\n            max_sum[i - n + 1] = max_sum[i - n + 2] - val + nums[i]\n\n\n        # calculate min_sum using max_heap for first part\n        max_heap = [-x for x in nums[:n]]\n        heapq.heapify(max_heap)\n\n        min_sum = [0] * (n + 2)\n        min_sum[0] = -sum(max_heap)\n        for i in range(n, (2 * n)):\n            # push current\n            heapq.heappush(max_heap, -nums[i])\n            # popout maximum from heap\n            val = -heapq.heappop(max_heap)\n            # min_sum for this partition\n            min_sum[i - n + 1] = min_sum[i - n] - val + nums[i]\n\n\n        # find min difference bw second part (max_sum) and first part (min_sum)\n        ans = math.inf\n        for i in range(0, n + 1):\n            print(i, min_sum[i], max_sum[i])\n            ans = min((min_sum[i] - max_sum[i + 1]), ans)\n\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2164": {
        "problem_id": 2164,
        "description": "You are given a 0-indexed integer array nums. Rearrange the values of nums according to the following rules:\n\t- Sort the values at odd indices of nums in non-increasing order.\t\t\t- For example, if nums = [4,1,2,3] before this step, it becomes [4,3,2,1] after. The values at odd indices 1 and 3 are sorted in non-increasing order.\n\t\t\n\t- Sort the values at even indices of nums in non-decreasing order.\t\t\t- For example, if nums = [4,1,2,3] before this step, it becomes [2,1,4,3] after. The values at even indices 0 and 2 are sorted in non-decreasing order.\n\t\t\nReturn the array formed after rearranging the values of nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def sortEvenOdd(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def sortEvenOdd(self, nums: List[int]) -> List[int]:\n       nums[0::2]=sorted(nums[0::2])\n       nums[1::2]=sorted(nums[1::2],reverse=True)\n       return nums",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2165": {
        "problem_id": 2165,
        "description": "You are given an integer num. Rearrange the digits of num such that its value is minimized and it does not contain any leading zeros.\nReturn the rearranged number with minimal value.\nNote that the sign of the number does not change after rearranging the digits.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestNumber(self, num: int) -> int:",
        "solution": "class Solution(object):\n    def smallestNumber(self, num):\n\n        if num == 0:\n            return 0\n        \n        isNegative, nums, countZero, s = False, [], 0, str(num)\n        \n        if  num < 0:\n            isNegative = True\n            s = s[1:]\n        \n        for i in range(len(s)):\n            if s[i] != '0':\n                nums.append(s[i])\n            else:\n                countZero += 1\n\n        nums.sort(reverse=isNegative)\n        newN = ''.join(nums)\n\n        if isNegative:\n            return int('-' + newN + '0' * countZero)\n\n        return int(newN[0] + '0' * countZero + newN[1:])",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2167": {
        "problem_id": 2167,
        "description": "You are given a 0-indexed binary string s which represents a sequence of train cars. s[i] = '0' denotes that the ith car does not contain illegal goods and s[i] = '1' denotes that the ith car does contain illegal goods.\nAs the train conductor, you would like to get rid of all the cars containing illegal goods. You can do any of the following three operations any number of times:\n\t1. Remove a train car from the left end (i.e., remove s[0]) which takes 1 unit of time.\n\t2. Remove a train car from the right end (i.e., remove s[s.length - 1]) which takes 1 unit of time.\n\t3. Remove a train car from anywhere in the sequence which takes 2 units of time.\nReturn the minimum time to remove all the cars containing illegal goods.\nNote that an empty sequence of cars is considered to have no cars containing illegal goods.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTime(self, s: str) -> int:",
        "solution": "class Solution:\n    def minimumTime(self, s: str) -> int:\n        length, start, res = len(s), 0, len(s)\n        for i, c in enumerate(s):\n            start = min(start + (c == \"1\") * 2, i + 1)\n            res = min(res, start + length - 1 - i)\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2169": {
        "problem_id": 2169,
        "description": "You are given two non-negative integers num1 and num2.\nIn one operation, if num1 >= num2, you must subtract num2 from num1, otherwise subtract num1 from num2.\n\t- For example, if num1 = 5 and num2 = 4, subtract num2 from num1, thus obtaining num1 = 1 and num2 = 4. However, if num1 = 4 and num2 = 5, after one operation, num1 = 4 and num2 = 1.\nReturn the number of operations required to make either num1 = 0 or num2 = 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def countOperations(self, num1: int, num2: int) -> int:",
        "solution": "class Solution:\n    def countOperations(self, num1: int, num2: int) -> int:\n        count = 0\n        while num1 != 0 and num2 != 0:\n            if num1 >= num2:\n                num1 -= num2\n            else:\n                num2 -= num1\n            count +=1\n        return count",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "condition",
                    "example",
                    "int return",
                    "math",
                    "short",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "example",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2170": {
        "problem_id": 2170,
        "description": "You are given a 0-indexed array nums consisting of n positive integers.\nThe array nums is called alternating if:\n\t- nums[i - 2] == nums[i], where 2 <= i <= n - 1.\n\t- nums[i - 1] != nums[i], where 1 <= i <= n - 1.\nIn one operation, you can choose an index i and change nums[i] into any positive integer.\nReturn the minimum number of operations required to make the array alternating.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumOperations(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumOperations(self, nums: List[int]) -> int:\n        pad = lambda x: x + [(None, 0)]*(2-len(x))\n        even = pad(Counter(nums[::2]).most_common(2))\n        odd = pad(Counter(nums[1::2]).most_common(2))\n        return len(nums) - (max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]) if even[0][0] == odd[0][0] else even[0][1] + odd[0][1])",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2171": {
        "problem_id": 2171,
        "description": "You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.\nRemove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean has been removed from a bag, you are not allowed to return it to any of the bags.\nReturn the minimum number of magic beans that you have to remove.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumRemoval(self, beans: List[int]) -> int:",
        "solution": "def minimumRemoval(self, beans: List[int]) -> int:\n        mx, n = 0, len(beans)\n        for i, bean in enumerate(sorted(beans)):\n            mx = max(mx, bean * (n - i))\n        return sum(beans) - mx",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2172": {
        "problem_id": 2172,
        "description": "You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n. There are numSlots slots numbered from 1 to numSlots.\nYou have to place all n integers into the slots such that each slot contains at most two numbers. The AND sum of a given placement is the sum of the bitwise AND of every number with its respective slot number.\n\t- For example, the AND sum of placing the numbers [1, 3] into slot 1 and [4, 6] into slot 2 is equal to (1 AND 1) + (3 AND 1) + (4 AND 2) + (6 AND 2) = 1 + 1 + 0 + 2 = 4.\nReturn the maximum possible AND sum of nums given numSlots slots.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumANDSum(self, nums: List[int], numSlots: int) -> int:",
        "solution": "class Solution:\n    def maximumANDSum(self, nums: List[int], numSlots: int) -> int:\n        \n        @cache\n        def fn(k, m): \n            \n            if k == len(nums): return 0 \n            ans = 0 \n            for i in range(numSlots): \n                if m & 1<<2*i == 0 or m & 1<<2*i+1 == 0: \n                    if m & 1<<2*i == 0: mm = m ^ 1<<2*i\n                    else: mm = m ^ 1<<2*i+1\n                    ans = max(ans, (nums[k] & i+1) + fn(k+1, mm))\n            return ans \n        \n        return fn(0, 0)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2176": {
        "problem_id": 2176,
        "description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) where 0 <= i < j < n, such that nums[i] == nums[j] and (i * j) is divisible by k.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPairs(self, nums: List[int], k: int) -> int:",
        "solution": "def countPairs(self, nums: List[int], k: int) -> int:\n        cnt, d = 0, defaultdict(list)\n        for i, n in enumerate(nums):\n            d[n].append(i)\n        for indices in d.values():    \n            for i, a in enumerate(indices):\n                for b in indices[: i]:\n                    if a * b % k == 0:\n                        cnt += 1\n        return cnt",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "list argument",
                    "math",
                    "short",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "Sentence with >25 words",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2177": {
        "problem_id": 2177,
        "description": "Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumOfThree(self, num: int) -> List[int]:",
        "solution": "def sumOfThree(self, num: int) -> List[int]:\n        if num % 3 == 0:\n            num //= 3\n            return [num - 1, num, num + 1]\n        return []",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2178": {
        "problem_id": 2178,
        "description": "You are given an integer finalSum. Split it into a sum of a maximum number of unique positive even integers.\n\t- For example, given finalSum = 12, the following splits are valid (unique positive even integers summing up to finalSum): (12), (2 + 10), (2 + 4 + 6), and (4 + 8). Among them, (2 + 4 + 6) contains the maximum number of integers. Note that finalSum cannot be split into (2 + 2 + 4 + 4) as all the numbers should be unique.\nReturn a list of integers that represent a valid split containing a maximum number of integers. If no valid split exists for finalSum, return an empty list. You may return the integers in any order.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumEvenSplit(self, finalSum: int) -> List[int]:",
        "solution": "def maximumEvenSplit(self, f: int) -> List[int]:\n        ans, i = [], 2\n        if f % 2 == 0:\n            while i <= f:\n                ans.append(i)\n                f -= i\n                i += 2\n            ans[-1] += f\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2179": {
        "problem_id": 2179,
        "description": "You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].\nA good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if we consider pos1v as the index of the value v in nums1 and pos2v as the index of the value v in nums2, then a good triplet will be a set (x, y, z) where 0 <= x, y, z <= n - 1, such that pos1x < pos1y < pos1z and pos2x < pos2y < pos2z.\nReturn the total number of good triplets.\n",
        "provided_code_snippet": "class Solution:\r\n    def goodTriplets(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def goodTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        n = len(nums1)\n        hashmap2 = {}\n        for i in range(n):\n            hashmap2[nums2[i]] = i\n        indices = []\n        for num in nums1:\n            indices.append(hashmap2[num])\n        from sortedcontainers import SortedList\n        left, right = SortedList(), SortedList()\n        leftCount, rightCount = [], []\n        for i in range(n):\n            leftCount.append(left.bisect_left(indices[i]))\n            left.add(indices[i])\n        for i in range(n - 1, -1, -1):\n            rightCount.append(len(right) - right.bisect_right(indices[i]))\n            right.add(indices[i])\n        count = 0\n        for i in range(n):\n            count += leftCount[i] * rightCount[n - 1 - i]\n        return count",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2180": {
        "problem_id": 2180,
        "description": "Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.\nThe digit sum of a positive integer is the sum of all its digits.\n",
        "provided_code_snippet": "class Solution:\r\n    def countEven(self, num: int) -> int:",
        "solution": "def countEven(self, num: int) -> int:\n    return (num - 1) // 2 if sum(map(int, str(num))) % 2 else num // 2",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "int return",
                    "math",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "definitions at the end",
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2181": {
        "problem_id": 2181,
        "description": "You are given the head of a linked list, which contains a series of integers separated by 0's. The beginning and end of the linked list will have Node.val == 0.\nFor every two consecutive 0's, merge all the nodes lying in between them into a single node whose value is the sum of all the merged nodes. The modified list should not contain any 0's.\nReturn the head of the modified linked list.\n",
        "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\r\nclass Solution:\r\n    def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:",
        "solution": "class Solution:\n    def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:\n        # BASE CASE -> if we have a single zero, simply return null\n        if not head.next:\n            return None\n        \n        # fetch sum from current 0 to next 0\n        ptr = head.next\n        sum = 0\n        while ptr.val != 0:\n            sum += ptr.val\n            ptr = ptr.next\n        \n        # assign sum on the first node between nodes having value 0\n        head.next.val = sum\n        \n        # call and get the answer and connect the answer to next of head->next\n        head.next.next = self.mergeNodes(ptr)\n        \n        # return head->next..=> new head\n        return head.next",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2182": {
        "problem_id": 2182,
        "description": "You are given a string s and an integer repeatLimit. Construct a new string repeatLimitedString using the characters of s such that no letter appears more than repeatLimit times in a row. You do not have to use all characters from s.\nReturn the lexicographically largest repeatLimitedString possible.\nA string a is lexicographically larger than a string b if in the first position where a and b differ, string a has a letter that appears later in the alphabet than the corresponding letter in b. If the first min(a.length, b.length) characters do not differ, then the longer string is the lexicographically larger one.\n",
        "provided_code_snippet": "class Solution:\r\n    def repeatLimitedString(self, s: str, repeatLimit: int) -> str:",
        "solution": "class Solution:\n    def repeatLimitedString(self, s: str, repeatLimit: int) -> str:\n        pq = [(-ord(k), v) for k, v in Counter(s).items()] \n        heapify(pq)\n        ans = []\n        while pq: \n            k, v = heappop(pq)\n            if ans and ans[-1] == k: \n                if not pq: break \n                kk, vv = heappop(pq)\n                ans.append(kk)\n                if vv-1: heappush(pq, (kk, vv-1))\n                heappush(pq, (k, v))\n            else: \n                m = min(v, repeatLimit)\n                ans.extend([k]*m)\n                if v-m: heappush(pq, (k, v-m))\n        return \"\".join(chr(-x) for x in ans)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2183": {
        "problem_id": 2183,
        "description": "Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that:\n\t- 0 <= i < j <= n - 1 and\n\t- nums[i] * nums[j] is divisible by k.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPairs(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        counter = Counter() #hashmap dicitionary of python\n        ans = 0\n        n = len(nums)\n        \n        for i in range(n):\n            x = math.gcd(k,nums[i]) #ex: 10 = k and we have nums[i] as 12 so gcd will be 2\n            want = k // x #what do we want from upper ex: we need 5\n            for num in counter:\n                if num % want == 0: #so if we find a number that is divisible by 5 then we can multiply it to 12 and make it a factor of 10 for ex we find 20 so it will be 240 which is divisible by 10 hence we will add it to answer\n                    ans += counter[num] #we are adding the freq as we can find no of numbers that have same factor\n            counter[x] += 1 #here we are increasing the freq of 2 so that if we find 5 next time we can add these to the answer\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2185": {
        "problem_id": 2185,
        "description": "You are given an array of strings words and a string pref.\nReturn the number of strings in words that contain pref as a prefix.\nA prefix of a string s is any leading contiguous substring of s.\n",
        "provided_code_snippet": "class Solution:\r\n    def prefixCount(self, words: List[str], pref: str) -> int:",
        "solution": "def prefixCount(self, words: List[str], pref: str) -> int:\n\treturn sum([word.startswith(pref) for word in words])",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "int return",
                    "list argument",
                    "short",
                    "string argument",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions at the end",
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2186": {
        "problem_id": 2186,
        "description": "You are given two strings s and t. In one step, you can append any character to either s or t.\nReturn the minimum number of steps to make s and t anagrams of each other.\nAn anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n",
        "provided_code_snippet": "class Solution:\r\n    def minSteps(self, s: str, t: str) -> int:",
        "solution": "class Solution:\n    def minSteps(self, s: str, t: str) -> int:\n        cs, ct = Counter(s), Counter(t)\n        return sum(cnt for ch, cnt in ((cs - ct) + (ct - cs)).items())",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "int return",
                    "short",
                    "string argument",
                    "string manipulation",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "definitions at the end",
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2187": {
        "problem_id": 2187,
        "description": "You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip.\nEach bus can make multiple trips successively; that is, the next trip can start immediately after completing the current trip. Also, each bus operates independently; that is, the trips of one bus do not influence the trips of any other bus.\nYou are also given an integer totalTrips, which denotes the number of trips all buses should make in total. Return the minimum time required for all buses to complete at least totalTrips trips.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTime(self, time: List[int], totalTrips: int) -> int:",
        "solution": "def minimumTime(self, time: List[int], totalTrips: int) -> int:\n\treturn bisect_left(range(1, 10**14), totalTrips, key= lambda x: sum(x // t for t in time)) + 1",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "list argument",
                    "medium long",
                    "optimisation",
                    "story",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "speaking method name"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2188": {
        "problem_id": 2188,
        "description": "You are given a 0-indexed 2D integer array tires where tires[i] = [fi, ri] indicates that the ith tire can finish its xth successive lap in fi * ri(x-1) seconds.\n\t- For example, if fi = 3 and ri = 2, then the tire would finish its 1st lap in 3 seconds, its 2nd lap in 3 * 2 = 6 seconds, its 3rd lap in 3 * 22 = 12 seconds, etc.\nYou are also given an integer changeTime and an integer numLaps.\nThe race consists of numLaps laps and you may start the race with any tire. You have an unlimited supply of each tire and after every lap, you may change to any given tire (including the current tire type) if you wait changeTime seconds.\nReturn the minimum time to finish the race.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumFinishTime(self, tires: List[List[int]], changeTime: int, numLaps: int) -> int:",
        "solution": "class Solution:\n    def minimumFinishTime(self, tires: List[List[int]], changeTime: int, numLaps: int) -> int:\n        tires.sort()\n        newTires = []\n        minTime = [changeTime*(i-1) + tires[0][0]*i for i in range(numLaps+1)]\n        minTime[0] = 0\n        maxi = 0\n        for f,r in tires:\n            if not newTires or f>newTires[-1][0] and rt:\n                        minTime[i]=t\n                        maxi = max(i,maxi)\n        for lap in range(numLaps+1):\n            for run in range(min(lap,maxi+1)):\n                minTime[lap] = min(minTime[lap],minTime[lap-run]+changeTime+minTime[run])\n        return minTime[numLaps]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2190": {
        "problem_id": 2190,
        "description": "You are given a 0-indexed integer array nums. You are also given an integer key, which is present in nums.\nFor every unique integer target in nums, count the number of times target immediately follows an occurrence of key in nums. In other words, count the number of indices i such that:\n\t- 0 <= i <= nums.length - 2,\n\t- nums[i] == key and,\n\t- nums[i + 1] == target.\nReturn the target with the maximum count. The test cases will be generated such that the target with maximum count is unique.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostFrequent(self, nums: List[int], key: int) -> int:",
        "solution": "def mostFrequent(self, nums: List[int], key: int) -> int:\n        c = Counter()\n        for i, n in enumerate(nums):\n            if n == key and i + 1 < len(nums):\n                c[nums[i + 1]] += 1\n        return c.most_common(1)[0][0]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "further clarification",
                    "int return",
                    "list argument",
                    "list of rules",
                    "math",
                    "pointless additional info",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "formal clarification",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2191": {
        "problem_id": 2191,
        "description": "You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.\nThe mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for all 0 <= i <= 9.\nYou are also given another integer array nums. Return the array nums sorted in non-decreasing order based on the mapped values of its elements.\nNotes:\n\t- Elements with the same mapped values should appear in the same relative order as in the input.\n\t- The elements of nums should only be sorted based on their mapped values and not be replaced by them.\n",
        "provided_code_snippet": "class Solution:\r\n    def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:\n        # List to hold tuples of the mapped value and its original index\n        mapped_with_index = []\n      \n        # Iterate over the input numbers' list\n        for index, num in enumerate(nums):\n            # If the number is 0, get the mapped value for 0, else start with 0\n            mapped_num = mapping[0] if num == 0 else 0\n            power_of_ten = 1  # To keep track of the decimal place\n          \n            # Decompose the number into digits and map using the provided mapping\n            while num:\n                num, digit = divmod(num, 10)\n                # Map the digit, adjust decimal place and add to the mapped number\n                mapped_num = mapping[digit] * power_of_ten + mapped_num\n                power_of_ten *= 10  # Increase the decimal place\n          \n            # Append the tuple of mapped number and original index to the list\n            mapped_with_index.append((mapped_num, index))\n      \n        # Sort the list according to the mapped numbers, stable for identical values\n        mapped_with_index.sort()\n      \n        # Reconstruct the sorted list using the original indices\n        return [nums[i] for _, i in mapped_with_index]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "list argument",
                    "list of rules",
                    "list return",
                    "medium long",
                    "note",
                    "output constraint",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "non-decreasing instead of increasing",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2192": {
        "problem_id": 2192,
        "description": "You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusive).\nYou are also given a 2D integer array edges, where edges[i] = [fromi, toi] denotes that there is a unidirectional edge from fromi to toi in the graph.\nReturn a list answer, where answer[i] is the list of ancestors of the ith node, sorted in ascending order.\nA node u is an ancestor of another node v if u can reach v via a set of edges.\n",
        "provided_code_snippet": "class Solution:\r\n    def getAncestors(self, n: int, edges: List[List[int]]) -> List[List[int]]:",
        "solution": "def getAncestors(self, n: int, edges: List[List[int]]) -> List[List[int]]:\n         \n        # Build graph, compute in degree and\n        # get direct parent for each node.   \n        ans = [set() for _ in range(n)]\n        in_degree = [0] * n\n        parent_to_kids = defaultdict(set)\n        for parent, kid in edges:\n            ans[kid].add(parent)\n            parent_to_kids[parent].add(kid)\n            in_degree[kid] += 1\n            \n        # Use Topological sort to get direct parent's all ancestors    \n        dq = deque([u for u, degree in enumerate(in_degree) if degree == 0])\n        while dq:\n            parent = dq.popleft()\n            for kid in parent_to_kids[parent]:\n                ans[kid].update(ans[parent])\n                in_degree[kid] -= 1\n                if in_degree[kid] == 0:\n                    dq.append(kid)\n        return [sorted(s) for s in  ans]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2193": {
        "problem_id": 2193,
        "description": "You are given a string s consisting only of lowercase English letters.\nIn one move, you can select any two adjacent characters of s and swap them.\nReturn the minimum number of moves needed to make s a palindrome.\nNote that the input will be generated such that s can always be converted to a palindrome.\n",
        "provided_code_snippet": "class Solution:\r\n    def minMovesToMakePalindrome(self, s: str) -> int:",
        "solution": "class Solution:\n    def minMovesToMakePalindrome(self, s: str) -> int:\n        ans = 0 \n        while len(s) > 2: \n            lo = s.find(s[-1])\n            hi = s.rfind(s[0])\n            if lo < len(s)-hi-1: \n                ans += lo \n                s = s[:lo] + s[lo+1:-1]\n            else: \n                ans += len(s)-hi-1\n                s = s[1:hi] + s[hi+1:]\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2194": {
        "problem_id": 2194,
        "description": "A cell (r, c) of an excel sheet is represented as a string \"\" where:\n\t-  denotes the column number c of the cell. It is represented by alphabetical letters.\t\t\t- For example, the 1st column is denoted by 'A', the 2nd by 'B', the 3rd by 'C', and so on.\n\t\t\n\t-  is the row number r of the cell. The rth row is represented by the integer r.\nYou are given a string s in the format \":\", where  represents the column c1,  represents the row r1,  represents the column c2, and  represents the row r2, such that r1 <= r2 and c1 <= c2.\nReturn the list of cells (x, y) such that r1 <= x <= r2 and c1 <= y <= c2. The cells should be represented as strings in the format mentioned above and be sorted in non-decreasing order first by columns and then by rows.\n",
        "provided_code_snippet": "class Solution:\r\n    def cellsInRange(self, s: str) -> List[str]:",
        "solution": "def cellsInRange(self, s: str) -> List[str]:\n        c1, c2 = ord(s[0]), ord(s[3])\n        r1, r2 = int(s[1]), int(s[4])\n        return [chr(c) + str(r) for c in range(c1, c2 + 1) for r in range(r1, r2 + 1)]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2195": {
        "problem_id": 2195,
        "description": "You are given an integer array nums and an integer k. Append k unique positive integers that do not appear in nums to nums such that the resulting total sum is minimum.\nReturn the sum of the k integers appended to nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimalKSum(self, nums: List[int], k: int) -> int:",
        "solution": "def minimalKSum(self, nums: List[int], k: int) -> int:\n        ans, lo = 0, 1\n        cnt = 0\n        for num in sorted(nums):\n            if num > lo:\n                hi = min(num - 1, k - 1 + lo)\n                cnt = hi - lo + 1\n                ans += (lo + hi) * cnt // 2 \n                k -= cnt\n                if k == 0:\n                    return ans\n            lo = num + 1\n        if k > 0:\n            ans += (lo + lo + k - 1) * k // 2\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2196": {
        "problem_id": 2196,
        "description": "You are given a 2D integer array descriptions where descriptions[i] = [parenti, childi, isLefti] indicates that parenti is the parent of childi in a binary tree of unique values. Furthermore,\n\t- If isLefti == 1, then childi is the left child of parenti.\n\t- If isLefti == 0, then childi is the right child of parenti.\nConstruct the binary tree described by descriptions and return its root.\nThe test cases will be generated such that the binary tree is valid.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def createBinaryTree(self, descriptions: List[List[int]]) -> Optional[TreeNode]:",
        "solution": "class Solution:\n    def createBinaryTree(self, descriptions: list[list[int]]) -> Optional[TreeNode]:\n        def construct_tree(cur_node_val):\n            new_node = TreeNode(cur_node_val)\n            if cur_node_val in children_hashmap:\n                if children_hashmap[cur_node_val][0] is not None:\n                    new_node.left = construct_tree(children_hashmap[cur_node_val][0])\n                if children_hashmap[cur_node_val][1] is not None:\n                    new_node.right = construct_tree(children_hashmap[cur_node_val][1])\n            return new_node\n\n        children_set = set()\n        children_hashmap: dict[int, list[int]] = {}\n\n        for parent, child, isleft in descriptions:\n            if not parent in children_hashmap:\n                children_hashmap[parent] = [None, None]  # left and right\n            children_set.add(child)\n            target = 0 if isleft else 1\n            children_hashmap[parent][target] = child\n\n        for parent in children_hashmap:\n            if parent not in children_set:\n                head_node_val: int = parent\n                break\n        head = construct_tree(head_node_val)\n        return head",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2197": {
        "problem_id": 2197,
        "description": "You are given an array of integers nums. Perform the following steps:\n\t1. Find any two adjacent numbers in nums that are non-coprime.\n\t2. If no such numbers are found, stop the process.\n\t3. Otherwise, delete the two numbers and replace them with their LCM (Least Common Multiple).\n\t4. Repeat this process as long as you keep finding two adjacent non-coprime numbers.\nReturn the final modified array. It can be shown that replacing adjacent non-coprime numbers in any arbitrary order will lead to the same result.\nThe test cases are generated such that the values in the final array are less than or equal to 108.\nTwo values x and y are non-coprime if GCD(x, y) > 1 where GCD(x, y) is the Greatest Common Divisor of x and y.\n",
        "provided_code_snippet": "class Solution:\r\n    def replaceNonCoprimes(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def replaceNonCoprimes(self, nums: List[int]) -> List[int]:\n        stack = []\n        for i in nums:\n            toBeAppended = i\n            while stack and gcd(stack[-1], toBeAppended) > 1:\n                toBeAppended = lcm(toBeAppended, stack.pop())\n            stack.append(toBeAppended)\n        return stack",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2200": {
        "problem_id": 2200,
        "description": "You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] == key.\nReturn a list of all k-distant indices sorted in increasing order.\n",
        "provided_code_snippet": "class Solution:\r\n    def findKDistantIndices(self, nums: List[int], key: int, k: int) -> List[int]:",
        "solution": "class Solution:\n    def findKDistantIndices(self, nums: List[int], key: int, k: int) -> List[int]:\n        ind_j = []\n        for ind, elem in enumerate(nums):\n            if elem == key:\n                ind_j.append(ind)\n        res = []\n        for i in range(len(nums)):\n            for j in ind_j:\n                if abs(i - j) <= k:\n                    res.append(i)\n                    break\n        return sorted(res)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "list argument",
                    "list return",
                    "math",
                    "output constraint",
                    "short",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    ">3 parameters",
                    "array",
                    "definitions in between",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2201": {
        "problem_id": 2201,
        "description": "There is an n x n 0-indexed grid with some artifacts buried in it. You are given the integer n and a 0-indexed 2D integer array artifacts describing the positions of the rectangular artifacts where artifacts[i] = [r1i, c1i, r2i, c2i] denotes that the ith artifact is buried in the subgrid where:\n\t- (r1i, c1i) is the coordinate of the top-left cell of the ith artifact and\n\t- (r2i, c2i) is the coordinate of the bottom-right cell of the ith artifact.\nYou will excavate some cells of the grid and remove all the mud from them. If the cell has a part of an artifact buried underneath, it will be uncovered. If all the parts of an artifact are uncovered, you can extract it.\nGiven a 0-indexed 2D integer array dig where dig[i] = [ri, ci] indicates that you will excavate the cell (ri, ci), return the number of artifacts that you can extract.\nThe test cases are generated such that:\n\t- No two artifacts overlap.\n\t- Each artifact only covers at most 4 cells.\n\t- The entries of dig are unique.\n",
        "provided_code_snippet": "class Solution:\r\n    def digArtifacts(self, n: int, artifacts: List[List[int]], dig: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def digArtifacts(self, n: int, artifacts: List[List[int]], dig: List[List[int]]) -> int:\n\t    # Time: O(max(artifacts, dig)) which is O(N^2) as every position in the grid can be in dig\n\t\t# Space: O(dig) which is O(N^2)\n        result, dig_pos = 0, set(tuple(pos) for pos in dig)\n        for pos in artifacts:\n            if all((x, y) in dig_pos for x in range(pos[0], pos[2] + 1) for y in range(pos[1], pos[3] + 1)):     \n                result += 1\n        return result",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "input late",
                    "int return",
                    "list argument",
                    "list of rules",
                    "medium long",
                    "story",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    ">3 parameters",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "List of rules to consider",
                    "matrix",
                    "Note with extra constraints",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2202": {
        "problem_id": 2202,
        "description": "You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile.\nIn one move, you can perform either of the following:\n\t- If the pile is not empty, remove the topmost element of the pile.\n\t- If there are one or more removed elements, add any one of them back onto the pile. This element becomes the new topmost element.\nYou are also given an integer k, which denotes the total number of moves to be made.\nReturn the maximum value of the topmost element of the pile possible after exactly k moves. In case it is not possible to obtain a non-empty pile after k moves, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumTop(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximumTop(self, nums: List[int], k: int) -> int:\n        if len(nums) == 1:\n            if k%2 != 0:\n                return -1\n            return nums[0]\n        \n        if k == 0:\n            return nums[0]\n        if k == len(nums):\n            return max(nums[:-1])\n        if k > len(nums):\n            return max(nums)\n        if k == 1:\n            return nums[1]\n        m = max(nums[:k-1])\n        m = max(m, nums[k])\n        return m",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2203": {
        "problem_id": 2203,
        "description": "You are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1.\nYou are also given a 2D integer array edges where edges[i] = [fromi, toi, weighti] denotes that there exists a directed edge from fromi to toi with weight weighti.\nLastly, you are given three distinct integers src1, src2, and dest denoting three distinct nodes of the graph.\nReturn the minimum weight of a subgraph of the graph such that it is possible to reach dest from both src1 and src2 via a set of edges of this subgraph. In case such a subgraph does not exist, return -1.\nA subgraph is a graph whose vertices and edges are subsets of the original graph. The weight of a subgraph is the sum of weights of its constituent edges.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumWeight(self, n: int, edges: List[List[int]], src1: int, src2: int, dest: int) -> int:",
        "solution": "class Solution:\n    def minimumWeight(self, n: int, edges: List[List[int]], src1: int, src2: int, dest: int) -> int:\n        g1 = collections.defaultdict(list)\n        g2 = collections.defaultdict(list)\n        for u, v , w in edges:\n            g1[u].append((v, w))\n            g2[v].append((u, w))\n\n        def get_distance(node: int, g: dict) -> List[float | int]:\n            distance = [float('inf') for _ in range(n)]\n            distance[node] = 0\n            q = [(0, node)]\n            while q:\n                d, u = heapq.heappop(q)\n                if d > distance[u]: continue\n                for v, w in g[u]:\n                    if d + w < distance[v]:\n                        distance[v] = d + w\n                        heapq.heappush(q, (distance[v], v))\n            return distance\n        \n        l1, l2, l3 = get_distance(src1, g1), get_distance(src2, g1), get_distance(dest, g2)\n        ans = float(\"inf\")\n        for i in range(n):\n            ans = min(ans, l1[i] + l2[i] + l3[i])\n        \n        return ans if ans != float(\"inf\") else -1",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2206": {
        "problem_id": 2206,
        "description": "You are given an integer array nums consisting of 2 * n integers.\nYou need to divide nums into n pairs such that:\n\t- Each element belongs to exactly one pair.\n\t- The elements present in a pair are equal.\nReturn true if nums can be divided into n pairs, otherwise return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def divideArray(self, nums: List[int]) -> bool:",
        "solution": "def divideArray(self, nums: List[int]) -> bool:\n        return all(v % 2 == 0 for v in Counter(nums).values())",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "list argument",
                    "list of rules",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "List of rules to consider",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2207": {
        "problem_id": 2207,
        "description": "You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.\nYou can add either pattern[0] or pattern[1] anywhere in text exactly once. Note that the character can be added even at the beginning or at the end of text.\nReturn the maximum number of times pattern can occur as a subsequence of the modified text.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumSubsequenceCount(self, text: str, pattern: str) -> int:",
        "solution": "    def maximumSubsequenceCount(self, text, pattern):\n        res = cnt1 = cnt2 = 0\n        for c in text:\n            if c == pattern[1]:\n                res += cnt1\n                cnt2 += 1\n            if c == pattern[0]:\n                cnt1 += 1\n        return res + max(cnt1, cnt2)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2208": {
        "problem_id": 2208,
        "description": "You are given an array nums of positive integers. In one operation, you can choose any number from nums and reduce it to exactly half the number. (Note that you may choose this reduced number in future operations.)\nReturn the minimum number of operations to reduce the sum of nums by at least half.\n",
        "provided_code_snippet": "class Solution:\r\n    def halveArray(self, nums: List[int]) -> int:",
        "solution": "def halveArray(self, nums: List[int]) -> int:\n        half, ops = sum(nums) / 2, 0\n        heap = [-num for num in nums]\n        heapify(heap)\n        while half > 0:\n            num = -heappop(heap)\n            num /= 2.0\n            half -= num\n            heappush(heap, -num)\n            ops += 1\n        return ops",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2209": {
        "problem_id": 2209,
        "description": "You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor:\n\t- floor[i] = '0' denotes that the ith tile of the floor is colored black.\n\t- On the other hand, floor[i] = '1' denotes that the ith tile of the floor is colored white.\nYou are also given numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Cover the tiles with the given carpets such that the number of white tiles still visible is minimum. Carpets may overlap one another.\nReturn the minimum number of white tiles still visible.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:",
        "solution": "class Solution:\n    def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n        \n        @cache\n        def fn(i, n):\n            \n            if n < 0: return inf \n            if i >= len(floor): return 0 \n            if floor[i] == '1': return min(fn(i+carpetLen, n-1), 1 + fn(i+1, n))\n            return fn(i+1, n)\n        \n        return fn(0, numCarpets)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2210": {
        "problem_id": 2210,
        "description": "You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums if the closest non-equal neighbors of i are larger than nums[i]. Adjacent indices i and j are part of the same hill or valley if nums[i] == nums[j].\nNote that for an index to be part of a hill or valley, it must have a non-equal neighbor on both the left and right of the index.\nReturn the number of hills and valleys in nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def countHillValley(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def countHillValley(self, nums: List[int]) -> int:\n        \n        #cnt: An integer to store total hills and valleys\n        #left: Highest point of hill or lowest point of valley left of the current index\n        cnt, left = 0, nums[0]\n        \n        for i in range(1, len(nums)-1):\n            if (leftnums[i+1]) or (left>nums[i] and nums[i] int:",
        "solution": "class Solution:\n    def countCollisions(self, directions: str) -> int:\n        \n        res, n, i, carsFromRight = 0, len(directions), 0, 0\n        \n        while i < n and directions[i] == 'L':\n               i+=1\n        \n        while i= bk, then Alice takes k points. If ak < bk, then Bob takes k points.\n\t\t- However, if ak == bk == 0, then nobody takes k points.\n\t\t\n\t- \tFor example, if Alice and Bob both shot 2 arrows on the section with score 11, then Alice takes 11 points. On the other hand, if Alice shot 0 arrows on the section with score 11 and Bob shot 2 arrows on that same section, then Bob takes 11 points.\n\t\nYou are given the integer numArrows and an integer array aliceArrows of size 12, which represents the number of arrows Alice shot on each scoring section from 0 to 11. Now, Bob wants to maximize the total number of points he can obtain.\nReturn the array bobArrows which represents the number of arrows Bob shot on each scoring section from 0 to 11. The sum of the values in bobArrows should equal numArrows.\nIf there are multiple ways for Bob to earn the maximum total points, return any one of them.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumBobPoints(self, numArrows: int, aliceArrows: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def maximumBobPoints(self, numArrows: int, aliceArrows: List[int]) -> List[int]:\n        maxScore = 0\n        res = [0] * len(aliceArrows)\n    \n        def recur(i, numArrows, score, path):\n            nonlocal maxScore, res\n            if i >= len(aliceArrows):\n                if score > maxScore:\n                    if numArrows > 0:\n                        path[0] += numArrows\n                    res = path\n                    maxScore = score\n                return score\n            \n            notPick = recur(i+1, numArrows, score, path + [0])\n            pick = 0\n            if numArrows - (aliceArrows[i] + 1) >= 0:\n                pick = recur(i+1, numArrows - (aliceArrows[i] + 1), score + i, path + [aliceArrows[i] + 1])\n            \n            return max(pick, notPick)\n        recur(0, numArrows, 0, [])\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2213": {
        "problem_id": 2213,
        "description": "You are given a 0-indexed string s. You are also given a 0-indexed string queryCharacters of length k and a 0-indexed array of integer indices queryIndices of length k, both of which are used to describe k queries.\nThe ith query updates the character in s at index queryIndices[i] to the character queryCharacters[i].\nReturn an array lengths of length k where lengths[i] is the length of the longest substring of s consisting of only one repeating character after the ith query is performed.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestRepeating(self, s: str, queryCharacters: str, queryIndices: List[int]) -> List[int]:",
        "solution": "from sortedcontainers import SortedList\n\nclass Solution:\n    def longestRepeating(self, s: str, queryCharacters: str, queryIndices: List[int]) -> List[int]:\n        \n        s = list(s)\n        loc = defaultdict(lambda: SortedList()) # segment offsets (start, end) stored by character\n        max_len = SortedList() # segment length stored by character\n\n        i = 0\n        while i < len(s):\n            j = i\n            while j < len(s) and s[i] == s[j]:\n                j += 1\n            loc[s[i]].add((i, j-1))\n            max_len.add(j - i)\n            i = j\n            \n        # helper function to remove segment\n        def del_seg(w, old_l, old_r):\n            loc[w].remove((old_l, old_r))\n            max_len.remove(old_r - old_l + 1)\n        \n        # helper function to add segment\n        def add_seg(w, new_l, new_r):\n            loc[w].add((new_l, new_r))\n            max_len.add(new_r - new_l + 1)\n\n        ans = [0] * len(queryIndices)\n        for k in range(len(queryIndices)):\n            old, new = s[queryIndices[k]], queryCharacters[k]\n            s[queryIndices[k]] = new\n            pos = (queryIndices[k], queryIndices[k])\n\n            # old segment delete\n            if pos in loc[old]:\n                del_seg(old, *pos)\n            else:\n                l1 = bisect.bisect_left(loc[old], pos)\n                if l1 == 0:\n                    old_pos = loc[old][l1]\n                    l, r = old_pos\n                    del_seg(old, *old_pos)\n                    add_seg(old, l + 1, r)\n                elif l1 == len(loc[old]):\n                    old_pos = loc[old][l1-1]\n                    l, r = old_pos\n                    del_seg(old, *old_pos)\n                    if pos[0] == r:\n                        add_seg(old, l, r-1)\n                    else:\n                        add_seg(old, l, pos[0]-1)\n                        add_seg(old, pos[0] + 1, r)\n                else:\n                    a, b = loc[old][l1 - 1]\n                    c, d = loc[old][l1]\n                    if pos[0] == b:\n                        del_seg(old, a, b)\n                        add_seg(old, a, b-1)\n                    elif pos[0] == c:\n                        del_seg(old, c, d)\n                        add_seg(old, c+1, d)\n                    elif pos[0] < b:\n                        del_seg(old, a, b)\n                        add_seg(old, a, pos[0]-1)\n                        add_seg(old, pos[0]+1, b)\n                    elif pos[0] > c:\n                        del_seg(old, c, d)\n                        add_seg(old, c, pos[0]-1)\n                        add_seg(old, pos[0]+1, d)\n\n            # new segment insert\n            if not loc[new]:\n                add_seg(new, *pos)\n                ans[k] = max_len[-1]\n                continue\n            l2 = bisect.bisect_left(loc[new], pos)\n            if l2 == 0:\n                l, r = loc[new][l2]\n                if l - pos[0] > 1:\n                    add_seg(new, *pos)\n                else:\n                    del_seg(new, l, r)\n                    add_seg(new, pos[0], r)\n\n            elif l2 == len(loc[new]):\n                l, r = loc[new][l2 - 1]\n                if pos[0] - r > 1:\n                    add_seg(new, *pos)\n                else:\n                    del_seg(new, l, r)\n                    add_seg(new, l, pos[0])\n            else:\n                a, b = loc[new][l2 - 1]\n                c, d = loc[new][l2]\n                if pos[0] - b == 1 and c - pos[0] == 1:\n                    del_seg(new, a, b)\n                    del_seg(new, c, d)\n                    add_seg(new, a, d)\n                elif pos[0] - b == 1:\n                    del_seg(new, a, b)\n                    add_seg(new, a, pos[0])\n                elif c - pos[0] == 1:\n                    del_seg(new, c, d)\n                    add_seg(new, pos[0], d)\n                else:\n                    add_seg(new, *pos)\n            ans[k] = max_len[-1]\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2215": {
        "problem_id": 2215,
        "description": "Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:\n\t- answer[0] is a list of all distinct integers in nums1 which are not present in nums2.\n\t- answer[1] is a list of all distinct integers in nums2 which are not present in nums1.\nNote that the integers in the lists may be returned in any order.\n",
        "provided_code_snippet": "class Solution:\r\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:",
        "solution": "class Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        res=[]\n        a=[]\n        a=set(nums1) - set(nums2)\n        b=[]\n        b=set(nums2) - set(nums1)\n        res.append(a)\n        res.append(b)\n        return res",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2216": {
        "problem_id": 2216,
        "description": "You are given a 0-indexed integer array nums. The array nums is beautiful if:\n\t- nums.length is even.\n\t- nums[i] != nums[i + 1] for all i % 2 == 0.\nNote that an empty array is considered beautiful.\nYou can delete any number of elements from nums. When you delete an element, all the elements to the right of the deleted element will be shifted one unit to the left to fill the gap created and all the elements to the left of the deleted element will remain unchanged.\nReturn the minimum number of elements to delete from nums to make it beautiful.\n",
        "provided_code_snippet": "class Solution:\r\n    def minDeletion(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minDeletion(self, nums: List[int]) -> int:\n        # Greedy !\n        # we first only consider requirement 2: nums[i] != nums[i + 1] for all i % 2 == 0\n        # at the begining, we consider the num on the even index\n        # when we delete a num, we need consider the num on the odd index\n        # then repeat this process\n        # at the end we check the requirement 1: nums.length is even or not\n        \n        n = len(nums)\n        count = 0\n        # flag is true then check the even index\n        # flag is false then check the odd index\n        flag = True\n        \n        for i in range(n):\n            # check the even index\n            if flag:\n                if i % 2 == 0 and i != n -1 and nums[i] == nums[i + 1]:\n                    count += 1\n                    flag = False\n            # check the odd index\n            elif not flag:\n                if i % 2 == 1 and i != n -1 and nums[i] == nums[i + 1]:\n                    count += 1\n                    flag = True\n        \n        curLength = n - count",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2217": {
        "problem_id": 2217,
        "description": "Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]th smallest positive palindrome of length intLength or -1 if no such palindrome exists.\nA palindrome is a number that reads the same backwards and forwards. Palindromes cannot have leading zeros.\n",
        "provided_code_snippet": "class Solution:\r\n    def kthPalindrome(self, queries: List[int], intLength: int) -> List[int]:",
        "solution": "class Solution:\n    def kthPalindrome(self, queries: List[int], intLength: int) -> List[int]:\n        # think the palindromes in half\n        # e.g. len  = 4 we only consider the first 2 digits\n        # half: 10, 11, 12, 13, 14, ..., 19, 20, \n        # full: 1001, 1111, 1221, 1331, ...\n        # e.g. len = 5 we consider the first 3 digits\n        # half: 100, 101, 102, ...\n        # full: 10001, 10101, 10201, ...\n        \n        result = []\n        \n        for i in queries:\n            result.append(self.generatePalindrome(intLength, i))\n        \n        return result\n    \n    def generatePalindrome(self, length, num):\n        # index start from 0\n\t\t# e.g. num =1 means we want to find the most smallest palindrome, then its index is 0\n\t\t# e.g. num =2 means we want to find the second most smallest palindrome, then its index is 1\n        index = num -1\n        \n\t\t# if the length is even\n\t\t# we only think about the fisrt half of digits\n        if length % 2 == 0:\n            cur = int('1' + '0' * (length // 2 -1))\n            maxLength = len(str(cur))\n            cur += index\n            \n            if len(str(cur)) > maxLength:\n                return -1\n            \n            else:\n                cur = str(cur)\n                cur = cur + cur[::-1]\n                cur = int(cur)\n                return cur\n\t\t\t\t\n        # if the length is odd\n\t\t# we consider first (length // 2 + 1) digits\n        else:\n            cur = int('1' + '0' * (length // 2))\n            maxLength = len(str(cur))\n            cur += index\n            \n            if len(str(cur)) > maxLength:\n                return -1\n            \n            else:\n                cur = str(cur)\n                temp = str(cur)[:-1]\n                cur = cur + temp[::-1]\n                cur = int(cur)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2218": {
        "problem_id": 2218,
        "description": "There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted denominations.\nIn one move, you can choose any coin on top of any pile, remove it, and add it to your wallet.\nGiven a list piles, where piles[i] is a list of integers denoting the composition of the ith pile from top to bottom, and a positive integer k, return the maximum total value of coins you can have in your wallet if you choose exactly k coins optimally.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxValueOfCoins(self, piles: List[List[int]], k: int) -> int:",
        "solution": "class Solution:\n    def maxValueOfCoins(self, piles: List[List[int]], k: int) -> int:\n        \n        @functools.lru_cache(None)\n        def _search(rest_k: int, pile_pos: int) -> int:\n            \n            if rest_k == 0 or pile_pos == len(piles): return 0\n\n            # Ignore the current pile and moving to next pile\n            current_mv_found = _search(rest_k, pile_pos+1)\n\n            # Start looking solution with current pile being involved\n            current_pile = piles[pile_pos]\n            accum_coin_value = 0\n            for i in range(min(rest_k, len(current_pile))):\n                # Accumulate the coins\n                accum_coin_value += current_pile[i]\n\n                # Moving to next pile with accumulated coin value in current pile\n                current_mv_found = max(\n                    current_mv_found, \n                    accum_coin_value + _search(rest_k-i-1, pile_pos+1))\n\n            # Return the maximum accumulated coin value found from current pile.\n            return current_mv_found\n\n        # Start searching with initial `k` and first pile\n        return _search(k, 0)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2220": {
        "problem_id": 2220,
        "description": "A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.\n\t- For example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip the second bit from the right to get 101, flip the fifth bit from the right (a leading zero) to get 10111, etc.\nGiven two integers start and goal, return the minimum number of bit flips to convert start to goal.\n",
        "provided_code_snippet": "class Solution:\r\n    def minBitFlips(self, start: int, goal: int) -> int:",
        "solution": "class Solution(object):\n    def minBitFlips(self, start, goal):\n        \n\n        xor_result = start ^ goal\n        ans = 0\n        \n        while xor_result > 0:\n            ans += xor_result & 1  \n            xor_result >>= 1     \n        \n        return ans",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2221": {
        "problem_id": 2221,
        "description": "You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive).\nThe triangular sum of nums is the value of the only element present in nums after the following process terminates:\n\t1. Let nums comprise of n elements. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n - 1.\n\t2. For each index i, where 0 <= i < n - 1, assign the value of newNums[i] as (nums[i] + nums[i+1]) % 10, where % denotes modulo operator.\n\t3. Replace the array nums with newNums.\n\t4. Repeat the entire process starting from step 1.\nReturn the triangular sum of nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def triangularSum(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def triangularSum(self, nums: List[int]) -> int:\n        return sum(n * comb(len(nums) - 1, i) for i, n in enumerate(nums)) % 10",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2222": {
        "problem_id": 2222,
        "description": "You are given a 0-indexed binary string s which represents the types of buildings along a street where:\n\t- s[i] = '0' denotes that the ith building is an office and\n\t- s[i] = '1' denotes that the ith building is a restaurant.\nAs a city official, you would like to select 3 buildings for random inspection. However, to ensure variety, no two consecutive buildings out of the selected buildings can be of the same type.\n\t- For example, given s = \"001101\", we cannot select the 1st, 3rd, and 5th buildings as that would form \"011\" which is not allowed due to having two consecutive buildings of the same type.\nReturn the number of valid ways to select 3 buildings.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfWays(self, s: str) -> int:",
        "solution": "def numberOfWays(self, s: str) -> int:\n        ways = 0\n        one = zero = zero_one = one_zero = 0\n        for c in s:\n            if c == '0':\n                zero += 1\n                one_zero += one\n                ways += zero_one\n            else:\n                one += 1    \n                zero_one += zero \n                ways += one_zero\n        return ways",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2223": {
        "problem_id": 2223,
        "description": "You are building a string s of length n one character at a time, prepending each new character to the front of the string. The strings are labeled from 1 to n, where the string with length i is labeled si.\n\t- For example, for s = \"abaca\", s1 == \"a\", s2 == \"ca\", s3 == \"aca\", etc.\nThe score of si is the length of the longest common prefix between si and sn (Note that s == sn).\nGiven the final string s, return the sum of the score of every si.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumScores(self, s: str) -> int:",
        "solution": "class Solution:\n    def sumScores(self, s: str) -> int:\n        mod = 119_218_851_371\n        hs = 0 \n        vals = [0]\n        for i, ch in enumerate(s): \n            hs = (hs * 26 + ord(ch) - 97) % mod\n            vals.append(hs)\n        \n        p26 = [1]\n        for _ in range(len(s)): p26.append(p26[-1] * 26 % mod)\n        \n        ans = 0 \n        for i in range(len(s)): \n            if s[0] == s[i]: \n                lo, hi = i, len(s)\n                while lo < hi: \n                    mid = lo + hi + 1 >> 1\n                    hs = (vals[mid] - vals[i]*p26[mid-i]) % mod\n                    if hs == vals[mid-i]: lo = mid\n                    else: hi = mid - 1\n                ans += lo - i \n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2224": {
        "problem_id": 2224,
        "description": "You are given two strings current and correct representing two 24-hour times.\n24-hour times are formatted as \"HH:MM\", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59.\nIn one operation you can increase the time current by 1, 5, 15, or 60 minutes. You can perform this operation any number of times.\nReturn the minimum number of operations needed to convert current to correct.\n",
        "provided_code_snippet": "class Solution:\r\n    def convertTime(self, current: str, correct: str) -> int:",
        "solution": "class Solution:\n    def convertTime(self, current: str, correct: str) -> int:\n        current_time = 60 * int(current[0:2]) + int(current[3:5]) # Current time in minutes\n        target_time = 60 * int(correct[0:2]) + int(correct[3:5]) # Target time in minutes\n        diff = target_time - current_time # Difference b/w current and target times in minutes\n        count = 0 # Required number of operations\n\t\t# Use GREEDY APPROACH to calculate number of operations\n        for i in [60, 15, 5, 1]:\n            count += diff // i # add number of operations needed with i to count\n            diff %= i # Diff becomes modulo of diff with i\n        return count",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "int return",
                    "math",
                    "short",
                    "string argument",
                    "two arguments",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "string encoding",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2225": {
        "problem_id": 2225,
        "description": "You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.\nReturn a list answer of size 2 where:\n\t- answer[0] is a list of all players that have not lost any matches.\n\t- answer[1] is a list of all players that have lost exactly one match.\nThe values in the two lists should be returned in increasing order.\nNote:\n\t- You should only consider the players that have played at least one match.\n\t- The testcases will be generated such that no two matches will have the same outcome.\n",
        "provided_code_snippet": "class Solution:\r\n    def findWinners(self, matches: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def findWinners(self, matches):\n        losses = [0] * 100001\n\n        for winner, loser in matches:\n            if losses[winner] == 0:\n                losses[winner] = -1\n\n            if losses[loser] == -1:\n                losses[loser] = 1\n            else:\n                losses[loser] += 1\n\n        zero_loss = [i for i in range(1, 100001) if losses[i] == -1]\n        one_loss = [i for i in range(1, 100001) if losses[i] == 1]\n\n        return [zero_loss, one_loss]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "list argument",
                    "list of rules",
                    "list return",
                    "note",
                    "one argument",
                    "predicted to be solved"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2226": {
        "problem_id": 2226,
        "description": "You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two piles together.\nYou are also given an integer k. You should allocate piles of candies to k children such that each child gets the same number of candies. Each child can take at most one pile of candies and some piles of candies may go unused.\nReturn the maximum number of candies each child can get.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumCandies(self, candies: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximumCandies(self, candies, k):\n        n = len(candies)\n        left = 1  # the least number of candy in each stack we can give to each student is one\n        right = max(candies)  # the max number of candy in each stack that we can give to each student is the maximum number in the candies array\n        ans = 0 # ans here is used to store the maximum amount in each stack that we can give to each children. \n               # If we don't have enough to distribute, we will return 0 at the end so we initialize it to be 0 now.\n\n        while left <= right:  # binary search\n            numberOfPiles = 0\n            mid = (left) + (right - left) // 2  # the number of candies we require to form a stack\n\n            for i in range(n):   # loop through the array to find the numbers of stack we can form\n                numberOfPiles += candies[i] // mid   # we add to the numberOfPiles whenever we find that this current stack (candies[i]) can be split into mid (the number of candies we require to form a stack)\n\n            if numberOfPiles >= k: # if our number of piles is greater or equal than the students we have, so we have enough to distribute\n                ans = max(ans, mid)   # we first store the max no. of candies in each stack that we can give to each student \n                left = mid + 1      # we will try to increase the number of candies in each stack that we can give to each student\n            else: \n                right = mid - 1   # we will try to reduce the number of candies in each stack that we can give to each student\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2231": {
        "problem_id": 2231,
        "description": "You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).\nReturn the largest possible value of num after any number of swaps.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestInteger(self, num: int) -> int:",
        "solution": "class Solution:\n    def largestInteger(self, num: int):\n        n = len(str(num))\n        arr = [int(i) for i in str(num)]\n        odd, even = [], []\n        for i in arr:\n            if i % 2 == 0:\n                even.append(i)\n            else:\n                odd.append(i)\n        odd.sort()\n        even.sort()\n        res = 0\n        for i in range(n):\n            if arr[i] % 2 == 0:\n                res = res*10 + even.pop()\n            else:\n                res = res*10 + odd.pop()\n        return res",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2232": {
        "problem_id": 2232,
        "description": "You are given a 0-indexed string expression of the form \"+\" where  and  represent positive integers.\nAdd a pair of parentheses to expression such that after the addition of parentheses, expression is a valid mathematical expression and evaluates to the smallest possible value. The left parenthesis must be added to the left of '+' and the right parenthesis must be added to the right of '+'.\nReturn expression after adding a pair of parentheses such that expression evaluates to the smallest possible value. If there are multiple answers that yield the same result, return any of them.\nThe input has been generated such that the original value of expression, and the value of expression after adding any pair of parentheses that meets the requirements fits within a signed 32-bit integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeResult(self, expression: str) -> str:",
        "solution": "class Solution:\n    def minimizeResult(self, expression: str) -> str:\n        plus_index, n, ans = expression.find('+'), len(expression), [float(inf),expression] \n        def evaluate(exps: str):\n            return eval(exps.replace('(','*(').replace(')', ')*').lstrip('*').rstrip('*'))\n        for l in range(plus_index):\n            for r in range(plus_index+1, n):\n                exps = f'{expression[:l]}({expression[l:plus_index]}+{expression[plus_index+1:r+1]}){expression[r+1:n]}'\n                res = evaluate(exps)\n                if ans[0] > res:\n                    ans[0], ans[1] = res, exps\n        return ans[1]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2233": {
        "problem_id": 2233,
        "description": "You are given an array of non-negative integers nums and an integer k. In one operation, you may choose any element from nums and increment it by 1.\nReturn the maximum product of nums after at most k operations. Since the answer may be very large, return it modulo 109 + 7. Note that you should maximize the product before taking the modulo. \n",
        "provided_code_snippet": "class Solution:\r\n    def maximumProduct(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximumProduct(self, nums: List[int], k: int) -> int:\n        heapq.heapify(nums)\n        while k:\n            heapq.heappush(nums, heapq.heappop(nums)+1)\n            k -= 1\n        ans = 1\n        for x in nums:\n            ans = (ans * x) % 1000000007\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2234": {
        "problem_id": 2234,
        "description": "Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens.\nYou are given a 0-indexed integer array flowers of size n, where flowers[i] is the number of flowers already planted in the ith garden. Flowers that are already planted cannot be removed. You are then given another integer newFlowers, which is the maximum number of flowers that Alice can additionally plant. You are also given the integers target, full, and partial.\nA garden is considered complete if it has at least target flowers. The total beauty of the gardens is then determined as the sum of the following:\n\t- The number of complete gardens multiplied by full.\n\t- The minimum number of flowers in any of the incomplete gardens multiplied by partial. If there are no incomplete gardens, then this value will be 0.\nReturn the maximum total beauty that Alice can obtain after planting at most newFlowers flowers.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumBeauty(self, flowers: List[int], newFlowers: int, target: int, full: int, partial: int) -> int:",
        "solution": "class Solution:\n    def maximumBeauty(self, flowers: List[int], newFlowers: int, target: int, full: int, partial: int) -> int:\n        n = len(flowers)\n        flowers.sort() \n        originally_complete = sum(flowers[i] >= target for i in range(n))\n        work_end = n - originally_complete\n        # [0,        j-1] \u2014 incomplete (with >=`level` flowers each, where `0 <= `level` <= target - 1) \n        # [j, work_end-1] \u2014 complete\n        # [work_end, n-1] \u2014 originally complete\n\n        i = -1\n        level = 0\n        def maximize_min_number_of_flowers() -> None:\n            nonlocal i, level, newFlowers\n            if j == 0:\n                return\n            if i == -1:\n                i = 0\n                level = flowers[0]\n            while i < j:\n                next_level = flowers[i+1] if i + 1 < j else target - 1\n                max_boost = min(next_level - level, newFlowers // (i+1))\n                level += max_boost\n                newFlowers -= max_boost * (i+1)\n                if level != next_level:\n                    break\n                i += 1\n        \n        j = work_end\n        def add_complete_garden() -> bool:\n            nonlocal j, newFlowers\n            if j - 1 < 0 or newFlowers < target - flowers[j-1]:\n                return False\n            newFlowers -= target - flowers[j-1]\n            j -= 1\n            return True\n        def remove_complete_garden() -> None:\n            nonlocal j, newFlowers\n            assert j < work_end\n            newFlowers += target - flowers[j]\n            flowers[j] = flowers[j]\n            j += 1\n\n        while add_complete_garden():\n            pass\n        maximize_min_number_of_flowers()\n        ans = full * (n - j) + partial * level\n        while j < work_end:\n            remove_complete_garden()\n            maximize_min_number_of_flowers()\n            ans = max(ans, full * (n - j) + partial * level)\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2235": {
        "problem_id": 2235,
        "description": "Given two integers num1 and num2, return the sum of the two integers.\n",
        "provided_code_snippet": "class Solution:\r\n    def sum(self, num1: int, num2: int) -> int:",
        "solution": "class Solution(object):\n    sum = add",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "math",
                    "short",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "speaking method name",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2236": {
        "problem_id": 2236,
        "description": "You are given the root of a binary tree that consists of exactly 3 nodes: the root, its left child, and its right child.\nReturn true if the value of the root is equal to the sum of the values of its two children, or false otherwise.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def checkTree(self, root: Optional[TreeNode]) -> bool:",
        "solution": "class Solution:\n    def checkTree(self, root: Optional[TreeNode]) -> bool:\n        return root.val==root.left.val+root.right.val",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "condition",
                    "data structure",
                    "graph",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "coded data type definition",
                    "complex sentences (where, if, which)",
                    "Given and Return",
                    "tree",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2239": {
        "problem_id": 2239,
        "description": "Given an integer array nums of size n, return the number with the value closest to 0 in nums. If there are multiple answers, return the number with the largest value.\n",
        "provided_code_snippet": "class Solution:\r\n    def findClosestNumber(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findClosestNumber(self, nums: List[int]) -> int:\n        CloseNum=nums[0]\n\n        for i in nums:\n            if abs(i) < abs(CloseNum):\n                CloseNum = i\n\n        if CloseNum < 0 and abs(CloseNum) in nums:\n            return abs(CloseNum)\n        return CloseNum",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "condition",
                    "int return",
                    "list argument",
                    "math",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "ambiguous terms",
                    "array",
                    "complex sentences (where, if, which)",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2240": {
        "problem_id": 2240,
        "description": "You are given an integer total indicating the amount of money you have. You are also given two integers cost1 and cost2 indicating the price of a pen and pencil respectively. You can spend part or all of your money to buy multiple quantities (or none) of each kind of writing utensil.\nReturn the number of distinct ways you can buy some number of pens and pencils.\n",
        "provided_code_snippet": "class Solution:\r\n    def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:",
        "solution": "from math import floor\nclass Solution:\n    def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:\n        ans = 0\n        y = lambda x: (total-x*cost1)/cost2\n        for i in range(total+1):\n            c = floor(y(i))\n            if c>=0:\n                ans += c+1\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2242": {
        "problem_id": 2242,
        "description": "There is an undirected graph with n nodes, numbered from 0 to n - 1.\nYou are given a 0-indexed integer array scores of length n where scores[i] denotes the score of node i. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA node sequence is valid if it meets the following conditions:\n\t- There is an edge connecting every pair of adjacent nodes in the sequence.\n\t- No node appears more than once in the sequence.\nThe score of a node sequence is defined as the sum of the scores of the nodes in the sequence.\nReturn the maximum score of a valid node sequence with a length of 4. If no such sequence exists, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumScore(self, scores: List[int], edges: List[List[int]]) -> int:",
        "solution": "def maximumScore(self, A, edges):\n        n = len(A)\n        G = [[] for i in range(n)]\n        for i,j in edges:\n            G[i].append([A[j], j])\n            G[j].append([A[i], i])\n        for i in range(n):\n            G[i] = nlargest(3, G[i])\n            \n        res = -1\n        for i,j  in edges:\n            for vii, ii in G[i]:\n                for vjj, jj in G[j]:\n                    if ii != jj and ii != j and j != ii:\n                        res = max(res, vii + vjj + A[i] + A[j])\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2243": {
        "problem_id": 2243,
        "description": "You are given a string s consisting of digits and an integer k.\nA round can be completed if the length of s is greater than k. In one round, do the following:\n\t1. Divide s into consecutive groups of size k such that the first k characters are in the first group, the next k characters are in the second group, and so on. Note that the size of the last group can be smaller than k.\n\t2. Replace each group of s with a string representing the sum of all its digits. For example, \"346\" is replaced with \"13\" because 3 + 4 + 6 = 13.\n\t3. Merge consecutive groups together to form a new string. If the length of the string is greater than k, repeat from step 1.\nReturn s after all rounds have been completed.\n",
        "provided_code_snippet": "class Solution:\r\n    def digitSum(self, s: str, k: int) -> str:",
        "solution": "class Solution:\n    def digitSum(self, s: str, k: int) -> str:\n        while len(s) > k:\n            set_3 = [s[i:i+k] for i in range(0, len(s), k)]\n            s = ''\n            for e in set_3:\n                val = 0\n                for n in e:\n                    val += int(n)\n                s += str(val)\n        return s",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2244": {
        "problem_id": 2244,
        "description": "You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level.\nReturn the minimum rounds required to complete all the tasks, or -1 if it is not possible to complete all the tasks.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumRounds(self, tasks: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumRounds(self, tasks: list[int]) -> int:\n                                            # Example: tasks = [2,2,3,3,2,4,4,4,4,4,4,4]\n\n        tasks = Counter(tasks)              #          tasks = {3:2, 2:3, 4:5}\n        \n        if 1 in tasks.values(): return -1   # <-- no solution if there's a singleton\n\n        ans = 0                             # tasks.values() = [2, 3, 5]     \n        for n in tasks.values():\n            ans+= n//3 + bool(n%3)          # ans  = (2//3+True) + (3//3+False) + (5//3+True)\n                                            #      = ( 0  +  1  ) + (  1 +  0 ) + (1   +  1 )\n        return  ans                         #      = 4  <-- return",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2245": {
        "problem_id": 2245,
        "description": "You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.\nA cornered path is defined as a set of adjacent cells with at most one turn. More specifically, the path should exclusively move either horizontally or vertically up to the turn (if there is one), without returning to a previously visited cell. After the turn, the path will then move exclusively in the alternate direction: move vertically if it moved horizontally, and vice versa, also without returning to a previously visited cell.\nThe product of a path is defined as the product of all the values in the path.\nReturn the maximum number of trailing zeros in the product of a cornered path found in grid.\nNote:\n\t- Horizontal movement means moving in either the left or right direction.\n\t- Vertical movement means moving in either the up or down direction.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxTrailingZeros(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def maxTrailingZeros(self, grid: list[list[int]]) -> int:\n\n        m, n = len(grid)+1, len(grid[0])+1\n        grid = [[(0,0,0,0)]*n]+[[(0,0,0,0)]+row for row in grid]\n\n        def pref(row: int,col: int)-> tuple:        # <-- prefix for each cell\n        \n            val = grid[row][col]\n            for f2 in range(19):\n                if val%2: break\n                val//= 2\n   \n            for f5 in range(6):\n                if val%5: break\n                val//= 5\n        \n            (u2, u5, _,_), (_,_, l2, l5) = grid[row-1][col], grid[row][col-1]\n            return (f2 + u2, f5 + u5, f2 + l2, f5 + l5)\n        \n        def countZeros(r: int,c: int)-> int:        #  <--Count the zeros    \n            up2   ,up5    = grid[r][c][0],grid[r][c][1]\n            down2 ,down5  = grid[m-1][c][0]-grid[r-1][c][0],grid[m-1][c][1]-grid[r-1][c][1]\n            \n            left2 ,left5  = grid[r][c-1][2],grid[r][c-1][3]\n            right2,right5 = grid[r][n-1][2]-grid[r][c][2],grid[r][n-1][3]-grid[r][c][3] \n\n            return max(min(up2+left2 ,up5+left5 ), min(down2+left2 ,down5+left5 ),\n                       min(up2+right2,up5+right5), min(down2+right2,down5+right5))\n\n        for r in range(1,m):\n            for c in range(1,n):grid[r][c] = pref(r,c)\n\n        return max(countZeros(r,c) for c in range(1,n) for r in range(1,m))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2246": {
        "problem_id": 2246,
        "description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.\nYou are also given a string s of length n, where s[i] is the character assigned to node i.\nReturn the length of the longest path in the tree such that no pair of adjacent nodes on the path have the same character assigned to them.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestPath(self, parent: List[int], s: str) -> int:",
        "solution": "class Solution:\n    def longestPath(self, par: List[int], s: str) -> int:\n        dit = {}\n        # store tree in dictionary\n        for i in range(len(par)):\n            if par[i] in dit:\n                dit[par[i]].append(i)\n            else:\n                dit[par[i]] = [i]\n                \n        ans = 1        \n        def dfs(n):\n            nonlocal ans\n            if n not in dit:\n                return 1\n            \n            largest=0 # largest path lenght among all children\n            second_largest=0 # second largest path lenght among all children\n            for u in dit[n]:\n                curr = dfs(u)\n                if s[u]!=s[n]: # pick child path if child and parent both have different value\n                    if curr>largest:\n                        second_largest = largest\n                        largest = curr\n                    elif curr>second_largest:\n                        second_largest = curr\n                        \n            ans = max(ans,largest+second_largest+1) # largest path including parent with at most two children \n            \n            return largest+1  # return largest path end at parent\n        \n        dfs(0)\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2248": {
        "problem_id": 2248,
        "description": "Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.\n",
        "provided_code_snippet": "class Solution:\r\n    def intersection(self, nums: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def intersection(self, nums: List[List[int]]) -> List[int]:\n        res = set(nums[0])\n        for i in range(1, len(nums)):\n            res &= set(nums[i])\n        res = list(res)\n        res.sort()\n        return res",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "list argument",
                    "list return",
                    "output constraint",
                    "short",
                    "sorting"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    "Sentence with >25 words",
                    "speaking method name",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2249": {
        "problem_id": 2249,
        "description": "Given a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, return the number of lattice points that are present inside at least one circle.\nNote:\n\t- A lattice point is a point with integer coordinates.\n\t- Points that lie on the circumference of a circle are also considered to be inside it.\n",
        "provided_code_snippet": "class Solution:\r\n    def countLatticePoints(self, circles: List[List[int]]) -> int:",
        "solution": "def countLatticePoints(self, A: List[List[int]]) -> int:\n        res = set()\n        for x,y,r in A:\n            for i in range(x - r,x + r + 1):\n                for j in range(y - r, y + r + 1):\n                    if (x - i) ** 2 + (y - j) ** 2 <= r * r:\n                        res.add((i,j))\n        return len(res)",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "geometry",
                    "int return",
                    "list argument",
                    "math",
                    "note",
                    "one argument",
                    "short"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    "definitions at the end",
                    "Given and Return",
                    "Note with extra constraints",
                    "Sentence with >25 words",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2250": {
        "problem_id": 2250,
        "description": "You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi. You are also given a 2D integer array points where points[j] = [xj, yj] is a point with coordinates (xj, yj).\nThe ith rectangle has its bottom-left corner point at the coordinates (0, 0) and its top-right corner point at (li, hi).\nReturn an integer array count of length points.length where count[j] is the number of rectangles that contain the jth point.\nThe ith rectangle contains the jth point if 0 <= xj <= li and 0 <= yj <= hi. Note that points that lie on the edges of a rectangle are also considered to be contained by that rectangle.\n",
        "provided_code_snippet": "class Solution:\r\n    def countRectangles(self, rectangles: List[List[int]], points: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def countRectangles(self, rectangles: List[List[int]], points: List[List[int]]) -> List[int]:\n        maxH = 101 \n        hToL = [[] for _ in range(maxH)]\n        \n\t\t# Create the 100 list (0 is not used) \n        for l, h in rectangles:\n            hToL[h].append(l)\n\t\t\t\n        # Sort the 100 list\n        for h in range(1, maxH):\n            hToL[h].sort()\n        \n\t\tres = []\n        for px, py in points:\n            count = 0\n            # Only search the height (y) which equals to or greater than given py \n            for h in range(py, maxH):\n                if len(hToL[h]) == 0:\n                    continue\n                # Find the first index of length (x) which equals to or greater than given px in the sorted array\n                idx = bisect.bisect_left(hToL[h], px) \n                count += len(hToL[h]) - idx\n            res.append(count)\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2251": {
        "problem_id": 2251,
        "description": "You are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (inclusive). You are also given a 0-indexed integer array people of size n, where poeple[i] is the time that the ith person will arrive to see the flowers.\nReturn an integer array answer of size n, where answer[i] is the number of flowers that are in full bloom when the ith person arrives.\n",
        "provided_code_snippet": "class Solution:\r\n    def fullBloomFlowers(self, flowers: List[List[int]], people: List[int]) -> List[int]:",
        "solution": "def fullBloomFlowers(self, A: List[List[int]], persons: List[int]) -> List[int]:\n        start, end = sorted(a for a,b in A), sorted(b for a,b in A)\n        return [bisect_right(start, t) - bisect_left(end, t) for t in persons]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2255": {
        "problem_id": 2255,
        "description": "You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.\nReturn the number of strings in words that are a prefix of s.\nA prefix of a string is a substring that occurs at the beginning of the string. A substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPrefixes(self, words: List[str], s: str) -> int:",
        "solution": "class Solution:\n    def countPrefixes(self, words: List[str], s: str) -> int:\n        count=0\n        for i in words:\n            if (s[:len(i)]==i):\n                count+=1\n        return count",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "int return",
                    "list argument",
                    "short",
                    "string argument",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions at the end",
                    "Given and Return",
                    "speaking method name",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2256": {
        "problem_id": 2256,
        "description": "You are given a 0-indexed integer array nums of length n.\nThe average difference of the index i is the absolute difference between the average of the first i + 1 elements of nums and the average of the last n - i - 1 elements. Both averages should be rounded down to the nearest integer.\nReturn the index with the minimum average difference. If there are multiple such indices, return the smallest one.\nNote:\n\t- The absolute difference of two numbers is the absolute value of their difference.\n\t- The average of n elements is the sum of the n elements divided (integer division) by n.\n\t- The average of 0 elements is considered to be 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumAverageDifference(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumAverageDifference(self, nums: List[int]) -> int:\n\n        sumEnd, sumFront, res, diff, n = 0, 0, 0, 1e9, len(nums)\n        for num in nums:\n            sumEnd += num\n\n        for i in range(n):\n            sumFront += nums[i]\n            sumEnd -= nums[i]\n\n            avg1 = sumEnd//(n-1-i) if i != n-1 else 0\n            avg2 = sumFront//(i+1)\n\n            if abs(avg1-avg2) < diff:\n                diff = abs(avg1-avg2)\n                res = i\n        \n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2257": {
        "problem_id": 2257,
        "description": "You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [rowi, coli] and walls[j] = [rowj, colj] represent the positions of the ith guard and jth wall respectively.\nA guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless obstructed by a wall or another guard. A cell is guarded if there is at least one guard that can see it.\nReturn the number of unoccupied cells that are not guarded.\n",
        "provided_code_snippet": "class Solution:\r\n    def countUnguarded(self, m: int, n: int, guards: List[List[int]], walls: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def countUnguarded(self, m: int, n: int, guards: List[List[int]], walls: List[List[int]]) -> int:\n        vis = [[0]*n for _ in range(m)]\n        # i - rows, j - colums\n        # sum(row.count('hit') for row in grid)\n        for i,j in walls:\n            vis[i][j] = 2\n        for i,j in guards:\n            vis[i][j] = 2\n        for i,j in guards:\n            for l in range(j-1,-1,-1):\n                if self.checkWall(i,l,vis):\n                    break    \n                vis[i][l] = 1\n            for r in range(j+1,n):\n                if self.checkWall(i,r,vis):\n                    break\n                vis[i][r] = 1\n            for u in range(i-1,-1,-1):\n                if self.checkWall(u,j,vis):\n                    break\n                vis[u][j] = 1\n            for d in range(i+1,m):\n                if self.checkWall(d,j, vis):\n                    break\n                vis[d][j] = 1\n        return sum(row.count(0) for row in vis)\n        \n    def checkWall(self, i, j, vis):\n        if vis[i][j] ==2:\n            return True",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2258": {
        "problem_id": 2258,
        "description": "You are given a 0-indexed 2D integer array grid of size m x n which represents a field. Each cell has one of three values:\n\t- 0 represents grass,\n\t- 1 represents fire,\n\t- 2 represents a wall that you and fire cannot pass through.\nYou are situated in the top-left cell, (0, 0), and you want to travel to the safehouse at the bottom-right cell, (m - 1, n - 1). Every minute, you may move to an adjacent grass cell. After your move, every fire cell will spread to all adjacent cells that are not walls.\nReturn the maximum number of minutes that you can stay in your initial position before moving while still safely reaching the safehouse. If this is impossible, return -1. If you can always reach the safehouse regardless of the minutes stayed, return 109.\nNote that even if the fire spreads to the safehouse immediately after you have reached it, it will be counted as safely reaching the safehouse.\nA cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumMinutes(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def maximumMinutes(self, grid):\n        m,n = len(grid),len(grid[0])\n\n        fires, dist = [], [[float(\"inf\")]*n for _ in range(m)]\n\n        for i in range(m):\n            for j in range(n):\n                if grid[i][j] == 1:\n                    fires.append((i,j,0))\n                    dist[i][j] = 0\n\n        while fires:\n            x,y,t = fires.pop(0)\n\n            for nx,ny in [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]:\n                if 0 <= nx <= m-1 and 0 <= ny <= n-1 and grid[nx][ny] == 0 and dist[nx][ny] > t+1:\n                    dist[nx][ny] = t+1\n                    fires.append((nx,ny,t+1))\n\n        def is_possible(t): \n            stack, visited = [(0,0,t)], [[0]*n for _ in range(m)]\n\n            while stack:\n                x,y,val = stack.pop(0)\n\n                for nx,ny in [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]:\n                    if nx == m-1 and ny == n-1 and val+1 <= dist[nx][ny]:\n                        return True\n\n                    if 0 <= nx <= m-1 and 0 <= ny <= n-1 and grid[nx][ny] == 0 and visited[nx][ny] == 0 and val+1 < dist[nx][ny]:\n                        stack.append((nx,ny,val+1))\n                        visited[nx][ny] = 1\n\n            return False\n\n        low, high = 0, 10**9\n\n        while low <= high:\n            mid = (low+high)//2\n\n            if is_possible(mid):\n                low = mid + 1\n            else:\n                high = mid - 1\n\n        return high",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2259": {
        "problem_id": 2259,
        "description": "You are given a string number representing a positive integer and a character digit.\nReturn the resulting string after removing exactly one occurrence of digit from number such that the value of the resulting string in decimal form is maximized. The test cases are generated such that digit occurs at least once in number.\n",
        "provided_code_snippet": "class Solution:\r\n    def removeDigit(self, number: str, digit: str) -> str:",
        "solution": "class Solution:\n    def removeDigit(self, number: str, digit: str) -> str:\n        \n        # Initializing the last index as zero\n        last_index = 0\n        \n        #iterating each number to find the occurences, \\\\\n        # and to find if the number is greater than the next element \\\\ \n\n        for num in range(1, len(number)):\n            \n            # Handling [case 1] and [case 2]\n            if number[num-1] == digit:\n                if int(number[num]) > int(number[num-1]):\n                    return number[:num-1] + number[num:]\n                else:\n                    last_index = num - 1\n        \n        # If digit is the last number (last occurence) in the string [case 3]\n        if number[-1] == digit:\n            last_index = len(number) - 1\n\n        return number[:last_index] + number[last_index + 1:]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2260": {
        "problem_id": 2260,
        "description": "You are given an integer array cards where cards[i] represents the value of the ith card. A pair of cards are matching if the cards have the same value.\nReturn the minimum number of consecutive cards you have to pick up to have a pair of matching cards among the picked cards. If it is impossible to have matching cards, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumCardPickup(self, cards: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumCardPickup(self, cards: List[int]) -> int:\n        minPick = float('inf')\n        seen = {}\n        for i, n in enumerate(cards):\n            if n in seen:\n                if i - seen[n] + 1 < minPick:\n                    minPick = i - seen[n] + 1\n            seen[n] = i\n        if minPick == float('inf'):\n            return -1\n        return minPick",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2261": {
        "problem_id": 2261,
        "description": "Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.\nTwo arrays nums1 and nums2 are said to be distinct if:\n\t- They are of different lengths, or\n\t- There exists at least one index i where nums1[i] != nums2[i].\nA subarray is defined as a non-empty contiguous sequence of elements in an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:",
        "solution": "class Solution:\n    def countDistinct(self, nums: List[int], k: int, p: int) -> int:\n        n = len(nums)                        \n        sub_arrays = set()\n        \n\t\t# generate all combinations of subarray\n        for start in range(n):\n            cnt = 0\n            temp = ''\n            for i in range(start, n):\n                if nums[i]%p == 0:\n                    cnt+=1                 \n                temp+=str(nums[i]) + ',' # build the sequence subarray in CSV format          \n                if cnt>k: # check for termination \n                    break\n                sub_arrays.add(temp)                                    \n                \n        return len(sub_arrays)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2262": {
        "problem_id": 2262,
        "description": "The appeal of a string is the number of distinct characters found in the string.\n\t- For example, the appeal of \"abbca\" is 3 because it has 3 distinct characters: 'a', 'b', and 'c'.\nGiven a string s, return the total appeal of all of its substrings.\nA substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def appealSum(self, s: str) -> int:",
        "solution": "class Solution:\n    def appealSum(self, s: str) -> int:\n        res, cur, prev = 0, 0, defaultdict(lambda: -1)\n        for i, ch in enumerate(s):\n            cur += i - prev[ch]\n            prev[ch] = i\n            res += cur\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2264": {
        "problem_id": 2264,
        "description": "You are given a string num representing a large integer. An integer is good if it meets the following conditions:\n\t- It is a substring of num with length 3.\n\t- It consists of only one unique digit.\nReturn the maximum good integer as a string or an empty string \"\" if no such integer exists.\nNote:\n\t- A substring is a contiguous sequence of characters within a string.\n\t- There may be leading zeroes in num or a good integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestGoodInteger(self, num: str) -> str:",
        "solution": "class Solution:\n    def largestGoodInteger(self, n: str) -> str:\n        return max(n[i-2:i+1] if n[i] == n[i - 1] == n[i - 2] else \"\" for i in range(2, len(n)))",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2265": {
        "problem_id": 2265,
        "description": "Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree.\nNote:\n\t- The average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.\n\t- A subtree of root is a tree consisting of root and all of its descendants.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def averageOfSubtree(self, root: Optional[TreeNode]) -> int:",
        "solution": "class Solution:\n    def __init__(self):\n        self.matchingSubtreeCount = 0  # Initialize the count of subtrees with matching averages.\n\n    # A Depth-First Search (DFS) function that returns a tuple of two values:\n    # - The sum of values within the current subtree.\n    # - The number of nodes within the current subtree.\n    def calculateSubtreeValues(self, currentNode):\n        if currentNode is None:\n            return 0, 0  # Base case: Return 0 for both sum and number of nodes if the node is None.\n\n        # Recursively calculate values for the left and right subtrees.\n        leftSubtree  = self.calculateSubtreeValues(currentNode.left)\n        rightSubtree = self.calculateSubtreeValues(currentNode.right)\n\n        # Calculate the sum of values and the number of nodes in the current subtree.\n        sumOfValues  = leftSubtree [0] + rightSubtree[0] + currentNode.val\n        numberOfNodes  = leftSubtree [1] + rightSubtree[1] + 1\n\n        # Check if the current node's value matches the average of its subtree.\n        if sumOfValues  // numberOfNodes  == currentNode.val:\n            self.matchingSubtreeCount += 1\n\n        return sumOfValues , numberOfNodes   # Return the calculated values for the current subtree.\n\n\n    def averageOfSubtree(self, root):\n        self.calculateSubtreeValues(root)  # Start the DFS from the root node.\n        return self.matchingSubtreeCount",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2266": {
        "problem_id": 2266,
        "description": "Alice is texting Bob using her phone. The mapping of digits to letters is shown in the figure below.\nIn order to add a letter, Alice has to press the key of the corresponding digit i times, where i is the position of the letter in the key.\n\t- For example, to add the letter 's', Alice has to press '7' four times. Similarly, to add the letter 'k', Alice has to press '5' twice.\n\t- Note that the digits '0' and '1' do not map to any letters, so Alice does not use them.\nHowever, due to an error in transmission, Bob did not receive Alice's text message but received a string of pressed keys instead.\n\t- For example, when Alice sent the message \"bob\", Bob received the string \"2266622\".\nGiven a string pressedKeys representing the string received by Bob, return the total number of possible text messages Alice could have sent.\nSince the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def countTexts(self, pressedKeys: str) -> int:",
        "solution": "class Solution:\n    def countTexts(self, pressedKeys: str) -> int:\n        MOD = 1_000_000_007 \n        \n        @cache \n        def fn(n, k): \n            \n            if n < 0: return 0\n            if n == 0: return 1\n            ans = 0\n            for x in range(1, k+1): ans = (ans + fn(n-x, k)) % MOD\n            return ans \n        \n        ans = 1\n        for key, grp in groupby(pressedKeys): \n            if key in \"79\": k = 4\n            else: k = 3\n            ans = (ans * fn(len(list(grp)), k)) % MOD \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2267": {
        "problem_id": 2267,
        "description": "A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:\n\t- It is ().\n\t- It can be written as AB (A concatenated with B), where A and B are valid parentheses strings.\n\t- It can be written as (A), where A is a valid parentheses string.\nYou are given an m x n matrix of parentheses grid. A valid parentheses string path in the grid is a path satisfying all of the following conditions:\n\t- The path starts from the upper left cell (0, 0).\n\t- The path ends at the bottom-right cell (m - 1, n - 1).\n\t- The path only ever moves down or right.\n\t- The resulting parentheses string formed by the path is valid.\nReturn true if there exists a valid parentheses string path in the grid. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def hasValidPath(self, grid: List[List[str]]) -> bool:",
        "solution": "class Solution:\n    def hasValidPath(self, grid: List[List[str]]) -> bool:  \n        m = len(grid)\n        n = len(grid[0])\n        @lru_cache(maxsize=None)\n        def hasValidPathInner(x, y, cnt):\n            # cnt variable would act as a counter to track \n            # the balance of parantheses sequence\n            if x == m or y == n or cnt < 0:\n                return False\n            \n            # logic to check the balance of sequence\n            cnt += 1 if grid[x][y] == '(' else -1\n            \n            # if balanced and end of grid, return True\n            if x == m - 1 and y == n - 1 and not cnt:\n                return True\n            \n            return hasValidPathInner(x + 1, y, cnt) or hasValidPathInner(x, y + 1, cnt)\n\n        return hasValidPathInner(0, 0, 0)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2269": {
        "problem_id": 2269,
        "description": "The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:\n\t- It has a length of k.\n\t- It is a divisor of num.\nGiven integers num and k, return the k-beauty of num.\nNote:\n\t- Leading zeros are allowed.\n\t- 0 is not a divisor of any value.\nA substring is a contiguous sequence of characters in a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def divisorSubstrings(self, num: int, k: int) -> int:",
        "solution": "def divisorSubstrings(self, num: int, k: int) -> int:\n        s=str(num)\n        c=0\n        for i in range(k,len(s)+1):\n            x=int(s[i-k:i])\n            if x!=0 and num%x==0:\n                c+=1\n        return c",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2270": {
        "problem_id": 2270,
        "description": "You are given a 0-indexed integer array nums of length n.\nnums contains a valid split at index i if the following are true:\n\t- The sum of the first i + 1 elements is greater than or equal to the sum of the last n - i - 1 elements.\n\t- There is at least one element to the right of i. That is, 0 <= i < n - 1.\nReturn the number of valid splits in nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def waysToSplitArray(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def waysToSplitArray(self, n: List[int]) -> int:\n        n = list(accumulate(n))\n        return sum(n[i] >= n[-1] - n[i] for i in range(len(n) - 1))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2271": {
        "problem_id": 2271,
        "description": "You are given a 2D integer array tiles where tiles[i] = [li, ri] represents that every tile j in the range li <= j <= ri is colored white.\nYou are also given an integer carpetLen, the length of a single carpet that can be placed anywhere.\nReturn the maximum number of white tiles that can be covered by the carpet.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumWhiteTiles(self, tiles: List[List[int]], carpetLen: int) -> int:",
        "solution": "def maximumWhiteTiles(self, tiles: List[List[int]], carpetLen: int) -> int:\n\ttiles.sort()\n\tmaxCover = 0\n\tstarts, ends = zip(*tiles)\n\tdp = [0]*(len(tiles) + 1) # dp: total covered lengths from 0\n\tfor i in range(len(tiles)):\n\t\tdp[i+1] = dp[i] + ends[i] - starts[i] + 1 # length of each tile is end - start + 1\n\tfor l in range(len(tiles)):\n\t\te = starts[l] + carpetLen\n\t\tr = bisect_right(starts, e)\n\t\tcover = dp[r] - dp[l] - max(0, ends[r-1] - e + 1) # total cover on the right MINUS total cover on the left MINUS offset\n\t\tmaxCover = max(maxCover, cover)\n\treturn maxCover",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2272": {
        "problem_id": 2272,
        "description": "The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string. Note the two characters may or may not be the same.\nGiven a string s consisting of lowercase English letters only, return the largest variance possible among all substrings of s.\nA substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestVariance(self, s: str) -> int:",
        "solution": "class Solution:\n    def largestVariance(self, s: str) -> int:\n        count1 = 0\n        count2 = 0\n        max_variance = 0\n        \n        # create distinct list of character pairs\n        pairs = [(l1, l2) for l1 in set(s) for l2 in set(s) if l1 != l2]\n\n        # run once for original string order, then again for reverse string order\n        for runs in range(2):\n            for pair in pairs:\n                count1 = count2 = 0\n                for letter in s:\n                    # no reason to process letters that aren't part of the current pair\n                    if letter not in pair:\n                        continue\n                    if letter == pair[0]:\n                        count1 += 1\n                    elif letter == pair[1]:\n                        count2 += 1\n                    if count1 < count2:\n                        count1 = count2 = 0\n                    elif count1 > 0 and count2 > 0:\n                        max_variance = max(max_variance, count1 - count2)\n                \n            \n            # reverse the string for the second time around\n            s = s[::-1]\n                \n        return max_variance",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2273": {
        "problem_id": 2273,
        "description": "You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.\nIn one operation, select any index i such that 0 < i < words.length and words[i - 1] and words[i] are anagrams, and delete words[i] from words. Keep performing this operation as long as you can select an index that satisfies the conditions.\nReturn words after performing all operations. It can be shown that selecting the indices for each operation in any arbitrary order will lead to the same result.\nAn Anagram is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. For example, \"dacb\" is an anagram of \"abdc\".\n",
        "provided_code_snippet": "class Solution:\r\n    def removeAnagrams(self, words: List[str]) -> List[str]:",
        "solution": "class Solution:\n    def removeAnagrams(self, w: List[str]) -> List[str]:\n        return [next(g) for _, g in groupby(w, sorted)]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "example",
                    "list argument",
                    "list return",
                    "math",
                    "one argument",
                    "pointless additional info",
                    "predicted to be unsolved"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions at the end",
                    "example",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2274": {
        "problem_id": 2274,
        "description": "Alice manages a company and has rented some floors of a building as office space. Alice has decided some of these floors should be special floors, used for relaxation only.\nYou are given two integers bottom and top, which denote that Alice has rented all the floors from bottom to top (inclusive). You are also given the integer array special, where special[i] denotes a special floor that Alice has designated for relaxation.\nReturn the maximum number of consecutive floors without a special floor.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxConsecutive(self, bottom: int, top: int, special: List[int]) -> int:",
        "solution": "class Solution:\n    def maxConsecutive(self, bottom: int, top: int, special: list[int]) -> int:\n        special.sort()\n        res = special[0] - bottom\n        \n        for i in range(1, len(special)):\n            res = max(res, special[i] - special[i - 1] - 1)\n            \n        return max(res, top - special[-1])",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "business",
                    "int return",
                    "list argument",
                    "short",
                    "story",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    ">3 parameters",
                    "array",
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "problem_theme",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2275": {
        "problem_id": 2275,
        "description": "The bitwise AND of an array nums is the bitwise AND of all integers in nums.\n\t- For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1.\n\t- Also, for nums = [7], the bitwise AND is 7.\nYou are given an array of positive integers candidates. Evaluate the bitwise AND of every combination of numbers of candidates. Each number in candidates may only be used once in each combination.\nReturn the size of the largest combination of candidates with a bitwise AND greater than 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestCombination(self, candidates: List[int]) -> int:",
        "solution": "class Solution:\n    def largestCombination(self, candidates: List[int]) -> int:\n        return max(sum(n & (1 << i) > 0 for n in candidates) for i in range(0, 24))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2278": {
        "problem_id": 2278,
        "description": "Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.\n",
        "provided_code_snippet": "class Solution:\r\n    def percentageLetter(self, s: str, letter: str) -> int:",
        "solution": "class Solution:\n    def percentageLetter(self, s: str, letter: str) -> int:\n        return int((s.count(letter) / len(s)) * 100)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "short",
                    "string argument",
                    "string manipulation",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2279": {
        "problem_id": 2279,
        "description": "You have n bags numbered from 0 to n - 1. You are given two 0-indexed integer arrays capacity and rocks. The ith bag can hold a maximum of capacity[i] rocks and currently contains rocks[i] rocks. You are also given an integer additionalRocks, the number of additional rocks you can place in any of the bags.\nReturn the maximum number of bags that could have full capacity after placing the additional rocks in some bags.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumBags(self, capacity: List[int], rocks: List[int], additionalRocks: int) -> int:",
        "solution": "class Solution:\r\n    def maximumBags(self, cap, rocks, addRocks):\r\n        return bisect_right(list(accumulate(sorted(starmap(sub,zip(cap,rocks))))),addRocks)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2280": {
        "problem_id": 2280,
        "description": "You are given a 2D integer array stockPrices where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei. A line chart is created from the array by plotting the points on an XY plane with the X-axis representing the day and the Y-axis representing the price and connecting adjacent points. One such example is shown below:\nReturn the minimum number of lines needed to represent the line chart.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumLines(self, stockPrices: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minimumLines(self, stockPrices: List[List[int]]) -> int:\n        # key point: never use devision to judge whether 3 points are on a same line or not, use the multiplication instead !!\n        \n        n = len(stockPrices)\n        stockPrices.sort(key = lambda x: (x[0], x[1]))\n        \n        if n == 1:\n            return 0\n        \n        pre_delta_y = stockPrices[0][1] - stockPrices[1][1]\n        pre_delta_x = stockPrices[0][0] - stockPrices[1][0]\n        num = 1\n        \n        for i in range(1, n-1):\n            cur_delta_y = stockPrices[i][1] - stockPrices[i+1][1]\n            cur_delta_x = stockPrices[i][0] - stockPrices[i+1][0]\n            \n            if pre_delta_y * cur_delta_x != pre_delta_x * cur_delta_y:\n                num += 1\n                pre_delta_x = cur_delta_x\n                pre_delta_y = cur_delta_y",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2281": {
        "problem_id": 2281,
        "description": "As the ruler of a kingdom, you have an army of wizards at your command.\nYou are given a 0-indexed integer array strength, where strength[i] denotes the strength of the ith wizard. For a contiguous group of wizards (i.e. the wizards' strengths form a subarray of strength), the total strength is defined as the product of the following two values:\n\t- The strength of the weakest wizard in the group.\n\t- The total of all the individual strengths of the wizards in the group.\nReturn the sum of the total strengths of all contiguous groups of wizards. Since the answer may be very large, return it modulo 109 + 7.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def totalStrength(self, strength: List[int]) -> int:",
        "solution": "class Solution:\n        \n        def totalStrength(self, strength: List[int]) -> int:\n            mod, n = 10 ** 9 + 7, len(strength)\n            \n            # Get the first index of the non-larger value to strength[i]'s right.\n            right_index = [n] * n\n            stack = []\n            for i in range(n):\n                while stack and strength[stack[-1]] >= strength[i]:\n                    right_index[stack.pop()] = i\n                stack.append(i)\n\n            # Get the first index of the smaller value to strength[i]'s left.\n            left_index = [-1] * n\n            stack = []\n            for i in range(n - 1, -1, -1):\n                while stack and strength[stack[-1]] > strength[i]:\n                    left_index[stack.pop()] = i\n                stack.append(i)\n                \n            # prefix sum of the prefix sum array of strength.\n            presum_of_presum =  list(accumulate(accumulate(strength, initial = 0), initial = 0))\n            answer = 0\n            # For each element in strength, we get the value of R_term - L_term.\n            for i in range(n):\n                # Get the left index and the right index.\n                left_bound = left_index[i]\n                right_bound = right_index[i]\n                \n                # Get the left_count and right_count (marked as L and R in the previous slides)\n                left_count = i - left_bound\n                right_count = right_bound - i\n                \n                # Get positive presum and the negative presum.\n                neg_presum = (presum_of_presum[i + 1] - presum_of_presum[i - left_count + 1]) % mod\n                pos_presum = (presum_of_presum[i + right_count + 1] - presum_of_presum[i + 1]) % mod\n                \n                # The total strength of all subarrays that have strength[i] as the minimum.\n                answer += strength[i] * (pos_presum * left_count - neg_presum * right_count)\n                answer %= mod\n                \n            return answer",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2283": {
        "problem_id": 2283,
        "description": "You are given a 0-indexed string num of length n consisting of digits.\nReturn true if for every index i in the range 0 <= i < n, the digit i occurs num[i] times in num, otherwise return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def digitCount(self, num: str) -> bool:",
        "solution": "class Solution:\n    def digitCount(self, num: str) -> bool:\n        for i in range(len(num)):\n            if int(num[i]) != num.count(str(i)):\n                return False\n        return True",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "bool return",
                    "math",
                    "one argument",
                    "short",
                    "string argument"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "string encoding",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2284": {
        "problem_id": 2284,
        "description": "You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i].\nA message is list of words that are separated by a single space with no leading or trailing spaces. The word count of a sender is the total number of words sent by the sender. Note that a sender may send more than one message.\nReturn the sender with the largest word count. If there is more than one sender with the largest word count, return the one with the lexicographically largest name.\nNote:\n\t- Uppercase letters come before lowercase letters in lexicographical order.\n\t- \"Alice\" and \"alice\" are distinct.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestWordCount(self, messages: List[str], senders: List[str]) -> str:",
        "solution": "class Solution:\n    def largestWordCount(self, messages: List[str], senders: List[str]) -> str:\n        d={}\n        l=[]\n        for i in range(len(messages)):\n            if senders[i] not in d:\n                d[senders[i]]=len(messages[i].split())\n            else:\n                d[senders[i]]+=len(messages[i].split())\n        x=max(d.values())\n        for k,v in d.items():\n            if v==x :\n                l.append(k)\n        if len(l)==1:\n            return l[0]\n        else:\n            l=sorted(l)[::-1]      #Lexigograhical sorting of list\n            return l[0]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "list argument",
                    "note",
                    "string return",
                    "two arguments",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "definitions in between",
                    "Given and Return",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2285": {
        "problem_id": 2285,
        "description": "You are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1.\nYou are also given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting cities ai and bi.\nYou need to assign each city with an integer value from 1 to n, where each value can only be used once. The importance of a road is then defined as the sum of the values of the two cities it connects.\nReturn the maximum total importance of all roads possible after assigning the values optimally.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumImportance(self, n: int, roads: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def maximumImportance(self, n: int, roads: List[List[int]]) -> int:\n        res = 0\n        cost = 1\n        conn = [0] * n\n        for road in roads:\n            conn[road[0]] += 1\n            conn[road[1]] += 1\n\n        conn.sort()\n        for con in conn:\n            res += con * cost\n            cost += 1\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2287": {
        "problem_id": 2287,
        "description": "You are given two 0-indexed strings s and target. You can take some letters from s and rearrange them to form new strings.\nReturn the maximum number of copies of target that can be formed by taking letters from s and rearranging them.\n",
        "provided_code_snippet": "class Solution:\r\n    def rearrangeCharacters(self, s: str, target: str) -> int:",
        "solution": "class Solution:\n    def rearrangeCharacters(self, s: str, target: str) -> int:\n        counter_s = Counter(s)        \n        return min(counter_s[c] // count for c,count in Counter(target).items())",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2288": {
        "problem_id": 2288,
        "description": "A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'. A word represents a price if it is a sequence of digits preceded by a dollar sign.\n\t- For example, \"$100\", \"$23\", and \"$6\" represent prices while \"100\", \"$\", and \"$1e5\" do not.\nYou are given a string sentence representing a sentence and an integer discount. For each word representing a price, apply a discount of discount% on the price and update the word in the sentence. All updated prices should be represented with exactly two decimal places.\nReturn a string representing the modified sentence.\nNote that all prices will contain at most 10 digits.\n",
        "provided_code_snippet": "class Solution:\r\n    def discountPrices(self, sentence: str, discount: int) -> str:",
        "solution": "class Solution:\n    def discountPrices(self, sentence: str, discount: int) -> str:\n        s = sentence.split() # convert to List to easily update\n        m = discount / 100 \n        for i,word in enumerate(s):\n            if word[0] == \"$\" and word[1:].isdigit(): # Check whether it is in correct format\n                num = int(word[1:]) * (1-m) # discounted price\n                w = \"$\" + \"{:.2f}\".format(num) #correctly format\n                s[i] = w #Change inside the list\n        \n        return \" \".join(s) #Combine the updated list",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2289": {
        "problem_id": 2289,
        "description": "You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length.\nReturn the number of steps performed until nums becomes a non-decreasing array.\n",
        "provided_code_snippet": "class Solution:\r\n    def totalSteps(self, nums: List[int]) -> int:",
        "solution": "def totalSteps(self, nums: List[int]) -> int:\n        res,stack = 0, []\n        for i in range(len(nums)-1,-1,-1):\n            cur = 0\n            while stack and nums[stack[-1][0]] int:",
        "solution": "def minimumObstacles(self, grid: List[List[int]]) -> int:\n        m, n = map(len, (grid, grid[0]))\n        dist = [[inf] * n for _ in range(m)]\n        dist[0][0] = grid[0][0]\n        hp = [(dist[0][0], 0, 0)]\n        while hp:\n            o, r, c = heappop(hp)\n            if (r, c) == (m - 1, n - 1):\n                return o\n            for i, j in (r + 1, c), (r - 1, c), (r, c + 1), (r, c - 1):\n                if m > i >= 0 <= j < n and grid[i][j] + o < dist[i][j]:\n                    dist[i][j] = grid[i][j] + o\n                    heappush(hp, (dist[i][j], i, j))",
        "submission_passed": true,
        "difficulty": "Hard",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "int return",
                    "list of rules",
                    "one argument",
                    "short",
                    "story"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    "Given and Return",
                    "List of rules to consider"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "problem_type",
            "function_input"
        ]
    },
    "2293": {
        "problem_id": 2293,
        "description": "You are given a 0-indexed integer array nums whose length is a power of 2.\nApply the following algorithm on nums:\n\t1. Let n be the length of nums. If n == 1, end the process. Otherwise, create a new 0-indexed integer array newNums of length n / 2.\n\t2. For every even index i where 0 <= i < n / 2, assign the value of newNums[i] as min(nums[2 * i], nums[2 * i + 1]).\n\t3. For every odd index i where 0 <= i < n / 2, assign the value of newNums[i] as max(nums[2 * i], nums[2 * i + 1]).\n\t4. Replace the array nums with newNums.\n\t5. Repeat the entire process starting from step 1.\nReturn the last number that remains in nums after applying the algorithm.\n",
        "provided_code_snippet": "class Solution:\r\n    def minMaxGame(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minMaxGame(self, nums: List[int]) -> int:                \n        l=nums\n        while len(l)>1:\n            is_min=True     \n            tmp=[]\n            for i in range(0, len(l), 2):\n                if is_min:\n                    tmp.append(min(l[i:i+2]))\n                else:\n                    tmp.append(max(l[i:i+2]))\n                is_min=not is_min            \n            l=tmp            \n        return l[0]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2294": {
        "problem_id": 2294,
        "description": "You are given an integer array nums and an integer k. You may partition nums into one or more subsequences such that each element in nums appears in exactly one of the subsequences.\nReturn the minimum number of subsequences needed such that the difference between the maximum and minimum values in each subsequence is at most k.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def partitionArray(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def partitionArray(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        ans = 1\n\t\t# To keep track of starting element of each subsequence\n        start = nums[0]\n        \n        for i in range(1, len(nums)):\n            diff = nums[i] - start\n            if diff > k:\n\t\t\t\t# If difference of starting and current element of subsequence is greater\n\t\t\t\t# than K, then only start new subsequence\n                ans += 1\n                start = nums[i]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "definition after description",
                    "int return",
                    "list argument",
                    "short",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "definitions at the end",
                    "Given and Return",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "description_order",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "function_input"
        ]
    },
    "2295": {
        "problem_id": 2295,
        "description": "You are given a 0-indexed array nums that consists of n distinct positive integers. Apply m operations to this array, where in the ith operation you replace the number operations[i][0] with operations[i][1].\nIt is guaranteed that in the ith operation:\n\t- operations[i][0] exists in nums.\n\t- operations[i][1] does not exist in nums.\nReturn the array obtained after applying all the operations.\n",
        "provided_code_snippet": "class Solution:\r\n    def arrayChange(self, nums: List[int], operations: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def arrayChange(self, nums: List[int], operations: List[List[int]]) -> List[int]:\n            replacements = {}\n            for x, y in reversed(operations):\n                replacements[x] = replacements.get(y, y)\n            for idx, val in enumerate(nums):\n                if val in replacements:\n                    nums[idx] = replacements[val]\n            return nums",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2299": {
        "problem_id": 2299,
        "description": "A password is said to be strong if it satisfies all the following criteria:\n\t- It has at least 8 characters.\n\t- It contains at least one lowercase letter.\n\t- It contains at least one uppercase letter.\n\t- It contains at least one digit.\n\t- It contains at least one special character. The special characters are the characters in the following string: \"!@#$%^&*()-+\".\n\t- It does not contain 2 of the same character in adjacent positions (i.e., \"aab\" violates this condition, but \"aba\" does not).\nGiven a string password, return true if it is a strong password. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def strongPasswordCheckerII(self, password: str) -> bool:",
        "solution": "def strongPasswordCheckerII(self, password: str) -> bool:\n        seen = set()\n        for i, c in enumerate(password):\n            if i > 0 and c == password[i - 1]:\n                return False\n            if c.isupper():\n                seen.add('u')\n            elif c.islower():\n                seen.add('l')\n            elif c.isdigit():\n                seen.add('d')             \n            else:\n                seen.add('s')\n        return  len(password) > 7 and len(seen) == 4",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2300": {
        "problem_id": 2300,
        "description": "You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents the strength of the jth potion.\nYou are also given an integer success. A spell and potion pair is considered successful if the product of their strengths is at least success.\nReturn an integer array pairs of length n where pairs[i] is the number of potions that will form a successful pair with the ith spell.\n",
        "provided_code_snippet": "class Solution:\r\n    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:",
        "solution": "class Solution:\n    def successfulPairs(self, spells, potions, success):\n        sorted_potions = sorted(potions)\n        result = []\n        for a in spells:\n            count = len(sorted_potions) - bisect_left(sorted_potions, (success + a - 1) // a)\n            result.append(count)\n        return result",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2301": {
        "problem_id": 2301,
        "description": "You are given two strings s and sub. You are also given a 2D character array mappings where mappings[i] = [oldi, newi] indicates that you may perform the following operation any number of times:\n\t- Replace a character oldi of sub with newi.\nEach character in sub cannot be replaced more than once.\nReturn true if it is possible to make sub a substring of s by replacing zero or more characters according to mappings. Otherwise, return false.\nA substring is a contiguous non-empty sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def matchReplacement(self, s: str, sub: str, mappings: List[List[str]]) -> bool:",
        "solution": "class Solution:\n    def matchReplacement(self, s: str, sub: str, mappings: List[List[str]]) -> bool:\n        s_maps = defaultdict(lambda : set())\n        for x,y in mappings:\n            s_maps[x].add(y)\n                \n        # build a sequence of set for substring match\n        # eg: sub=leet, mappings = {e: 3, t:7}\n        # subs = [{l}, {e, 3}, {e, 3}, {t, 7}]\n        # precalculation helps to eliminate TLE\n        subs = [s_maps[c] | {c} for c in sub] \n        \n        for i in range(len(s)-len(sub) + 1):\n            c=s[i]            \n            j=i\n            # Try to match substring\n            while j-i int:",
        "solution": "class Solution:\n    def countSubarrays(self, nums: List[int], k: int) -> int:\n        sum, res, j = 0, 0, 0\n        for i, n in enumerate(nums):\n            sum += n\n            while sum * (i - j + 1) >= k:\n                sum -= nums[j]\n                j += 1\n            res += i - j + 1\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2303": {
        "problem_id": 2303,
        "description": "You are given a 0-indexed 2D integer array brackets where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of percenti. The brackets are sorted by upper bound (i.e. upperi-1 < upperi for 0 < i < brackets.length).\nTax is calculated as follows:\n\t- The first upper0 dollars earned are taxed at a rate of percent0.\n\t- The next upper1 - upper0 dollars earned are taxed at a rate of percent1.\n\t- The next upper2 - upper1 dollars earned are taxed at a rate of percent2.\n\t- And so on.\nYou are given an integer income representing the amount of money you earned. Return the amount of money that you have to pay in taxes. Answers within 10-5 of the actual answer will be accepted.\n",
        "provided_code_snippet": "class Solution:\r\n    def calculateTax(self, brackets: List[List[int]], income: int) -> float:",
        "solution": "def calculateTax(self, brackets: List[List[int]], income: int) -> float:\n        tax = prev = 0\n        for upper, p in brackets:\n            if income >= upper:\n                tax += (upper - prev) * p / 100\n                prev = upper\n            else:\n                tax += (income - prev) * p / 100\n                return tax\n        return tax",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2304": {
        "problem_id": 2304,
        "description": "You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1. You can move in this matrix from a cell to any other cell in the next row. That is, if you are in cell (x, y) such that x < m - 1, you can move to any of the cells (x + 1, 0), (x + 1, 1), ..., (x + 1, n - 1). Note that it is not possible to move from cells in the last row.\nEach possible move has a cost given by a 0-indexed 2D array moveCost of size (m * n) x n, where moveCost[i][j] is the cost of moving from a cell with value i to a cell in column j of the next row. The cost of moving from cells in the last row of grid can be ignored.\nThe cost of a path in grid is the sum of all values of cells visited plus the sum of costs of all the moves made. Return the minimum cost of a path that starts from any cell in the first row and ends at any cell in the last row.\n",
        "provided_code_snippet": "class Solution:\r\n    def minPathCost(self, grid: List[List[int]], moveCost: List[List[int]]) -> int:",
        "solution": "def minPathCost(self, grid: List[List[int]], moveCost: List[List[int]]) -> int:\n        m, n = map(len, (grid, grid[0]))\n        min_cost = 0\n        cost = [grid[0][:]]\n        for r, row in enumerate(grid):\n            if r > 0:\n                cost.append([])\n                for c, cell in enumerate(row):\n                        cost[-1].append(cell + min(cost[-2][j] + moveCost[i][c] for j, i in enumerate(grid[r - 1])))\n        return min(cost[-1])",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2305": {
        "problem_id": 2305,
        "description": "You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.\nThe unfairness of a distribution is defined as the maximum total cookies obtained by a single child in the distribution.\nReturn the minimum unfairness of all distributions.\n",
        "provided_code_snippet": "class Solution:\r\n    def distributeCookies(self, cookies: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def distributeCookies(self, cookies: List[int], k: int) -> int:\n        def dfs(p):\n            nonlocal best\n            if p==len(cookies):\n                best = min(best, max(split))\n                return\n            # give to a new kid\n            if len(split) int:",
        "solution": "class Solution:\n  def distinctNames(self, ideas: List[str]) -> int:\n    ans = 0\n    # Group strings by initials\n    suffixes = [set() for _ in range(26)]\n\n    for idea in ideas:\n      suffixes[ord(idea[0]) - ord('a')].add(idea[1:])\n\n    for i in range(25):\n      for j in range(i + 1, 26):\n        count = len(suffixes[i] & suffixes[j])\n        ans += 2 * (len(suffixes[i]) - count) * (len(suffixes[j]) - count)\n\n    return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2309": {
        "problem_id": 2309,
        "description": "Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s. The returned letter should be in uppercase. If no such letter exists, return an empty string.\nAn English letter b is greater than another letter a if b appears after a in the English alphabet.\n",
        "provided_code_snippet": "class Solution:\r\n    def greatestLetter(self, s: str) -> str:",
        "solution": "class Solution:\n    def greatestLetter(self, s: str) -> str:\n        cnt = Counter(s)\n        return next((u for u in reversed(ascii_uppercase) if cnt[u] and cnt[u.lower()]), \"\")",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2310": {
        "problem_id": 2310,
        "description": "Given two integers num and k, consider a set of positive integers with the following properties:\n\t- The units digit of each integer is k.\n\t- The sum of the integers is num.\nReturn the minimum possible size of such a set, or -1 if no such set exists.\nNote:\n\t- The set can contain multiple instances of the same integer, and the sum of an empty set is considered 0.\n\t- The units digit of a number is the rightmost digit of the number.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumNumbers(self, num: int, k: int) -> int:",
        "solution": "\tdef minimumNumbers(self, num: int, k: int) -> int:\n        t = num%10\n        if num==0:\n            return 0\n        if num int:",
        "solution": "class Solution:\n    def longestSubsequence(self, s: str, k: int) -> int:\n        n = len(s)\n        ones = []\n\t\t# Notice how I reversed the string,\n\t\t# because the binary representation is written from greatest value of 2**n\n        for i, val in enumerate(s[::-1]):\n            if val == '1':\n                ones.append(i)\n\t\t# Initialize ans, there are already number of zeroes (num_of_zeroes = len(nums) - len(ones)\n        ans = n - len(ones)\n        i = 0\n\t\t# imagine k == 5 and binary string 001011\n\t\t# ones = [0, 1, 3]\n\t\t# first loop: 5 - 2**0 -> 4, ans += 1\n\t\t# second loop: 4 - 2**1 -> 2, ans +=1\n\t\t# Third loop does not occur because 2 - 2**3 -> -6 which is less than zero\n\t\t# So the ans is 3 + 2 = 5\n        while i < len(ones) and k - 2 ** ones[i] >= 0:\n            ans += 1\n            k -= 2 ** ones[i]\n            i += 1\n\t\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2312": {
        "problem_id": 2312,
        "description": "You are given two integers m and n that represent the height and width of a rectangular piece of wood. You are also given a 2D integer array prices, where prices[i] = [hi, wi, pricei] indicates you can sell a rectangular piece of wood of height hi and width wi for pricei dollars.\nTo cut a piece of wood, you must make a vertical or horizontal cut across the entire height or width of the piece to split it into two smaller pieces. After cutting a piece of wood into some number of smaller pieces, you can sell pieces according to prices. You may sell multiple pieces of the same shape, and you do not have to sell all the shapes. The grain of the wood makes a difference, so you cannot rotate a piece to swap its height and width.\nReturn the maximum money you can earn after cutting an m x n piece of wood.\nNote that you can cut the piece of wood as many times as you want.\n",
        "provided_code_snippet": "class Solution:\r\n    def sellingWood(self, m: int, n: int, prices: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def sellingWood(self, m: int, n: int, prices: List[List[int]]) -> int:\n\n        priceMap = {}\n        for p in prices:\n            if p[0] in priceMap:\n                priceMap[p[0]][p[1]] = p[2]\n            else:\n                priceMap[p[0]] = {p[1]: p[2]}\n\n        def getPrice(h, w):\n            if h in priceMap and w in priceMap[h]:\n                return priceMap[h][w]\n            return 0\n\n        @cache\n        def rec(h, w):\n            money = getPrice(h, w)\n\n            # cut horizontal\n            for i in range(1, h):\n                money = max(money, rec(i, w) + rec(h - i, w))\n\n            # cut vertical\n            for i in range(1, w):\n                money = max(money, rec(h, i) + rec(h, w - i))\n\n            return money\n\n        return rec(m, n)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2315": {
        "problem_id": 2315,
        "description": "You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth.\nReturn the number of '*' in s, excluding the '*' between each pair of '|'.\nNote that each '|' will belong to exactly one pair.\n",
        "provided_code_snippet": "class Solution:\r\n    def countAsterisks(self, s: str) -> int:",
        "solution": "def countAsterisks(self, s: str) -> int:\n        bar_even, star = True, 0\n        for c in s:\n            if c == '|':\n                bar_even = not bar_even\n            elif c == '*' and bar_even:\n                star += 1   \n        return star",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2316": {
        "problem_id": 2316,
        "description": "You are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nReturn the number of pairs of different nodes that are unreachable from each other.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPairs(self, n: int, edges: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def countPairs(self, n: int, edges: List[List[int]]) -> int:\n        def dfs(node):\n            if visited[node]:\n                return 0\n            visited[node] = True\n            res = 1\n            for nbr in graph[node]:\n                res += dfs(nbr)\n            return res\n        graph = {}\n        for i in range(n):\n            graph[i] = []\n        for edge in edges:\n            graph[edge[0]].append(edge[1])\n            graph[edge[1]].append(edge[0])\n            \n        visited = [False for _ in range(n)]\n        components = []\n        for node in range(n):\n            if visited[node] == False:\n                components.append(dfs(node))   \n        \n        ans = n * (n - 1) // 2\n        for k in components:\n            ans -= k * (k - 1) // 2\n        \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2317": {
        "problem_id": 2317,
        "description": "You are given a 0-indexed integer array nums. In one operation, select any non-negative integer x and an index i, then update nums[i] to be equal to nums[i] AND (nums[i] XOR x).\nNote that AND is the bitwise AND operation and XOR is the bitwise XOR operation.\nReturn the maximum possible bitwise XOR of all elements of nums after applying the operation any number of times.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumXOR(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def maximumXOR(self, nums: List[int]) -> int:\n        return reduce(lambda x,y: x|y, nums)\n\nclass Solution:\n    def maximumXOR(self, nums: List[int]) -> int:\n        return reduce(or_, nums)\n\nclass Solution:\n    def maximumXOR(self, nums: List[int]) -> int:\n        \n        ans = 0\n        for n in nums:\n            ans |= n      \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2318": {
        "problem_id": 2318,
        "description": "You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following conditions are satisfied:\n\t1. The greatest common divisor of any adjacent values in the sequence is equal to 1.\n\t2. There is at least a gap of 2 rolls between equal valued rolls. More formally, if the value of the ith roll is equal to the value of the jth roll, then abs(i - j) > 2.\nReturn the total number of distinct sequences possible. Since the answer may be very large, return it modulo 109 + 7.\nTwo sequences are considered distinct if at least one element is different.\n",
        "provided_code_snippet": "class Solution:\r\n    def distinctSequences(self, n: int) -> int:",
        "solution": "class Solution:\n    def distinctSequences(self, n: int) -> int:\n        \n        @lru_cache\n        def fn(n, p0, p1): \n            \n            if n == 0: return 1\n            ans = 0\n            for x in range(1, 7): \n                if x not in (p0, p1) and gcd(x, p0) == 1: ans += fn(n-1, x, p0)\n            return ans % 1_000_000_007\n        \n        return fn(n, -1, -1)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2319": {
        "problem_id": 2319,
        "description": "A square matrix is said to be an X-Matrix if both of the following conditions hold:\n\t1. All the elements in the diagonals of the matrix are non-zero.\n\t2. All other elements are 0.\nGiven a 2D integer array grid of size n x n representing a square matrix, return true if grid is an X-Matrix. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def checkXMatrix(self, grid: List[List[int]]) -> bool:",
        "solution": "class Solution:\n    def checkXMatrix(self, grid: List[List[int]]) -> bool:\n        i, k, j, N = 0, len(grid) - 1, 0, len(grid)\n\n        def isValid(r, c): # to check validity of co-ordinates\n            return r in range(0, N) and c in range(0, N)\n        \n        while isValid(i,j): # traverse primary and secondary diagonal\n            if grid[i][j] == 0: return 0 # checking 'X' Condition\n            if grid[k][j] == 0: return 0 # checking 'X' Condition\n            grid[i][j] = 0 # Falgging them 0\n            grid[k][j] = 0 # Falgging them 0\n            i += 1 # moving to next primary diagonal\n            j += 1 # Common column factor\n            k -= 1 # moving to next Secondary diagonal\n        \n        ans = 0\n# travsersing all the elements\n        for r in range(N): \n            for c in range(N): \n                ans += grid[r][c] # adding to cherck 'X' Condition at last\n        return not ans # as said return \"1 if 0\" or \"0 if otherwise\"",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2320": {
        "problem_id": 2320,
        "description": "There is a street with n * 2 plots, where there are n plots on each side of the street. The plots on each side are numbered from 1 to n. On each plot, a house can be placed.\nReturn the number of ways houses can be placed such that no two houses are adjacent to each other on the same side of the street. Since the answer may be very large, return it modulo 109 + 7.\nNote that if a house is placed on the ith plot on one side of the street, a house can also be placed on the ith plot on the other side of the street.\n",
        "provided_code_snippet": "class Solution:\r\n    def countHousePlacements(self, n: int) -> int:",
        "solution": "class Solution:\n    def countHousePlacements(self, n: int) -> int:\n        # the two sides of the roads are identical. We just need to count one side\n        self.dp = collections.defaultdict(lambda: None)\n        self.dp[0, 0] = 1  # the number cases not building house at index 0\n        self.dp[0, 1] = 2  # total cases: including building house and not building house at index 0\n        \n        idx = 1\n        while idx < n:\n            self.dp[idx, 0] = self.dp[idx - 1, 1]\n            self.dp[idx, 1] = self.dp[idx - 1, 1] + self.dp[idx - 1, 0]\n            idx += 1\n        \n        return (self.dp[n - 1, 1] * self.dp[n - 1, 1]) % 1000000007",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2321": {
        "problem_id": 2321,
        "description": "You are given two 0-indexed integer arrays nums1 and nums2, both of length n.\nYou can choose two integers left and right where 0 <= left <= right < n and swap the subarray nums1[left...right] with the subarray nums2[left...right].\n\t- For example, if nums1 = [1,2,3,4,5] and nums2 = [11,12,13,14,15] and you choose left = 1 and right = 2, nums1 becomes [1,12,13,4,5] and nums2 becomes [11,2,3,14,15].\nYou may choose to apply the mentioned operation once or not do anything.\nThe score of the arrays is the maximum of sum(nums1) and sum(nums2), where sum(arr) is the sum of all the elements in the array arr.\nReturn the maximum possible score.\nA subarray is a contiguous sequence of elements within an array. arr[left...right] denotes the subarray that contains the elements of nums between indices left and right (inclusive).\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumsSplicedArray(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def maximumsSplicedArray(self, nums1: List[int], nums2: List[int]) -> int:\n        # create a difference array between nums1 and nums2\n        # idea: find two subarray(elements are contiguous) in the diff\n        # one is the subarray that have the minimum negative sum\n        # another one is the subarray that have the maximum positive sum\n        # so there are four candidates for maximum score:\n        # 1. original_sum1 \n        # 2. original_sum \n        # 3. original_sum1 - min_negative_sum\n        # 4. original_sum2 + max_positive_sum\n        \n        original_sum1 = sum(nums1)\n        original_sum2 = sum(nums2)\n        diff = [num1 - num2 for num1, num2 in zip(nums1, nums2)]\n        min_negative_sum = float('inf')\n        max_positive_sum = - float('inf')\n        cur_negative_sum = 0\n        cur_positive_sum = 0\n        \n        for val in diff:\n            cur_negative_sum += val\n\n            if cur_negative_sum > 0:\n                cur_negative_sum = 0\n            \n            cur_positive_sum += val\n            \n            if cur_positive_sum < 0:\n                cur_positive_sum = 0\n                    \n            min_negative_sum = min(min_negative_sum, cur_negative_sum)\n            max_positive_sum = max(max_positive_sum, cur_positive_sum)\n\n        return max(original_sum1 - min_negative_sum, original_sum2 + max_positive_sum, original_sum2, original_sum1)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2322": {
        "problem_id": 2322,
        "description": "There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nRemove two distinct edges of the tree to form three connected components. For a pair of removed edges, the following steps are defined:\n\t- Get the XOR of all the values of the nodes for each of the three components respectively.\n\t- The difference between the largest XOR value and the smallest XOR value is the score of the pair.\n\t- For example, say the three components have the node values: [4,5,7], [1,9], and [3,3,3]. The three XOR values are 4 ^ 5 ^ 7 = 6, 1 ^ 9 = 8, and 3 ^ 3 ^ 3 = 3. The largest XOR value is 8 and the smallest XOR value is 3. The score is then 8 - 3 = 5.\nReturn the minimum score of any possible pair of edge removals on the given tree.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumScore(self, nums: List[int], edges: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minimumScore(self, nums: List[int], edges: List[List[int]]) -> int:        \n        n = len(nums)\n        graph = [[] for _ in range(n)]\n        for u, v in edges: \n            graph[u].append(v)\n            graph[v].append(u)\n            \n        def fn(u): \n            score[u] = nums[u]\n            child[u] = {u}\n            for v in graph[u]: \n                if seen[v] == 0: \n                    seen[v] = 1\n                    fn(v)\n                    score[u] ^= score[v]\n                    child[u] |= child[v]\n        \n        seen = [1] + [0]*(n-1)\n        score = [0]*n\n        child = [set() for _ in range(n)]\n        fn(0)\n        \n        ans = inf \n        for u in range(1, n): \n            for v in range(u+1, n): \n                if u in child[v]: \n                    uu = score[u]\n                    vv = score[v] ^ score[u]\n                    xx = score[0] ^ score[v]\n                elif v in child[u]: \n                    uu = score[u] ^ score[v]\n                    vv = score[v]\n                    xx = score[0] ^ score[u]\n                else: \n                    uu = score[u]\n                    vv = score[v]\n                    xx = score[0] ^ score[u] ^ score[v]\n                ans = min(ans, max(uu, vv, xx) - min(uu, vv, xx))\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2325": {
        "problem_id": 2325,
        "description": "You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:\n\t- Use the first appearance of all 26 lowercase English letters in key as the order of the substitution table.\n\t- Align the substitution table with the regular English alphabet.\n\t- Each letter in message is then substituted using the table.\n\t- Spaces ' ' are transformed to themselves.\n\t- For example, given key = \"happy boy\" (actual key would have at least one instance of each letter in the alphabet), we have the partial substitution table of ('h' -> 'a', 'a' -> 'b', 'p' -> 'c', 'y' -> 'd', 'b' -> 'e', 'o' -> 'f').\nReturn the decoded message.\n",
        "provided_code_snippet": "class Solution:\r\n    def decodeMessage(self, key: str, message: str) -> str:",
        "solution": "class Solution:\n    def decodeMessage(self, key: str, message: str) -> str:\n        mapping = {' ': ' '}\n        i = 0\n        res = ''\n        letters = 'abcdefghijklmnopqrstuvwxyz'\n        \n        for char in key:\n            if char not in mapping:\n                mapping[char] = letters[i]\n                i += 1\n        \n        for char in message:\n            res += mapping[char]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2326": {
        "problem_id": 2326,
        "description": "You are given two integers m and n, which represent the dimensions of a matrix.\nYou are also given the head of a linked list of integers.\nGenerate an m x n matrix that contains the integers in the linked list presented in spiral order (clockwise), starting from the top-left of the matrix. If there are remaining empty spaces, fill them with -1.\nReturn the generated matrix.\n",
        "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\r\nclass Solution:\r\n    def spiralMatrix(self, m: int, n: int, head: Optional[ListNode]) -> List[List[int]]:",
        "solution": "class Solution:\n    def spiralMatrix(self, m: int, n: int, \n                           head: ListNode) -> List[List[int]]:\n\n        ans = [[-1] * n for _ in range(m)]\n        ans[0][0], head = head.val, head.next\n        r, c, dr, dc, R, C = 0, 0, 0, 1, range(m), range(n)\n\n        while head:\n            if r+dr in R and c+dc in C and ans[r+dr][c+dc] == -1:\n                r+= dr ;  c+= dc \n                ans[r][c], head = head.val, head.next\n            else:                               \n                dr, dc = dc, -dr\n                \n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "data structure",
                    "list return",
                    "short",
                    "three arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    ">3 parameters",
                    "coded data type definition",
                    "Given and Return",
                    "linked list",
                    "matrix"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2327": {
        "problem_id": 2327,
        "description": "On day 1, one person discovers a secret.\nYou are given an integer delay, which means that each person will share the secret with a new person every day, starting from delay days after discovering the secret. You are also given an integer forget, which means that each person will forget the secret forget days after discovering it. A person cannot share the secret on the same day they forgot it, or on any day afterwards.\nGiven an integer n, return the number of people who know the secret at the end of day n. Since the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def peopleAwareOfSecret(self, n: int, delay: int, forget: int) -> int:",
        "solution": "class Solution:\n    def peopleAwareOfSecret(self, n: int, d: int, f: int) -> int:\n        dp, md = [1] + [0] * (f - 1), 10**9 + 7\n        for i in range(1, n):\n            dp[i % f] = (md + dp[(i + f - d) % f] - dp[i % f] + (0 if i == 1 else dp[(i - 1) % f])) % md\n        return sum(dp) % md",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2328": {
        "problem_id": 2328,
        "description": "You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions.\nReturn the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may be very large, return it modulo 109 + 7.\nTwo paths are considered different if they do not have exactly the same sequence of visited cells.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPaths(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def countPaths(self, grid: List[List[int]]) -> int:\n        noOfRows, noOfCols, res = len(grid), len(grid[0]), 0\n        dp = [[-1 for _ in range(noOfCols)] for _ in range(noOfRows)]\n        \n        def dfs(row: int, col: int, prev: int, dp: List[List[int]], grid: List[List[int]]) -> int:\n            directions = [[0, 1], [0, -1], [1, 0], [-1, 0]]\n            if row < 0 or col < 0 or row >= len(grid) or col >= len(grid[0]) or grid[row][col] <= prev:\n                return 0\n            if dp[row][col] != -1: \n                return dp[row][col]\n            ans = 1\n            for direction in directions:\n                newRow, newCol = row + direction[0], col + direction[1]\n                ans += dfs(newRow, newCol, grid[row][col], dp, grid)\n            dp[row][col] = ans\n            return ans\n        \n        for row in range(noOfRows):\n            for col in range(noOfCols):\n                res += dfs(row, col, -1, dp, grid)\n        return res % (10 ** 9 + 7)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2331": {
        "problem_id": 2331,
        "description": "You are given the root of a full binary tree with the following properties:\n\t- Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.\n\t- Non-leaf nodes have either the value 2 or 3, where 2 represents the boolean OR and 3 represents the boolean AND.\nThe evaluation of a node is as follows:\n\t- If the node is a leaf node, the evaluation is the value of the node, i.e. True or False.\n\t- Otherwise, evaluate the node's two children and apply the boolean operation of its value with the children's evaluations.\nReturn the boolean result of evaluating the root node.\nA full binary tree is a binary tree where each node has either 0 or 2 children.\nA leaf node is a node that has zero children.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def evaluateTree(self, root: Optional[TreeNode]) -> bool:",
        "solution": "# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def helper(self, root):\n        if root.val == 0 or root.val == 1:\n            return root.val == 1\n        elif root.val == 2:\n            return self.helper(root.left) or self.helper(root.right)\n        elif root.val == 3:\n            return self.helper(root.left) and self.helper(root.right)\n        return False\n        \n    def evaluateTree(self, root: Optional[TreeNode]) -> bool:\n        return self.helper(root)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2332": {
        "problem_id": 2332,
        "description": "You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the ith bus. You are also given a 0-indexed integer array passengers of length m, where passengers[j] represents the arrival time of the jth passenger. All bus departure times are unique. All passenger arrival times are unique.\nYou are given an integer capacity, which represents the maximum number of passengers that can get on each bus.\nWhen a passenger arrives, they will wait in line for the next available bus. You can get on a bus that departs at x minutes if you arrive at y minutes where y <= x, and the bus is not full. Passengers with the earliest arrival times get on the bus first.\nMore formally when a bus arrives, either:\n\t- If capacity or fewer passengers are waiting for a bus, they will all get on the bus, or\n\t- The capacity passengers with the earliest arrival times will get on the bus.\nReturn the latest time you may arrive at the bus station to catch a bus. You cannot arrive at the same time as another passenger.\nNote: The arrays buses and passengers are not necessarily sorted.\n",
        "provided_code_snippet": "class Solution:\r\n    def latestTimeCatchTheBus(self, buses: List[int], passengers: List[int], capacity: int) -> int:",
        "solution": "class Solution:\n    def latestTimeCatchTheBus(self, buses: List[int], passengers: List[int], capacity: int) -> int:\n        buses.sort()\n        passengers.sort()\n        \n        passenger = 0\n        for bus in buses:\n            maxed_out = False\n            cap = capacity\n            \n            while passenger < len(passengers) and passengers[passenger] <= bus and cap != 0:\n                passenger += 1\n                cap -= 1\n                \n            if cap == 0:\n                maxed_out = True\n                \n        if maxed_out:\n            max_seat = passengers[passenger - 1]\n        else:\n            max_seat = buses[-1]\n    \n        booked = set(passengers)\n        for seat in range(max_seat, 0, -1):\n            if seat not in booked:\n                return seat",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2333": {
        "problem_id": 2333,
        "description": "You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n.\nThe sum of squared difference of arrays nums1 and nums2 is defined as the sum of (nums1[i] - nums2[i])2 for each 0 <= i < n.\nYou are also given two positive integers k1 and k2. You can modify any of the elements of nums1 by +1 or -1 at most k1 times. Similarly, you can modify any of the elements of nums2 by +1 or -1 at most k2 times.\nReturn the minimum sum of squared difference after modifying array nums1 at most k1 times and modifying array nums2 at most k2 times.\nNote: You are allowed to modify the array elements to become negative integers.\n",
        "provided_code_snippet": "class Solution:\r\n    def minSumSquareDiff(self, nums1: List[int], nums2: List[int], k1: int, k2: int) -> int:",
        "solution": "class Solution:\n    def minSumSquareDiff(self, nums1: List[int], nums2: List[int], k1: int, k2: int) -> int:\n        freq = Counter(abs(x1-x2) for x1, x2 in zip(nums1, nums2) if x1 != x2)\n        pq = [(-k, v) for k, v in freq.items()]\n        heapify(pq)\n        k1 += k2\n        while pq and k1: \n            x, v = heappop(pq)\n            if pq: xx, vv = heappop(pq)\n            else: xx = vv = 0\n            diff = xx - x\n            if diff * v <= k1: \n                k1 -= diff * v \n                if vv: heappush(pq, (xx, v+vv))\n            else: \n                q, r = divmod(k1, v)\n                k1 = 0\n                heappush(pq, (x+q+1, r))\n                heappush(pq, (x+q, v-r))\n                if vv: heappush(pq, (xx, vv))\n        return sum(x*x*v for x, v in pq)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2334": {
        "problem_id": 2334,
        "description": "You are given an integer array nums and an integer threshold.\nFind any subarray of nums of length k such that every element in the subarray is greater than threshold / k.\nReturn the size of any such subarray. If there is no such subarray, return -1.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def validSubarraySize(self, nums: List[int], threshold: int) -> int:",
        "solution": "class Solution:\n    def validSubarraySize(self, nums: List[int], threshold: int) -> int:\n                            \n        nums.append(0)\n        stack = deque()\n\n        for idx in range(len(nums)):\n\n            while stack and nums[idx] <= nums[stack[-1]]:     # n is the next smaller          \n                n = nums[stack.pop()]                         # value for nums[idx]\n                k = idx if not stack else idx - stack[-1] -1        \n                if n > threshold //k: return k                # threshold criterion. if n\n                                                              # passes, all elements\n                                                              # of the interval pass\n            stack.append(idx)\n\n        return -1",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2335": {
        "problem_id": 2335,
        "description": "You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up 2 cups with different types of water, or 1 cup of any type of water.\nYou are given a 0-indexed integer array amount of length 3 where amount[0], amount[1], and amount[2] denote the number of cold, warm, and hot water cups you need to fill respectively. Return the minimum number of seconds needed to fill up all the cups.\n",
        "provided_code_snippet": "class Solution:\r\n    def fillCups(self, amount: List[int]) -> int:",
        "solution": "class Solution:\n    def fillCups(self, amount: List[int]) -> int:\n        pq = [-q for q in amount if q != 0]\n        heapq.heapify(pq)\n        ret = 0\n        \n        while len(pq) > 1:\n            first = heapq.heappop(pq)\n            second = heapq.heappop(pq)\n            first += 1\n            second += 1\n            ret += 1\n            if first:\n                heapq.heappush(pq, first)\n            if second:\n                heapq.heappush(pq, second)\n\n        if pq:\n            return ret - pq[0]\n        else:\n            return ret",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2337": {
        "problem_id": 2337,
        "description": "You are given two strings start and target, both of length n. Each string consists only of the characters 'L', 'R', and '_' where:\n\t- The characters 'L' and 'R' represent pieces, where a piece 'L' can move to the left only if there is a blank space directly to its left, and a piece 'R' can move to the right only if there is a blank space directly to its right.\n\t- The character '_' represents a blank space that can be occupied by any of the 'L' or 'R' pieces.\nReturn true if it is possible to obtain the string target by moving the pieces of the string start any number of times. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def canChange(self, start: str, target: str) -> bool:",
        "solution": "def canChange(self, start: str, target: str) -> bool:\n        if start.replace('_', '') != target.replace('_', ''):\n            return False\n        i = j = 0\n        n = len(start)\n        while i < n and j < n:\n            while i < n and start[i] == '_':\n                i += 1\n            while j < n and target[j] == '_':\n                j += 1\n            if i < n and j < n and (start[i] == 'L' and i < j or start[i] == 'R' and i > j):\n                return False\n            i += 1\n            j += 1\n        return True",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2338": {
        "problem_id": 2338,
        "description": "You are given two integers n and maxValue, which are used to describe an ideal array.\nA 0-indexed integer array arr of length n is considered ideal if the following conditions hold:\n\t- Every arr[i] is a value from 1 to maxValue, for 0 <= i < n.\n\t- Every arr[i] is divisible by arr[i - 1], for 0 < i < n.\nReturn the number of distinct ideal arrays of length n. Since the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def idealArrays(self, n: int, maxValue: int) -> int:",
        "solution": "class Solution:\n    def idealArrays(self, n: int, maxValue: int) -> int:\n        ans = maxValue\n        freq = {x : 1 for x in range(1, maxValue+1)}\n        for k in range(1, n): \n            temp = Counter()\n            for x in freq: \n                for m in range(2, maxValue//x+1): \n                    ans += comb(n-1, k)*freq[x]\n                    temp[m*x] += freq[x]\n            freq = temp\n            ans %= 1_000_000_007\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2341": {
        "problem_id": 2341,
        "description": "You are given a 0-indexed integer array nums. In one operation, you may do the following:\n\t- Choose two integers in nums that are equal.\n\t- Remove both integers from nums, forming a pair.\nThe operation is done on nums as many times as possible.\nReturn a 0-indexed integer array answer of size 2 where answer[0] is the number of pairs that are formed and answer[1] is the number of leftover integers in nums after doing the operation as many times as possible.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfPairs(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution(object):\n    def numberOfPairs(self, nums):\n        hashT = {}\n        for n in nums:\n            if n not in hashT: hashT[n] = 1\n            else: hashT[n] += 1\n        pairs, rem = 0, 0\n        for n in hashT:\n            pairs += (hashT[n] // 2)\n            rem += (hashT[n] % 2)\n        return [pairs, rem]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2342": {
        "problem_id": 2342,
        "description": "You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of the number nums[i] is equal to that of nums[j].\nReturn the maximum value of nums[i] + nums[j] that you can obtain over all possible indices i and j that satisfy the conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumSum(self, nums: List[int]) -> int:",
        "solution": "class Solution:     \r\n    def maximumSum(self, nums: List[int]) -> int:\r\n        d, mx = defaultdict(list), -1\r\n        digits = lambda x: sum(map(int, list(str(x))))      # <-- sum-of-digits function\r\n       \r\n        for n in nums:                  <-- construct max-heaps\r\n            heappush(d[digits(n)],-n)       (note \"-n\") \r\n\r\n        for i in d:                     <-- pop the two greatest values off\r\n            if len(d[i]) > 1:               each maxheap (when possible) and\r\n                mx= max(mx, -heappop(d[i])-heappop(d[i]))   #     compare with current max value.\r\n                                                           \r\n        return mx",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2343": {
        "problem_id": 2343,
        "description": "You are given a 0-indexed array of strings nums, where each string is of equal length and consists of only digits.\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [ki, trimi]. For each queries[i], you need to:\n\t- Trim each number in nums to its rightmost trimi digits.\n\t- Determine the index of the kith smallest trimmed number in nums. If two trimmed numbers are equal, the number with the lower index is considered to be smaller.\n\t- Reset each number in nums to its original length.\nReturn an array answer of the same length as queries, where answer[i] is the answer to the ith query.\nNote:\n\t- To trim to the rightmost x digits means to keep removing the leftmost digit, until only x digits remain.\n\t- Strings in nums may contain leading zeros.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestTrimmedNumbers(self, nums: List[str], queries: List[List[int]]) -> List[int]:",
        "solution": "def smallestTrimmedNumbers(self, nums: List[str], queries: List[List[int]]) -> List[int]:\n        ans, trimmed = [], {}\n        for k, trim in queries:\n            trimmed.setdefault(trim, sorted([(num[-trim :], i) for i, num in enumerate(nums)]))\n            ans.append(trimmed[trim][k - 1][1])\n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "list argument",
                    "list of rules",
                    "list return",
                    "medium long",
                    "note",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "2D array",
                    "array",
                    "Given and Return",
                    "List of rules to consider",
                    "Note with extra constraints"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2344": {
        "problem_id": 2344,
        "description": "You are given two positive integer arrays nums and numsDivide. You can delete any number of elements from nums.\nReturn the minimum number of deletions such that the smallest element in nums divides all the elements of numsDivide. If this is not possible, return -1.\nNote that an integer x divides y if y % x == 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def minOperations(self, nums: List[int], numsDivide: List[int]) -> int:",
        "solution": "def minOperations(self, nums: List[int], numsDivide: List[int]) -> int:\n        \n        def gcd(a, b) -> int:\n            while b > 0:\n                a, b = b, a % b\n            return a\n        \n        g = functools.reduce(gcd, numsDivide)\n        smallest = min([num for num in nums if g % num == 0], default = inf)\n        return -1 if smallest == inf else sum(smallest > num for num in nums)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2347": {
        "problem_id": 2347,
        "description": "You are given an integer array ranks and a character array suits. You have 5 cards where the ith card has a rank of ranks[i] and a suit of suits[i].\nThe following are the types of poker hands you can make from best to worst:\n\t1. \"Flush\": Five cards of the same suit.\n\t2. \"Three of a Kind\": Three cards of the same rank.\n\t3. \"Pair\": Two cards of the same rank.\n\t4. \"High Card\": Any single card.\nReturn a string representing the best type of poker hand you can make with the given cards.\nNote that the return values are case-sensitive.\n",
        "provided_code_snippet": "class Solution:\r\n    def bestHand(self, ranks: List[int], suits: List[str]) -> str:",
        "solution": "def bestHand(self, ranks: List[int], suits: List[str]) -> str:\n        if len(set(suits)) == 1:\n            return \"Flush\"\n        match max(Counter(ranks).values()):\n            case 3 | 4 | 5:\n                return \"Three of a Kind\"\n            case 2:\n                return \"Pair\"\n            case _:\n                return \"High Card\"",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2348": {
        "problem_id": 2348,
        "description": "Given an integer array nums, return the number of subarrays filled with 0.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def zeroFilledSubarray(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def zeroFilledSubarray(self, nums: List[int]) -> int:\n        total_zero_subarrays = current_zero_subarrays = 0\n                \n        for num in nums:\n            if num == 0:\n                current_zero_subarrays += 1\n                total_zero_subarrays += current_zero_subarrays\n            else:\n                current_zero_subarrays = 0\n                \n        return total_zero_subarrays",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2350": {
        "problem_id": 2350,
        "description": "You are given an integer array rolls of length n and an integer k. You roll a k sided dice numbered from 1 to k, n times, where the result of the ith roll is rolls[i].\nReturn the length of the shortest sequence of rolls that cannot be taken from rolls.\nA sequence of rolls of length len is the result of rolling a k sided dice len times.\nNote that the sequence taken does not have to be consecutive as long as it is in order.\n",
        "provided_code_snippet": "class Solution:\r\n    def shortestSequence(self, rolls: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def shortestSequence(self, rolls: List[int], k: int) -> int:\n        s = set()\n        res = 0\n        \n        for r in rolls:\n            s.add(r)\n            if len(s) == k:        # All possible number has appeared once.\n                res += 1           # So you must \"at least\" use one more place to store it.\n                s.clear()          # Clear the set.",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2351": {
        "problem_id": 2351,
        "description": "Given a string s consisting of lowercase English letters, return the first letter to appear twice.\nNote:\n\t- A letter a appears twice before another letter b if the second occurrence of a is before the second occurrence of b.\n\t- s will contain at least one letter that appears twice.\n",
        "provided_code_snippet": "class Solution:\r\n    def repeatedCharacter(self, s: str) -> str:",
        "solution": "class Solution:\n    def repeatedCharacter(self, s: str) -> str:\n        \n        setS = set()\n\n        for x in s:\n            if x in setS:\n                return x\n            else:\n                setS.add(x)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "note",
                    "one argument",
                    "short",
                    "string argument",
                    "string manipulation",
                    "string return"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "Note with extra constraints",
                    "very short"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2352": {
        "problem_id": 2352,
        "description": "Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal.\nA row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array).\n",
        "provided_code_snippet": "class Solution:\r\n    def equalPairs(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:                                \n    def equalPairs(self, grid: List[List[int]]) -> int:\n\n        tpse = Counter(zip(*grid))                  # <-- determine the transpose\n                                                    #     and hash the rows\n\n        grid = Counter(map(tuple,grid))             # <-- hash the rows of grid. (Note the tuple-map, so\n                                                    #     we can compare apples w/ apples in next step.)\n\n        return  sum(tpse[t]*grid[t] for t in tpse)  # <-- compute the number of identical pairs",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2354": {
        "problem_id": 2354,
        "description": "You are given a 0-indexed positive integer array nums and a positive integer k.\nA pair of numbers (num1, num2) is called excellent if the following conditions are satisfied:\n\t- Both the numbers num1 and num2 exist in the array nums.\n\t- The sum of the number of set bits in num1 OR num2 and num1 AND num2 is greater than or equal to k, where OR is the bitwise OR operation and AND is the bitwise AND operation.\nReturn the number of distinct excellent pairs.\nTwo pairs (a, b) and (c, d) are considered distinct if either a != c or b != d. For example, (1, 2) and (2, 1) are distinct.\nNote that a pair (num1, num2) such that num1 == num2 can also be excellent if you have at least one occurrence of num1 in the array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def countExcellentPairs(self, nums: List[int], k: int) -> int:\n        hamming = sorted([self.hammingWeight(num) for num in set(nums)])\n        ans = 0\n        for h in hamming:\n            ans += len(hamming) - bisect.bisect_left(hamming, k - h)\n        return ans\n        \n    def hammingWeight(self, n):\n        ans = 0\n        while n:\n            n &= (n - 1)\n            ans += 1\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2357": {
        "problem_id": 2357,
        "description": "You are given a non-negative integer array nums. In one operation, you must:\n\t- Choose a positive integer x such that x is less than or equal to the smallest non-zero element in nums.\n\t- Subtract x from every positive element in nums.\nReturn the minimum number of operations to make every element in nums equal to 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumOperations(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumOperations(self, nums: List[int]) -> int:\n        return len(set(nums) - {0})",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2358": {
        "problem_id": 2358,
        "description": "You are given a positive integer array grades which represents the grades of students in a university. You would like to enter all these students into a competition in ordered non-empty groups, such that the ordering meets the following conditions:\n\t- The sum of the grades of students in the ith group is less than the sum of the grades of students in the (i + 1)th group, for all groups (except the last).\n\t- The total number of students in the ith group is less than the total number of students in the (i + 1)th group, for all groups (except the last).\nReturn the maximum number of groups that can be formed.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumGroups(self, grades: List[int]) -> int:",
        "solution": "class Solution:\r\n    def maximumGroups(self, grades: List[int]) -> int:\r\n        \r\n        x = len(grades)\r\n        n = 0.5 * ((8 * x + 1) ** 0.5 - 1)\r\n        ans = int(n)\r\n        \r\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2359": {
        "problem_id": 2359,
        "description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from i, then edges[i] == -1.\nYou are also given two integers node1 and node2.\nReturn the index of the node that can be reached from both node1 and node2, such that the maximum between the distance from node1 to that node, and from node2 to that node is minimized. If there are multiple answers, return the node with the smallest index, and if no possible answer exists, return -1.\nNote that edges may contain cycles.\n",
        "provided_code_snippet": "class Solution:\r\n    def closestMeetingNode(self, edges: List[int], node1: int, node2: int) -> int:",
        "solution": "class Solution:\n    def dfs(self, node, dist, edges, dis):\n        \n        # iterate until we reach the end of the edge or a node that has already been visited\n        while node != -1 and dis[node] == -1:\n            dis[node] = dist\n            dist += 1 # update distance of current node\n            node = edges[node] # move to next node\n\n    def closestMeetingNode(self, edges, node1, node2):\n        \n        res, min_dist, n = -1, float('inf'), len(edges)\n        # create distance vectors for both nodes\n        dist1, dist2 = [-1]*n, [-1]*n\n        # perform DFS starting from node1 and node2\n        self.dfs(node1, 0, edges, dist1)\n        self.dfs(node2, 0, edges, dist2)\n\n        # iterate through all nodes\n        for i in range(n):\n            # check if current node is the closest meeting point\n            if min(dist1[i], dist2[i]) >= 0 and max(dist1[i], dist2[i]) < min_dist:\n                min_dist = max(dist1[i], dist2[i])\n                res = i\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2360": {
        "problem_id": 2360,
        "description": "You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.\nThe graph is represented with a given 0-indexed array edges of size n, indicating that there is a directed edge from node i to node edges[i]. If there is no outgoing edge from node i, then edges[i] == -1.\nReturn the length of the longest cycle in the graph. If no cycle exists, return -1.\nA cycle is a path that starts and ends at the same node.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestCycle(self, edges: List[int]) -> int:",
        "solution": "class Solution:\n  def longestCycle(self, edges: List[int]) -> int:\n    ans = -1  # Initialize the answer to -1\n    time = 1  # Initialize the current time step to 1\n    timeVisited = [0] * len(edges)  # Initialize a list to store the time at which each node was first visited\n\n    # Iterate through each node in the graph\n    for i, edge in enumerate(edges):\n      if timeVisited[i]:  # If the node has already been visited, skip it\n        continue\n      startTime = time  # Record the start time of the current traversal\n      u = i  # Initialize the current node to the ith node\n      # Traverse the graph until the end of the path is reached or a visited node is encountered\n      while u != -1 and not timeVisited[u]:\n        timeVisited[u] = time  # Record the current time step\n        time += 1  # Increment time\n        u = edges[u]  # Move to the next node in the path\n      # If a cycle is found that includes the current node, update the answer\n      if u != -1 and timeVisited[u] >= startTime:\n        ans = max(ans, time - timeVisited[u])\n\n    return ans  # Return the length of the longest cycle found",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2363": {
        "problem_id": 2363,
        "description": "You are given two 2D integer arrays, items1 and items2, representing two sets of items. Each array items has the following properties:\n\t- items[i] = [valuei, weighti] where valuei represents the value and weighti represents the weight of the ith item.\n\t- The value of each item in items is unique.\nReturn a 2D integer array ret where ret[i] = [valuei, weighti], with weighti being the sum of weights of all items with value valuei.\nNote: ret should be returned in ascending order by value.\n",
        "provided_code_snippet": "class Solution:\r\n    def mergeSimilarItems(self, items1: List[List[int]], items2: List[List[int]]) -> List[List[int]]:",
        "solution": "def mergeSimilarItems(self, items1: List[List[int]], items2: List[List[int]]) -> List[List[int]]:\n        cnt = Counter()\n        for v, w in items1 + items2:\n            cnt[v] += w\n        return sorted(cnt.items())",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2364": {
        "problem_id": 2364,
        "description": "You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i < j and j - i != nums[j] - nums[i].\nReturn the total number of bad pairs in nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def countBadPairs(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def countBadPairs(self, nums: List[int]) -> int:\n        nums_len = len(nums)\n        count_dict = dict()\n        for i in range(nums_len):\n            nums[i] -= i\n            if nums[i] not in count_dict:\n                count_dict[nums[i]] = 0\n            count_dict[nums[i]] += 1\n        \n        count = 0\n        for key in count_dict:\n            count += math.comb(count_dict[key], 2)\n        return math.comb(nums_len, 2) - count",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2365": {
        "problem_id": 2365,
        "description": "You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the ith task.\nYou are also given a positive integer space, which represents the minimum number of days that must pass after the completion of a task before another task of the same type can be performed.\nEach day, until all tasks have been completed, you must either:\n\t- Complete the next task from tasks, or\n\t- Take a break.\nReturn the minimum number of days needed to complete all tasks.\n",
        "provided_code_snippet": "class Solution:\r\n    def taskSchedulerII(self, tasks: List[int], space: int) -> int:",
        "solution": "import math\nclass Solution:\n    def taskSchedulerII(self, tasks: List[int], space: int) -> int:\n        count_dict = {}\n        total_days = 0\n        for task in tasks:\n            if task not in count_dict:\n                count_dict[task] = -math.inf\n            total_days = max(total_days + 1, count_dict[task] + space + 1)\n            count_dict[task] = total_days\n        return total_days",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2366": {
        "problem_id": 2366,
        "description": "You are given a 0-indexed integer array nums. In one operation you can replace any element of the array with any two elements that sum to it.\n\t- For example, consider nums = [5,6,7]. In one operation, we can replace nums[1] with 2 and 4 and convert nums to [5,2,4,7].\nReturn the minimum number of operations to make an array that is sorted in non-decreasing order.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumReplacement(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumReplacement(self, nums: List[int]) -> int:\n        n = len(nums)\n        last = nums[n - 1]  # Initialize 'last' with the last element\n        ans = 0  # Initialize the total operations count\n\n        # Traverse the array in reverse order\n        for i in range(n - 2, -1, -1):\n            if nums[i] > last:  # If the current element needs replacement\n                t = nums[i] // last  # Calculate how many times the element needs to be divided\n                if nums[i] % last:\n                    t += 1  # If there's a remainder, increment 't'\n                last = nums[i] // t  # Update 'last' for the next comparison\n                ans += t - 1  # Add (t - 1) to 'ans' for the number of operations\n            else:\n                last = nums[i]  # Update 'last' without replacement\n        return ans  # Return the total number of operations",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2367": {
        "problem_id": 2367,
        "description": "You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following conditions are met:\n\t- i < j < k,\n\t- nums[j] - nums[i] == diff, and\n\t- nums[k] - nums[j] == diff.\nReturn the number of unique arithmetic triplets.\n",
        "provided_code_snippet": "class Solution:\r\n    def arithmeticTriplets(self, nums: List[int], diff: int) -> int:",
        "solution": "class Solution:\n    def arithmeticTriplets(self, nums: List[int], diff: int) -> int:\n        counter = 0\n        n = len(nums)\n        for i in range(n):\n            for j in range(i + 1, n):\n                for k in range(j + 1, n):\n                    if nums[k] - nums[j] == diff and nums[j] - nums[i] == diff:\n                        counter += 1\n        return counter",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "definition",
                    "int return",
                    "list argument",
                    "list of rules",
                    "math",
                    "short",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "Given and Return",
                    "List of rules to consider"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2368": {
        "problem_id": 2368,
        "description": "There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.\nYou are given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given an integer array restricted which represents restricted nodes.\nReturn the maximum number of nodes you can reach from node 0 without visiting a restricted node.\nNote that node 0 will not be a restricted node.\n",
        "provided_code_snippet": "class Solution:\r\n    def reachableNodes(self, n: int, edges: List[List[int]], restricted: List[int]) -> int:",
        "solution": "def reachableNodes(self, n: int, edges: List[List[int]], restricted: List[int]) -> int:\n        seen = set(restricted)\n        g = defaultdict(set)\n        for a, b in edges:\n            g[a].add(b)\n            g[b].add(a)\n        dq = deque([0])\n        while dq:\n            node = dq.popleft()\n            seen.add(node)\n            for kid in g[node]:\n                if kid not in seen:\n                    seen.add(kid)\n                    dq.append(kid)\n        return len(seen) - len(restricted)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2369": {
        "problem_id": 2369,
        "description": "You are given a 0-indexed integer array nums. You have to partition the array into one or more contiguous subarrays.\nWe call a partition of the array valid if each of the obtained subarrays satisfies one of the following conditions:\n\t1. The subarray consists of exactly 2, equal elements. For example, the subarray [2,2] is good.\n\t2. The subarray consists of exactly 3, equal elements. For example, the subarray [4,4,4] is good.\n\t3. The subarray consists of exactly 3 consecutive increasing elements, that is, the difference between adjacent elements is 1. For example, the subarray [3,4,5] is good, but the subarray [1,3,5] is not.\nReturn true if the array has at least one valid partition. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def validPartition(self, nums: List[int]) -> bool:",
        "solution": "class Solution:\n    def validPartition(self, nums: List[int]) -> bool:\n        n = len(nums) \n\n        # If the array has only one element, then not possible to partition into valid subarrays \n        if n == 1: \n            return False \n\n        # Initialization for the first three values \n        dp = [True, False, nums[0] == nums[1] if n > 1 else False] \n\n        for i in range(2, n): \n            current_dp = False \n\n            # Check for 2 equal elements \n            if nums[i] == nums[i-1] and dp[1]: \n                current_dp = True \n\n            # Check for 3 equal elements \n            elif nums[i] == nums[i-1] == nums[i-2] and dp[0]: \n                current_dp = True \n\n            # Check for 3 consecutive increasing elements \n            elif nums[i] - nums[i-1] == 1 and nums[i-1] - nums[i-2] == 1 and dp[0]: \n                current_dp = True \n\n            # Move the window forward \n            dp[0], dp[1], dp[2] = dp[1], dp[2], current_dp \n\n        return dp[2]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2370": {
        "problem_id": 2370,
        "description": "You are given a string s consisting of lowercase letters and an integer k. We call a string t ideal if the following conditions are satisfied:\n\t- t is a subsequence of the string s.\n\t- The absolute difference in the alphabet order of every two adjacent letters in t is less than or equal to k.\nReturn the length of the longest ideal string.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nNote that the alphabet order is not cyclic. For example, the absolute difference in the alphabet order of 'a' and 'z' is 25, not 1.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestIdealString(self, s: str, k: int) -> int:",
        "solution": "class Solution:\n    def longestIdealString(self, s: str, k: int) -> int:\n        dp = [0] * 27\n        n = len(s)\n\n        for i in range(n - 1, -1, -1):\n            cc = s[i]\n            idx = ord(cc) - ord('a')\n            maxi = float('-inf')\n\n            left = max((idx - k), 0)\n            right = min((idx + k), 26)\n\n            for j in range(left, right + 1):\n                maxi = max(maxi, dp[j])\n\n            dp[idx] = maxi + 1\n\n        return max(dp)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2373": {
        "problem_id": 2373,
        "description": "You are given an n x n integer matrix grid.\nGenerate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:\n\t- maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1.\nIn other words, we want to find the largest value in every contiguous 3 x 3 matrix in grid.\nReturn the generated matrix.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def largestLocal(self, grid: List[List[int]]) -> List[List[int]]:\n        n, res = len(grid), []\n\n        for i in range(1, n - 1):\n            temp_row = []\n            for j in range(1, n - 1):\n                temp = 0\n\n                for k in range(i - 1, i + 2):\n                    for l in range(j - 1, j + 2):\n                        temp = max(temp, grid[k][l])\n\n                temp_row.append(temp)\n            res.append(temp_row)\n\n        return res",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "2d array",
                    "further clarification",
                    "list argument",
                    "list return",
                    "math",
                    "one argument",
                    "variables unclear"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "formal clarification",
                    "Given and Return",
                    "matrix"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "impreciseness",
            "problem_domain",
            "input/output_wording",
            "description_building_block",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2374": {
        "problem_id": 2374,
        "description": "You are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge.\nThe graph is represented by a given 0-indexed integer array edges of length n, where edges[i] indicates that there is a directed edge from node i to node edges[i].\nThe edge score of a node i is defined as the sum of the labels of all the nodes that have an edge pointing to i.\nReturn the node with the highest edge score. If multiple nodes have the same edge score, return the node with the smallest index.\n",
        "provided_code_snippet": "class Solution:\r\n    def edgeScore(self, edges: List[int]) -> int:",
        "solution": "def edgeScore(self, edges: List[int]) -> int:\n\tscore = defaultdict(int)\n\n\tfor u, v in enumerate(edges):\n\t\tscore[v] += u\n\n\treturn max(score, key=lambda x: (score[x], -x))",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "condition",
                    "graph",
                    "int return",
                    "list argument",
                    "math",
                    "medium long",
                    "one argument",
                    "optimisation",
                    "predicted to be solved"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "array",
                    "complex sentences (where, if, which)",
                    "definitions in between",
                    "graph",
                    "Sentence with >25 words"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "length_of_problem",
            "description_order",
            "output",
            "data_structure",
            "prediction",
            "sentences",
            "problem_type",
            "function_input"
        ]
    },
    "2375": {
        "problem_id": 2375,
        "description": "You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.\nA 0-indexed string num of length n + 1 is created using the following conditions:\n\t- num consists of the digits '1' to '9', where each digit is used at most once.\n\t- If pattern[i] == 'I', then num[i] < num[i + 1].\n\t- If pattern[i] == 'D', then num[i] > num[i + 1].\nReturn the lexicographically smallest possible string num that meets the conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestNumber(self, pattern: str) -> str:",
        "solution": "class Solution:\n    def smallestNumber(self, pattern: str) -> str:\n        ans = [1]\n        for ch in pattern: \n            if ch == 'I': \n                m = ans[-1]+1\n                while m in ans: m += 1\n                ans.append(m)\n            else: \n                ans.append(ans[-1])\n                for i in range(len(ans)-1, 0, -1): \n                    if ans[i-1] == ans[i]: ans[i-1] += 1\n        return ''.join(map(str, ans))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2376": {
        "problem_id": 2376,
        "description": "We call a positive integer special if all of its digits are distinct.\nGiven a positive integer n, return the number of special integers that belong to the interval [1, n].\n",
        "provided_code_snippet": "class Solution:\r\n    def countSpecialNumbers(self, n: int) -> int:",
        "solution": "class Solution:\n    def countSpecialNumbers(self, n: int) -> int:\n        vals = list(map(int, str(n)))\n        \n        @cache\n        def fn(i, m, on): \n            \n            ans = 0 \n            if i == len(vals): return 1\n            for v in range(vals[i] if on else 10 ): \n                if m & 1< int:",
        "solution": "def minimumRecolors(self, blocks: str, k: int) -> int:\n        lo, white, mi = -1, 0, inf\n        for hi, c in enumerate(blocks):\n            if c == 'W':\n                white += 1\n            if hi - lo >= k:\n                mi = min(white, mi)\n                lo += 1\n                white -= blocks[lo] == 'W' \n        return mi",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "int return",
                    "short",
                    "string argument",
                    "two arguments"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return",
                    "string encoding"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "input/output_wording",
            "length_of_problem",
            "output",
            "data_structure",
            "prediction",
            "function_input"
        ]
    },
    "2380": {
        "problem_id": 2380,
        "description": "You are given a binary string s. In one second, all occurrences of \"01\" are simultaneously replaced with \"10\". This process repeats until no occurrences of \"01\" exist.\nReturn the number of seconds needed to complete this process.\n",
        "provided_code_snippet": "class Solution:\r\n    def secondsToRemoveOccurrences(self, s: str) -> int:",
        "solution": "class Solution: \n    def secondsToRemoveOccurrences(self, s: str) -> int:\n        ans = prefix = prev = 0 \n        for i, ch in enumerate(s): \n            if ch == '1': \n                ans = max(prev, i - prefix)\n                prefix += 1\n                if ans: prev = ans+1\n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [
            {
                "researcher_id": 1,
                "tags": [
                    "base",
                    "int return",
                    "one argument",
                    "short",
                    "string argument",
                    "string manipulation",
                    "time"
                ]
            },
            {
                "researcher_id": 2,
                "tags": [
                    "Given and Return"
                ]
            }
        ],
        "solution_tags": [],
        "categories": [
            "problem_domain",
            "input/output_wording",
            "length_of_problem",
            "output",
            "prediction",
            "function_input"
        ]
    },
    "2381": {
        "problem_id": 2381,
        "description": "You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni]. For every i, shift the characters in s from the index starti to the index endi (inclusive) forward if directioni = 1, or shift the characters backward if directioni = 0.\nShifting a character forward means replacing it with the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Similarly, shifting a character backward means replacing it with the previous letter in the alphabet (wrapping around so that 'a' becomes 'z').\nReturn the final string after all such shifts to s are applied.\n",
        "provided_code_snippet": "class Solution:\r\n    def shiftingLetters(self, s: str, shifts: List[List[int]]) -> str:",
        "solution": "class Solution:\n    def shiftingLetters(self, s: str, shifts: List[List[int]]) -> str:\n        cum_shifts = [0 for _ in range(len(s)+1)]\n        \n        for st, end, d in shifts:\n            if d == 0:\n                cum_shifts[st] -= 1\n                cum_shifts[end+1] += 1\n            else:\n                cum_shifts[st] += 1\n                cum_shifts[end+1] -= 1\n        \n        cum_sum = 0\n        for i in range(len(s)):\n            cum_sum += cum_shifts[i]\n            \n            new_code = (((ord(s[i]) + cum_sum) - 97) % 26) + 97\n            s = s[:i] + chr(new_code) + s[i+1:]\n        \n        return s",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2382": {
        "problem_id": 2382,
        "description": "You are given two 0-indexed integer arrays nums and removeQueries, both of length n. For the ith query, the element in nums at the index removeQueries[i] is removed, splitting nums into different segments.\nA segment is a contiguous sequence of positive integers in nums. A segment sum is the sum of every element in a segment.\nReturn an integer array answer, of length n, where answer[i] is the maximum segment sum after applying the ith removal.\nNote: The same index will not be removed more than once.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumSegmentSum(self, nums: List[int], removeQueries: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def maximumSegmentSum(self, nums: List[int], removeQueries: List[int]) -> List[int]:\n        mp, cur, res = {}, 0, []\n        for q in reversed(removeQueries[1:]):\n            mp[q] = (nums[q], 1)\n            rv, rLen = mp.get(q+1, (0, 0))\n            lv, lLen = mp.get(q-1, (0, 0))\n                \n            total = nums[q] + rv + lv\n            mp[q+rLen] = (total, lLen + rLen + 1)\n            mp[q-lLen] = (total, lLen + rLen + 1)\n        \n            cur = max(cur, total)\n            res.append(cur)\n            \n        return res[::-1] + [0]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2383": {
        "problem_id": 2383,
        "description": "You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively.\nYou are also given two 0-indexed integer arrays energy and experience, both of length n.\nYou will face n opponents in order. The energy and experience of the ith opponent is denoted by energy[i] and experience[i] respectively. When you face an opponent, you need to have both strictly greater experience and energy to defeat them and move to the next opponent if available.\nDefeating the ith opponent increases your experience by experience[i], but decreases your energy by energy[i].\nBefore starting the competition, you can train for some number of hours. After each hour of training, you can either choose to increase your initial experience by one, or increase your initial energy by one.\nReturn the minimum number of training hours required to defeat all n opponents.\n",
        "provided_code_snippet": "class Solution:\r\n    def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int], experience: List[int]) -> int:",
        "solution": "class Solution:\n    def minNumberOfHours(self, initialEnergy: int, initialExperience: int, energy: List[int], experience: List[int]) -> int:\n        \n        ans = 0\n        n = len(energy)\n\n        for i in range(n):\n            while initialEnergy <= energy[i] or initialExperience <= experience[i]:\n                if initialEnergy <= energy[i]:\n                    initialEnergy += 1\n                    ans += 1\n                if initialExperience <= experience[i]:\n                    initialExperience += 1\n                    ans += 1\n            initialEnergy -= energy[i]\n            initialExperience += experience[i]\n        \n        return ans",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2384": {
        "problem_id": 2384,
        "description": "You are given a string num consisting of digits only.\nReturn the largest palindromic integer (in the form of a string) that can be formed using digits taken from num. It should not contain leading zeroes.\nNotes:\n\t- You do not need to use all the digits of num, but you must use at least one digit.\n\t- The digits can be reordered.\n",
        "provided_code_snippet": "class Solution:\r\n    def largestPalindromic(self, num: str) -> str:",
        "solution": "class Solution:\n    def largestPalindromic(self, num: str) -> str:\n\n        ans = []\n        b = [str(x) for x in range(9, -1, -1)]\n        from collections import defaultdict\n\n        a = defaultdict(int)\n\n        for x in num:\n            a[x] += 1\n\n        for x in b:\n            n = len(ans)\n            if n % 2 == 0:\n                if a[x] > 0:\n                    ans = ans[:n // 2] + [x] * a[x] + ans[n // 2:]\n            else:\n                if x == '0':\n                    if len(ans) != 1:\n                        ans = ans[:n // 2] + [x] * (a[x] // 2) + [ans[n // 2]] + [x] * (a[x] // 2) + ans[n // 2 + 1:]\n                else:\n                    if a[x] >= 2:\n                        ans = ans[:n // 2] + [x] * (a[x] // 2) + [ans[n // 2]] + [x] * (a[x] // 2) + ans[n // 2 + 1:]\n\n        res = \"\".join(ans)\n        return str(int(res))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2385": {
        "problem_id": 2385,
        "description": "You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start.\nEach minute, a node becomes infected if:\n\t- The node is currently uninfected.\n\t- The node is adjacent to an infected node.\nReturn the number of minutes needed for the entire tree to be infected.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def amountOfTime(self, root: Optional[TreeNode], start: int) -> int:",
        "solution": "class Solution:\n    def amountOfTime(self, root: Optional[TreeNode], start: int) -> int:\n        def dfs(node):\n            if node is None:\n                return\n            if node.left:\n                graph[node.val].append(node.left.val)\n                graph[node.left.val].append(node.val)\n            if node.right:\n                graph[node.val].append(node.right.val)\n                graph[node.right.val].append(node.val)\n            dfs(node.left)\n            dfs(node.right)\n\n        graph = defaultdict(list)\n        dfs(root)\n        visited = set()\n        queue = deque([start])\n        time = -1\n        while queue:\n            time += 1\n            for _ in range(len(queue)):\n                current_node = queue.popleft()\n                visited.add(current_node)\n                for neighbor in graph[current_node]:\n                    if neighbor not in visited:\n                        queue.append(neighbor)\n        return time",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2386": {
        "problem_id": 2386,
        "description": "You are given an integer array nums and a positive integer k. You can choose any subsequence of the array and sum all of its elements together.\nWe define the K-Sum of the array as the kth largest subsequence sum that can be obtained (not necessarily distinct).\nReturn the K-Sum of the array.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\nNote that the empty subsequence is considered to have a sum of 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def kSum(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def kSum(self, nums: List[int], k: int) -> int:\n        maxSum = sum([max(0, num) for num in nums])\n        absNums = sorted([abs(num) for num in nums])\n        maxHeap = [(-maxSum + absNums[0], 0)]\n        ans = [maxSum]\n        while len(ans) < k:\n            nextSum, i = heapq.heappop(maxHeap)\n            heapq.heappush(ans, -nextSum)\n            if i + 1 < len(absNums):\n                heapq.heappush(maxHeap, (nextSum - absNums[i] + absNums[i + 1], i + 1))\n                heapq.heappush(maxHeap, (nextSum + absNums[i + 1], i + 1))\n        return ans[0]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2389": {
        "problem_id": 2389,
        "description": "You are given an integer array nums of length n, and an integer array queries of length m.\nReturn an array answer of length m where answer[i] is the maximum size of a subsequence that you can take from nums such that the sum of its elements is less than or equal to queries[i].\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def answerQueries(self, nums: List[int], queries: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def answerQueries(self, nums: List[int], queries: List[int]) -> List[int]:\n        nums = list(accumulate(sorted(nums)))\n        return [bisect_right(nums, q) for q in queries]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2390": {
        "problem_id": 2390,
        "description": "You are given a string s, which contains stars *.\nIn one operation, you can:\n\t- Choose a star in s.\n\t- Remove the closest non-star character to its left, as well as remove the star itself.\nReturn the string after all stars have been removed.\nNote:\n\t- The input will be generated such that the operation is always possible.\n\t- It can be shown that the resulting string will always be unique.\n",
        "provided_code_snippet": "class Solution:\r\n    def removeStars(self, s: str) -> str:",
        "solution": "class Solution:\n    def removeStars(self, s: str) -> str:\n        res = []\n        for i in s:\n            if i != '*':\n                res.append(i)\n            elif res:\n                res.pop()\n        return ''.join(res)",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2391": {
        "problem_id": 2391,
        "description": "You are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the ith house. garbage[i] consists only of the characters 'M', 'P' and 'G' representing one unit of metal, paper and glass garbage respectively. Picking up one unit of any type of garbage takes 1 minute.\nYou are also given a 0-indexed integer array travel where travel[i] is the number of minutes needed to go from house i to house i + 1.\nThere are three garbage trucks in the city, each responsible for picking up one type of garbage. Each garbage truck starts at house 0 and must visit each house in order; however, they do not need to visit every house.\nOnly one garbage truck may be used at any given moment. While one truck is driving or picking up garbage, the other two trucks cannot do anything.\nReturn the minimum number of minutes needed to pick up all the garbage.\n",
        "provided_code_snippet": "class Solution:\r\n    def garbageCollection(self, garbage: List[str], travel: List[int]) -> int:",
        "solution": "class Solution:\n    def garbageCollection(self, garbage: List[str], travel: List[int]) -> int:\n        res = 0\n        \n        for g in garbage:\n            res += len(g)\n\n        m, p, g = False, False, False\n\n        for i in range(len(travel), 0, -1):\n            m = m or 'M' in garbage[i]\n            p = p or 'P' in garbage[i]\n            g = g or 'G' in garbage[i]\n\n            res += travel[i-1] * (m + p + g)\n        \n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2392": {
        "problem_id": 2392,
        "description": "You are given a positive integer k. You are also given:\n\t- a 2D integer array rowConditions of size n where rowConditions[i] = [abovei, belowi], and\n\t- a 2D integer array colConditions of size m where colConditions[i] = [lefti, righti].\nThe two arrays contain integers from 1 to k.\nYou have to build a k x k matrix that contains each of the numbers from 1 to k exactly once. The remaining cells should have the value 0.\nThe matrix should also satisfy the following conditions:\n\t- The number abovei should appear in a row that is strictly above the row at which the number belowi appears for all i from 0 to n - 1.\n\t- The number lefti should appear in a column that is strictly left of the column at which the number righti appears for all i from 0 to m - 1.\nReturn any matrix that satisfies the conditions. If no answer exists, return an empty matrix.\n",
        "provided_code_snippet": "class Solution:\r\n    def buildMatrix(self, k: int, rowConditions: List[List[int]], colConditions: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def buildMatrix(self, k: int, rowConditions: list[list[int]], colConditions: list[list[int]]) -> list[list[int]]:\n        # return True if all okay and return False if cycle was found\n        def dfs(src, graph, visited, cur_path, res) -> bool:\n            if src in cur_path:\n                return False  # cycle detected\n\n            if src in visited:\n                return True  # all okay, but we've already visited this node\n\n            visited.add(src)\n            cur_path.add(src)\n\n            for neighbor in graph[src]:\n                if not dfs(neighbor, graph, visited, cur_path, res):  # if any child returns false\n                    return False\n\n            cur_path.remove(src)  # backtrack path\n            res.append(src)\n            return True\n\n        # if there will be cycle - return empty array, in other case return 1d array as described above\n        def topo_sort(edges) -> list[int]:\n            graph = defaultdict(list)\n            for src, dst in edges:\n                graph[src].append(dst)\n\n            visited: set[int] = set()\n            cur_path: set[int] = set()\n            res: list[int] = []\n\n            for src in range(1, k + 1, 1):\n                if not dfs(src, graph, visited, cur_path, res):\n                    return []\n\n            return res[::-1]  # we will have res as reversed so we need to reverse it one more time\n\n        row_sorting: list[int] = topo_sort(rowConditions)\n        col_sorting: list[int] = topo_sort(colConditions)\n        if [] in (row_sorting, col_sorting):\n            return []\n\n        value_position: dict[int, list[int]] = {\n            n: [0, 0] for n in range(1, k + 1, 1)\n        }  # element -> [row_index, col_index]\n        for ind, val in enumerate(row_sorting):\n            value_position[val][0] = ind\n        for ind, val in enumerate(col_sorting):\n            value_position[val][1] = ind\n\n        res: list[list[int]] = [[0 for _ in range(k)] for _ in range(k)]\n        for value in range(1, k + 1, 1):\n            row, column = value_position[value]\n            res[row][column] = value\n\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2395": {
        "problem_id": 2395,
        "description": "Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum. Note that the two subarrays must begin at different indices.\nReturn true if these subarrays exist, and false otherwise.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def findSubarrays(self, nums: List[int]) -> bool:",
        "solution": "def findSubarrays(self, nums: List[int]) -> bool:\n        seen = set()\n        for i in range(len(nums)-1):\n            s = nums[i] + nums[i+1]\n            if s in seen:\n                return True\n            seen.add(s)\n        return False",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2396": {
        "problem_id": 2396,
        "description": "An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.\nGiven an integer n, return true if n is strictly palindromic and false otherwise.\nA string is palindromic if it reads the same forward and backward.\n",
        "provided_code_snippet": "class Solution:\r\n    def isStrictlyPalindromic(self, n: int) -> bool:",
        "solution": "class Solution:\n    def isStrictlyPalindromic(self, n: int) -> bool:\n        return False",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2397": {
        "problem_id": 2397,
        "description": "You are given a 0-indexed m x n binary matrix matrix and an integer numSelect, which denotes the number of distinct columns you must select from matrix.\nLet us consider s = {c1, c2, ...., cnumSelect} as the set of columns selected by you. A row row is covered by s if:\n\t- For each cell matrix[row][col] (0 <= col <= n - 1) where matrix[row][col] == 1, col is present in s or,\n\t- No cell in row has a value of 1.\nYou need to choose numSelect columns such that the number of rows that are covered is maximized.\nReturn the maximum number of rows that can be covered by a set of numSelect columns.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumRows(self, matrix: List[List[int]], numSelect: int) -> int:",
        "solution": "class Solution:\n    def maximumRows(self, mat: List[List[int]], cols: int) -> int:\n        n,m = len(mat),len(mat[0])\n        ans = 0\n\n        def check(state,row,rowIncludedCount):\n            nonlocal ans\n            if row==n:\n                if sum(state)<=cols:\n                    ans = max(ans,rowIncludedCount)\n                return\n            \n            check(state[::],row+1,rowIncludedCount)\n            for j in range(m):\n                if mat[row][j]==1:\n                    state[j] = 1\n            check(state,row+1,rowIncludedCount+1)\n        \n        check([0]*m,0,0)\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2398": {
        "problem_id": 2398,
        "description": "You have n robots. You are given two 0-indexed integer arrays, chargeTimes and runningCosts, both of length n. The ith robot costs chargeTimes[i] units to charge and costs runningCosts[i] units to run. You are also given an integer budget.\nThe total cost of running k chosen robots is equal to max(chargeTimes) + k * sum(runningCosts), where max(chargeTimes) is the largest charge cost among the k robots and sum(runningCosts) is the sum of running costs among the k robots.\nReturn the maximum number of consecutive robots you can run such that the total cost does not exceed budget.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumRobots(self, chargeTimes: List[int], runningCosts: List[int], budget: int) -> int:",
        "solution": "class Solution:\n    def maximumRobots(self, chargeTimes: List[int], runningCosts: List[int], budget: int) -> int:\n        queue = deque()\n        left = best_length = curr = 0\n\n        for right in range(len(chargeTimes)):\n        \tcurr += runningCosts[right]\n        \twhile queue and chargeTimes[queue[-1]] < chargeTimes[right]:\n        \t\tqueue.pop()\n\n        \tqueue.append(right)\n\n        \twhile queue and (chargeTimes[queue[0]] + (right - left + 1) * curr) > budget:\n        \t\tif queue[0] == left:\n        \t\t\tqueue.popleft()\n        \t\tcurr -= runningCosts[left]\n        \t\tleft += 1\n\n        \tbest_length = max(best_length, right - left + 1)\n\n        return best_length",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2399": {
        "problem_id": 2399,
        "description": "You are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice. You are also given a 0-indexed integer array distance of length 26.\nEach letter in the alphabet is numbered from 0 to 25 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, ... , 'z' -> 25).\nIn a well-spaced string, the number of letters between the two occurrences of the ith letter is distance[i]. If the ith letter does not appear in s, then distance[i] can be ignored.\nReturn true if s is a well-spaced string, otherwise return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def checkDistances(self, s: str, distance: List[int]) -> bool:",
        "solution": "class Solution:\n    def checkDistances(self, s: str, distance: List[int]) -> bool:\n        \n        d = defaultdict(list)\n\n        for i, ch in enumerate(s):\n            d[ch].append(i)\n\n        return all(b-a-1 == distance[ord(ch)-97] for ch, (a,b) in d.items())",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2400": {
        "problem_id": 2400,
        "description": "You are given two positive integers startPos and endPos. Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right.\nGiven a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. Since the answer may be very large, return it modulo 109 + 7.\nTwo ways are considered different if the order of the steps made is not exactly the same.\nNote that the number line includes negative integers.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfWays(self, startPos: int, endPos: int, k: int) -> int:",
        "solution": "class Solution:          \n    def numberOfWays(self, startPos: int, endPos: int, k: int) -> int:\n\n        dist = endPos-startPos\n\n        if k%2 != dist%2 or abs(dist) > k: return 0\n\n        return comb(k, (dist+k)//2) %1_000_000_007",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2401": {
        "problem_id": 2401,
        "description": "You are given an array nums consisting of positive integers.\nWe call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0.\nReturn the length of the longest nice subarray.\nA subarray is a contiguous part of an array.\nNote that subarrays of length 1 are always considered nice.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestNiceSubarray(self, nums: List[int]) -> int:",
        "solution": "def longestNiceSubarray(self, nums: List[int]) -> int:\n        lo, mask, ans = -1, 0, 1\n        for hi, n in enumerate(nums):\n            while (mask & n): # n has duplicate set bits for current sliding window.\n                lo += 1 # shrink left bound of current sliding window.\n                mask ^= nums[lo] # remove the corresponding element out of the window.\n            mask |= n # Expand right bound and put n into window.\n            ans = max(ans, hi - lo) # update the max window size.\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2402": {
        "problem_id": 2402,
        "description": "You are given an integer n. There are n rooms numbered from 0 to n - 1.\nYou are given a 2D integer array meetings where meetings[i] = [starti, endi] means that a meeting will be held during the half-closed time interval [starti, endi). All the values of starti are unique.\nMeetings are allocated to rooms in the following manner:\n\t1. Each meeting will take place in the unused room with the lowest number.\n\t2. If there are no available rooms, the meeting will be delayed until a room becomes free. The delayed meeting should have the same duration as the original meeting.\n\t3. When a room becomes unused, meetings that have an earlier original start time should be given the room.\nReturn the number of the room that held the most meetings. If there are multiple rooms, return the room with the lowest number.\nA half-closed interval [a, b) is the interval between a and b including a and not including b.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostBooked(self, n: int, meetings: List[List[int]]) -> int:",
        "solution": "class Solution:\r\n    def mostBooked(self, n: int, meetings: List[List[int]]) -> int:\r\n        ans = [0] * n\r\n        times = [0] * n\r\n        meetings.sort()\r\n\r\n        for start, end in meetings:\r\n            flag = False\r\n            minind = -1\r\n            val = float('inf')\r\n            for j in range(n):\r\n                if times[j] < val:\r\n                    val = times[j]\r\n                    minind = j\r\n                if times[j] <= start:\r\n                    flag = True\r\n                    ans[j] += 1\r\n                    times[j] = end\r\n                    break\r\n            if not flag:\r\n                ans[minind] += 1\r\n                times[minind] += (end - start)\r\n\r\n        maxi = -1\r\n        id = -1\r\n        for i in range(n):\r\n            if ans[i] > maxi:\r\n                maxi = ans[i]\r\n                id = i\r\n        return id",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2404": {
        "problem_id": 2404,
        "description": "Given an integer array nums, return the most frequent even element.\nIf there is a tie, return the smallest one. If there is no such element, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostFrequentEven(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def mostFrequentEven(self, nums: List[int]) -> int:\n        seen = {}\n        for item in nums:\n            if item % 2 ==0:\n                seen[item] = 1 if item not in seen else seen[item] + 1\n        maxx = 0    \n        output = -1        \n        for num, count in seen.items():\n            if count > maxx:\n                maxx, output = count, num\n            elif count == maxx:\n                output = min(num,output)\n        return output",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2405": {
        "problem_id": 2405,
        "description": "Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a single substring more than once.\nReturn the minimum number of substrings in such a partition.\nNote that each character should belong to exactly one substring in a partition.\n",
        "provided_code_snippet": "class Solution:\r\n    def partitionString(self, s: str) -> int:",
        "solution": "class Solution:\r\n    def partitionString(self, s: str) -> int:\r\n        i, ans, flag = 0, 1, 0\r\n        while i < len(s):\r\n            val = ord(s[i]) - ord('a')\r\n            if flag & (1 << val):\r\n                flag = 0\r\n                ans += 1\r\n            flag |= 1 << val\r\n            i += 1\r\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2406": {
        "problem_id": 2406,
        "description": "You are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti].\nYou have to divide the intervals into one or more groups such that each interval is in exactly one group, and no two intervals that are in the same group intersect each other.\nReturn the minimum number of groups you need to make.\nTwo intervals intersect if there is at least one common number between them. For example, the intervals [1, 5] and [5, 8] intersect.\n",
        "provided_code_snippet": "class Solution:\r\n    def minGroups(self, intervals: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minGroups(self, intervals: List[List[int]]) -> int:\n        pq = []\n        for left, right in sorted(intervals):\n            if pq and pq[0] < left:\n                heappop(pq)\n            heappush(pq, right)\n        return len(pq)",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2407": {
        "problem_id": 2407,
        "description": "You are given an integer array nums and an integer k.\nFind the longest subsequence of nums that meets the following requirements:\n\t- The subsequence is strictly increasing and\n\t- The difference between adjacent elements in the subsequence is at most k.\nReturn the length of the longest subsequence that meets the requirements.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def lengthOfLIS(self, nums: List[int], k: int) -> int:",
        "solution": "# Iterative Segment Tree\nclass SegmentTree:\n    def __init__(self, n, fn):\n        self.n = n\n        self.fn = fn\n        self.tree = [0] * (2 * n)\n       \n    def query(self, l, r):\n        l += self.n\n        r += self.n\n        res = 0\n        while l < r:\n            if l & 1:\n                res = self.fn(res, self.tree[l])\n                l += 1\n            if r & 1:\n                r -= 1\n                res = self.fn(res, self.tree[r])\n            l >>= 1\n            r >>= 1\n        return res\n    \n    def update(self, i, val):\n        i += self.n\n        self.tree[i] = val\n        while i > 1:\n            i >>= 1\n            self.tree[i] = self.fn(self.tree[i * 2], self.tree[i * 2 + 1])\nclass Solution:\n    # Inspired from the solution of Bakerston\n    # Basically we make an array to store nums in increasing order and find what is the size of the LIS ending there\n\t# Our array is 0 to max element from the given nums\n    # We need to find the elements smaller than n till the limit k which are in nums before this num\n    # so simply all the elements previous to our current num are smaller(till k smaller)\n    # now how to find LIS's size?\n    # Since we are updating elements left to right in our array we know the LIS's size of elements smaller\n    # than our current num\n    # we just need to find the largest LIS size in range (num - k, num) from our array\n    # This is a range query and can be efficiently answered using Segment Trees.\n    \n    def lengthOfLIS(self, nums: List[int], k: int) -> int:\n        n = max(nums)\n        res = 1\n        tree = SegmentTree(n, max)\n        for num in nums:\n            num -= 1\n            mm = tree.query(max(0, num - k), num)\n            tree.update(num, mm + 1)\n            res = max(res, mm + 1)\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2409": {
        "problem_id": 2409,
        "description": "Alice and Bob are traveling to Rome for separate business meetings.\nYou are given 4 strings arriveAlice, leaveAlice, arriveBob, and leaveBob. Alice will be in the city from the dates arriveAlice to leaveAlice (inclusive), while Bob will be in the city from the dates arriveBob to leaveBob (inclusive). Each will be a 5-character string in the format \"MM-DD\", corresponding to the month and day of the date.\nReturn the total number of days that Alice and Bob are in Rome together.\nYou can assume that all dates occur in the same calendar year, which is not a leap year. Note that the number of days per month can be represented as: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31].\n",
        "provided_code_snippet": "class Solution:\r\n    def countDaysTogether(self, arriveAlice: str, leaveAlice: str, arriveBob: str, leaveBob: str) -> int:",
        "solution": "class Solution:\r\n    def countDaysTogether(self, arriveAlice: str, leaveAlice: str, arriveBob: str, leaveBob: str) -> int:\r\n        return max(0, self.getDate(min(leaveAlice, leaveBob)) - self.getDate(max(arriveAlice, arriveBob)) + 1)\r\n    \r\n    def getDate(self, date):\r\n        monthList = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\r\n        month = int(date[:2])\r\n        days = int(date[3:])\r\n        return sum(monthList[: month - 1]) + days",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2410": {
        "problem_id": 2410,
        "description": "You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the training capacity of the jth trainer.\nThe ith player can match with the jth trainer if the player's ability is less than or equal to the trainer's training capacity. Additionally, the ith player can be matched with at most one trainer, and the jth trainer can be matched with at most one player.\nReturn the maximum number of matchings between players and trainers that satisfy these conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def matchPlayersAndTrainers(self, players: List[int], trainers: List[int]) -> int:",
        "solution": "class Solution:\n    def matchPlayersAndTrainers(self, players:  List[int], \n                                      trainers: List[int]) -> int:\n        ans = 0\n        trainers.sort()\n        heapify(players)\n\n        for t in trainers:\n\n            if players and players[0] <= t:\n                heappop(players)\n\n                ans+= 1\n\n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2411": {
        "problem_id": 2411,
        "description": "You are given a 0-indexed array nums of length n, consisting of non-negative integers. For each index i from 0 to n - 1, you must determine the size of the minimum sized non-empty subarray of nums starting at i (inclusive) that has the maximum possible bitwise OR.\n\t- In other words, let Bij be the bitwise OR of the subarray nums[i...j]. You need to find the smallest subarray starting at i, such that bitwise OR of this subarray is equal to max(Bik) where i <= k <= n - 1.\nThe bitwise OR of an array is the bitwise OR of all the numbers in it.\nReturn an integer array answer of size n where answer[i] is the length of the minimum sized subarray starting at i with maximum bitwise OR.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\r\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\r\n\r\n        def create(m):\r\n            t = 0\r\n            for n in m:\r\n                if m[n] > 0:\r\n                    t = t | (1 << n)\r\n            return t\r\n        \r\n        def add(a,m):\r\n            ans = bin( a )\r\n            s = str(ans)[2:]\r\n            for i, b in enumerate( s[::-1]):\r\n                if b == '1':\r\n                    m[i] += 1\r\n\r\n        def remove(a,m):\r\n            ans = bin( a )\r\n            s = str(ans)[2:]\r\n            for i, b in enumerate( s[::-1]):\r\n                if b == '1':\r\n                    m[i] -= 1\r\n        \r\n        res = []\r\n\r\n        \r\n        n = defaultdict(int)\r\n        for i in nums:\r\n            add(i,n)\r\n\r\n        \r\n        m = defaultdict(int)\r\n        r = 0\r\n        c = 0\r\n\r\n        for i,v in enumerate(nums):\r\n            # The last check is for if nums[i] == 0, in that case we still want to add to the map\r\n            while r < len(nums) and (create(m) != create(n) or (c==0 and nums[i] ==0)):\r\n                add(nums[r],m)\r\n                r+=1\r\n                c+=1\r\n\r\n            res.append(c)\r\n\r\n            remove(nums[i],m)\r\n            remove(nums[i],n)\r\n            c-=1\r\n\r\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2412": {
        "problem_id": 2412,
        "description": "You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costi, cashbacki].\nThe array describes transactions, where each transaction must be completed exactly once in some order. At any given moment, you have a certain amount of money. In order to complete transaction i, money >= costi must hold true. After performing a transaction, money becomes money - costi + cashbacki.\nReturn the minimum amount of money required before any transaction so that all of the transactions can be completed regardless of the order of the transactions.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumMoney(self, transactions: List[List[int]]) -> int:",
        "solution": "def minimumMoney(self, transactions: List[List[int]]) -> int:\n        \n\tgoodTransactions = [txn for txn in transactions if txn[0] <= txn[1]]\n\tbadTransactions = [txn for txn in transactions if txn[0] > txn[1]]\n\n\tbadTransactions.sort(key=lambda x: x[1])\n\n\tneed = 0\n\tcur_amount = 0\n\n\tfor cost,cashback in badTransactions:\n\t\tcur_amount += cost\n\t\tneed = max(need,cur_amount)\n\t\tcur_amount -= cashback\n\n\tif goodTransactions:\n\t\tcostliest_good_transaction = max(goodTransactions, key=lambda x: x[0])\n\t\tcur_amount += costliest_good_transaction[0]  \n\t\tneed = max(need, cur_amount)\n\n\treturn need\n```\t\t",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2413": {
        "problem_id": 2413,
        "description": "Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestEvenMultiple(self, n: int) -> int:",
        "solution": "class Solution:\n    def smallestEvenMultiple(self, n: int) -> int:\n        return n if n % 2 ==0 else n * 2",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2414": {
        "problem_id": 2414,
        "description": "An alphabetical continuous string is a string consisting of consecutive letters in the alphabet. In other words, it is any substring of the string \"abcdefghijklmnopqrstuvwxyz\".\n\t- For example, \"abc\" is an alphabetical continuous string, while \"acb\" and \"za\" are not.\nGiven a string s consisting of lowercase letters only, return the length of the longest alphabetical continuous substring.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestContinuousSubstring(self, s: str) -> int:",
        "solution": "class Solution:\n    def longestContinuousSubstring(self, s: str) -> int:\n\n        pairs = set(pairwise(ascii_lowercase))\n        count = mx = 1\n\n        for p in pairwise(s):\n            \n            if p in pairs:\n                count+= 1\n\n            else:\n                mx = max(mx, count)\n                count = 1\n        \n        return max(mx, count)",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2415": {
        "problem_id": 2415,
        "description": "Given the root of a perfect binary tree, reverse the node values at each odd level of the tree.\n\t- For example, suppose the node values at level 3 are [2,1,3,4,7,11,29,18], then it should become [18,29,11,7,4,3,1,2].\nReturn the root of the reversed tree.\nA binary tree is perfect if all parent nodes have two children and all leaves are on the same level.\nThe level of a node is the number of edges along the path between it and the root node.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def reverseOddLevels(self, root: Optional[TreeNode]) -> Optional[TreeNode]:",
        "solution": "# Definition for a binary tree node.\n# class TreeNode:\n#     def __init__(self, val=0, left=None, right=None):\n#         self.val = val\n#         self.left = left\n#         self.right = right\nclass Solution:\n    def reverseOddLevels(self, root: Optional[TreeNode]) -> Optional[TreeNode]:\n        v=[root]\n        l=0\n        while v:\n            l+=1\n            vc=[]\n            for i in v:\n                if(i.left):\n                    vc+=[i.left]\n                if(i.right):\n                    vc+=[i.right]\n            if(l%2==1):\n                for i in range((len(vc)+1)//2):\n                    vc[i].val,vc[len(vc)-i-1].val=vc[len(vc)-i-1].val,vc[i].val\n            v=vc\n        return root",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2416": {
        "problem_id": 2416,
        "description": "You are given an array words of size n consisting of non-empty strings.\nWe define the score of a string word as the number of strings words[i] such that word is a prefix of words[i].\n\t- For example, if words = [\"a\", \"ab\", \"abc\", \"cab\"], then the score of \"ab\" is 2, since \"ab\" is a prefix of both \"ab\" and \"abc\".\nReturn an array answer of size n where answer[i] is the sum of scores of every non-empty prefix of words[i].\nNote that a string is considered as a prefix of itself.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumPrefixScores(self, words: List[str]) -> List[int]:",
        "solution": "class Node:\r\n    def __init__(self):\r\n        self.count = 0\r\n        self.list = [None] * 26\r\n\r\n    def containKey(self, ch):\r\n        return self.list[ord(ch) - ord('a')] is not None\r\n\r\n    def get(self, ch):\r\n        return self.list[ord(ch) - ord('a')]\r\n\r\n    def put(self, ch, new_node):\r\n        self.list[ord(ch) - ord('a')] = new_node\r\n\r\n    def inc(self, ch):\r\n        self.list[ord(ch) - ord('a')].count += 1\r\n\r\n    def retCount(self, ch):\r\n        return self.list[ord(ch) - ord('a')].count\r\n\r\n\r\nclass Solution:\r\n    def __init__(self):\r\n        self.root = Node()\r\n\r\n    def insert(self, word):\r\n        node = self.root\r\n        for ch in word:\r\n            if not node.containKey(ch):\r\n                node.put(ch, Node())\r\n            node.inc(ch)\r\n            node = node.get(ch)\r\n\r\n    def search(self, word):\r\n        node = self.root\r\n        preCount = 0\r\n        for ch in word:\r\n            preCount += node.retCount(ch)\r\n            node = node.get(ch)\r\n        return preCount\r\n\r\n    def sumPrefixScores(self, words):\r\n        # This problem can be solved using the trie data structure\r\n        for word in words:\r\n            self.insert(word)\r\n\r\n        res = []\r\n        for word in words:\r\n            preCount = self.search(word)\r\n            res.append(preCount)\r\n\r\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2418": {
        "problem_id": 2418,
        "description": "You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.\nFor each index i, names[i] and heights[i] denote the name and height of the ith person.\nReturn names sorted in descending order by the people's heights.\n",
        "provided_code_snippet": "class Solution:\r\n    def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:",
        "solution": "class Solution:\n    def sortPeople(self, names: list[str], heights: list[int]) -> list[str]:\n        return [p[0] for p in sorted(zip(names, heights), key=lambda person: -person[1])]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2419": {
        "problem_id": 2419,
        "description": "You are given an integer array nums of size n.\nConsider a non-empty subarray from nums that has the maximum possible bitwise AND.\n\t- In other words, let k be the maximum value of the bitwise AND of any subarray of nums. Then, only subarrays with a bitwise AND equal to k should be considered.\nReturn the length of the longest such subarray.\nThe bitwise AND of an array is the bitwise AND of all the numbers in it.\nA subarray is a contiguous sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestSubarray(self, nums: List[int]) -> int:",
        "solution": "def longestSubarray(self, nums: List[int]) -> int:\n        mx = max(nums)\n        longest = cur = 0\n        for num in nums:\n            if num == mx:\n                cur += 1\n                longest = max(longest, cur)\n            else:\n                cur = 0\n        return longest",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2420": {
        "problem_id": 2420,
        "description": "You are given a 0-indexed integer array nums of size n and a positive integer k.\nWe call an index i in the range k <= i < n - k good if the following conditions are satisfied:\n\t- The k elements that are just before the index i are in non-increasing order.\n\t- The k elements that are just after the index i are in non-decreasing order.\nReturn an array of all good indices sorted in increasing order.\n",
        "provided_code_snippet": "class Solution:\r\n    def goodIndices(self, nums: List[int], k: int) -> List[int]:",
        "solution": "class Solution:\n    def goodIndices(self, nums: List[int], k: int) -> List[int]:\n        ### forward pass.\n        forward = [False]*len(nums) ### For the forward pass, store if index i is good or not.\n        stack = []\n        for i in range(len(nums)):\n        \t### if the leangth of stack is greater or equal to k, it means this index is good.\n            if len(stack)>=k:\n                forward[i] = True\n            ### if the stack is empty, just add the current number to it.\n            if not stack:\n                stack.append(nums[i])\n            ### check to see if the current number is smaller or equal to the last number in stack, if it is not, put this number into the stack.\n            else:\n                if nums[i]<=stack[-1]:\n                    stack.append(nums[i])\n                else:\n                    stack = [nums[i]]\n        ### backward pass\n        res = []\n        stack = []\n        for i in reversed(range(len(nums))):\n        \t### Check to see if the length of stack is greater or equal to k and also check if the forward pass at this index is Ture.\n            if len(stack)>=k and forward[i]:\n                res.append(i)\n            if not stack:\n                stack.append(nums[i])\n            else:\n                if nums[i]<=stack[-1]:\n                    stack.append(nums[i])\n                else:\n                    stack = [nums[i]]\n        return res[::-1]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2421": {
        "problem_id": 2421,
        "description": "There is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges.\nYou are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node. You are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA good path is a simple path that satisfies the following conditions:\n\t1. The starting node and the ending node have the same value.\n\t2. All nodes between the starting node and the ending node have values less than or equal to the starting node (i.e. the starting node's value should be the maximum value along the path).\nReturn the number of distinct good paths.\nNote that a path and its reverse are counted as the same path. For example, 0 -> 1 is considered to be the same as 1 -> 0. A single node is also considered as a valid path.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfGoodPaths(self, vals: List[int], edges: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def numberOfGoodPaths(self, vals: List[int], edges: List[List[int]]) -> int:\n\n        def get_root(i):\n            if i == par[i]: return i\n            par[i] = get_root(par[i])\n            return par[i]\n\n        def connect(i, j):\n            i,j = get_root(i), get_root(j)\n           \n            if i != j:\n                if sz[i] < sz[j]: i, j = j, i\n                par[j] = i\n                sz[i] += sz[j]\n                \n                if cur[i] == cur[j]:\n                    r = cnt[i] * cnt[j]\n                    cnt[i] += cnt[j]\n                    return r\n                \n                elif cur[i] < cur[j]:\n                    cur[i],cnt[i] = cur[j],cnt[j]\n            return 0\n                    \n        n = ans =len(vals)\n        sz, cur,cnt, par  = [1]*n, vals,[1] *n, list(range(n))\n        \n        for a, b in sorted(edges, key=lambda p: max(vals[p[0]], vals[p[1]])):\n            ans += connect(a, b)\n            \n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2423": {
        "problem_id": 2423,
        "description": "You are given a 0-indexed string word, consisting of lowercase English letters. You need to select one index and remove the letter at that index from word so that the frequency of every letter present in word is equal.\nReturn true if it is possible to remove one letter so that the frequency of all letters in word are equal, and false otherwise.\nNote:\n\t- The frequency of a letter x is the number of times it occurs in the string.\n\t- You must remove exactly one letter and cannot choose to do nothing.\n",
        "provided_code_snippet": "class Solution:\r\n    def equalFrequency(self, word: str) -> bool:",
        "solution": "class Solution:\n    def equalFrequency(self, word: str) -> bool:\n        cnt = Counter(Counter(word).values())\n        if (len(cnt) == 1):\n            return list(cnt.keys())[0] == 1 or list(cnt.values())[0] == 1\n        if (len(cnt) == 2):\n            f1, f2 = min(cnt.keys()), max(cnt.keys())\n            return (f1 + 1 == f2 and cnt[f2] == 1) or (f1 == 1 and cnt[f1] == 1)\n        return False",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2425": {
        "problem_id": 2425,
        "description": "You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once).\nReturn the bitwise XOR of all integers in nums3.\n",
        "provided_code_snippet": "class Solution:\r\n    def xorAllNums(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def xorAllNums(self, nums1: List[int], nums2: List[int]) -> int:\n        m, n = map(len, (nums1, nums2))\n        return (m % 2 * reduce(xor, nums2)) ^ (n % 2 * reduce(xor, nums1))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2426": {
        "problem_id": 2426,
        "description": "You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff. Find the number of pairs (i, j) such that:\n\t- 0 <= i < j <= n - 1 and\n\t- nums1[i] - nums1[j] <= nums2[i] - nums2[j] + diff.\nReturn the number of pairs that satisfy the conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfPairs(self, nums1: List[int], nums2: List[int], diff: int) -> int:",
        "solution": "from sortedcontainers import SortedList\nclass Solution:\n    def numberOfPairs(self, nums1: List[int], nums2: List[int], diff: int) -> int:\n        sl, ans = SortedList(), 0\n        for num1, num2 in zip(nums1, nums2):\n            ans += sl.bisect_right(num1 - num2 + diff)\n            sl.add(num1 - num2)\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2427": {
        "problem_id": 2427,
        "description": "Given two positive integers a and b, return the number of common factors of a and b.\nAn integer x is a common factor of a and b if x divides both a and b.\n",
        "provided_code_snippet": "class Solution:\r\n    def commonFactors(self, a: int, b: int) -> int:",
        "solution": "def commonFactors(self, a: int, b: int) -> int:\n        return sum(not(a%i or b%i) for i in range(1,min(a,b)+1))",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2428": {
        "problem_id": 2428,
        "description": "You are given an m x n integer matrix grid.\nWe define an hourglass as a part of the matrix with the following form:\nReturn the maximum sum of the elements of an hourglass.\nNote that an hourglass cannot be rotated and must be entirely contained within the matrix.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxSum(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def maxSum(self, grid: List[List[int]]) -> int:\n\n        m, n, ans = len(grid)-1, len(grid[0])-1, 0\n\n        for i, j in product(range(1, m), range(1,n)):\n\n                sm = ( grid[i-1][j-1] + grid[i-1][j] + grid[i-1][j+1]\n                                      + grid[i  ][j] + # <-- hourglass center\n                       grid[i+1][j-1] + grid[i+1][j] + grid[i+1][j+1] )\n\n                if sm > ans: ans = sm\n\n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2429": {
        "problem_id": 2429,
        "description": "Given two positive integers num1 and num2, find the positive integer x such that:\n\t- x has the same number of set bits as num2, and\n\t- The value x XOR num1 is minimal.\nNote that XOR is the bitwise XOR operation.\nReturn the integer x. The test cases are generated such that x is uniquely determined.\nThe number of set bits of an integer is the number of 1's in its binary representation.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeXor(self, num1: int, num2: int) -> int:",
        "solution": "class Solution:\r\n    def minimizeXor(self, num1: int, num2: int, mxbits = 31) -> int:\r\n\r\n        num1 = bin(num1)[2:].rjust(mxbits,'0') \r\n        bitNum =bin(num2).count('1')\r\n        ans = ['0'] * mxbits\r\n\r\n        for i in range(mxbits):\r\n            if num1[i] == '1':\r\n                ans[i] = '1'\r\n                bitNum-= 1\r\n                if bitNum == 0: break\r\n                \r\n        else:\r\n            for i in range(mxbits - 1, -1, -1):\r\n \r\n                if num1[i] == '0':\r\n                    ans[i] = '1'\r\n                    bitNum-= 1\r\n                    if bitNum == 0: break\r\n\r\n        return int(''.join(ans),2)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2430": {
        "problem_id": 2430,
        "description": "You are given a string s consisting of only lowercase English letters. In one operation, you can:\n\t- Delete the entire string s, or\n\t- Delete the first i letters of s if the first i letters of s are equal to the following i letters in s, for any i in the range 1 <= i <= s.length / 2.\nFor example, if s = \"ababc\", then in one operation, you could delete the first two letters of s to get \"abc\", since the first two letters of s and the following two letters of s are both equal to \"ab\".\nReturn the maximum number of operations needed to delete all of s.\n",
        "provided_code_snippet": "class Solution:\r\n    def deleteString(self, s: str) -> int:",
        "solution": "class Solution:\n    def deleteString(self, s: str) -> int:\n        n = len(s)\n        if len(set(s)) == 1:\n            return n\n        dp = [1] * n\n        for i in range(n - 2, -1, -1):\n            for l in range(1, (n - i) // 2 + 1):\n                if s[i : i + l] == s[i + l : i + 2 * l]:\n                    dp[i] = max(dp[i], 1 + dp[i + l])\n        return dp[0]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2432": {
        "problem_id": 2432,
        "description": "There are n employees, each with a unique id from 0 to n - 1.\nYou are given a 2D integer array logs where logs[i] = [idi, leaveTimei] where:\n\t- idi is the id of the employee that worked on the ith task, and\n\t- leaveTimei is the time at which the employee finished the ith task. All the values leaveTimei are unique.\nNote that the ith task starts the moment right after the (i - 1)th task ends, and the 0th task starts at time 0.\nReturn the id of the employee that worked the task with the longest time. If there is a tie between two or more employees, return the smallest id among them.\n",
        "provided_code_snippet": "class Solution:\r\n    def hardestWorker(self, n: int, logs: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def hardestWorker(self, n: int, logs: List[List[int]]) -> int:\n         \n        prev, ans = 0, (0,0)\n\t\t\n        for id, curr in logs:\n            ans = min(ans,(prev-curr,id))\n            prev = curr\n\n        return ans[1]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2433": {
        "problem_id": 2433,
        "description": "You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:\n\t- pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].\nNote that ^ denotes the bitwise-xor operation.\nIt can be proven that the answer is unique.\n",
        "provided_code_snippet": "class Solution:\r\n    def findArray(self, pref: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def findArray(self, pref: List[int]) -> List[int]:\n        \n        prev = pref[0]\n\n        for i in range(1, len(pref)):\n            pref[i] ^= prev\n            prev ^= pref[i]\n        \n        return pref",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2434": {
        "problem_id": 2434,
        "description": "You are given a string s and a robot that currently holds an empty string t. Apply one of the following operations until s and t are both empty:\n\t- Remove the first character of a string s and give it to the robot. The robot will append this character to the string t.\n\t- Remove the last character of a string t and give it to the robot. The robot will write this character on paper.\nReturn the lexicographically smallest string that can be written on the paper.\n",
        "provided_code_snippet": "class Solution:\r\n    def robotWithString(self, s: str) -> str:",
        "solution": "class Solution:\r\n    def robotWithString(self, s: str) -> str:\r\n        cnt, lo, p, t = Counter(s), 'a', [], []\r\n        for ch in s:\r\n            t += ch\r\n            cnt[ch] -= 1\r\n            while lo < 'z' and cnt[lo] == 0:\r\n                lo = chr(ord(lo) + 1)\r\n            while t and t[-1] <= lo:\r\n                p += t.pop()\r\n        return \"\".join(p)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2435": {
        "problem_id": 2435,
        "description": "You are given a 0-indexed m x n integer matrix grid and an integer k. You are currently at position (0, 0) and you want to reach position (m - 1, n - 1) moving only down or right.\nReturn the number of paths where the sum of the elements on the path is divisible by k. Since the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfPaths(self, grid: List[List[int]], k: int) -> int:",
        "solution": "def numberOfPaths(self, grid: List[List[int]], k: int) -> int:\n    n, m = len(grid), len(grid[0])\n    dp = [[[0] * k for _ in range(m)] for _ in range(n)]\n    dp[0][0][grid[0][0] % k] = 1\n    \n    for i in range(n):\n        for j in range(m):\n            for mod in range(k):\n                if j > 0:\n                    dp[i][j][(mod + grid[i][j]) % k] += dp[i][j - 1][mod] % 1000000007\n                if i > 0:\n                    dp[i][j][(mod + grid[i][j]) % k] += dp[i - 1][j][mod] % 1000000007\n    \n    return dp[-1][-1][0] % 1000000007",
        "submission_passed": true,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2437": {
        "problem_id": 2437,
        "description": "You are given a string of length 5 called time, representing the current time on a digital clock in the format \"hh:mm\". The earliest possible time is \"00:00\" and the latest possible time is \"23:59\".\nIn the string time, the digits represented by the ? symbol are unknown, and must be replaced with a digit from 0 to 9.\nReturn an integer answer, the number of valid clock times that can be created by replacing every ? with a digit from 0 to 9.\n",
        "provided_code_snippet": "class Solution:\r\n    def countTime(self, time: str) -> int:",
        "solution": "import re\n\n\nclass Solution:\n    \n\n    def countTime(self, time: str) -> int:\n        pattern = time.replace('?', '.')\n        return sum(\n            re.fullmatch(pattern, f'{hour:02}:{minute:02}') is not None\n            for hour in range(24)\n            for minute in range(60)\n        )",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2438": {
        "problem_id": 2438,
        "description": "Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the array.\nYou are also given a 0-indexed 2D integer array queries, where queries[i] = [lefti, righti]. Each queries[i] represents a query where you have to find the product of all powers[j] with lefti <= j <= righti.\nReturn an array answers, equal in length to queries, where answers[i] is the answer to the ith query. Since the answer to the ith query may be too large, each answers[i] should be returned modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def productQueries(self, n: int, queries: List[List[int]]) -> List[int]:",
        "solution": "from itertools import accumulate\nfrom typing import List, Generator\n\n\nclass Solution:\n    \n\n    MAX_POWER = 32\n    MOD = 10 ** 9 + 7\n\n    def productQueries(self, n: int, queries: List[List[int]]) -> List[int]:\n        cum_powers = list(accumulate(self._to_powers(n), initial=1))\n        return [pow(2, cum_powers[r + 1] - cum_powers[l], self.MOD) for l, r in queries]\n\n    @classmethod\n    def _to_powers(cls, num: int) -> Generator:\n        return (p for p in range(cls.MAX_POWER) if num & (1 << p) != 0)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2439": {
        "problem_id": 2439,
        "description": "You are given a 0-indexed array nums comprising of n non-negative integers.\nIn one operation, you must:\n\t- Choose an integer i such that 1 <= i < n and nums[i] > 0.\n\t- Decrease nums[i] by 1.\n\t- Increase nums[i - 1] by 1.\nReturn the minimum possible value of the maximum integer of nums after performing any number of operations.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeArrayValue(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimizeArrayValue(self, A: List[int]) -> int:\n        return max((a + i) // (i + 1) for i,a in enumerate(accumulate(A)))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2440": {
        "problem_id": 2440,
        "description": "There is an undirected tree with n nodes labeled from 0 to n - 1.\nYou are given a 0-indexed integer array nums of length n where nums[i] represents the value of the ith node. You are also given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nYou are allowed to delete some edges, splitting the tree into multiple connected components. Let the value of a component be the sum of all nums[i] for which node i is in the component.\nReturn the maximum number of edges you can delete, such that every connected component in the tree has the same value.\n",
        "provided_code_snippet": "class Solution:\r\n    def componentValue(self, nums: List[int], edges: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def componentValue(self, nums: List[int], edges: List[List[int]]) -> int:\n        tree = [[] for _ in nums]\n        for u, v in edges: \n            tree[u].append(v)\n            tree[v].append(u)\n        \n        def fn(u, p):\n            \n            ans = nums[u]\n            for v in tree[u]: \n                if v != p: ans += fn(v, u)\n            return 0 if ans == cand else ans\n        \n        total = sum(nums)\n        for cand in range(1, total//2+1): \n            if total % cand == 0 and fn(0, -1) == 0: return total//cand-1\n        return 0",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2441": {
        "problem_id": 2441,
        "description": "Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.\nReturn the positive integer k. If there is no such integer, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def findMaxK(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findMaxK(self, nums: List[int]) -> int:\n        nums.sort()\n        n = len(nums)\n        for i in range(n-1, -1, -1):\n            if nums[i] > 0 and -nums[i] in nums:\n                return nums[i]\n        return -1  # If no such pair found",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2442": {
        "problem_id": 2442,
        "description": "You are given an array nums consisting of positive integers.\nYou have to take each integer in the array, reverse its digits, and add it to the end of the array. You should apply this operation to the original integers in nums.\nReturn the number of distinct integers in the final array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countDistinctIntegers(self, nums: List[int]) -> int:",
        "solution": "class Solution:            \n    def countDistinctIntegers(self, nums: List[int]) -> int:\n\t\n        nums= set(nums)\n        \n        return len(set(int(str(x)[::-1]) for x in nums)|nums)",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2443": {
        "problem_id": 2443,
        "description": "Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumOfNumberAndReverse(self, num: int) -> bool:",
        "solution": "class Solution:\n    def sumOfNumberAndReverse(self, num: int) -> bool:\n        for i in range(0,num+1):\n            s=str(i)\n            s=s[::-1]\n            s=int(s)\n            if (s+i) == num:\n                return True\n        return False",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2444": {
        "problem_id": 2444,
        "description": "You are given an integer array nums and two integers minK and maxK.\nA fixed-bound subarray of nums is a subarray that satisfies the following conditions:\n\t- The minimum value in the subarray is equal to minK.\n\t- The maximum value in the subarray is equal to maxK.\nReturn the number of fixed-bound subarrays.\nA subarray is a contiguous part of an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countSubarrays(self, nums: List[int], minK: int, maxK: int) -> int:",
        "solution": "class Solution:\n    def countSubarrays(self, nums: List[int], mink: int, maxK: int) -> int:\n\n        res = 0\n        bad_idx = left_idx = right_idx = -1\n\n        for i, num in enumerate(nums) :\n            if not mink <= num <= maxK:\n                bad_idx = i\n\n            if num == mink:\n                left_idx = i\n\n            if num == maxK:\n                right_idx = i\n\n            res += max(0, min(left_idx, right_idx) - bad_idx)\n\n        return res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2446": {
        "problem_id": 2446,
        "description": "You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where:\n\t- event1 = [startTime1, endTime1] and\n\t- event2 = [startTime2, endTime2].\nEvent times are valid 24 hours format in the form of HH:MM.\nA conflict happens when two events have some non-empty intersection (i.e., some moment is common to both events).\nReturn true if there is a conflict between two events. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def haveConflict(self, event1: List[str], event2: List[str]) -> bool:",
        "solution": "class Solution:\n    def haveConflict(self, event1: List[str], event2: List[str]) -> bool:\n        return event1[0] <= event2[0] <= event1[1] or event2[0] <= event1[0] <= event2[1]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2447": {
        "problem_id": 2447,
        "description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the greatest common divisor of the subarray's elements is k.\nA subarray is a contiguous non-empty sequence of elements within an array.\nThe greatest common divisor of an array is the largest integer that evenly divides all the array elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def subarrayGCD(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def subarrayGCD(self, nums: List[int], k: int) -> int:\n        n = len(nums)\n        ans = 0\n        for i in range(n):\n            temp = nums[i]\n            for j in range(i, n):\n                temp = math.gcd(temp, nums[j])\n                if temp == k:\n                    ans += 1\n                elif temp < k:\n                    break\n        return ans",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2448": {
        "problem_id": 2448,
        "description": "You are given two 0-indexed arrays nums and cost consisting each of n positive integers.\nYou can do the following operation any number of times:\n\t- Increase or decrease any element of the array nums by 1.\nThe cost of doing one operation on the ith element is cost[i].\nReturn the minimum total cost such that all the elements of the array nums become equal.\n",
        "provided_code_snippet": "class Solution:\r\n    def minCost(self, nums: List[int], cost: List[int]) -> int:",
        "solution": "class Solution:\n    def minCost(self, nums: List[int], cost: List[int]) -> int:\n        arr = sorted(zip(nums, cost))\n        total, cnt = sum(cost), 0\n        for num, c in arr:\n            cnt += c\n            if cnt > total // 2:\n                target = num\n                break\n        return sum(c * abs(num - target) for num, c in arr)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2449": {
        "problem_id": 2449,
        "description": "You are given two positive integer arrays nums and target, of the same length.\nIn one operation, you can choose any two distinct indices i and j where 0 <= i, j < nums.length and:\n\t- set nums[i] = nums[i] + 2 and\n\t- set nums[j] = nums[j] - 2.\nTwo arrays are considered to be similar if the frequency of each element is the same.\nReturn the minimum number of operations required to make nums similar to target. The test cases are generated such that nums can always be similar to target.\n",
        "provided_code_snippet": "class Solution:\r\n    def makeSimilar(self, nums: List[int], target: List[int]) -> int:",
        "solution": "class Solution:\n    def makeSimilar(self, A: List[int], B: List[int]) -> int:\n        if sum(A)!=sum(B): return 0\n        # The first intuition is that only odd numbers can be chaged to odd numbers and even to even hence separate them\n        # Now minimum steps to making the target to highest number in B is by converting max of A to max of B similarily\n        # every number in A can be paired with a number in B by index hence sorting\n        # now we need only the number of positives or number of negatives.\n        oddA,evenA=[i for i in A if i%2],[i for i in A if i%2==0]\n        oddB,evenB=[i for i in B if i%2],[i for i in B if i%2==0]        \n        oddA.sort(),evenA.sort()\n        oddB.sort(),evenB.sort()\n        res=0\n        for i,j in zip(oddA,oddB):\n            if i>=j: res+=i-j\n        \n        for i,j in zip(evenA,evenB):\n            if i>=j: res+=i-j\n        \n        return res//2",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2451": {
        "problem_id": 2451,
        "description": "You are given an array of equal-length strings words. Assume that the length of each string is n.\nEach string words[i] can be converted into a difference integer array difference[i] of length n - 1 where difference[i][j] = words[i][j+1] - words[i][j] where 0 <= j <= n - 2. Note that the difference between two letters is the difference between their positions in the alphabet i.e. the position of 'a' is 0, 'b' is 1, and 'z' is 25.\n\t- For example, for the string \"acb\", the difference integer array is [2 - 0, 1 - 2] = [2, -1].\nAll the strings in words have the same difference integer array, except one. You should find that string.\nReturn the string in words that has different difference integer array.\n",
        "provided_code_snippet": "class Solution:\r\n    def oddString(self, words: List[str]) -> str:",
        "solution": "class Solution:\n    def oddString(self, words: List[str]) -> str:\n\n        diff = lambda x: [ord(x[j])-ord(x[j-1]) for j in range(1,len(x))]\n\n        words.sort(key = diff)\n\n        return words[0] if diff(words[0]) != diff(words[1]) else words[-1]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2452": {
        "problem_id": 2452,
        "description": "You are given two string arrays, queries and dictionary. All words in each array comprise of lowercase English letters and have the same length.\nIn one edit you can take a word from queries, and change any letter in it to any other letter. Find all words from queries that, after a maximum of two edits, equal some word from dictionary.\nReturn a list of all words from queries, that match with some word from dictionary after a maximum of two edits. Return the words in the same order they appear in queries.\n",
        "provided_code_snippet": "class Solution:\r\n    def twoEditWords(self, queries: List[str], dictionary: List[str]) -> List[str]:",
        "solution": "class Solution:\n    def twoEditWords(self, queries: List[str], dictionary: List[str]) -> List[str]:\n\n        N, ans = range(len(queries[0])), []\n\n        f = lambda x,y: sum(x[i] != y[i] for i in N) < 3  # boolean function that returns whether\n                                                          # x and y are within two edits\n        for q in queries:                                 \n            for d in dictionary:\n                if f(q,d):\n                    ans.append(q)\n                    break\n        return  ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2453": {
        "problem_id": 2453,
        "description": "You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line. You are also given an integer space.\nYou have a machine which can destroy targets. Seeding the machine with some nums[i] allows it to destroy all targets with values that can be represented as nums[i] + c * space, where c is any non-negative integer. You want to destroy the maximum number of targets in nums.\nReturn the minimum value of nums[i] you can seed the machine with to destroy the maximum number of targets.\n",
        "provided_code_snippet": "class Solution:\r\n    def destroyTargets(self, nums: List[int], space: int) -> int:",
        "solution": "def destroyTargets(self, nums: List[int], space: int) -> int:\n        freqs, mi = Counter(), inf\n        for num in nums:\n            freqs[num % space] += 1\n        max_freq = max(freqs.values())\n        for num in nums:\n            if freqs[num % space] == max_freq and num < mi:\n                mi = num\n        return mi",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2454": {
        "problem_id": 2454,
        "description": "You are given a 0-indexed array of non-negative integers nums. For each integer in nums, you must find its respective second greater integer.\nThe second greater integer of nums[i] is nums[j] such that:\n\t- j > i\n\t- nums[j] > nums[i]\n\t- There exists exactly one index k such that nums[k] > nums[i] and i < k < j.\nIf there is no such nums[j], the second greater integer is considered to be -1.\n\t- For example, in the array [1, 2, 4, 3], the second greater integer of 1 is 4, 2 is 3, and that of 3 and 4 is -1.\nReturn an integer array answer, where answer[i] is the second greater integer of nums[i].\n",
        "provided_code_snippet": "class Solution:\r\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def secondGreaterElement(self, nums: List[int]) -> List[int]:\n        ans = [-1] * len(nums)\n        s, ss = [], []\n        for i, x in enumerate(nums): \n            while ss and nums[ss[-1]] < x: ans[ss.pop()] = x\n            buff = []\n            while s and nums[s[-1]] < x: buff.append(s.pop())\n            while buff: ss.append(buff.pop())\n            s.append(i)\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2455": {
        "problem_id": 2455,
        "description": "Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.\nNote that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def averageValue(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def averageValue(self, nums: List[int]) -> int:\n        \n        nums = [n for n in nums if not n%6]\n        \n        return sum(nums)//len(nums) if nums else 0",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2456": {
        "problem_id": 2456,
        "description": "You are given two string arrays creators and ids, and an integer array views, all of length n. The ith video on a platform was created by creator[i], has an id of ids[i], and has views[i] views.\nThe popularity of a creator is the sum of the number of views on all of the creator's videos. Find the creator with the highest popularity and the id of their most viewed video.\n\t- If multiple creators have the highest popularity, find all of them.\n\t- If multiple videos have the highest view count for a creator, find the lexicographically smallest id.\nReturn a 2D array of strings answer where answer[i] = [creatori, idi] means that creatori has the highest popularity and idi is the id of their most popular video. The answer can be returned in any order.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostPopularCreator(self, creators: List[str], ids: List[str], views: List[int]) -> List[List[str]]:",
        "solution": "class Solution:\n    def mostPopularCreator(self, creators: List[str], ids: List[str], views: List[int]) -> List[List[str]]:\n        memo = {}\n\t\t#tracking the max popular video count\n        overall_max_popular_video_count = -1\n        #looping over the creators\n        for i in range(len(creators)):\n            if creators[i] in memo:\n                #Step 1: update number of views for the creator\n                memo[creators[i]][0] += views[i]\n                #Step 2: update current_popular_video_view and id_of_most_popular_video_so_far\n                if memo[creators[i]][2] < views[i]:\n                    memo[creators[i]][1] = ids[i]\n                    memo[creators[i]][2] = views[i]\n                #Step 2a: finding the lexicographically smallest id as we hit the current_popularity_video_view again!\n                elif memo[creators[i]][2] == views[i]:\n                    memo[creators[i]][1] = min(memo[creators[i]][1],ids[i])\n            else:\n\t\t\t#adding new entry to our memo\n\t\t\t#new entry is of the format memo[creator[i]] = [total number current views for the creator, store the lexicographic id of the popular video, current popular view of the creator]\n                memo[creators[i]] = [views[i],ids[i],views[i]]\n\t\t\t#track the max popular video count\n            overall_max_popular_video_count = max(memo[creators[i]][0],overall_max_popular_video_count)\n        \n        result = []\n        for i in memo:\n            if memo[i][0] == overall_max_popular_video_count:\n                result.append([i,memo[i][1]])\n        return result",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2457": {
        "problem_id": 2457,
        "description": "You are given two positive integers n and target.\nAn integer is considered beautiful if the sum of its digits is less than or equal to target.\nReturn the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful.\n",
        "provided_code_snippet": "class Solution:\r\n    def makeIntegerBeautiful(self, n: int, target: int) -> int:",
        "solution": "class Solution:\n    def makeIntegerBeautiful(self, n: int, target: int) -> int:\n\n        sm = lambda n: sum(map(int,list(str(n))))\n\n        zeros, diff = 10, 0                     #  Ex: n = 5617     ; target = 7\n\n        while sm(n + diff) > target:            #   n    zeros   diff  n+diff  sm(n+diff)\n                                                # -----  \\u2013\\u2013\\u2013\\u2013\\u2013  \\u2013\\u2013\\u2013\\u2013\\u2013  \\u2013\\u2013\\u2013\\u2013\\u2013\\u2013  \\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013\\u2013  \n            diff = zeros - n%zeros              # 5617     10      3    5620     13  \n                                                # 5617    100     83    5700     12\n            zeros*= 10                          # 5617   1000    383    6000      6  <-- less than target\n                                                #                 |\n        return diff                             #               answer",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2458": {
        "problem_id": 2458,
        "description": "You are given the root of a binary tree with n nodes. Each node is assigned a unique value from 1 to n. You are also given an array queries of size m.\nYou have to perform m independent queries on the tree where in the ith query you do the following:\n\t- Remove the subtree rooted at the node with the value queries[i] from the tree. It is guaranteed that queries[i] will not be equal to the value of the root.\nReturn an array answer of size m where answer[i] is the height of the tree after performing the ith query.\nNote:\n\t- The queries are independent, so the tree returns to its initial state after each query.\n\t- The height of a tree is the number of edges in the longest simple path from the root to some node in the tree.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def treeQueries(self, root: Optional[TreeNode], queries: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def treeQueries(self, root, queries):\n        @lru_cache(None)\n        def height(node):\n            if not node:\n                return -1\n\n            return 1 + max(height(node.left),height(node.right))\n\n        dict1 = collections.defaultdict(int)\n\n        def dfs(node,depth,max_val):\n            if not node: return \n\n            dict1[node.val] = max_val\n\n            dfs(node.left,depth+1,max(max_val,depth+1+height(node.right)))\n            dfs(node.right,depth+1,max(max_val,depth+1+height(node.left)))\n\n        dfs(root,0,0)\n\n        return [dict1[i] for i in queries]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2460": {
        "problem_id": 2460,
        "description": "You are given a 0-indexed array nums of size n consisting of non-negative integers.\nYou need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums:\n\t- If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwise, you skip this operation.\nAfter performing all the operations, shift all the 0's to the end of the array.\n\t- For example, the array [1,0,2,0,0,1] after shifting all its 0's to the end, is [1,2,1,0,0,0].\nReturn the resulting array.\nNote that the operations are applied sequentially, not all at once.\n",
        "provided_code_snippet": "class Solution:\r\n    def applyOperations(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def applyOperations(self, nums: List[int]) -> List[int]:\n\n        for i in range(len(nums)-1):\n            if nums[i] == nums[i+1]:\n                nums[i]*= 2\n                nums[i + 1] = 0   # <-- performing the \"operation.\"  \n      \n        return sorted(nums, key=lambda x: x == 0)   # Sorting on a boolean key: False, then True. O(N*logN) worst case, but likely much better because of the key.",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2461": {
        "problem_id": 2461,
        "description": "You are given an integer array nums and an integer k. Find the maximum subarray sum of all the subarrays of nums that meet the following conditions:\n\t- The length of the subarray is k, and\n\t- All the elements of the subarray are distinct.\nReturn the maximum subarray sum of all the subarrays that meet the conditions. If no subarray meets the conditions, return 0.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumSubarraySum(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximumSubarraySum(self, nums: List[int], k: int) -> int:\n        l, r =0, 0\n        mx, total = 0, 0\n        visit = set()\n        while r int:",
        "solution": "class Solution:\r\n    def totalCost(self, costs, k, candidates):\r\n        i = 0\r\n        j = len(costs) - 1\r\n        pq1 = []\r\n        pq2 = []\r\n\r\n        ans = 0\r\n        while k > 0:\r\n            while len(pq1) < candidates and i <= j:\r\n                heapq.heappush(pq1, costs[i])\r\n                i += 1\r\n            while len(pq2) < candidates and i <= j:\r\n                heapq.heappush(pq2, costs[j])\r\n                j -= 1\r\n\r\n            t1 = pq1[0] if pq1 else float('inf')\r\n            t2 = pq2[0] if pq2 else float('inf')\r\n\r\n            if t1 <= t2:\r\n                ans += t1\r\n                heapq.heappop(pq1)\r\n            else:\r\n                ans += t2\r\n                heapq.heappop(pq2)\r\n\r\n            k -= 1\r\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2463": {
        "problem_id": 2463,
        "description": "There are some robots and factories on the X-axis. You are given an integer array robot where robot[i] is the position of the ith robot. You are also given a 2D integer array factory where factory[j] = [positionj, limitj] indicates that positionj is the position of the jth factory and that the jth factory can repair at most limitj robots.\nThe positions of each robot are unique. The positions of each factory are also unique. Note that a robot can be in the same position as a factory initially.\nAll the robots are initially broken; they keep moving in one direction. The direction could be the negative or the positive direction of the X-axis. When a robot reaches a factory that did not reach its limit, the factory repairs the robot, and it stops moving.\nAt any moment, you can set the initial direction of moving for some robot. Your target is to minimize the total distance traveled by all the robots.\nReturn the minimum total distance traveled by all the robots. The test cases are generated such that all the robots can be repaired.\nNote that\n\t- All robots move at the same speed.\n\t- If two robots move in the same direction, they will never collide.\n\t- If two robots move in opposite directions and they meet at some point, they do not collide. They cross each other.\n\t- If a robot passes by a factory that reached its limits, it crosses it as if it does not exist.\n\t- If the robot moved from a position x to a position y, the distance it moved is |y - x|.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTotalDistance(self, robot: List[int], factory: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minimumTotalDistance(self, robot: List[int], factory: List[List[int]]) -> int:\n        robot.sort()\n        factory.sort()\n        m, n = len(robot), len(factory)\n        dp = [[0]*(n+1) for _ in range(m+1)] \n        for i in range(m): dp[i][-1] = inf \n        for j in range(n-1, -1, -1): \n            prefix = 0 \n            qq = deque([(m, 0)])\n            for i in range(m-1, -1, -1): \n                prefix += abs(robot[i] - factory[j][0])\n                if qq[0][0] > i+factory[j][1]: qq.popleft()\n                while qq and qq[-1][1] >= dp[i][j+1] - prefix: qq.pop()\n                qq.append((i, dp[i][j+1] - prefix))\n                dp[i][j] = qq[0][1] + prefix\n        return dp[0][0]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2465": {
        "problem_id": 2465,
        "description": "You are given a 0-indexed integer array nums of even length.\nAs long as nums is not empty, you must repetitively:\n\t- Find the minimum number in nums and remove it.\n\t- Find the maximum number in nums and remove it.\n\t- Calculate the average of the two removed numbers.\nThe average of two numbers a and b is (a + b) / 2.\n\t- For example, the average of 2 and 3 is (2 + 3) / 2 = 2.5.\nReturn the number of distinct averages calculated using the above process.\nNote that when there is a tie for a minimum or maximum number, any can be removed.\n",
        "provided_code_snippet": "class Solution:\r\n    def distinctAverages(self, nums: List[int]) -> int:",
        "solution": "def distinctAverages(self, nums: List[int]) -> int:\n        a, n = sorted(nums), len(nums) // 2\n        return len({a[i] + a[~i] for i in range(n)})",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2466": {
        "problem_id": 2466,
        "description": "Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following:\n\t- Append the character '0' zero times.\n\t- Append the character '1' one times.\nThis can be performed any number of times.\nA good string is a string constructed by the above process having a length between low and high (inclusive).\nReturn the number of different good strings that can be constructed satisfying these properties. Since the answer can be large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def countGoodStrings(self, low: int, high: int, zero: int, one: int) -> int:",
        "solution": "class Solution:\n    def countGoodStrings(self, low: int, high: int, zero: int, one: int) -> int:\n        dp = [0] * (high+1)\n        dp[0] = 1\n        ans = 0\n        for i in range(1, high+1):\n            dp[i] = ((dp[i-zero] if i-zero>=0 else 0) + (dp[i-one] if i-one>=0 else 0)) % 1000000007\n            if i >= low:\n                ans = (ans + dp[i]) % 1000000007\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2467": {
        "problem_id": 2467,
        "description": "There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nAt every node i, there is a gate. You are also given an array of even integers amount, where amount[i] represents:\n\t- the price needed to open the gate at node i, if amount[i] is negative, or,\n\t- the cash reward obtained on opening the gate at node i, otherwise.\nThe game goes on as follows:\n\t- Initially, Alice is at node 0 and Bob is at node bob.\n\t- At every second, Alice and Bob each move to an adjacent node. Alice moves towards some leaf node, while Bob moves towards node 0.\n\t- For every node along their path, Alice and Bob either spend money to open the gate at that node, or accept the reward. Note that:\t\t\t- If the gate is already open, no price will be required, nor will there be any cash reward.\n\t\t- If Alice and Bob reach the node simultaneously, they share the price/reward for opening the gate there. In other words, if the price to open the gate is c, then both Alice and Bob pay c / 2 each. Similarly, if the reward at the gate is c, both of them receive c / 2 each.\n\t\t\n\t- If Alice reaches a leaf node, she stops moving. Similarly, if Bob reaches node 0, he stops moving. Note that these events are independent of each other.\nReturn the maximum net income Alice can have if she travels towards the optimal leaf node.\n",
        "provided_code_snippet": "class Solution:\r\n    def mostProfitablePath(self, edges: List[List[int]], bob: int, amount: List[int]) -> int:",
        "solution": "class Solution:\n    def mostProfitablePath(self, edges: List[List[int]], bob: int, amount: List[int]) -> int:\n        n = len(amount) # number of nodes\n        graph = [set() for _ in range(n)] # adjacency list presentation of the tree\n        for i,j in edges:\n            graph[i].add(j)\n            graph[j].add(i)\n        bobpath = dict() # use hashmap to record nodes on the path from bob to root 0 \n                         # as well as time: node = key, time = value\n        self.stop = False # True when Bob reaches root 0, this helps stop the DFS\n        visited = [False]*n # True if node is visited, initialized as False for all nodes\n        def backtrackbob(node,time): # the first backtracking, with time at each node\n            bobpath[node] = time # add node:time to the hashmap\n            visited[node] = True # mark node as visited\n            if node==0: # root 0 is reached\n                self.stop = True # this helps stop the DFS\n                return None\n            count = 0 # this helps determine if a node is leaf node\n            for nei in graph[node]: \n                if not visited[nei]:\n                    count += 1\n                    break\n            if count==0: # node is leaf node if all neighbors are already visited\n                del bobpath[node] # delete leaf node from hashmap before retreating from leaf node\n                return None\n            for nei in graph[node]: # explore unvisited neighbors of node\n                if self.stop: return None # if root 0 is already reached, stop the DFS\n                if not visited[nei]:\n                    backtrackbob(nei,time+1)\n            if not self.stop: # if root 0 is reached, keep node in the hashmap when backtracking\n                del bobpath[node] # otherwise, delete node before retreating\n            return None\n\n        backtrackbob(bob,0) # execute the first backtracking, time at bob is initialized = 0\n\n        self.ans = float(-inf) # answer of the problem\n        self.income = 0 # income of Alice when travelling to leaf nodes, initialized = 0\n        visited = [False]*n # True if node is visited, initialized as False for all nodes\n        def backtrackalice(node,time): # second backtracking, with time at each node\n            visited[node] = True\n            if node in bobpath: # if the node Alice visits is on Bob's path, there are 3 cases\n                if time == bobpath[node]: # Alice and Bob reach the node at the same time\n                    reward = amount[node]//2\n                elif time\", where \"b\" is to be replaced with the total number of parts and \"a\" is to be replaced with the index of the part, starting from 1 and going up to b. Additionally, the length of each resulting part (including its suffix) should be equal to limit, except for the last part whose length can be at most limit.\nThe resulting parts should be formed such that when their suffixes are removed and they are all concatenated in order, they should be equal to message. Also, the result should contain as few parts as possible.\nReturn the parts message would be split into as an array of strings. If it is impossible to split message as required, return an empty array.\n",
        "provided_code_snippet": "class Solution:\r\n    def splitMessage(self, message: str, limit: int) -> List[str]:",
        "solution": "class Solution:\n    def splitMessage(self, message: str, limit: int) -> List[str]:\n        def splitable_within(parts_limit):\n            # check the message length achievable with  parts\n            length = sum(limit - len(str(i)) - len(str(parts_limit)) - 3 for i in range(1, parts_limit + 1))\n            return length >= len(message)\n        \n        parts_limit = 9\n        if not splitable_within(parts_limit):\n            parts_limit = 99\n        if not splitable_within(parts_limit):\n            parts_limit = 999\n        if not splitable_within(parts_limit):\n            parts_limit = 9999\n        if not splitable_within(parts_limit):\n            return []\n        \n        # generate the actual message parts\n        parts = []\n        m_index = 0  # message index\n        for part_index in range(1, parts_limit + 1):\n            if m_index >= len(message): break\n            length = limit - len(str(part_index)) - len(str(parts_limit)) - 3\n            parts.append(message[m_index:m_index + length])\n            m_index += length\n        \n        return [f'{part}<{i + 1}/{len(parts)}>' for i, part in enumerate(parts)]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2469": {
        "problem_id": 2469,
        "description": "You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.\nYou should convert Celsius into Kelvin and Fahrenheit and return it as an array ans = [kelvin, fahrenheit].\nReturn the array ans. Answers within 10-5 of the actual answer will be accepted.\nNote that:\n\t- Kelvin = Celsius + 273.15\n\t- Fahrenheit = Celsius * 1.80 + 32.00\n",
        "provided_code_snippet": "class Solution:\r\n    def convertTemperature(self, celsius: float) -> List[float]:",
        "solution": "class Solution:\n    def convertTemperature(self, celsius: float) -> List[float]:\n        return [celsius + 273.15, celsius * 1.80 + 32.00]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2470": {
        "problem_id": 2470,
        "description": "Given an integer array nums and an integer k, return the number of subarrays of nums where the least common multiple of the subarray's elements is k.\nA subarray is a contiguous non-empty sequence of elements within an array.\nThe least common multiple of an array is the smallest positive integer that is divisible by all the array elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def subarrayLCM(self, nums: List[int], k: int) -> int:",
        "solution": "import math\nclass Solution:\n    def subarrayLCM(self, nums: List[int], k: int) -> int:\n        def gcd(a,b):\n            return math.gcd(a,b)\n        def lcm(n1,n2):\n            return (n1*n2)//gcd(n1,n2)\n        n=len(nums)\n        ans=0\n        for i in range(n):\n            lcmi=nums[i]\n            for j in range(i,n):\n                lcmi=lcm(lcmi,nums[j])\n                if(lcmi==k):\n                    ans+=1\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2471": {
        "problem_id": 2471,
        "description": "You are given the root of a binary tree with unique values.\nIn one operation, you can choose any two nodes at the same level and swap their values.\nReturn the minimum number of operations needed to make the values at each level sorted in a strictly increasing order.\nThe level of a node is the number of edges along the path between it and the root node.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def minimumOperations(self, root: Optional[TreeNode]) -> int:",
        "solution": "class Solution:                                                             # Ex:  root = [1, 4,3, 7,6,8,5, None,None,11,None,9,None,10,None]\n    def minimumOperations(self, root: TreeNode) -> int:                     #           _____1____\n                                                                            #          /          \\\\\n        ans, queue, level = 0, [root],[]                                    #         4___         3___\n                                                                            #        /    \\\\       /    \\\\\n        while queue :                                                       #       7     _6     8     _5\n                                                                            #            /      /     /\n            for node in queue:                                              #           11     9     10\n                    if node:  level.extend([node.left, node.right])         #\n                                                                            #  level         idx             ans\n            arr = [(v,i) for i,v in enumerate([c.val for c in level if c])] #  \\u2013\\u2013\\u2013\\u2013\\u2013        \\u2013\\u2013\\u2013\\u2013\\u2013           \\u2013\\u2013\\u2013\\u2013\\u2013\n            idx = [i for _,i in sorted(arr)]                                #  [4,3]        [1,0]             1\n                                                                            #  [7,6,8,5]    [2,1,3,0]         2\n            for i in range(len(idx)):                                       #  [11,9,10]    [1,2,0]           2\n                while (idx[i] != i):                                        #                               \\u2013\\u2013\\u2013\\u2013\\u2013\n                    j = idx[i]                                              #                                 5   <--- ans\n                    idx[i], idx[j] = idx[j], idx[i]\n                    ans += 1\n\n            queue, level = level, []\n        \n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2472": {
        "problem_id": 2472,
        "description": "You are given a string s and a positive integer k.\nSelect a set of non-overlapping substrings from the string s that satisfy the following conditions:\n\t- The length of each substring is at least k.\n\t- Each substring is a palindrome.\nReturn the maximum number of substrings in an optimal selection.\nA substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxPalindromes(self, s: str, k: int) -> int:",
        "solution": "class Solution:\n    def maxPalindromes(self, s: str, k: int) -> int:\n        n = len(s)\n        dp = [0] * (n + 1)\n        for i in range(k, n + 1):\n            dp[i] = dp[i - 1]\n            for length in range(k, k + 2):\n                j = i - length\n                if j < 0:\n                    break\n                if self.isPalindrome(s, j, i):\n                    dp[i] = max(dp[i], 1 + dp[j])\n        return dp[-1]\n    \n    \n    def isPalindrome(self, s, j, i):\n        left, right = j, i - 1\n        while left < right:\n            if s[left] != s[right]:\n                return False\n            left += 1\n            right -= 1\n        return True",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2475": {
        "problem_id": 2475,
        "description": "You are given a 0-indexed array of positive integers nums. Find the number of triplets (i, j, k) that meet the following conditions:\n\t- 0 <= i < j < k < nums.length\n\t- nums[i], nums[j], and nums[k] are pairwise distinct.\t\t\t- In other words, nums[i] != nums[j], nums[i] != nums[k], and nums[j] != nums[k].\n\t\t\nReturn the number of triplets that meet the conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def unequalTriplets(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def unequalTriplets(self, nums: List[int]) -> int:\n        c = Counter(nums)\n        res = 0\n        \n        left = 0\n        right = len(nums)\n        \n        for _, freq in c.items():\n            right -= freq\n            res += left * freq * right\n            left += freq\n        \n        return res",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2476": {
        "problem_id": 2476,
        "description": "You are given the root of a binary search tree and an array queries of size n consisting of positive integers.\nFind a 2D array answer of size n where answer[i] = [mini, maxi]:\n\t- mini is the largest value in the tree that is smaller than or equal to queries[i]. If a such value does not exist, add -1 instead.\n\t- maxi is the smallest value in the tree that is greater than or equal to queries[i]. If a such value does not exist, add -1 instead.\nReturn the array answer.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def closestNodes(self, root: Optional[TreeNode], queries: List[int]) -> List[List[int]]:",
        "solution": "class Solution(object):\n    def closestNodes(self, root, queries):\n        def dfs(root, arr):\n            if not root: return\n            dfs(root.left, arr)\n            arr.append(root.val)\n            dfs(root.right, arr)\n        arr = []\n        dfs(root, arr)\n        ans = []\n        n = len(arr)\n        for key in queries:\n            left, right = 0, n - 1\n            while right >= left:\n                mid = (right + left) // 2\n                if arr[mid] == key:\n                    break\n                elif arr[mid] > key:\n                    right = mid - 1\n                else:\n                    left = mid + 1\n            if arr[mid] == key:\n                ans.append([arr[mid], arr[mid]])\n            elif arr[mid] > key:\n                if (mid - 1) >= 0:\n                    ans.append([arr[mid - 1], arr[mid]])\n                else:\n                    ans.append([-1, arr[mid]])\n            else:\n                if (mid + 1) < n:\n                    ans.append([arr[mid], arr[mid + 1]])\n                else:\n                    ans.append([arr[mid], -1])\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2477": {
        "problem_id": 2477,
        "description": "There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads. The capital city is city 0. You are given a 2D integer array roads where roads[i] = [ai, bi] denotes that there exists a bidirectional road connecting cities ai and bi.\nThere is a meeting for the representatives of each city. The meeting is in the capital city.\nThere is a car in each city. You are given an integer seats that indicates the number of seats in each car.\nA representative can use the car in their city to travel or change the car and ride with another representative. The cost of traveling between two cities is one liter of fuel.\nReturn the minimum number of liters of fuel to reach the capital city.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumFuelCost(self, roads: List[List[int]], seats: int) -> int:",
        "solution": "def minimumFuelCost(self, roads: List[List[int]], seats: int) -> int:\n        graph = defaultdict(list)\n        for x, y in roads:\n            graph[x].append(y)\n            graph[y].append(x)\n        self.ans = 0\n        \n        def dfs(i, prev, people = 1):\n            for x in graph[i]:\n                if x == prev: continue\n                people += dfs(x, i)\n            self.ans += (int(ceil(people / seats)) if i else 0)\n            return people\n        \n        dfs(0, 0)\n        return self.ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2478": {
        "problem_id": 2478,
        "description": "You are given a string s that consists of the digits '1' to '9' and two integers k and minLength.\nA partition of s is called beautiful if:\n\t- s is partitioned into k non-intersecting substrings.\n\t- Each substring has a length of at least minLength.\n\t- Each substring starts with a prime digit and ends with a non-prime digit. Prime digits are '2', '3', '5', and '7', and the rest of the digits are non-prime.\nReturn the number of beautiful partitions of s. Since the answer may be very large, return it modulo 109 + 7.\nA substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def beautifulPartitions(self, s: str, k: int, minLength: int) -> int:",
        "solution": "def beautifulPartitions(self, s: str, k: int, minLength: int) -> int:\n    n, primes, mod = len(s), set('2357'), (10 ** 9) + 7\n    @cache\n    def dp(i, at_start, k):\n        if i == n: return int(k == 0)\n        if i > n or k == 0 or s[i] not in primes and at_start: return 0\n        if s[i] in primes:\n            if at_start: return dp(i + minLength - 1, False, k)\n            else: return dp(i + 1, False, k)\n        return (dp(i + 1, True, k - 1) + dp(i + 1, False, k)) % mod\n    return dp(0, True, k)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2481": {
        "problem_id": 2481,
        "description": "A valid cut in a circle can be:\n\t- A cut that is represented by a straight line that touches two points on the edge of the circle and passes through its center, or\n\t- A cut that is represented by a straight line that touches one point on the edge of the circle and its center.\nSome valid and invalid cuts are shown in the figures below.\nGiven the integer n, return the minimum number of cuts needed to divide a circle into n equal slices.\n",
        "provided_code_snippet": "class Solution:\r\n    def numberOfCuts(self, n: int) -> int:",
        "solution": "class Solution:\n    def numberOfCuts(self, n: int) -> int:\n\n        return n if n %2 and n!= 1 else n//2",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2482": {
        "problem_id": 2482,
        "description": "You are given a 0-indexed m x n binary matrix grid.\nA 0-indexed m x n difference matrix diff is created with the following procedure:\n\t- Let the number of ones in the ith row be onesRowi.\n\t- Let the number of ones in the jth column be onesColj.\n\t- Let the number of zeros in the ith row be zerosRowi.\n\t- Let the number of zeros in the jth column be zerosColj.\n\t- diff[i][j] = onesRowi + onesColj - zerosRowi - zerosColj\nReturn the difference matrix diff.\n",
        "provided_code_snippet": "class Solution:\r\n    def onesMinusZeros(self, grid: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def onesMinusZeros(self, grid: List[List[int]]) -> List[List[int]]:\n        m = len(grid)\n        n = len(grid[0])\n        res = [[0] * n for _ in range(m)]\n        ones_row = [row.count(1) for row in grid]\n        ones_col = [col.count(1) for col in zip(*grid)]\n\n        for i in range(m):\n            for j in range(n):\n                res[i][j] = ones_row[i] + ones_col[j] - (m - ones_row[i]) - (n - ones_col[j])\n\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2483": {
        "problem_id": 2483,
        "description": "You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y':\n\t- if the ith character is 'Y', it means that customers come at the ith hour\n\t- whereas 'N' indicates that no customers come at the ith hour.\nIf the shop closes at the jth hour (0 <= j <= n), the penalty is calculated as follows:\n\t- For every hour when the shop is open and no customers come, the penalty increases by 1.\n\t- For every hour when the shop is closed and customers come, the penalty increases by 1.\nReturn the earliest hour at which the shop must be closed to incur a minimum penalty.\nNote that if a shop closes at the jth hour, it means the shop is closed at the hour j.\n",
        "provided_code_snippet": "class Solution:\r\n    def bestClosingTime(self, customers: str) -> int:",
        "solution": "class Solution:\n    def bestClosingTime(self, customers: str) -> int:\n        max_score = score = 0\n        best_hour = -1\n\n        for i, c in enumerate(customers):\n            score += 1 if c == 'Y' else -1\n            if score > max_score:\n                max_score, best_hour = score, i\n                \n        return best_hour + 1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2484": {
        "problem_id": 2484,
        "description": "Given a string of digits s, return the number of palindromic subsequences of s having length 5. Since the answer may be very large, return it modulo 109 + 7.\nNote:\n\t- A string is palindromic if it reads the same forward and backward.\n\t- A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPalindromes(self, s: str) -> int:",
        "solution": "def countPalindromes(self, s: str) -> int:\n    mod, n, ans = 10 ** 9 + 7, len(s), 0\n    pre, cnts = [[[0] * 10 for _ in range(10)] for _ in range(n)], [0] * 10\n    for i in range(n):\n        c = ord(s[i]) - ord('0')\n        if i:\n            for j in range(10):\n                for k in range(10):\n                    pre[i][j][k] = pre[i - 1][j][k] \n                    if k == c: pre[i][j][k] += cnts[j]\n        cnts[c] += 1\n    suf, cnts = [[[0] * 10 for _ in range(10)] for _ in range(n)], [0] * 10\n    for i in range(n - 1, -1, -1):\n        c = ord(s[i]) - ord('0')\n        if i < n - 1:\n            for j in range(10):\n                for k in range(10):\n                    suf[i][j][k] = suf[i + 1][j][k]\n                    if k == c: suf[i][j][k] += cnts[j]\n        cnts[c] += 1\n    for i in range(2, n - 2):\n        for j in range(10):\n            for k in range(10):\n                ans += pre[i - 1][j][k] * suf[i + 1][j][k]\n    return ans % mod",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2485": {
        "problem_id": 2485,
        "description": "Given a positive integer n, find the pivot integer x such that:\n\t- The sum of all elements between 1 and x inclusively equals the sum of all elements between x and n inclusively.\nReturn the pivot integer x. If no such integer exists, return -1. It is guaranteed that there will be at most one pivot index for the given input.\n",
        "provided_code_snippet": "class Solution:\r\n    def pivotInteger(self, n: int) -> int:",
        "solution": "class Solution:\n    def pivotInteger(self, n: int) -> int:\n        sum = n * (n + 1) // 2\n        a = math.sqrt(sum)\n\n        if a - math.ceil(a) == 0:\n            return int(a)\n        else:\n            return -1",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2486": {
        "problem_id": 2486,
        "description": "You are given two strings s and t consisting of only lowercase English letters.\nReturn the minimum number of characters that need to be appended to the end of s so that t becomes a subsequence of s.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\n",
        "provided_code_snippet": "class Solution:\r\n    def appendCharacters(self, s: str, t: str) -> int:",
        "solution": "class Solution:\n    def appendCharacters(self, s: str, t: str) -> int:\n        i, j = 0, 0  # Start both pointers at the beginning of s and t\n        \n        while i < len(s) and j < len(t):  # Continue until one of the strings is fully scanned\n            if s[i] == t[j]:  # If characters match\n                j += 1  # Move the pointer in t forward\n            i += 1  # Always move the pointer in s forward\n        \n        return len(t) - j  # The number of characters in t not matched in s",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2487": {
        "problem_id": 2487,
        "description": "You are given the head of a linked list.\nRemove every node which has a node with a strictly greater value anywhere to the right side of it.\nReturn the head of the modified linked list.\n",
        "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n#     def __init__(self, val=0, next=None):\r\n#         self.val = val\r\n#         self.next = next\r\nclass Solution:\r\n    def removeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:",
        "solution": "class Solution:\n    def removeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]:\n        cur = head\n        stack = []\n        while cur:\n            while stack and stack[-1].val < cur.val:\n                stack.pop()\n            stack.append(cur)\n            cur = cur.next\n        \n        nxt = None\n        while stack:\n            cur = stack.pop()\n            cur.next = nxt\n            nxt = cur\n        \n        return cur",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2488": {
        "problem_id": 2488,
        "description": "You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k.\nReturn the number of non-empty subarrays in nums that have a median equal to k.\nNote:\n\t- The median of an array is the middle element after sorting the array in ascending order. If the array is of even length, the median is the left middle element.\t\t\t- For example, the median of [2,3,1,4] is 2, and the median of [8,4,3,5,1] is 4.\n\t\t\n\t- A subarray is a contiguous part of an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countSubarrays(self, nums: List[int], k: int) -> int:",
        "solution": "def countSubarrays(self, nums: List[int], k: int) -> int:\n        prefix_sum_of_balance = Counter([0]) # Dummy value of 0's frequency is 1.\n        running_balance = ans = 0\n        found = False\n        for num in nums:\n            if num < k:\n                running_balance -= 1\n            elif num > k:\n                running_balance += 1\n            else:\n                found = True\n            if found:\n                ans += prefix_sum_of_balance[running_balance] + prefix_sum_of_balance[running_balance - 1]    \n            else:\n                prefix_sum_of_balance[running_balance] += 1\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2490": {
        "problem_id": 2490,
        "description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces.\n\t- For example, \"Hello World\", \"HELLO\", \"hello world hello world\" are all sentences.\nWords consist of only uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different.\nA sentence is circular if:\n\t- The last character of a word is equal to the first character of the next word.\n\t- The last character of the last word is equal to the first character of the first word.\nFor example, \"leetcode exercises sound delightful\", \"eetcode\", \"leetcode eats soul\" are all circular sentences. However, \"Leetcode is cool\", \"happy Leetcode\", \"Leetcode\" and \"I like Leetcode\" are not circular sentences.\nGiven a string sentence, return true if it is circular. Otherwise, return false.\n",
        "provided_code_snippet": "class Solution:\r\n    def isCircularSentence(self, sentence: str) -> bool:",
        "solution": "class Solution(object):\n    def isCircularSentence(self, s):\n        if s[0] != s[-1]: return False\n        flag = 1\n        for ch in s:\n            if flag:\n                if ch != ' ': last = ch\n                else: flag = 0\n            else:\n                if ch != last: return False\n                flag = 1\n        return True",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2491": {
        "problem_id": 2491,
        "description": "You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skill of each team is equal.\nThe chemistry of a team is equal to the product of the skills of the players on that team.\nReturn the sum of the chemistry of all the teams, or return -1 if there is no way to divide the players into teams such that the total skill of each team is equal.\n",
        "provided_code_snippet": "class Solution:\r\n    def dividePlayers(self, skill: List[int]) -> int:",
        "solution": "class Solution:\n    def dividePlayers(self, skill: List[int]) -> int:\n        # Step 1: Sort the skill array\n        skill.sort()\n        \n        total_skill = skill[0] + skill[-1]  # Required sum for each pair\n        chemistry_sum = 0\n\n        # Step 2: Pair players using two pointers\n        for i in range(len(skill) // 2):\n            # Check if the sum of current pair matches the required total_skill\n            if skill[i] + skill[-i - 1] != total_skill:\n                return -1  # Invalid configuration, return -1\n            # Calculate the chemistry (product of pair) and add it to the sum\n            chemistry_sum += skill[i] * skill[-i - 1]\n\n        return chemistry_sum  # Return total chemistry",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2492": {
        "problem_id": 2492,
        "description": "You are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei] indicates that there is a bidirectional road between cities ai and bi with a distance equal to distancei. The cities graph is not necessarily connected.\nThe score of a path between two cities is defined as the minimum distance of a road in this path.\nReturn the minimum possible score of a path between cities 1 and n.\nNote:\n\t- A path is a sequence of roads between two cities.\n\t- It is allowed for a path to contain the same road multiple times, and you can visit cities 1 and n multiple times along the path.\n\t- The test cases are generated such that there is at least one path between 1 and n.\n",
        "provided_code_snippet": "class Solution:\r\n    def minScore(self, n: int, roads: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minScore(self, num_nodes: int, edges: List[List[int]]) -> int:\n        \n        graph = defaultdict(dict)\n        for u, v, w in edges:\n            graph[u][v] = graph[v][u] = w\n        \n        min_score = float('inf')\n        visited = set()\n        queue = deque([1])\n\n        while queue:\n            node = queue.popleft()\n            for adj, score in graph[node].items():\n                if adj not in visited:\n                    queue.append(adj)\n                    visited.add(adj)\n                min_score = min(min_score, score)\n                \n        return min_score",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2493": {
        "problem_id": 2493,
        "description": "You are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n.\nYou are also given a 2D integer array edges, where edges[i] = [ai, bi] indicates that there is a bidirectional edge between nodes ai and bi. Notice that the given graph may be disconnected.\nDivide the nodes of the graph into m groups (1-indexed) such that:\n\t- Each node in the graph belongs to exactly one group.\n\t- For every pair of nodes in the graph that are connected by an edge [ai, bi], if ai belongs to the group with index x, and bi belongs to the group with index y, then |y - x| = 1.\nReturn the maximum number of groups (i.e., maximum m) into which you can divide the nodes. Return -1 if it is impossible to group the nodes with the given conditions.\n",
        "provided_code_snippet": "class Solution:\r\n    def magnificentSets(self, n: int, edges: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def magnificentSets(self, n: int, edges: List[List[int]]) -> int:\n        graph = defaultdict(list)\n        for a, b in edges:\n            graph[a].append(b)\n            graph[b].append(a)\n        components = []\n        seen = set()\n        for i in range(1, n + 1):\n            if i in seen:\n                continue\n            queue = deque([i])\n            visited = set([i])\n            while queue:\n                for _ in range(len(queue)):\n                    node = queue.popleft()\n                    for neighbor in graph[node]:\n                        if neighbor in visited:\n                            continue\n                        visited.add(neighbor)\n                        queue.append(neighbor)\n            components.append(visited)\n            seen = seen.union(visited)\n        longest = [-1] * len(components)        \n        for k in range(len(components)):\n            for i in components[k]:\n                longest[k] = max(longest[k], self.bfs(graph, i))\n        if min(longest) < 0:\n            return -1\n        return sum(longest)\n            \n    def bfs(self, graph, i):\n        queue = deque([i])\n        seen = set([i])\n        seenLevel = set()\n        ans = 0\n        while queue:\n            ans += 1\n            nextLevel = set()\n            for _ in range(len(queue)):\n                node = queue.popleft()\n                for neighbor in graph[node]:\n                    if neighbor in seenLevel:\n                        return -1\n                    if neighbor in seen:\n                        continue\n                    seen.add(neighbor)\n                    nextLevel.add(neighbor)\n                    queue.append(neighbor)\n            seenLevel = nextLevel\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2496": {
        "problem_id": 2496,
        "description": "The value of an alphanumeric string can be defined as:\n\t- The numeric representation of the string in base 10, if it comprises of digits only.\n\t- The length of the string, otherwise.\nGiven an array strs of alphanumeric strings, return the maximum value of any string in strs.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumValue(self, strs: List[str]) -> int:",
        "solution": "class Solution(object):\n    def maximumValue(self, strs):\n        max_ = 0\n        for ch in strs:\n            if ch.isdigit(): max_ = max(max_, int(ch))\n            else: max_ = max(max_, len(ch))\n        return max_",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2497": {
        "problem_id": 2497,
        "description": "There is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] denotes the value of the ith node.\nYou are also given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting nodes ai and bi.\nA star graph is a subgraph of the given graph having a center node containing 0 or more neighbors. In other words, it is a subset of edges of the given graph such that there exists a common node for all edges.\nThe image below shows star graphs with 3 and 4 neighbors respectively, centered at the blue node.\nThe star sum is the sum of the values of all the nodes present in the star graph.\nGiven an integer k, return the maximum star sum of a star graph containing at most k edges.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:",
        "solution": "class Solution:\n    def maxStarSum(self, vals: List[int], edges: List[List[int]], k: int) -> int:\n        \n        m = defaultdict(list)                   # For each node, we will have min heap of size k which stores values                                                             # of Top-K nodes it is connected to.\n        \n        for x,y in edges:       \n            \n            if vals[y]>0:                       # If neighbor value is negative, our star will have more value without it.\n                \n                heapq.heappush(m[x], vals[y])   # For each node, push this neighbors value to its heap\n                if len(m[x])>k:                 # If the Min-Heap size is more than K.                      \n                    heapq.heappop(m[x])         # Pop the smallest Neighbour value as we can't use it anyway.             \n            \n            if vals[x]>0:\n                heapq.heappush(m[y], vals[x])   # Repeat the same for other neighbor              \n                if len(m[y])>k:\n                    heapq.heappop(m[y])\n            \n            \n        res = -math.inf\n        for i in range(len(vals)):              # We'll try to maximize the star with each node being center\n            tot = vals[i]                       # Our total will be value of that node as it has to be included.\n            \n            for nei_value in m[i]:              # We will check each value in the heap for the node.                      \n                tot+=nei_value                  # We have already excluded neg values when pushing to Min-Heap\n                \n            res = max(res, tot)                 # We'll maximize our result\n            \n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2498": {
        "problem_id": 2498,
        "description": "You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river.\nA frog, initially on the first stone, wants to travel to the last stone and then return to the first stone. However, it can jump to any stone at most once.\nThe length of a jump is the absolute difference between the position of the stone the frog is currently on and the position of the stone to which the frog jumps.\n\t- More formally, if the frog is at stones[i] and is jumping to stones[j], the length of the jump is |stones[i] - stones[j]|.\nThe cost of a path is the maximum length of a jump among all jumps in the path.\nReturn the minimum cost of a path for the frog.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxJump(self, stones: List[int]) -> int:",
        "solution": "class Solution:\n    def maxJump(self, stones: List[int]) -> int:\n        if len(stones) == 2:\n            return (stones[-1] - stones[0])\n        maxjump = 0\n        i, j = 0, 2\n        while j < len(stones):\n            maxjump = max(maxjump, (stones[j] - stones[i]))\n            i+= 1; j+= 1\n        return maxjump",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2499": {
        "problem_id": 2499,
        "description": "You are given two 0-indexed integer arrays nums1 and nums2, of equal length n.\nIn one operation, you can swap the values of any two indices of nums1. The cost of this operation is the sum of the indices.\nFind the minimum total cost of performing the given operation any number of times such that nums1[i] != nums2[i] for all 0 <= i <= n - 1 after performing all the operations.\nReturn the minimum total cost such that nums1 and nums2 satisfy the above condition. In case it is not possible, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTotalCost(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def minimumTotalCost(self, A, B):\n        N = len(A)\n        indexes = {i for i in range(N) if A[i] == B[i]}\n        if not indexes:\n            return 0\n\n        count = Counter(A[i] for i in indexes)\n        major = max(count, key=count.__getitem__)\n        to_add = max(count[major] * 2 - len(indexes), 0)\n        for i in range(N):\n            if to_add and A[i] != major != B[i] and i not in indexes:\n                to_add -= 1\n                indexes.add(i)\n\n        return -1 if to_add else sum(indexes)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2500": {
        "problem_id": 2500,
        "description": "You are given an m x n matrix grid consisting of positive integers.\nPerform the following operation until grid becomes empty:\n\t- Delete the element with the greatest value from each row. If multiple such elements exist, delete any of them.\n\t- Add the maximum of deleted elements to the answer.\nNote that the number of columns decreases by one after each operation.\nReturn the answer after performing the operations described above.\n",
        "provided_code_snippet": "class Solution:\r\n    def deleteGreatestValue(self, grid: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def deleteGreatestValue(self, grid: List[List[int]]) -> int:\n        return sum(max(c) for c in zip(*[sorted(r) for r in grid]))",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2501": {
        "problem_id": 2501,
        "description": "You are given an integer array nums. A subsequence of nums is called a square streak if:\n\t- The length of the subsequence is at least 2, and\n\t- after sorting the subsequence, each element (except the first element) is the square of the previous number.\nReturn the length of the longest square streak in nums, or return -1 if there is no square streak.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestSquareStreak(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def longestSquareStreak(self, nums: List[int]) -> int:\n\n        s = set(nums)\n        nums, ans = sorted(s), 0\n        s = {n for n in s if n%4 < 2}\n\n        for n in nums:\n            square, tally = n*n, 1\n\n            while square in s:\n                s.remove(square)\n                tally+= 1\n                square*= square\n\n            ans = max(ans, tally)\n   \n        return ans if ans > 1 else -1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2503": {
        "problem_id": 2503,
        "description": "You are given an m x n integer matrix grid and an array queries of size k.\nFind an array answer of size k such that for each integer queries[i] you start in the top left cell of the matrix and repeat the following process:\n\t- If queries[i] is strictly greater than the value of the current cell that you are in, then you get one point if it is your first time visiting this cell, and you can move to any adjacent cell in all 4 directions: up, down, left, and right.\n\t- Otherwise, you do not get any points, and you end this process.\nAfter the process, answer[i] is the maximum number of points you can get. Note that for each query you are allowed to visit the same cell multiple times.\nReturn the resulting array answer.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxPoints(self, grid: List[List[int]], queries: List[int]) -> List[int]:",
        "solution": "class Solution:\n\tdef maxPoints(self, grid: List[List[int]], queries: List[int]) -> List[int]:\n\t\t#It is a simple questions based on the concept of graph\n\t\t#As we all know we can represent a matrix/grid into a graph\n\t\t#Then we can use the heap(min Heap) to get a perfect path.\n\t\t#Then we are using maxYet(means max till that index).\n\t\tm = len(grid)\n\t\tn = len(grid[0])\n\t\theap = [(grid[0][0], 0, 0)]\n\t\tv = {(0, 0)}\n\t\torder = []\n\t\twhile len(heap) > 0:\n\t\t\tcurr, i, j = heapq.heappop(heap)\n\t\t\torder.append(curr)\n\t\t\tfor x, y in [(i - 1, j), (i, j - 1), (i + 1, j), (i, j + 1)]:\n\t\t\t\tif 0 <= x < m and 0 <= y < n and (x, y) not in v:\n\t\t\t\t\tv.add((x, y))\n\t\t\t\t\theapq.heappush(heap, (grid[x][y], x, y))\n\t\tmaxYet = -1\n\t\tfor i in range(len(order)):\n\t\t\tmaxYet = max(maxYet, order[i])\n\t\t\torder[i] = maxYet\n\t\tres = []\n\t\tfor q in queries:\n\t\t\tres.append(bisect.bisect_left(order, q))\n\t\treturn res",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2506": {
        "problem_id": 2506,
        "description": "You are given a 0-indexed string array words.\nTwo strings are similar if they consist of the same characters.\n\t- For example, \"abca\" and \"cba\" are similar since both consist of characters 'a', 'b', and 'c'.\n\t- However, \"abacba\" and \"bcfd\" are not similar since they do not consist of the same characters.\nReturn the number of pairs (i, j) such that 0 <= i < j <= word.length - 1 and the two strings words[i] and words[j] are similar.\n",
        "provided_code_snippet": "class Solution:\r\n    def similarPairs(self, words: List[str]) -> int:",
        "solution": "class Solution: \n\tdef similarPairs(self, words: List[str]) -> int: \n\t\tans = 0\n\t\tfreq = Counter()\n\t\tfor word in words: \n\t\t\tmask = reduce(or_, (1< int:",
        "solution": "class Solution:\n    def smallestValue(self, n):\n\n        prev, ans = n, 0\n\n        while not n%2:                  # 2 is the unique even prime\n                ans += 2\n                n//= 2\n\n        for i in range(3,n+1,2):        #  <\\u2013\\u2013 prune even divisors...\n                while not n%i:\n                    ans += i\n                    n//= i\n\n        return self.smallestValue(ans) if ans != prev else ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2508": {
        "problem_id": 2508,
        "description": "There is an undirected graph consisting of n nodes numbered from 1 to n. You are given the integer n and a 2D array edges where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi. The graph can be disconnected.\nYou can add at most two additional edges (possibly none) to this graph so that there are no repeated edges and no self-loops.\nReturn true if it is possible to make the degree of each node in the graph even, otherwise return false.\nThe degree of a node is the number of edges connected to it.\n",
        "provided_code_snippet": "class Solution:\r\n    def isPossible(self, n: int, edges: List[List[int]]) -> bool:",
        "solution": "class Solution:\n    def isPossible(self, n: int, edges: List[List[int]]) -> bool:\n\n        dic = defaultdict(set)                      # <\\u2013\\u2013 Build the graph       \n                                                    # \n        for p,q in edges:                           # \n            dic[p].add(q)                           # \n            dic[q].add(p)                           # \n        \n        oddNodes = [node for node in dic            # <\\u2013\\u2013 Determine the odd nodes\n                        if len(dic[node])%2]        #\n       \n        m = len(oddNodes)\n\n        if m == 0: return True                      # <\\u2013\\u2013 Case 0\n     \n        if m == 2:                                  # <\\u2013\\u2013 Case 2\n\n            a,b = oddNodes \n\n            return (not {a} & dic[b] or             # <\\u2013\\u2013 Case 2i\n              not all({a,b} & dic[i]for i in dic))  # <\\u2013\\u2013 Case 2ii\n  \n        if m == 4:                                  # <\\u2013\\u2013 Case 4\n            a, b, c, d = oddNodes\n            \n            if (not(a in dic[b] or c in dic[d]) or  # <\\u2013\\u2013 Find the pairings, if possible \n                not(a in dic[c] or b in dic[d]) or\n                not(a in dic[d] or b in dic[c])):\n                return True\n\n        return False                                # <\\u2013\\u2013 If nothing works, return False",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2509": {
        "problem_id": 2509,
        "description": "You are given an integer n. There is a complete binary tree with 2n - 1 nodes. The root of that tree is the node with the value 1, and every node with a value val in the range [1, 2n - 1 - 1] has two children where:\n\t- The left node has the value 2 * val, and\n\t- The right node has the value 2 * val + 1.\nYou are also given a 2D integer array queries of length m, where queries[i] = [ai, bi]. For each query, solve the following problem:\n\t- Add an edge between the nodes with values ai and bi.\n\t- Find the length of the cycle in the graph.\n\t- Remove the added edge between nodes with values ai and bi.\nNote that:\n\t- A cycle is a path that starts and ends at the same node, and each edge in the path is visited only once.\n\t- The length of a cycle is the number of edges visited in the cycle.\n\t- There could be multiple edges between two nodes in the tree after adding the edge of the query.\nReturn an array answer of length m where answer[i] is the answer to the ith query.\n",
        "provided_code_snippet": "class Solution:\r\n    def cycleLengthQueries(self, n: int, queries: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def cycleLengthQueries(self, n: int, queries: List[List[int]]) -> List[int]:\n        ans = []\n\n        for a, b in queries:\n            moves = 1\n\n            while a != b:\n                if a > b: a//= 2\n                else    : b//= 2\n\n                moves+= 1\n\n            ans.append(moves)  \n              \n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2511": {
        "problem_id": 2511,
        "description": "You are given a 0-indexed integer array forts of length n representing the positions of several forts. forts[i] can be -1, 0, or 1 where:\n\t- -1 represents there is no fort at the ith position.\n\t- 0 indicates there is an enemy fort at the ith position.\n\t- 1 indicates the fort at the ith the position is under your command.\nNow you have decided to move your army from one of your forts at position i to an empty position j such that:\n\t- 0 <= i, j <= n - 1\n\t- The army travels over enemy forts only. Formally, for all k where min(i,j) < k < max(i,j), forts[k] == 0.\nWhile moving the army, all the enemy forts that come in the way are captured.\nReturn the maximum number of enemy forts that can be captured. In case it is impossible to move your army, or you do not have any fort under your command, return 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def captureForts(self, forts: List[int]) -> int:",
        "solution": "class Solution: \n    def captureForts(self, forts: List[int]) -> int:\n        ans = ii = 0 \n        for i, x in enumerate(forts): \n            if x: \n                if forts[ii] == -x: ans = max(ans, i-ii-1)\n                ii = i \n        return ans ",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2512": {
        "problem_id": 2512,
        "description": "You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively. Note that no word is both positive and negative.\nInitially every student has 0 points. Each positive word in a feedback report increases the points of a student by 3, whereas each negative word decreases the points by 1.\nYou are given n feedback reports, represented by a 0-indexed string array report and a 0-indexed integer array student_id, where student_id[i] represents the ID of the student who has received the feedback report report[i]. The ID of each student is unique.\nGiven an integer k, return the top k students after ranking them in non-increasing order by their points. In case more than one student has the same points, the one with the lower ID ranks higher.\n",
        "provided_code_snippet": "class Solution:\r\n    def topStudents(self, positive_feedback: List[str], negative_feedback: List[str], report: List[str], student_id: List[int], k: int) -> List[int]:",
        "solution": "class Solution:\n    def topStudents(self, pos_feed: List[str], neg_feed: List[str], report: List[str], student_id: List[int], k: int) -> List[int]:\n        pos, neg, score_id = set(pos_feed), set(neg_feed), []\n        for r, id in zip(report, student_id):\n            score = sum(3 if w in pos else -1 if w in neg else 0 for w in r.split(\" \"))\n            score_id.append((-score, id))\n        return [id for _, id in sorted(score_id)[0 : k]]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2513": {
        "problem_id": 2513,
        "description": "We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:\n\t- arr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1.\n\t- arr2 contains uniqueCnt2 distinct positive integers, each of which is not divisible by divisor2.\n\t- No integer is present in both arr1 and arr2.\nGiven divisor1, divisor2, uniqueCnt1, and uniqueCnt2, return the minimum possible maximum integer that can be present in either array.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeSet(self, divisor1: int, divisor2: int, uniqueCnt1: int, uniqueCnt2: int) -> int:",
        "solution": "class Solution: \n\tdef minimizeSet(self, divisor1: int, divisor2: int, uniqueCnt1: int, uniqueCnt2: int) -> int: \n\t\tlo, hi = 0, 1<<32-1\n\t\tmult = lcm(divisor1, divisor2)\n\t\twhile lo < hi: \n\t\t\tmid = lo + hi >> 1\n\t\t\tif uniqueCnt1 <= mid - mid//divisor1 and uniqueCnt2 <= mid - mid//divisor2 and uniqueCnt1+uniqueCnt2 <= mid - mid//mult: hi = mid\n\t\t\telse: lo = mid+1\n\t\treturn lo ",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2514": {
        "problem_id": 2514,
        "description": "You are given a string s containing one or more words. Every consecutive pair of words is separated by a single space ' '.\nA string t is an anagram of string s if the ith word of t is a permutation of the ith word of s.\n\t- For example, \"acb dfe\" is an anagram of \"abc def\", but \"def cab\" and \"adc bef\" are not.\nReturn the number of distinct anagrams of s. Since the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def countAnagrams(self, s: str) -> int:",
        "solution": "class Solution:\n    def countAnagrams(self, s: str) -> int:\n\n        def get(word):\n            n = math.factorial(len(word))\n\n            for v in Counter(word).values():\n                n //= math.factorial(v)\n\n            return int(n) % (10**9 + 7)\n\n        total = 1  \n        for word in s.split():\n            total *= get(word)\n\n        return total % (10**9 + 7)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2515": {
        "problem_id": 2515,
        "description": "You are given a 0-indexed circular string array words and a string target. A circular array means that the array's end connects to the array's beginning.\n\t- Formally, the next element of words[i] is words[(i + 1) % n] and the previous element of words[i] is words[(i - 1 + n) % n], where n is the length of words.\nStarting from startIndex, you can move to either the next word or the previous word with 1 step at a time.\nReturn the shortest distance needed to reach the string target. If the string target does not exist in words, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def closetTarget(self, words: List[str], target: str, startIndex: int) -> int:",
        "solution": "    def closetTarget(self, words: List[str], target: str, startIndex: int) -> int:\r\n\r\n        n = len(words)\r\n\r\n        for left in range(n):\r\n            if words[(startIndex+left)%n ] == target: break\r\n        else: return -1    \r\n\r\n        for right in range(n):\r\n            if words[(startIndex-right)%n] == target: break\r\n  \r\n        return  min(left, right)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2516": {
        "problem_id": 2516,
        "description": "You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost character of s, or the rightmost character of s.\nReturn the minimum number of minutes needed for you to take at least k of each character, or return -1 if it is not possible to take k of each character.\n",
        "provided_code_snippet": "class Solution:\r\n    def takeCharacters(self, s: str, k: int) -> int:",
        "solution": "class Solution:\n    def takeCharacters(self, s: str, k: int) -> int:\n        limits = {c: s.count(c) - k for c in 'abc'}\n        if any(x < 0 for x in limits.values()):\n            return -1\n\n        cnts = {c: 0 for c in 'abc'}\n        ans = l = 0\n        for r, c in enumerate(s):\n            cnts[c] += 1\n            while cnts[c] > limits[c]:\n                cnts[s[l]] -= 1\n                l += 1\n            ans = max(ans, r - l + 1)\n\n        return len(s) - ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2517": {
        "problem_id": 2517,
        "description": "You are given an array of positive integers price where price[i] denotes the price of the ith candy and a positive integer k.\nThe store sells baskets of k distinct candies. The tastiness of a candy basket is the smallest absolute difference of the prices of any two candies in the basket.\nReturn the maximum tastiness of a candy basket.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumTastiness(self, price: List[int], k: int) -> int:",
        "solution": "def maximumTastiness(self, price: List[int], k: int) -> int:\n    price.sort()\n    def check(x):\n        last, count, i = price[0], 1, 1\n        while count < k and i < len(price):\n            if price[i] - last >= x:\n                last, count = price[i], count + 1\n            i += 1\n        return count == k\n    lo, hi = 0, 10 ** 9\n    while lo < hi:\n        mid = (lo + hi) // 2\n        if check(mid): lo = mid + 1\n        else: hi = mid\n    return lo - 1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2518": {
        "problem_id": 2518,
        "description": "You are given an array nums consisting of positive integers and an integer k.\nPartition the array into two ordered groups such that each element is in exactly one group. A partition is called great if the sum of elements of each group is greater than or equal to k.\nReturn the number of distinct great partitions. Since the answer may be too large, return it modulo 109 + 7.\nTwo partitions are considered distinct if some element nums[i] is in different groups in the two partitions.\n",
        "provided_code_snippet": "class Solution:\r\n    def countPartitions(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def countPartitions(self, nums: List[int], k: int) -> int:\n        n = len(nums)\n        dp = [[0] * (k + 1)] + [[-1] * (k + 1) for _ in range(n)]\n        dp[0][0] = 1\n        def subsetSumCounts(s, idx):\n            if s < 0:\n            \treturn 0\n            if dp[idx][s] < 0:\n                dp[idx][s] = subsetSumCounts(s, idx - 1) + subsetSumCounts(s - nums[idx - 1], idx - 1)\n            return dp[idx][s]\n                \n        invalid_pairs = sum([subsetSumCounts(i, n) for i in range(k)]) * 2\n        return max(2**n - invalid_pairs, 0) % (10**9 + 7)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2520": {
        "problem_id": 2520,
        "description": "Given an integer num, return the number of digits in num that divide num.\nAn integer val divides nums if nums % val == 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def countDigits(self, num: int) -> int:",
        "solution": "class Solution(object):\n    def countDigits(self, num):\n        str_num, count = str(num), 0\n        for digit in str_num:\n            if num % int(digit) == 0:\n                count += 1\n        return count",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2521": {
        "problem_id": 2521,
        "description": "Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums.\nNote that:\n\t- A number greater than 1 is called prime if it is divisible by only 1 and itself.\n\t- An integer val1 is a factor of another integer val2 if val2 / val1 is an integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def distinctPrimeFactors(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def distinctPrimeFactors(self, nums: List[int]) -> int:\n        \n        def primes(n) -> int:\n\n            if n %2 == 0: self.ans|= (1 << 2)\n            while n %2 == 0: n//= 2\n\n            for p in range(3, isqrt(n) + 1, 2):\n                if  n == 1: break\n\n                if n %p == 0: self.ans|= (1 << p)\n                while n %p == 0: n//= p\n\n            if  n > 1: self.ans|= (1 << n)\n            return \n\n        self.ans = 0\n        for n in nums: primes(n)\n        return self.ans.bit_count()",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2522": {
        "problem_id": 2522,
        "description": "You are given a string s consisting of digits from 1 to 9 and an integer k.\nA partition of a string s is called good if:\n\t- Each digit of s is part of exactly one substring.\n\t- The value of each substring is less than or equal to k.\nReturn the minimum number of substrings in a good partition of s. If no good partition of s exists, return -1.\nNote that:\n\t- The value of a string is its result when interpreted as an integer. For example, the value of \"123\" is 123 and the value of \"1\" is 1.\n\t- A substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumPartition(self, s: str, k: int) -> int:",
        "solution": "class Solution:\n    def minimumPartition(self, s: str, k: int) -> int:\n\n        if k < 10: return len(s) if k >= int(max(s)) else -1\n        \n        k, ans = str(k), 0\n        digits = len(k)\n\n        while s:\n            s = s[digits:] if s[:digits] <= k else s[digits-1:]\n            ans+= 1\n\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2523": {
        "problem_id": 2523,
        "description": "Given two positive integers left and right, find the two integers num1 and num2 such that:\n\t- left <= num1 < num2 <= right .\n\t- num1 and num2 are both prime numbers.\n\t- num2 - num1 is the minimum amongst all other pairs satisfying the above conditions.\nReturn the positive integer array ans = [num1, num2]. If there are multiple pairs satisfying these conditions, return the one with the minimum num1 value or [-1, -1] if such numbers do not exist.\nA number greater than 1 is called prime if it is only divisible by 1 and itself.\n",
        "provided_code_snippet": "class Solution:\r\n    def closestPrimes(self, left: int, right: int) -> List[int]:",
        "solution": "import math\n\n\ndef is_prime(num: int) -> bool:\n    if num == 1:\n        return False\n    for divisor in range(2, math.floor(math.sqrt(num)) + 1):\n        if num % divisor == 0:\n            return False\n    return True\n\n\nclass Solution:\n    def closestPrimes(self, left: int, right: int) -> list[int]:\n        primes = []\n        for candidate in range(left, right + 1):\n            if is_prime(candidate):\n                if primes and candidate <= primes[-1] + 2:\n                    return [primes[-1], candidate]  # twin or [2, 3]\n                primes.append(candidate)\n        \n        gaps = ([primes[i - 1], primes[i]]\n                for i in range(1, len(primes)))\n\n        return min(gaps,\n                   key=lambda gap: (gap[1] - gap[0], gap[0]),\n                   default=[-1, -1])",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2525": {
        "problem_id": 2525,
        "description": "Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the category of the box.\n\t- The box is \"Bulky\" if:\t\t\t- Any of the dimensions of the box is greater or equal to 104.\n\t\t- Or, the volume of the box is greater or equal to 109.\n\t\t\n\t- If the mass of the box is greater or equal to 100, it is \"Heavy\".\n\t- If the box is both \"Bulky\" and \"Heavy\", then its category is \"Both\".\n\t- If the box is neither \"Bulky\" nor \"Heavy\", then its category is \"Neither\".\n\t- If the box is \"Bulky\" but not \"Heavy\", then its category is \"Bulky\".\n\t- If the box is \"Heavy\" but not \"Bulky\", then its category is \"Heavy\".\nNote that the volume of the box is the product of its length, width and height.\n",
        "provided_code_snippet": "class Solution:\r\n    def categorizeBox(self, length: int, width: int, height: int, mass: int) -> str:",
        "solution": "class Solution:\n    def categorizeBox(self, length: int, width: int, height: int, mass: int) -> str:\n\n        idx = int(length >= 10000 or width >= 10000 or height >= 10000 or \n               length * width * height >= 10**9) + 2*(mass >= 100)\n        \n        return (\"Neither\", \"Bulky\", \"Heavy\", \"Both\")[idx]",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2527": {
        "problem_id": 2527,
        "description": "You are given a 0-indexed integer array nums.\nThe effective value of three indices i, j, and k is defined as ((nums[i] | nums[j]) & nums[k]).\nThe xor-beauty of the array is the XORing of the effective values of all the possible triplets of indices (i, j, k) where 0 <= i, j, k < n.\nReturn the xor-beauty of nums.\nNote that:\n\t- val1 | val2 is bitwise OR of val1 and val2.\n\t- val1 & val2 is bitwise AND of val1 and val2.\n",
        "provided_code_snippet": "class Solution:\r\n    def xorBeauty(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def xorBeauty(self, nums: List[int]) -> int:\n        return reduce(xor, nums)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2528": {
        "problem_id": 2528,
        "description": "You are given a 0-indexed integer array stations of length n, where stations[i] represents the number of power stations in the ith city.\nEach power station can provide power to every city in a fixed range. In other words, if the range is denoted by r, then a power station at city i can provide power to all cities j such that |i - j| <= r and 0 <= i, j <= n - 1.\n\t- Note that |x| denotes absolute value. For example, |7 - 5| = 2 and |3 - 10| = 7.\nThe power of a city is the total number of power stations it is being provided power from.\nThe government has sanctioned building k more power stations, each of which can be built in any city, and have the same range as the pre-existing ones.\nGiven the two integers r and k, return the maximum possible minimum power of a city, if the additional power stations are built optimally.\nNote that you can build the k power stations in multiple cities.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxPower(self, stations: List[int], r: int, k: int) -> int:",
        "solution": "    def maxPower(self, stations: List[int], r: int, k: int) -> int:\n        n = len(stations)\n\n        def isGood(minPowerRequired, additionalStations):\n            windowPower = sum(stations[:r])  # init windowPower to store power of 0th city (minus stations[r])\n            additions = [0] * n\n            for i in range(n):\n                if i + r < n:  # now, windowPower stores sum of power stations from [i-r..i+r], it also means it's the power of city `ith`\n                    windowPower += stations[i + r]\n\n                if windowPower < minPowerRequired:\n                    needed = minPowerRequired - windowPower\n                    if needed > additionalStations:  # Not enough additional stations to plant\n                        return False\n                    # Plant the additional stations on the farthest city in the range to cover as many cities as possible\n                    additions[min(n - 1, i + r)] += needed\n                    windowPower = minPowerRequired\n                    additionalStations -= needed\n\n                if i - r >= 0:  # out of window range\n                    windowPower -= stations[i - r] + additions[i - r]\n\n            return True\n\n        left = 0\n        right = sum(stations) + k  # The answer = `right`, when `r = n`, all value of stations are the same!\n        ans = 0\n        while left <= right:\n            mid = (left + right) // 2\n            if isGood(mid, k):\n                ans = mid  # This is the maximum possible minimum power so far\n                left = mid + 1  # Search for a larger value in the right side\n            else:\n                right = mid - 1  # Decrease minPowerRequired to need fewer additional power stations\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2529": {
        "problem_id": 2529,
        "description": "Given an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers.\n\t- In other words, if the number of positive integers in nums is pos and the number of negative integers is neg, then return the maximum of pos and neg.\nNote that 0 is neither positive nor negative.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumCount(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def maximumCount(self, nums: List[int]) -> int:\n        neg = bisect_left(nums, 0)\n        pos = len(nums) - bisect_right(nums, 0)\n        return max(neg, pos)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2530": {
        "problem_id": 2530,
        "description": "You are given a 0-indexed integer array nums and an integer k. You have a starting score of 0.\nIn one operation:\n\t1. choose an index i such that 0 <= i < nums.length,\n\t2. increase your score by nums[i], and\n\t3. replace nums[i] with ceil(nums[i] / 3).\nReturn the maximum possible score you can attain after applying exactly k operations.\nThe ceiling function ceil(val) is the least integer greater than or equal to val.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxKelements(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maxKelements(self, nums: List[int], k: int) -> int:\n        heapify(pq:=[-x for x in nums])\n        score=0\n        for i in range(k):\n            x=-heappop(pq)\n            score+=x\n            if x==1:\n                score+=k-1-i\n                break\n            heappush(pq, -((x+2)//3))\n        return score",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2531": {
        "problem_id": 2531,
        "description": "You are given two 0-indexed strings word1 and word2.\nA move consists of choosing two indices i and j such that 0 <= i < word1.length and 0 <= j < word2.length and swapping word1[i] with word2[j].\nReturn true if it is possible to get the number of distinct characters in word1 and word2 to be equal with exactly one move. Return false otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def isItPossible(self, word1: str, word2: str) -> bool:",
        "solution": "class Solution:\r\n    \r\n    def insertAndRemove(self, mp, toInsert, toRemove): \r\n        mp[toInsert]+=1\r\n        mp[toRemove]-=1\r\n        \r\n        if(mp[toRemove]==0):\r\n            del mp[toRemove]     # if freq of that char reaches zero, then remove the key from dict\r\n        \r\n        \r\n    def isItPossible(self, word1: str, word2: str) -> bool:\r\n        \r\n        mp1, mp2 = Counter(word1), Counter(word2)  # Get freq of chars using Counter\r\n\t\t\r\n        for c1 in string.ascii_lowercase:         # this for loop iterates through c1='a' to c1='z'\r\n            for c2 in string.ascii_lowercase:     # this for loop iterates through c2='a' to c2='z'\r\n                \r\n                if c1 not in mp1 or c2 not in mp2:  # if any of the char is not present then skip\r\n                    continue\r\n\r\n                self.insertAndRemove(mp1, c2, c1); # insert c2 to word1 and remove c1 from word1\r\n                self.insertAndRemove(mp2, c1, c2); # insert c1 to word2 and remove c2 from word2\r\n                \r\n                if len(mp1)== len(mp2):  # if size of both dicts are equal then possible return true\r\n                    return True\r\n\t\t\t\t\r\n                # reset back the maps\r\n                self.insertAndRemove(mp1, c1, c2); # insert c1 back to word1 and remove c2 from word1         \r\n                self.insertAndRemove(mp2, c2, c1); # insert c2 back to word2 and remove c1 from word2                \r\n        return False",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2532": {
        "problem_id": 2532,
        "description": "There are k workers who want to move n boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers n and k, and a 2D integer array time of size k x 4 where time[i] = [righti, picki, lefti, puti].\nThe warehouses are separated by a river and connected by a bridge. Initially, all k workers are waiting on the left side of the bridge. To move the boxes, the ith worker can do the following:\n\t- Cross the bridge to the right side in righti minutes.\n\t- Pick a box from the right warehouse in picki minutes.\n\t- Cross the bridge to the left side in lefti minutes.\n\t- Put the box into the left warehouse in puti minutes.\nThe ith worker is less efficient than the jth worker if either condition is met:\n\t- lefti + righti > leftj + rightj\n\t- lefti + righti == leftj + rightj and i > j\nThe following rules regulate the movement of the workers through the bridge:\n\t- Only one worker can use the bridge at a time.\n\t- When the bridge is unused prioritize the least efficient worker on the right side to cross. If there are no workers on the right side, prioritize the least efficient worker on the left side to cross.\nReturn the elapsed minutes at which the last box reaches the left side of the bridge.\n",
        "provided_code_snippet": "class Solution:\r\n    def findCrossingTime(self, n: int, k: int, time: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def findCrossingTime(self, n: int, k: int, time: List[List[int]]) -> int:\n        ans = free = 0 \n        l, ll = [], []\n        r, rr = [], []\n        for i, (x, _, y, _) in enumerate(time): heappush(ll, (-x-y, -i))\n        while n or r or rr: \n            if not rr and (not r or r[0][0] > free) and (not n or not ll and (not l or l[0][0] > free)): \n                cand = inf \n                if n and l: cand = min(cand, l[0][0])\n                if r: cand = min(cand, r[0][0])\n                free = cand\n                \n            while r and r[0][0] <= free: \n                _, i = heappop(r)\n                heappush(rr, (-time[i][0] - time[i][2], -i))\n\n            while l and l[0][0] <= free: \n                _, i = heappop(l)\n                heappush(ll, (-time[i][0] - time[i][2], -i))\n                \n            if rr: \n                _, i = heappop(rr)\n                free += time[-i][2]\n                if n: heappush(l, (free + time[-i][3], -i))\n                else: ans = max(ans, free)\n            else: \n                _, i = heappop(ll)\n                free += time[-i][0]\n                heappush(r, (free + time[-i][1], -i))\n                n -= 1\n        return ans ",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2535": {
        "problem_id": 2535,
        "description": "You are given a positive integer array nums.\n\t- The element sum is the sum of all the elements in nums.\n\t- The digit sum is the sum of all the digits (not necessarily distinct) that appear in nums.\nReturn the absolute difference between the element sum and digit sum of nums.\nNote that the absolute difference between two integers x and y is defined as |x - y|.\n",
        "provided_code_snippet": "class Solution:\r\n    def differenceOfSum(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def differenceOfSum(self, nums: List[int]) -> int:\n\n        digitSum = sum((map(int,list(''.join(map(str,nums))))))\n\n        return sum(nums) - digitSum",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2536": {
        "problem_id": 2536,
        "description": "You are given a positive integer n, indicating that we initially have an n x n 0-indexed integer matrix mat filled with zeroes.\nYou are also given a 2D integer array query. For each query[i] = [row1i, col1i, row2i, col2i], you should do the following operation:\n\t- Add 1 to every element in the submatrix with the top left corner (row1i, col1i) and the bottom right corner (row2i, col2i). That is, add 1 to mat[x][y] for all row1i <= x <= row2i and col1i <= y <= col2i.\nReturn the matrix mat after performing every query.\n",
        "provided_code_snippet": "class Solution:\r\n    def rangeAddQueries(self, n: int, queries: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def rangeAddQueries(self, n: int, queries: List[List[int]]) -> List[List[int]]:\n        ans = [[0] * n for _ in range(n)]\n        for r1, c1, r2, c2 in queries:\n            for r in range(r1, r2 + 1):\n                ans[r][c1] += 1\n                if c2 + 1 < n: ans[r][c2 + 1] -= 1\n        for r in range(n):\n            for c in range(1, n):\n                ans[r][c] += ans[r][c - 1]\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2537": {
        "problem_id": 2537,
        "description": "Given an integer array nums and an integer k, return the number of good subarrays of nums.\nA subarray arr is good if it there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j].\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def countGood(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def countGood(self, nums: List[int], k: int) -> int:\n\n        left = ans = tally = 0\n        n, d = len(nums), defaultdict(int)\n\n        for right,num in enumerate(nums):    # <-- 1\n            tally += d[num]\n            d[num] += 1\n            \n            while tally >= k:                # <-- 2     \n                ans+= n - right\n                d[nums[left]] -= 1           # <-- 3\n                tally -= d[nums[left]]\n                left += 1\n            \n        return ans                           # <-- 4",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2538": {
        "problem_id": 2538,
        "description": "There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nEach node has an associated price. You are given an integer array price, where price[i] is the price of the ith node.\nThe price sum of a given path is the sum of the prices of all nodes lying on that path.\nThe tree can be rooted at any node root of your choice. The incurred cost after choosing root is the difference between the maximum and minimum price sum amongst all paths starting at root.\nReturn the maximum possible cost amongst all possible root choices.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxOutput(self, n: int, edges: List[List[int]], price: List[int]) -> int:",
        "solution": "class Solution:\n    def maxOutput(self, n: int, edges: List[List[int]], \n                                price: List[int]) -> int:\n\n        g = defaultdict(list)\n        for a, b in edges:\n            g[a].append(b)\n            g[b].append(a)\n\n        def dfs(node1, node2 =-1):\n            p = price[node1]\n            state = (0, p, 0)\n\n            for n in g[node1]:\n                if n == node2: continue\n\n                (a1, a2, a3), (b1, b2, b3) = state, dfs(n, node1)\n                \n                state = (max(a1, b1, a2 + b3, a3 + b2),\n                         max(a2, b2 + p),\n                         max(a3, b3 + p))\n\n            return state\n\n\n        if n <= 2: return sum(price) - min(price)\n\n        for node in range(n):\n            if len(g[node]) > 1:\n                return dfs(node)[0]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2540": {
        "problem_id": 2540,
        "description": "Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays. If there is no common integer amongst nums1 and nums2, return -1.\nNote that an integer is said to be common to nums1 and nums2 if both arrays have at least one occurrence of that integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def getCommon(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def getCommon(self, nums1: List[int], nums2: List[int]) -> int:\n        i = 0\n        j = 0\n        common = float('inf')\n\n        while i < len(nums1) and j < len(nums2):\n            if nums1[i] == nums2[j]:\n                common = nums1[i]\n                break\n            elif nums1[i] < nums2[j]:\n                i += 1\n            else:\n                j += 1\n        \n        return common if common != float('inf') else -1",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2541": {
        "problem_id": 2541,
        "description": "You are given two integer arrays nums1 and nums2 of equal length n and an integer k. You can perform the following operation on nums1:\n\t- Choose two indexes i and j and increment nums1[i] by k and decrement nums1[j] by k. In other words, nums1[i] = nums1[i] + k and nums1[j] = nums1[j] - k.\nnums1 is said to be equal to nums2 if for all indices i such that 0 <= i < n, nums1[i] == nums2[i].\nReturn the minimum number of operations required to make nums1 equal to nums2. If it is impossible to make them equal, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minOperations(self, nums1: List[int], nums2: List[int], k: int) -> int:",
        "solution": "def minOperations(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        if k == 0:\n            return 0 if nums1 == nums2 else -1\n        ops = bal = 0\n        for a, b in zip(nums1, nums2):\n            if (a - b) % k != 0:\n                return -1\n            bal += a - b\n            if a > b:\n                ops += (a - b) // k\n        return ops if bal == 0 else -1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2542": {
        "problem_id": 2542,
        "description": "You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k. You must choose a subsequence of indices from nums1 of length k.\nFor chosen indices i0, i1, ..., ik - 1, your score is defined as:\n\t- The sum of the selected elements from nums1 multiplied with the minimum of the selected elements from nums2.\n\t- It can defined simply as: (nums1[i0] + nums1[i1] +...+ nums1[ik - 1]) * min(nums2[i0] , nums2[i1], ... ,nums2[ik - 1]).\nReturn the maximum possible score.\nA subsequence of indices of an array is a set that can be derived from the set {0, 1, ..., n-1} by deleting some or no elements.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxScore(self, nums1: List[int], nums2: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maxScore(self, nums1: List[int], nums2: List[int], k: int) -> int:\n        res, prefixSum, minHeap = 0, 0, []\n\n        for a, b in sorted(list(zip(nums1, nums2)), key=itemgetter(1), reverse=True):\n            prefixSum += a\n            heappush(minHeap, a)\n            if len(minHeap) == k:\n                res = max(res, prefixSum * b)\n                prefixSum -= heappop(minHeap)                           \n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2543": {
        "problem_id": 2543,
        "description": "There exists an infinitely large grid. You are currently at point (1, 1), and you need to reach the point (targetX, targetY) using a finite number of steps.\nIn one step, you can move from point (x, y) to any one of the following points:\n\t- (x, y - x)\n\t- (x - y, y)\n\t- (2 * x, y)\n\t- (x, 2 * y)\nGiven two integers targetX and targetY representing the X-coordinate and Y-coordinate of your final position, return true if you can reach the point from (1, 1) using some number of steps, and false otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def isReachable(self, targetX: int, targetY: int) -> bool:",
        "solution": "def isReachable(self, x: int, y: int) -> bool:\n        g = gcd(x, y)\n        while g % 2 == 0:\n            g //= 2\n        return g == 1",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2544": {
        "problem_id": 2544,
        "description": "You are given a positive integer n. Each digit of n has a sign according to the following rules:\n\t- The most significant digit is assigned a positive sign.\n\t- Each other digit has an opposite sign to its adjacent digits.\nReturn the sum of all digits with their corresponding sign.\n",
        "provided_code_snippet": "class Solution:\r\n    def alternateDigitSum(self, n: int) -> int:",
        "solution": "class Solution:\n    def alternateDigitSum(self, n: int) -> int:\n        s=str(n)\n        ans=0\n        for i in range(0,len(s),2):\n            ans+=int(s[i])\n        for i in range(1,len(s),2):\n            ans-=int(s[i])\n        return ans",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2545": {
        "problem_id": 2545,
        "description": "There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] denotes the score the ith student got in the jth exam. The matrix score contains distinct integers only.\nYou are also given an integer k. Sort the students (i.e., the rows of the matrix) by their scores in the kth (0-indexed) exam from the highest to the lowest.\nReturn the matrix after sorting it.\n",
        "provided_code_snippet": "class Solution:\r\n    def sortTheStudents(self, score: List[List[int]], k: int) -> List[List[int]]:",
        "solution": "class Solution:\n    def sortTheStudents(self, a: List[List[int]], k: int) -> List[List[int]]:\n        v=[]\n        \n        for i in range(len(a)):\n            v+=[[a[i][k],a[i]]]\n        print(v)\n        def cmp(a):\n            return a[0]\n        v=sorted(v,key=cmp)[::-1]\n        print(v)\n        ans=[]\n        for i in range(len(v)):\n            a[i]=v[i][1]\n        return a",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2546": {
        "problem_id": 2546,
        "description": "You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times:\n\t- Choose two different indices i and j where 0 <= i, j < n.\n\t- Simultaneously, replace s[i] with (s[i] OR s[j]) and s[j] with (s[i] XOR s[j]).\nFor example, if s = \"0110\", you can choose i = 0 and j = 2, then simultaneously replace s[0] with (s[0] OR s[2] = 0 OR 1 = 1), and s[2] with (s[0] XOR s[2] = 0 XOR 1 = 1), so we will have s = \"1110\".\nReturn true if you can make the string s equal to target, or false otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def makeStringsEqual(self, s: str, target: str) -> bool:",
        "solution": "def makeStringsEqual(self, s: str, target: str) -> bool:\n        if ('1' not in s) or ('1' not in target):\n            return s == target\n        return True",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2547": {
        "problem_id": 2547,
        "description": "You are given an integer array nums and an integer k.\nSplit the array into some number of non-empty subarrays. The cost of a split is the sum of the importance value of each subarray in the split.\nLet trimmed(subarray) be the version of the subarray where all numbers which appear only once are removed.\n\t- For example, trimmed([3,1,2,4,3,4]) = [3,4,3,4].\nThe importance value of a subarray is k + trimmed(subarray).length.\n\t- For example, if a subarray is [1,2,3,3,3,4,4], then trimmed([1,2,3,3,3,4,4]) = [3,3,3,4,4].The importance value of this subarray will be k + 5.\nReturn the minimum possible cost of a split of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def minCost(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def minCost(self, nums: List[int], k: int) -> int:\n        dp=[0]\n        nums=[-1]+nums\n        def main(i):\n            mp=defaultdict(int)\n            s=0\n            ans=10000000000000\n            while i>0:\n                if mp[nums[i]]>0:\n                    s+=1\n                    if mp[nums[i]]==1:\n                        s+=1\n                mp[nums[i]]+=1\n                ans=min(dp[i-1]+s,ans)\n                i-=1\n            return ans+k\n                \n            \n        for i in range(1,len(nums)):\n            dp.append(main(i))\n        return dp[-1]",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2549": {
        "problem_id": 2549,
        "description": "You are given a positive integer n, that is initially placed on a board. Every day, for 109 days, you perform the following procedure:\n\t- For each number x present on the board, find all numbers 1 <= i <= n such that x % i == 1.\n\t- Then, place those numbers on the board.\nReturn the number of distinct integers present on the board after 109 days have elapsed.\nNote:\n\t- Once a number is placed on the board, it will remain on it until the end.\n\t- % stands for the modulo operation. For example, 14 % 3 is 2.\n",
        "provided_code_snippet": "class Solution:\r\n    def distinctIntegers(self, n: int) -> int:",
        "solution": "class Solution:\n    def distinctIntegers(self, n: int) -> int:\n        return n if n<=1 else n-1",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2550": {
        "problem_id": 2550,
        "description": "There is a regular convex polygon with n vertices. The vertices are labeled from 0 to n - 1 in a clockwise direction, and each vertex has exactly one monkey. The following figure shows a convex polygon of 6 vertices.\nEach monkey moves simultaneously to a neighboring vertex. A neighboring vertex for a vertex i can be:\nA collision happens if at least two monkeys reside on the same vertex after the movement or intersect on an edge.\nReturn the number of ways the monkeys can move so that at least one collision happens. Since the answer may be very large, return it modulo 109 + 7.\nNote that each monkey can only move once.\n",
        "provided_code_snippet": "class Solution:\r\n    def monkeyMove(self, n: int) -> int:",
        "solution": "class Solution:\n    def monkeyMove(self, n: int) -> int:\n        modulo = 1_000_000_007\n        answer = 1\n        exponent = 2\n        while n:\n            if n&1:\n                answer *= exponent                \n            exponent = (exponent*exponent) % modulo\n            n >>= 1\n        answer += modulo - 2\n        answer %= modulo      \n        return answer",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2551": {
        "problem_id": 2551,
        "description": "You have k bags. You are given a 0-indexed integer array weights where weights[i] is the weight of the ith marble. You are also given the integer k.\nDivide the marbles into the k bags according to the following rules:\n\t- No bag is empty.\n\t- If the ith marble and jth marble are in a bag, then all marbles with an index between the ith and jth indices should also be in that same bag.\n\t- If a bag consists of all the marbles with an index from i to j inclusively, then the cost of the bag is weights[i] + weights[j].\nThe score after distributing the marbles is the sum of the costs of all the k bags.\nReturn the difference between the maximum and minimum scores among marble distributions.\n",
        "provided_code_snippet": "class Solution:\r\n    def putMarbles(self, weights: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def putMarbles(self, w: List[int], k: int) -> int:\n        p = sorted([w[i] + w[i + 1] for i in range(len(w) - 1)])\n        return sum(p[len(p) - k + 1:]) - sum(p[:k - 1])",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2552": {
        "problem_id": 2552,
        "description": "Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.\nA quadruplet (i, j, k, l) is increasing if:\n\t- 0 <= i < j < k < l < n, and\n\t- nums[i] < nums[k] < nums[j] < nums[l].\n",
        "provided_code_snippet": "class Solution:\r\n    def countQuadruplets(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def countQuadruplets(self, nums: List[int]) -> int:\n        n = len(nums)\n        cnt = [0] * n\n        ans = 0\n        for j in range(n):\n            prev_small = 0\n            for i in range(j):\n                if nums[j] > nums[i]:\n                    prev_small += 1\n                    ans += cnt[i]\n                elif nums[j] < nums[i]:\n                    cnt[i] += prev_small\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2553": {
        "problem_id": 2553,
        "description": "Given an array of positive integers nums, return an array answer that consists of the digits of each integer in nums after separating them in the same order they appear in nums.\nTo separate the digits of an integer is to get all the digits it has in the same order.\n\t- For example, for the integer 10921, the separation of its digits is [1,0,9,2,1].\n",
        "provided_code_snippet": "class Solution:\r\n    def separateDigits(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def separateDigits(self, nums: List[int]) -> List[int]:\n        return [int(d) for n in nums for d in str(n)]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2554": {
        "problem_id": 2554,
        "description": "You are given an integer array banned and two integers n and maxSum. You are choosing some number of integers following the below rules:\n\t- The chosen integers have to be in the range [1, n].\n\t- Each integer can be chosen at most once.\n\t- The chosen integers should not be in the array banned.\n\t- The sum of the chosen integers should not exceed maxSum.\nReturn the maximum number of integers you can choose following the mentioned rules.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:",
        "solution": "class Solution:\n    def maxCount(self, banned: List[int], n: int, maxSum: int) -> int:\n\n        ans, banned = -1, set(banned)\n\n        for i in range(1,n+1):\n            if i not in banned:\n                maxSum-= i\n                ans+= 1\n\n            if maxSum < 0: return ans\n\n        return ans+1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2555": {
        "problem_id": 2555,
        "description": "There are some prizes on the X-axis. You are given an integer array prizePositions that is sorted in non-decreasing order, where prizePositions[i] is the position of the ith prize. There could be different prizes at the same position on the line. You are also given an integer k.\nYou are allowed to select two segments with integer endpoints. The length of each segment must be k. You will collect all prizes whose position falls within at least one of the two selected segments (including the endpoints of the segments). The two selected segments may intersect.\n\t- For example if k = 2, you can choose segments [1, 3] and [2, 4], and you will win any prize i that satisfies 1 <= prizePositions[i] <= 3 or 2 <= prizePositions[i] <= 4.\nReturn the maximum number of prizes you can win if you choose the two segments optimally.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximizeWin(self, prizePositions: List[int], k: int) -> int:",
        "solution": "class Solution:\r\n    def maximizeWin(self, prizePositions: List[int], k: int) -> int:\r\n        # count of prizes for all intervals\r\n        # (count, end position of interval)        \r\n        intervals = []\r\n        # max stack of intervals\r\n        # (count, end position of interval),\r\n        # There can't be interval with bigger count before the interval\r\n        max_beffore = []\r\n        start_inx = 0 # start index of the current interval\r\n        count = 0 # count of the current interval\r\n        for inx, pos in enumerate(prizePositions):\r\n            count += 1\r\n            # subtract prizes from the current interval if they are not covered by the interval\r\n            while pos-k > prizePositions[start_inx]:\r\n                count -= 1\r\n                start_inx += 1\r\n            intervals.append((count, pos))\r\n            if not max_beffore or max_beffore[-1][0] < count:\r\n                max_beffore.append((count, pos))\r\n\r\n        max_solution = 0\r\n        while intervals:\r\n            # the last interval for the current solution\r\n            count, pos = intervals.pop()\r\n            # max_beffore stores only intervals before the last interval,\r\n            # max_beffore is a max stack,\r\n            # so the top of the max possible has the max count among all values in the max_beffore\r\n            while max_beffore and max_beffore[-1][1] >= pos-k:\r\n                max_beffore.pop()\r\n            # The soluthon if the current last interval is the last\r\n            candidate = count+(0 if not max_beffore else max_beffore[-1][0])\r\n            # we need to find maximum among all candidates\r\n            max_solution = max(candidate, max_solution)\r\n        return max_solution",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2556": {
        "problem_id": 2556,
        "description": "You are given a 0-indexed m x n binary matrix grid. You can move from a cell (row, col) to any of the cells (row + 1, col) or (row, col + 1) that has the value 1. The matrix is disconnected if there is no path from (0, 0) to (m - 1, n - 1).\nYou can flip the value of at most one (possibly none) cell. You cannot flip the cells (0, 0) and (m - 1, n - 1).\nReturn true if it is possible to make the matrix disconnect or false otherwise.\nNote that flipping a cell changes its value from 0 to 1 or from 1 to 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def isPossibleToCutPath(self, grid: List[List[int]]) -> bool:",
        "solution": "class Solution:\n    def isPossibleToCutPath(self, grid: List[List[int]]) -> bool:\n        m, n = len(grid), len(grid[0])\n\n        #  number of paths from (0, 0) to (i, j)\n        dp1 = [[0] * (n+1) for _ in range(m + 1)]\n        dp1[1][1] = 1\n        for i in range(1, m + 1):\n            for j in range(1, n + 1):\n                if grid[i-1][j-1]:\n                    dp1[i][j] += dp1[i-1][j] + dp1[i][j-1]\n        \n        #  number of paths from (i, j) to (m-1, n-1)      \n        dp2 = [[0] * (n+1) for _ in range(m + 1)]\n        dp2[-2][-2] = 1\n        for i in range(m - 1, -1, -1):\n            for j in range(n - 1, -1, -1):\n                if grid[i][j]:\n                    dp2[i][j] += dp2[i+1][j] + dp2[i][j+1]\n        \n        # number of paths from (0, 0) to (m-1, n-1)     \n        target = dp1[-1][-1]\n\n        for i in range(m):\n            for j in range(n):\n                if (i!=0 or j!=0) and (i!=m-1 or j!=n-1):\n                    if dp1[i+1][j+1] * dp2[i][j] == target: \n                        return True\n        return False",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2558": {
        "problem_id": 2558,
        "description": "You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following:\n\t- Choose the pile with the maximum number of gifts.\n\t- If there is more than one pile with the maximum number of gifts, choose any.\n\t- Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts.\nReturn the number of gifts remaining after k seconds.\n",
        "provided_code_snippet": "class Solution:\r\n    def pickGifts(self, gifts: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def pickGifts(self, gifts: List[int], k: int) -> int:\n        nums = [-num for num in gifts]\n        heapify(nums)\n        \n        while k:\n            tmp = math.isqrt(-heappop(nums))\n            heappush(nums, -tmp)\n            k -= 1\n            \n        return -sum(nums)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2559": {
        "problem_id": 2559,
        "description": "You are given a 0-indexed array of strings words and a 2D array of integers queries.\nEach query queries[i] = [li, ri] asks us to find the number of strings present in the range li to ri (both inclusive) of words that start and end with a vowel.\nReturn an array ans of size queries.length, where ans[i] is the answer to the ith query.\nNote that the vowel letters are 'a', 'e', 'i', 'o', and 'u'.\n",
        "provided_code_snippet": "class Solution:\r\n    def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def vowelStrings(self, words: List[str], queries: List[List[int]]) -> List[int]:\n                                                                # Example:\n                                                                #    words = ['aba','bcb','ece','aa','e'] \n                                                                #  queries = [[0,2], [1,4], [1,1]]\n\n        vowels = lambda w: w[0] in 'aeiou' and w[-1] in 'aeiou' #  <-- boolean function  \n\n        words = map(vowels, words)                              #    words = [True, False, True, True, True]\n        \n        pref = list(accumulate(words, initial = 0))             #     pref = [0, 1, 1, 2, 3, 4]\n        \n        return [pref[r+1] - pref[l] for l,r in queries]         #   return [2-0, 4-1, 1-1] = [2,3,0]",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2560": {
        "problem_id": 2560,
        "description": "There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he refuses to steal from adjacent homes.\nThe capability of the robber is the maximum amount of money he steals from one house of all the houses he robbed.\nYou are given an integer array nums representing how much money is stashed in each house. More formally, the ith house from the left has nums[i] dollars.\nYou are also given an integer k, representing the minimum number of houses the robber will steal from. It is always possible to steal at least k houses.\nReturn the minimum capability of the robber out of all the possible ways to steal at least k houses.\n",
        "provided_code_snippet": "class Solution:\r\n    def minCapability(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def minCapability(self, nums: List[int], k: int) -> int:\n        def check(cap):\n            count=taken=0\n            for x in nums:\n                if taken:\n                    taken=False\n                elif x<=cap:\n                    count+=1\n                    taken=True\n            return count>=k\n        l,r=min(nums),max(nums)\n        while l<=r:\n            mid=l+(r-l)//2\n            if check(mid):\n                res=mid\n                r=mid-1\n            else:\n                l=mid+1\n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2561": {
        "problem_id": 2561,
        "description": "You have two fruit baskets containing n fruits each. You are given two 0-indexed integer arrays basket1 and basket2 representing the cost of fruit in each basket. You want to make both baskets equal. To do so, you can use the following operation as many times as you want:\n\t- Chose two indices i and j, and swap the ith fruit of basket1 with the jth fruit of basket2.\n\t- The cost of the swap is min(basket1[i],basket2[j]).\nTwo baskets are considered equal if sorting them according to the fruit cost makes them exactly the same baskets.\nReturn the minimum cost to make both the baskets equal or -1 if impossible.\n",
        "provided_code_snippet": "class Solution:\r\n    def minCost(self, basket1: List[int], basket2: List[int]) -> int:",
        "solution": "class Solution:\n    def minCost(self, basket1: List[int], basket2: List[int]) -> int:\n        cnt = Counter(basket1)\n        for x in basket2: cnt[x] -= 1\n        last = []\n        for k, v in cnt.items():\n            # if v is odd, an even distribution is never possible\n            if v % 2 != 0:\n                return -1\n            # the count of transferred k is |v|/2\n            last += [k] * abs(v // 2)\n        # find the min of two input arrays as the intermediate\n        minx = min(basket1 + basket2)\n        # Use quickselect instead of sort can get a better complexity\n        last.sort()\n        # The first half may be the cost\n        return sum(min(2*minx, x) for x in last[0:len(last)//2])",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2562": {
        "problem_id": 2562,
        "description": "You are given a 0-indexed integer array nums.\nThe concatenation of two numbers is the number formed by concatenating their numerals.\n\t- For example, the concatenation of 15, 49 is 1549.\nThe concatenation value of nums is initially equal to 0. Perform this operation until nums becomes empty:\n\t- If there exists more than one number in nums, pick the first element and last element in nums respectively and add the value of their concatenation to the concatenation value of nums, then delete the first and last element from nums.\n\t- If one element exists, add its value to the concatenation value of nums, then delete it.\nReturn the concatenation value of the nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def findTheArrayConcVal(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findTheArrayConcVal(self, nums: List[int]) -> int:\n        ans=0\n        if len(nums)%2==1:\n            ans=nums[len(nums)//2]\n        for i in range(len(nums)//2):\n            ans+=int(str(nums[i])+str(nums[len(nums)-1-i]))\n        return ans",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2563": {
        "problem_id": 2563,
        "description": "Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.\nA pair (i, j) is fair if:\n\t- 0 <= i < j < n, and\n\t- lower <= nums[i] + nums[j] <= upper\n",
        "provided_code_snippet": "class Solution:\r\n    def countFairPairs(self, nums: List[int], lower: int, upper: int) -> int:",
        "solution": "class Solution:\n    def countFairPairs(self, nums: List[int], lower: int, upper: int) -> int:\n        def countLess(val: int) -> int:\n            res, j = 0, len(nums) - 1\n            for i in range(len(nums)):\n                while i < j and nums[i] + nums[j] > val:\n                    j -= 1\n                res += max(0, j - i)\n            return res\n        nums.sort()\n        return countLess(upper) - countLess(lower - 1)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2564": {
        "problem_id": 2564,
        "description": "You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi].\nFor the ith query, find the shortest substring of s whose decimal value, val, yields secondi when bitwise XORed with firsti. In other words, val ^ firsti == secondi.\nThe answer to the ith query is the endpoints (0-indexed) of the substring [lefti, righti] or [-1, -1] if no such substring exists. If there are multiple answers, choose the one with the minimum lefti.\nReturn an array ans where ans[i] = [lefti, righti] is the answer to the ith query.\nA substring is a contiguous non-empty sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def substringXorQueries(self, s: str, queries: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def substringXorQueries(self, s: str, v: List[List[int]]) -> List[List[int]]:\n        def cmp():\n            return -2\n        ans=[]\n        mp=defaultdict(cmp)\n        for i in v:\n            x=bin((i[0]^i[1]))[2:]\n            if mp[x]!=-2:\n                if mp[x]==-1:\n                    ans+=[[-1,-1]]\n                else:\n                    ans+=[[mp[x],mp[x]+len(x)-1]]\n                continue \n            y=s.find(x)\n            if y==-1:\n                ans+=[[-1,-1]]\n            else:\n                ans+=[[y,y+len(x)-1]]\n            mp[x]=y\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2565": {
        "problem_id": 2565,
        "description": "You are given two strings s and t.\nYou are allowed to remove any number of characters from the string t.\nThe score of the string is 0 if no characters are removed from the string t, otherwise:\n\t- Let left be the minimum index among all removed characters.\n\t- Let right be the maximum index among all removed characters.\nThen the score of the string is right - left + 1.\nReturn the minimum possible score to make t a subsequence of s.\nA subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., \"ace\" is a subsequence of \"abcde\" while \"aec\" is not).\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumScore(self, s: str, t: str) -> int:",
        "solution": "class Solution:\n    def minimumScore(self, s: str, t: str) -> int:\n        suffix = [-1]*len(s)\n        j = len(t)-1\n        for i in reversed(range(len(s))): \n            if 0 <= j and s[i] == t[j]: j -= 1\n            suffix[i] = j \n        ans = j + 1\n        j = 0 \n        for i, ch in enumerate(s): \n            ans = min(ans, max(0, suffix[i] - j + 1))\n            if j < len(t) and s[i] == t[j]: j += 1\n        return min(ans, len(t)-j)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2566": {
        "problem_id": 2566,
        "description": "You are given an integer num. You know that Bob will sneakily remap one of the 10 possible digits (0 to 9) to another digit.\nReturn the difference between the maximum and minimum values Bob can make by remapping exactly one digit in num.\nNotes:\n\t- When Bob remaps a digit d1 to another digit d2, Bob replaces all occurrences of d1 in num with d2.\n\t- Bob can remap a digit to itself, in which case num does not change.\n\t- Bob can remap different digits for obtaining minimum and maximum values respectively.\n\t- The resulting number after remapping can contain leading zeroes.\n",
        "provided_code_snippet": "class Solution:\r\n    def minMaxDifference(self, num: int) -> int:",
        "solution": "class Solution:\n    def minMaxDifference(self, num: int) -> int:\n        num = str(num)\n        i = 0\n        while num[i] == \"9\" and i < len(num)-1:\n            i += 1\n\n        return int(num.replace(num[i], \"9\")) - int(num.replace(num[0], \"0\"))",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2567": {
        "problem_id": 2567,
        "description": "You are given an integer array nums.\n\t- The low score of nums is the minimum absolute difference between any two integers.\n\t- The high score of nums is the maximum absolute difference between any two integers.\n\t- The score of nums is the sum of the high and low scores.\nReturn the minimum score after changing two elements of nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeSum(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minimizeSum(self, nums: List[int]) -> int:\n\n        nums.sort()\n\n        return min(nums[-1] - nums[2],  #  [a,b,c, ..., x,y,z] => [c,c,c, ..., x,y,z]\n                   nums[-2] - nums[1],  #  [a,b,c, ..., x,y,z] => [b,b,c, ..., x,y,y] \n                   nums[-3] - nums[0])  #  [a,b,c, ..., x,y,z] => [a,b,c, ..., x,x,x]",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2568": {
        "problem_id": 2568,
        "description": "You are given a 0-indexed integer array nums.\nWe say that an integer x is expressible from nums if there exist some integers 0 <= index1 < index2 < ... < indexk < nums.length for which nums[index1] | nums[index2] | ... | nums[indexk] = x. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of nums.\nReturn the minimum positive non-zero integer that is not expressible from nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def minImpossibleOR(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minImpossibleOR(self, nums: List[int]) -> int:\n        nums.sort()\n        x=1\n        for i in nums:\n            if x==i:\n                x*=2\n        return x",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2569": {
        "problem_id": 2569,
        "description": "You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries. There are three types of queries:\n\t1. For a query of type 1, queries[i] = [1, l, r]. Flip the values from 0 to 1 and from 1 to 0 in nums1 from index l to index r. Both l and r are 0-indexed.\n\t2. For a query of type 2, queries[i] = [2, p, 0]. For every index 0 <= i < n, set nums2[i] = nums2[i] + nums1[i] * p.\n\t3. For a query of type 3, queries[i] = [3, 0, 0]. Find the sum of the elements in nums2.\nReturn an array containing all the answers to the third type queries.\n",
        "provided_code_snippet": "class Solution:\r\n    def handleQuery(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:",
        "solution": "class segtree():\n    def __init__(self, n, nums):\n        self.lazy = defaultdict(int)\n        self.len = defaultdict(int)\n        self.tree = defaultdict(int)\n        # initial length and summation\n        self.init_len(1, 0, n, 0, n, nums)\n        self.init_num(1, 0, n, 0, n, nums)\n        \n    def init_len(self, ind, ul, ur, cl, cr, num):\n        if cr < cl or cl >= len(num):\n            return 0\n        if cr == cl:\n            self.len[ind] = 1\n            return 1\n        mid = (cl + cr) // 2\n        if cl != cr:\n            self.init_len(ind*2, ul, ur, cl, mid, num)\n        self.init_len(ind*2+1, ul, ur, mid+1, cr, num)\n        self.len[ind] = self.len[ind*2] + self.len[ind*2+1]\n    \n    def init_num(self, ind, ul, ur, cl, cr, num):\n        if cr < cl or cl >= len(num):\n            return\n        if cl == cr:\n            self.tree[ind] = num[cl]\n            return\n        mid = (cl + cr) // 2\n        if cl != cr:\n            self.init_num(ind*2, ul, ur, cl, mid, num)\n        self.init_num(ind*2+1, ul, ur, mid+1, cr, num)\n        \n        self.tree[ind] = self.tree[ind*2] + self.tree[ind*2+1]\n        \n    \n    def proplazy(self, ind):\n        # if the parent node has the notation to flip, then we update all summation of children nodes.\n        if self.lazy[ind]:\n            self.lazy[ind*2] ^= self.lazy[ind]\n            self.tree[ind*2] = self.len[ind*2] - self.tree[ind*2]\n            self.lazy[ind*2 + 1] ^= self.lazy[ind]\n            self.tree[ind*2 + 1] = self.len[ind*2+1] - self.tree[ind*2 + 1]\n            self.tree[ind] = self.tree[ind*2] + self.tree[ind*2+1]\n            self.lazy[ind] = 0\n        \n    def update(self, ind, ul, ur, cl, cr):\n        if cl > ur or cr < ul:\n            return \n        if ul <= cl and cr <= ur:\n            # mark to flip\n            self.lazy[ind] ^= 1\n            self.tree[ind] = self.len[ind] - self.tree[ind]\n        else:\n            mid = (cl + cr) // 2\n            self.proplazy(ind)\n            self.update(ind*2, ul, ur, cl, mid)\n            self.update(ind*2+1, ul, ur, mid+1, cr)\n            self.tree[ind] = self.tree[ind*2] + self.tree[ind*2+1]\n           \n    def query(self, ind, ul, ur, cl, cr):\n        if cl > ur or cr < ul:\n            return 0\n        if ul <= cl and cr <= ur:\n            return self.tree[ind]\n        else:\n            mid = (cl + cr) // 2\n            self.proplazy(ind)\n            return self.query(ind*2, ul, ur, cl, mid) + self.query(ind*2+1, ul, ur, mid+1, cr)\n         \nclass Solution:\n    def handleQuery(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:\n        seg = segtree(len(nums1) + 10, nums1)\n        anss = []\n        ans = sum(nums2)\n        n = len(nums1) + 10\n        for i, j, k in queries:\n            if i == 1:\n                seg.update(1, j, k, 0, n)\n            if i == 2:\n                ans += seg.tree[1] * j\n            if i == 3:\n                anss.append(ans)\n        return anss",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2570": {
        "problem_id": 2570,
        "description": "You are given two 2D integer arrays nums1 and nums2.\n\t- nums1[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.\n\t- nums2[i] = [idi, vali] indicate that the number with the id idi has a value equal to vali.\nEach array contains unique ids and is sorted in ascending order by id.\nMerge the two arrays into one array that is sorted in ascending order by id, respecting the following conditions:\n\t- Only ids that appear in at least one of the two arrays should be included in the resulting array.\n\t- Each id should be included only once and its value should be the sum of the values of this id in the two arrays. If the id does not exist in one of the two arrays then its value in that array is considered to be 0.\nReturn the resulting array. The returned array must be sorted in ascending order by id.\n",
        "provided_code_snippet": "class Solution:\r\n    def mergeArrays(self, nums1: List[List[int]], nums2: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def mergeArrays(self, nums1: List[List[int]], nums2: List[List[int]]) -> List[List[int]]:\n        res = []\n        i = 0\n        j = 0\n        while i < len(nums1) or j < len(nums2):\n            if i == len(nums1):\n                res.append(nums2[j])\n                j += 1\n            elif j == len(nums2):\n                res.append(nums1[i])\n                i += 1\n            else:\n                if nums1[i][0] == nums2[j][0]:\n                    res.append([nums1[i][0], nums1[i][1] + nums2[j][1]])\n                    i += 1\n                    j += 1\n                elif nums1[i][0] < nums2[j][0]:\n                    res.append(nums1[i])\n                    i += 1\n                else:\n                    res.append(nums2[j])\n                    j += 1\n        return res",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2571": {
        "problem_id": 2571,
        "description": "You are given a positive integer n, you can do the following operation any number of times:\n\t- Add or subtract a power of 2 from n.\nReturn the minimum number of operations to make n equal to 0.\nA number x is power of 2 if x == 2i where i >= 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def minOperations(self, n: int) -> int:",
        "solution": "class Solution:\n    def minOperations(self, n: int) -> int:\n\n        from math import log2\n\n        # Powers of 2: TC = SC = O(log2(n))\n        '''\n        powers = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]\n        # Why required till 131072 only? Because n <= 10^5.\n        '''\n        # (Good Practice) Keep it dynamic so that even if n > 10^5, code will work:\n        # powers = [2**i for i in range(int(log2(n))+2)]\n        powers = [1 << i for i in range(int(log2(n))+2)]\n\n        ops = 0\n\n        # While `n` doesn't become 0:\n        while n:  # TC = O(1) because it doesn't matter what `n` is, we're directly subtracting the closest power of 2 from\n            # it, so, it will fall to 0 in a couple of ops only (take a big number and check yourself to get the hang of it)\n\n            # Find the power of 2 which is closest to n: TC = O(log2(n))\n            '''\n            min_diff, closest = float('inf'), None\n            for p in powers:\n                if abs(n-p) < min_diff:\n                    min_diff, closest = abs(n-p), p\n            '''\n            # One-liner of above (Thanks for pointing it out @SmittyWerbenjagermanjensen):\n            closest = min(powers, key=lambda p: abs(n-p))\n\n            # (Absolute) Subtract it (the closest power of 2):\n            n = abs(n-closest)\n\n            ops += 1\n\n        return ops",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2572": {
        "problem_id": 2572,
        "description": "You are given a positive integer 0-indexed array nums.\nA subset of the array nums is square-free if the product of its elements is a square-free integer.\nA square-free integer is an integer that is divisible by no square number other than 1.\nReturn the number of square-free non-empty subsets of the array nums. Since the answer may be too large, return it modulo 109 + 7.\nA non-empty subset of nums is an array that can be obtained by deleting some (possibly none but not all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n",
        "provided_code_snippet": "class Solution:\r\n    def squareFreeSubsets(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def squareFreeSubsets(self, nums: List[int]) -> int:\n        MOD = 10 ** 9 + 7\n        candidates = set([2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30])\n        cnt = defaultdict(int)\n        for num in nums:\n            if num in candidates:\n                cnt[num] += 1\n        \n        def count(arr):\n            if not arr:\n                return 1\n            arr1 = []\n            for num in arr[1:]:\n                if math.gcd(num, arr[0]) == 1:\n                    arr1.append(num)\n            return (count(arr[1:]) + cnt[arr[0]] * count(arr1)) % MOD\n            \n        ones = nums.count(1)\n        tmp = 1\n        for _ in range(ones):\n            tmp = (tmp * 2) % MOD\n        return (count(list(cnt)) * tmp - 1) % MOD",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2573": {
        "problem_id": 2573,
        "description": "We define the lcp matrix of any 0-indexed string word of n lowercase English letters as an n x n grid such that:\n\t- lcp[i][j] is equal to the length of the longest common prefix between the substrings word[i,n-1] and word[j,n-1].\nGiven an n x n matrix lcp, return the alphabetically smallest string word that corresponds to lcp. If there is no such string, return an empty string.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b. For example, \"aabd\" is lexicographically smaller than \"aaca\" because the first position they differ is at the third letter, and 'b' comes before 'c'.\n",
        "provided_code_snippet": "class Solution:\r\n    def findTheString(self, lcp: List[List[int]]) -> str:",
        "solution": "class Solution:\r\n    def findTheString(self, lcp: List[List[int]]) -> str:\r\n        n = len(lcp)\r\n        uf = [i for i in range(n)]\r\n        \r\n        def find(x):\r\n            if uf[x] == x:\r\n                return x\r\n            uf[x] = find(uf[x])\r\n            return uf[x]\r\n        \r\n        #  Step 1: Use rules from lcp array to unify same symbols. Simultaneously checking for inconsistencies.\r\n        for i in range(n):\r\n            # bc symbols are equal to themselves\r\n            if lcp[i][i] + i != n:\r\n                return \"\"\r\n            for j in range(i + 1, n):\r\n                # border and symmetry check\r\n                if j + lcp[i][j] > n or lcp[i][j] != lcp[j][i]:\r\n                    return \"\"\r\n                \r\n                if lcp[i][j]:\r\n                    if j + 1 < n and lcp[i + 1][j + 1] + 1 != lcp[i][j]:\r\n                        return \"\"\r\n        \r\n                    uf[i] = uf[j] = min(find(i), find(j))\r\n                    \r\n        #  Step 2: Check all conditions fulfilled and self-consistent.\r\n        for i in range(n):\r\n            for j in range(i + 1, n):\r\n                # cases: need to be unequal, but in reality opposite\r\n                if lcp[i][j] == 0 and find(i) == find(j):\r\n                    return \"\"\r\n                if lcp[i][j] > 0 and lcp[i][j] + j < n and find(i + lcp[i][j]) == find(j + lcp[i][j]):\r\n                    return \"\"\r\n                \r\n        #  Step 3: Use union find structure to fill answer with chars.\r\n        ret = [None] * n\r\n        letter = 97  # ASCII code of 'a' letter\r\n        for i in range(len(ret)):\r\n            val = find(i)\r\n            if ret[val] is not None:\r\n                ret[i] = ret[val]\r\n            else:\r\n                # if needed more letters, we can't afford it, as 'z' has 122 ASCII code\r\n                if letter == 123:\r\n                    return \"\"\r\n                ret[i] = chr(letter)\r\n                letter += 1\r\n        return ''.join(ret)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2574": {
        "problem_id": 2574,
        "description": "Given a 0-indexed integer array nums, find a 0-indexed integer array answer where:\n    - answer.length == nums.length.\n    - answer[i] = |leftSum[i] - rightSum[i]|.\nWhere:\n    - leftSum[i] is the sum of elements to the left of the index i in the array nums. If there is no such element, leftSum[i] = 0.\n    - rightSum[i] is the sum of elements to the right of the index i in the array nums. If there is no such element, rightSum[i] = 0.\nReturn the array answer.\n",
        "provided_code_snippet": "class Solution:\r\n    def leftRightDifference(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def leftRigthDifference(self, nums: List[int]) -> List[int]:\n        prefix = 0 \n        suffix = sum(nums)\n        ans = []\n        for x in nums: \n            prefix += x\n            ans.append(abs(prefix - suffix))\n            suffix -= x\n        return ans",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2575": {
        "problem_id": 2575,
        "description": "You are given a 0-indexed string word of length n consisting of digits, and a positive integer m.\nThe divisibility array div of word is an integer array of length n such that:\n\t- div[i] = 1 if the numeric value of word[0,...,i] is divisible by m, or\n\t- div[i] = 0 otherwise.\nReturn the divisibility array of word.\n",
        "provided_code_snippet": "class Solution:\r\n    def divisibilityArray(self, word: str, m: int) -> List[int]:",
        "solution": "class Solution:\n    def divisibilityArray(self, word: str, m: int) -> List[int]:\n        x=0\n        a=[]\n        for i in word:\n            x=x*10+int(i)\n            if(x%m==0):\n                a+=[1]\n            else:\n                a+=[0]\n            x%=m\n        return a",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2576": {
        "problem_id": 2576,
        "description": "You are given a 0-indexed integer array nums.\nInitially, all of the indices are unmarked. You are allowed to make this operation any number of times:\n\t- Pick two different unmarked indices i and j such that 2 * nums[i] <= nums[j], then mark i and j.\nReturn the maximum possible number of marked indices in nums using the above operation any number of times.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxNumOfMarkedIndices(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def maxNumOfMarkedIndices(self, nums: List[int]) -> int:\n        i, n = 0, len(nums)\n        nums.sort()\n        for j in range(n - n // 2, n):\n            i += 2 * nums[i] <= nums[j]\n        return i * 2",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2577": {
        "problem_id": 2577,
        "description": "You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which means you can visit the cell (row, col) only when the time you visit it is greater than or equal to grid[row][col].\nYou are standing in the top-left cell of the matrix in the 0th second, and you must move to any adjacent cell in the four directions: up, down, left, and right. Each move you make takes 1 second.\nReturn the minimum time required in which you can visit the bottom-right cell of the matrix. If you cannot visit the bottom-right cell, then return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTime(self, grid: List[List[int]]) -> int:",
        "solution": "def minimumTime(self, grid: List[List[int]]) -> int:\n    if grid[0][1] > 1 and grid[1][0] > 1: return -1\n    m, n = len(grid), len(grid[0])\n    visited = set()\n    pq = [(grid[0][0], 0, 0)]\n    \n    while pq:\n        time, row, col = heappop(pq)\n        if row == m-1 and col == n-1: return time\n        if (row, col) in visited: continue\n        visited.add((row, col))\n        for dr, dc in [(0, 1), (0, -1), (1, 0), (-1, 0)]:\n            r, c = row + dr, col + dc\n            if 0 <= r < m and 0 <= c < n and (r, c) not in visited:\n                wait = 1 if ((grid[r][c] - time) % 2 == 0) else 0\n                heappush(pq, (max(time + 1, grid[r][c] + wait), r, c))",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2578": {
        "problem_id": 2578,
        "description": "Given a positive integer num, split it into two non-negative integers num1 and num2 such that:\n\t- The concatenation of num1 and num2 is a permutation of num.\t\t\t- In other words, the sum of the number of occurrences of each digit in num1 and num2 is equal to the number of occurrences of that digit in num.\n\t\t\n\t- num1 and num2 can contain leading zeros.\nReturn the minimum possible sum of num1 and num2.\nNotes:\n\t- It is guaranteed that num does not contain any leading zeros.\n\t- The order of occurrence of the digits in num1 and num2 may differ from the order of occurrence of num.\n",
        "provided_code_snippet": "class Solution:\r\n    def splitNum(self, num: int) -> int:",
        "solution": "def splitNum(self, num: int) -> int:\r\n        a, b = [], []\r\n        for i, c in enumerate(sorted(str(num))):\r\n            (a if i % 2 == 0 else b).append(c)\r\n        return int(''.join(a)) + int(''.join(b))",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2579": {
        "problem_id": 2579,
        "description": "There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer n, indicating that you must do the following routine for n minutes:\n\t- At the first minute, color any arbitrary unit cell blue.\n\t- Every minute thereafter, color blue every uncolored cell that touches a blue cell.\nBelow is a pictorial representation of the state of the grid after minutes 1, 2, and 3.\nReturn the number of colored cells at the end of n minutes.\n",
        "provided_code_snippet": "class Solution:\r\n    def coloredCells(self, n: int) -> int:",
        "solution": "def coloredCells(self, n: int) -> int:\n        return n ** 2 + (n - 1) ** 2",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2580": {
        "problem_id": 2580,
        "description": "You are given a 2D integer array ranges where ranges[i] = [starti, endi] denotes that all integers between starti and endi (both inclusive) are contained in the ith range.\nYou are to split ranges into two (possibly empty) groups such that:\n\t- Each range belongs to exactly one group.\n\t- Any two overlapping ranges must belong to the same group.\nTwo ranges are said to be overlapping if there exists at least one integer that is present in both ranges.\n\t- For example, [1, 3] and [2, 5] are overlapping because 2 and 3 occur in both ranges.\nReturn the total number of ways to split ranges into two groups. Since the answer may be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def countWays(self, ranges: List[List[int]]) -> int:",
        "solution": "def countWays(self, ranges: List[List[int]]) -> int:\n        cnt, hi = 1, -1\n        for a, b in sorted(ranges):\n            if hi < a:\n                cnt <<= 1\n                cnt %= 10 ** 9 + 7\n            hi = max(hi, b)\n        return cnt",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2581": {
        "problem_id": 2581,
        "description": "Alice has an undirected tree with n nodes labeled from 0 to n - 1. The tree is represented as a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nAlice wants Bob to find the root of the tree. She allows Bob to make several guesses about her tree. In one guess, he does the following:\n\t- Chooses two distinct integers u and v such that there exists an edge [u, v] in the tree.\n\t- He tells Alice that u is the parent of v in the tree.\nBob's guesses are represented by a 2D integer array guesses where guesses[j] = [uj, vj] indicates Bob guessed uj to be the parent of vj.\nAlice being lazy, does not reply to each of Bob's guesses, but just says that at least k of his guesses are true.\nGiven the 2D integer arrays edges, guesses and the integer k, return the number of possible nodes that can be the root of Alice's tree. If there is no such tree, return 0.\n",
        "provided_code_snippet": "class Solution:\r\n    def rootCount(self, edges: List[List[int]], guesses: List[List[int]], k: int) -> int:",
        "solution": "class Solution:\n    def rootCount(self, edges: List[List[int]], guesses: List[List[int]], k: int) -> int:\n        # n memory\n        # build graph\n        graph = defaultdict(list)\n        for i, j in edges:\n            graph[i].append(j)\n            graph[j].append(i)\n        \n        gt = set((i, j) for i, j in guesses)\n\n        # dfs traverse from parent -> i\n        @cache\n        def get_correct_pairs(i, parent):\n            next_nodes = graph[i]\n            n_correct = 0\n            for next_node in next_nodes:\n                if next_node == parent:\n                    continue\n                if (i, next_node) in gt:\n                    n_correct += 1\n                n_correct += get_correct_pairs(next_node, i)\n            return n_correct\n        \n        ans = 0\n        for i in graph:\n            if get_correct_pairs(i, None) >= k:\n                ans += 1\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2582": {
        "problem_id": 2582,
        "description": "There are n people standing in a line labeled from 1 to n. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction changes, and people continue passing the pillow in the opposite direction.\n\t- For example, once the pillow reaches the nth person they pass it to the n - 1th person, then to the n - 2th person and so on.\nGiven the two positive integers n and time, return the index of the person holding the pillow after time seconds.\n",
        "provided_code_snippet": "class Solution:\r\n    def passThePillow(self, n: int, time: int) -> int:",
        "solution": "class Solution:\n    def passThePillow(self, n: int, time: int) -> int:\n        return n - abs(n - 1 - time % (n * 2 - 2));",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2583": {
        "problem_id": 2583,
        "description": "You are given the root of a binary tree and a positive integer k.\nThe level sum in the tree is the sum of the values of the nodes that are on the same level.\nReturn the kth largest level sum in the tree (not necessarily distinct). If there are fewer than k levels in the tree, return -1.\nNote that two nodes are on the same level if they have the same distance from the root.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def kthLargestLevelSum(self, root: Optional[TreeNode], k: int) -> int:",
        "solution": "class Solution:\n    def kthLargestLevelSum(self, root: Optional[TreeNode], k: int) -> int:\n        vals = []\n        stack = [(root, 0)]\n        while stack: \n            node, i = stack.pop()\n            if i == len(vals): vals.append(0)\n            vals[i] += node.val \n            if node.left: stack.append((node.left, i+1))\n            if node.right: stack.append((node.right, i+1))\n        return sorted(vals, reverse=True)[k-1] if len(vals) >= k else -1",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2584": {
        "problem_id": 2584,
        "description": "You are given a 0-indexed integer array nums of length n.\nA split at an index i where 0 <= i <= n - 2 is called valid if the product of the first i + 1 elements and the product of the remaining elements are coprime.\n\t- For example, if nums = [2, 3, 3], then a split at the index i = 0 is valid because 2 and 9 are coprime, while a split at the index i = 1 is not valid because 6 and 3 are not coprime. A split at the index i = 2 is not valid because i == n - 1.\nReturn the smallest index i at which the array can be split validly or -1 if there is no such split.\nTwo values val1 and val2 are coprime if gcd(val1, val2) == 1 where gcd(val1, val2) is the greatest common divisor of val1 and val2.\n",
        "provided_code_snippet": "class Solution:\r\n    def findValidSplit(self, nums: List[int]) -> int:",
        "solution": "mx = 10**6\nspf = [i for i in range(mx+1)]\nfor i in range(2,int(math.sqrt(mx))+1):\n    if spf[i]==i:\n        for j in range(i*i,mx+1,i):\n            spf[j]=min(spf[j],i)\ndef getPrimeFactors(x):\n    while x!=1:\n        yield spf[x]\n        x//=spf[x]\nclass Solution:\n    def findValidSplit(self, nums: List[int]) -> int:\n        fac_idx = defaultdict(int)\n        for i,v in enumerate(nums):\n            for fac in getPrimeFactors(v):\n                fac_idx[fac] = i\n        right_most = 0\n        for i in range(len(nums)-1):\n            for fac in getPrimeFactors(nums[i]):\n                right_most = max(right_most,fac_idx[fac])\n            if right_most==i:\n                return i\n        return -1",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2585": {
        "problem_id": 2585,
        "description": "There is a test that has n types of questions. You are given an integer target and a 0-indexed 2D integer array types where types[i] = [counti, marksi] indicates that there are counti questions of the ith type, and each one of them is worth marksi points.\nReturn the number of ways you can earn exactly target points in the exam. Since the answer may be too large, return it modulo 109 + 7.\nNote that questions of the same type are indistinguishable.\n\t- For example, if there are 3 questions of the same type, then solving the 1st and 2nd questions is the same as solving the 1st and 3rd questions, or the 2nd and 3rd questions.\n",
        "provided_code_snippet": "class Solution:\r\n    def waysToReachTarget(self, target: int, types: List[List[int]]) -> int:",
        "solution": "def waysToReachTarget(self, target: int, types: List[List[int]]) -> int:\n    @cache\n    def dfs(i, target):\n        if target == 0: return 1\n        if i >= len(types) or target < 0: return 0\n        return sum(dfs(i + 1, target - j * types[i][1]) for j in range(types[i][0] + 1)) % 1000000007\n    return dfs(0, target)",
        "submission_passed": true,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2586": {
        "problem_id": 2586,
        "description": "You are given a 0-indexed array of string words and two integers left and right.\nA string is called a vowel string if it starts with a vowel character and ends with a vowel character where vowel characters are 'a', 'e', 'i', 'o', and 'u'.\nReturn the number of vowel strings words[i] where i belongs to the inclusive range [left, right].\n",
        "provided_code_snippet": "class Solution:\r\n    def vowelStrings(self, words: List[str], left: int, right: int) -> int:",
        "solution": "class Solution:\r\n    def vowelStrings(self, words: List[str], left: int, right: int) -> int:\r\n\r\n        vowels = set('aeiou')\r\n        \r\n        return sum({w[0],w[-1]}.issubset(vowels) for w in words[left:right+1])",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2587": {
        "problem_id": 2587,
        "description": "You are given a 0-indexed integer array nums. You can rearrange the elements of nums to any order (including the given order).\nLet prefix be the array containing the prefix sums of nums after rearranging it. In other words, prefix[i] is the sum of the elements from 0 to i in nums after rearranging it. The score of nums is the number of positive integers in the array prefix.\nReturn the maximum score you can achieve.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxScore(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def maxScore(self, nums: List[int]) -> int:\n        return sum(n > 0 for n in accumulate(sorted(nums, reverse=True)))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2588": {
        "problem_id": 2588,
        "description": "You are given a 0-indexed integer array nums. In one operation, you can:\n\t- Choose two different indices i and j such that 0 <= i, j < nums.length.\n\t- Choose a non-negative integer k such that the kth bit (0-indexed) in the binary representation of nums[i] and nums[j] is 1.\n\t- Subtract 2k from nums[i] and nums[j].\nA subarray is beautiful if it is possible to make all of its elements equal to 0 after applying the above operation any number of times.\nReturn the number of beautiful subarrays in the array nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n",
        "provided_code_snippet": "class Solution:\r\n    def beautifulSubarrays(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def beautifulSubarrays(self, nums: List[int]) -> int:\n        cnt = Counter({0: 1})\n        for val in accumulate(nums, operator.xor):\n            cnt[val] += 1\n        return sum(v * (v - 1) // 2 for v in cnt.values())",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2589": {
        "problem_id": 2589,
        "description": "There is a computer that can run an unlimited number of tasks at the same time. You are given a 2D integer array tasks where tasks[i] = [starti, endi, durationi] indicates that the ith task should run for a total of durationi seconds (not necessarily continuous) within the inclusive time range [starti, endi].\nYou may turn on the computer only when it needs to run a task. You can also turn it off if it is idle.\nReturn the minimum time during which the computer should be turned on to complete all tasks.\n",
        "provided_code_snippet": "class Solution:\r\n    def findMinimumTime(self, tasks: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def findMinimumTime(self, tasks: List[List[int]]) -> int:\n        line = [0]*2001\n        for i, (lo, hi, time) in enumerate(sorted(tasks, key=lambda x: x[1])): \n            cnt = sum(line[x] for x in range(lo, hi+1))\n            time = max(0, time - cnt)\n            for x in range(hi, lo-1, -1): \n                if time and not line[x]: \n                    line[x] = 1\n                    time -= 1\n        return sum(line)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2591": {
        "problem_id": 2591,
        "description": "You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the money to.\nYou have to distribute the money according to the following rules:\n\t- All money must be distributed.\n\t- Everyone must receive at least 1 dollar.\n\t- Nobody receives 4 dollars.\nReturn the maximum number of children who may receive exactly 8 dollars if you distribute the money according to the aforementioned rules. If there is no way to distribute the money, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def distMoney(self, money: int, children: int) -> int:",
        "solution": "class Solution:\n    def distMoney(self, money: int, children: int) -> int:\n\n        if money < children: return -1          #   <-- More children than dollars\n\n        n = 8 * children - money                #   <-- Enough dollars for all children \n                                                #       to get at least 8 dollars; one\n        if n <= 0: return children - (n < 0)    #       child may get more than 8 dollars        \n        \n        ans, rem = divmod(money-children,7)     #   <-- Every child gets a dollar, then ans\n                                                #       children get an additional 7 dollars \n\n        return ans - ((ans, rem) == (children - 1, 3))\n                                                #   <-- Decrement the ans if only one child \n                                                #       gets less than 8 dollars and that \n                                                #       child gets exactly 4 dollars",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2592": {
        "problem_id": 2592,
        "description": "You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing.\nWe define the greatness of nums be the number of indices 0 <= i < nums.length for which perm[i] > nums[i].\nReturn the maximum possible greatness you can achieve after permuting nums.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximizeGreatness(self, nums: List[int]) -> int:",
        "solution": "def maximizeGreatness(self, nums: List[int]) -> int:\n        nums.sort()\n        ans = 0\n        for num in nums:\n            if nums[ans] < num:\n                ans += 1\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2593": {
        "problem_id": 2593,
        "description": "You are given an array nums consisting of positive integers.\nStarting with score = 0, apply the following algorithm:\n\t- Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index.\n\t- Add the value of the chosen integer to score.\n\t- Mark the chosen element and its two adjacent elements if they exist.\n\t- Repeat until all the array elements are marked.\nReturn the score you get after applying the above algorithm.\n",
        "provided_code_snippet": "class Solution:\r\n    def findScore(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findScore(self, nums: List[int]) -> int:\n\n        n, score, seen = len(nums), 0, set()\n\n        queue = sorted(enumerate(nums), key = lambda x: (x[1],x[0]))\n\n        for idx, num in queue:\n            if idx in seen: continue\n\n            score+= num\n            \n            seen.add(idx)\n            if idx > 0  : seen.add(idx-1)\n            if idx < n-1: seen.add(idx+1) \n            \n        return score",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2594": {
        "problem_id": 2594,
        "description": "You are given an integer array ranks representing the ranks of some mechanics. ranksi is the rank of the ith mechanic. A mechanic with a rank r can repair n cars in r * n2 minutes.\nYou are also given an integer cars representing the total number of cars waiting in the garage to be repaired.\nReturn the minimum time taken to repair all the cars.\nNote: All the mechanics can repair the cars simultaneously.\n",
        "provided_code_snippet": "class Solution:\r\n    def repairCars(self, ranks: List[int], cars: int) -> int:",
        "solution": "def repairCars(self, A: List[int], cars: int) -> int:\n    return bisect_left(range(10**14), cars, key=lambda x: sum(int(sqrt(x / a)) for a in A))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2595": {
        "problem_id": 2595,
        "description": "You are given a positive integer n.\nLet even denote the number of even indices in the binary representation of n (0-indexed) with value 1.\nLet odd denote the number of odd indices in the binary representation of n (0-indexed) with value 1.\nReturn an integer array answer where answer = [even, odd].\n",
        "provided_code_snippet": "class Solution:\r\n    def evenOddBit(self, n: int) -> List[int]:",
        "solution": "class Solution:\r\n    def evenOddBit(self, n: int) -> List[int]:                 \r\n        evens, odds = int('0101010101',2), int('1010101010',2)\r\n\r\n        return [(evens&n).bit_count(),(odds&n).bit_count()]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2596": {
        "problem_id": 2596,
        "description": "There is a knight on an n x n chessboard. In a valid configuration, the knight starts at the top-left cell of the board and visits every cell on the board exactly once.\nYou are given an n x n integer matrix grid consisting of distinct integers from the range [0, n * n - 1] where grid[row][col] indicates that the cell (row, col) is the grid[row][col]th cell that the knight visited. The moves are 0-indexed.\nReturn true if grid represents a valid configuration of the knight's movements or false otherwise.\nNote that a valid knight move consists of moving two squares vertically and one square horizontally, or two squares horizontally and one square vertically. The figure below illustrates all the possible eight moves of a knight from some cell.\n",
        "provided_code_snippet": "class Solution:\r\n    def checkValidGrid(self, grid: List[List[int]]) -> bool:",
        "solution": "class Solution:\n    def checkValidGrid(self, grid: List[List[int]]) -> bool:\n\n        n, d = len(grid), defaultdict(tuple)\n        if n < 5: return n == 1\n\n        notLegal = lambda x, y : {abs(x[0]-y[0]),\n                                  abs(x[1]-y[1])} != {1,2}\n\n        for row, col in product(range(n),range(n)):\n            d[grid[row][col]] = (row,col)\n        \n        prev, cnt = (0,0), 1\n\n        while cnt < n*n:\n            curr = d[cnt]\n\n            if notLegal(prev,curr):  return False\n\n            cnt+=1\n            prev = curr\n\n        return True",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2597": {
        "problem_id": 2597,
        "description": "You are given an array nums of positive integers and a positive integer k.\nA subset of nums is beautiful if it does not contain two integers with an absolute difference equal to k.\nReturn the number of non-empty beautiful subsets of the array nums.\nA subset of nums is an array that can be obtained by deleting some (possibly none) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n",
        "provided_code_snippet": "class Solution:\r\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def beautifulSubsets(self, nums: List[int], k: int) -> int:\n        freq = {}\n        def f(i: int) -> int:\n            if i == len(nums): # base case\n                return 1\n            result = f(i + 1) # nums[i] not taken\n            if not nums[i] - k in freq and not nums[i] + k in freq: # check if we can take nums[i]\n                freq[nums[i]] = freq.get(nums[i], 0) + 1\n                result += f(i + 1) # nums[i] taken\n                freq[nums[i]] -= 1\n                if freq[nums[i]] == 0:\n                    del freq[nums[i]]\n            return result\n        return f(0) - 1 # -1 for empty subset",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2598": {
        "problem_id": 2598,
        "description": "You are given a 0-indexed integer array nums and an integer value.\nIn one operation, you can add or subtract value from any element of nums.\n\t- For example, if nums = [1,2,3] and value = 2, you can choose to subtract value from nums[0] to make nums = [-1,2,3].\nThe MEX (minimum excluded) of an array is the smallest missing non-negative integer in it.\n\t- For example, the MEX of [-1,2,3] is 0 while the MEX of [1,0,3] is 2.\nReturn the maximum MEX of nums after applying the mentioned operation any number of times.\n",
        "provided_code_snippet": "class Solution:\r\n    def findSmallestInteger(self, nums: List[int], value: int) -> int:",
        "solution": "class Solution:\n    def findSmallestInteger(self, nums: List[int], value: int) -> int:\n        m = Counter([n % value for n in nums])\n        for i in range(len(nums)):\n            if m[i % value] == 0:\n                return i\n            m[i % value] -= 1\n        return len(nums)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2600": {
        "problem_id": 2600,
        "description": "There is a bag that consists of items, each item has a number 1, 0, or -1 written on it.\nYou are given four non-negative integers numOnes, numZeros, numNegOnes, and k.\nThe bag initially contains:\n\t- numOnes items with 1s written on them.\n\t- numZeroes items with 0s written on them.\n\t- numNegOnes items with -1s written on them.\nWe want to pick exactly k items among the available items. Return the maximum possible sum of numbers written on the items.\n",
        "provided_code_snippet": "class Solution:\r\n    def kItemsWithMaximumSum(self, numOnes: int, numZeros: int, numNegOnes: int, k: int) -> int:",
        "solution": "class Solution:\n    def kItemsWithMaximumSum(self, numOnes: int, numZeros: int,\n                                   numNegOnes: int, k: int) -> int:\n\n        return k if k<= numOnes else numOnes - max(0, k-numOnes-numZeros)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2601": {
        "problem_id": 2601,
        "description": "You are given a 0-indexed integer array nums of length n.\nYou can perform the following operation as many times as you want:\n\t- Pick an index i that you haven’t picked before, and pick a prime p strictly less than nums[i], then subtract p from nums[i].\nReturn true if you can make nums a strictly increasing array using the above operation and false otherwise.\nA strictly increasing array is an array whose each element is strictly greater than its preceding element.\n",
        "provided_code_snippet": "class Solution:\r\n    def primeSubOperation(self, nums: List[int]) -> bool:",
        "solution": "def isPrime(x: int) -> bool:\n    if x == 1:\n        return False\n    for i in range(2, int(x ** 0.5) + 1):\n        if x %i == 0:\n            return False\n    return True\n\ndef primeSubOperation(nums: List[int]) -> bool:\n    p = 0\n    for x in nums:\n        if x <= p:\n            return False\n        prime = x - p - 1\n        while prime > 0 and not isPrime(prime):\n            prime -= 1\n        if prime == 0:\n            p = x\n        else:\n            p = x - prime\n    return True",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2602": {
        "problem_id": 2602,
        "description": "You are given an array nums consisting of positive integers.\nYou are also given an integer array queries of size m. For the ith query, you want to make all of the elements of nums equal to queries[i]. You can perform the following operation on the array any number of times:\n\t- Increase or decrease an element of the array by 1.\nReturn an array answer of size m where answer[i] is the minimum number of operations to make all elements of nums equal to queries[i].\nNote that after each query the array is reset to its original state.\n",
        "provided_code_snippet": "class Solution:\r\n    def minOperations(self, nums: List[int], queries: List[int]) -> List[int]:",
        "solution": "def minOperations(self, nums: List[int], queries: List[int]) -> List[int]:\n    nums.sort()\n    ans, n, prefix = [], len(nums), [0] + list(accumulate(nums))\n    for x in queries:\n        i = bisect_left(nums, x)\n        ans.append(x * (2 * i - n) + prefix[n] - 2 * prefix[i])\n    return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2603": {
        "problem_id": 2603,
        "description": "There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given an integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree. You are also given an array coins of size n where coins[i] can be either 0 or 1, where 1 indicates the presence of a coin in the vertex i.\nInitially, you choose to start at any vertex in the tree. Then, you can perform the following operations any number of times: \n\t- Collect all the coins that are at a distance of at most 2 from the current vertex, or\n\t- Move to any adjacent vertex in the tree.\nFind the minimum number of edges you need to go through to collect all the coins and go back to the initial vertex.\nNote that if you pass an edge several times, you need to count it into the answer several times.\n",
        "provided_code_snippet": "class Solution:\r\n    def collectTheCoins(self, coins: List[int], edges: List[List[int]]) -> int:",
        "solution": "def collectTheCoins(coins: List[int], edges: List[List[int]]) -> int:\n    n = len(coins)\n    tree = [set() for _ in range(n)]\n    \n    # Build the tree from the edges\n    for e in edges:\n        tree[e[0]].add(e[1])\n        tree[e[1]].add(e[0])\n    \n    # Find the leaves with zero coins\n    leaf = []\n    for i in range(n):\n        u = i\n        while len(tree[u]) == 1 and coins[u] == 0:\n            v = tree[u].pop()\n            tree[v].remove(u)\n            u = v\n        if len(tree[u]) == 1:\n            leaf.append(u)\n    \n    # Remove the leaves one by one\n    for sz in range(2, 0, -1):\n        temp = []\n        for u in leaf:\n            if len(tree[u]) == 1:\n                v = tree[u].pop()\n                tree[v].remove(u)\n                if len(tree[v]) == 1:\n                    temp.append(v)\n        leaf = temp\n    \n    # Count the remaining edges in the tree\n    ans = 0\n    for i in range(n):\n        ans += len(tree[i])\n    \n    return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2605": {
        "problem_id": 2605,
        "description": "Given two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array.\n",
        "provided_code_snippet": "class Solution:\r\n    def minNumber(self, nums1: List[int], nums2: List[int]) -> int:",
        "solution": "class Solution:\n    def minNumber(self, n1: List[int], n2: List[int]) -> int:\n        common, m1, m2 = set(n1).intersection(n2), min(n1), min(n2)\n        return min(common) if common else min(m1, m2) * 10 + max(m1, m2)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2606": {
        "problem_id": 2606,
        "description": "You are given a string s, a string chars of distinct characters and an integer array vals of the same length as chars.\nThe cost of the substring is the sum of the values of each character in the substring. The cost of an empty string is considered 0.\nThe value of the character is defined in the following way:\n\t- If the character is not in the string chars, then its value is its corresponding position (1-indexed) in the alphabet.\t\t\t- For example, the value of 'a' is 1, the value of 'b' is 2, and so on. The value of 'z' is 26.\n\t\t\n\t- Otherwise, assuming i is the index where the character occurs in the string chars, then its value is vals[i].\nReturn the maximum cost among all substrings of the string s.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumCostSubstring(self, s: str, chars: str, vals: List[int]) -> int:",
        "solution": "from typing import List\n\nclass Solution:\n    def maximumCostSubstring(self, s: str, chars: str, vals: List[int]) -> int:\n        char_dict = {}\n        for i in range(len(chars)):\n            char_dict[chars[i]] = vals[i]\n        \n        max_cost = 0\n        curr_cost = 0\n        for i in range(len(s)):\n            if s[i] not in char_dict:\n                curr_cost += ord(s[i]) - 96\n            else:\n                curr_cost += char_dict[s[i]]\n            \n            if curr_cost < 0:\n                curr_cost = 0\n            if curr_cost > max_cost:\n                max_cost = curr_cost\n        \n        return max_cost",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2607": {
        "problem_id": 2607,
        "description": "You are given a 0-indexed integer array arr and an integer k. The array arr is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element of the first element.\nYou can do the following operation any number of times:\n\t- Pick any element from arr and increase or decrease it by 1.\nReturn the minimum number of operations such that the sum of each subarray of length k is equal.\nA subarray is a contiguous part of the array.\n",
        "provided_code_snippet": "class Solution:\r\n    def makeSubKSumEqual(self, arr: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def makeSubKSumEqual(self, arr: List[int], k: int) -> int:\n        n = len(arr)\n        gcd = math.gcd(n, k)\n        ans = 0\n        for i in range(gcd):\n            tmp = sorted([arr[j] for j in range(i, n, gcd)])\n            median = tmp[len(tmp) // 2]\n            ans += sum(abs(num - median) for num in tmp)\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2608": {
        "problem_id": 2608,
        "description": "There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph are represented by a given 2D integer array edges, where edges[i] = [ui, vi] denotes an edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.\nReturn the length of the shortest cycle in the graph. If no cycle exists, return -1.\nA cycle is a path that starts and ends at the same node, and each edge in the path is used only once.\n",
        "provided_code_snippet": "class Solution:\r\n    def findShortestCycle(self, n: int, edges: List[List[int]]) -> int:",
        "solution": "def findShortestCycle(self, n: int, edges: List[List[int]]) -> int:\n        g = defaultdict(set)\n        for u, v in edges:\n            g[u].add(v)\n            g[v].add(u)\n        shortest = inf\n        for i in range(n):\n            dq, dist, parent = deque([i]), [inf] * n, [-1] * n\n            dist[i] = 0\n            while dq:\n                node = dq.popleft()\n                for kid in g.get(node, set()):\n                    if dist[kid] == inf:\n                        dist[kid] = dist[node] + 1\n                        parent[kid] = node\n                        dq.append(kid)\n                    elif parent[kid] != node and parent[node] != kid:\n                        shortest = min(shortest, dist[node] + dist[kid] + 1)\n        return -1 if shortest == inf else shortest",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2609": {
        "problem_id": 2609,
        "description": "You are given a binary string s consisting only of zeroes and ones.\nA substring of s is considered balanced if all zeroes are before ones and the number of zeroes is equal to the number of ones inside the substring. Notice that the empty substring is considered a balanced substring.\nReturn the length of the longest balanced substring of s.\nA substring is a contiguous sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def findTheLongestBalancedSubstring(self, s: str) -> int:",
        "solution": "class Solution:\r\n    def findTheLongestBalancedSubstring(self, s: str) -> int:\r\n        res, temp = 0, \"01\"\r\n        while len(temp) <= len(s):\r\n            if temp in s: \r\n                res = len(temp)\r\n            temp = '0' + temp + '1'\r\n        return res",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2610": {
        "problem_id": 2610,
        "description": "You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions:\n\t- The 2D array should contain only the elements of the array nums.\n\t- Each row in the 2D array contains distinct integers.\n\t- The number of rows in the 2D array should be minimal.\nReturn the resulting array. If there are multiple answers, return any of them.\nNote that the 2D array can have a different number of elements on each row.\n",
        "provided_code_snippet": "class Solution:\r\n    def findMatrix(self, nums: List[int]) -> List[List[int]]:",
        "solution": "class Solution:\n    def findMatrix(self, v: List[int]) -> List[List[int]]:\n        um = {}\n        for i in v:\n            um[i] = um.get(i, 0) + 1\n        \n        ans = []\n        while um:\n            temp = []\n            to_erase = []\n            for f, s in um.items():\n                temp.append(f)\n                s -= 1\n                if s == 0:\n                    to_erase.append(f)\n                um[f] = s\n            ans.append(temp)\n            for i in to_erase:\n                del um[i]\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2611": {
        "problem_id": 2611,
        "description": "There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.\nA point of the cheese with index i (0-indexed) is:\n\t- reward1[i] if the first mouse eats it.\n\t- reward2[i] if the second mouse eats it.\nYou are given a positive integer array reward1, a positive integer array reward2, and a non-negative integer k.\nReturn the maximum points the mice can achieve if the first mouse eats exactly k types of cheese.\n",
        "provided_code_snippet": "class Solution:\r\n    def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int:\n        output = 0\n        n = len(reward1)\n        heap = []\n        for i in range(n):\n            heap.append((reward2[i] - reward1[i], i))\n            \n        heapq.heapify(heap)\n        visited = set()\n        while k:\n            k -= 1\n            _, idx = heapq.heappop(heap)\n            visited.add(idx)\n            output += reward1[idx]\n            \n        # If there is anything left that has not been taken, we take it from reward2.\n        for idx, val in enumerate(reward2):\n            if idx in visited:\n                continue\n            output += val\n        \n        return output",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2612": {
        "problem_id": 2612,
        "description": "You are given an integer n and an integer p representing an array arr of length n where all elements are set to 0's, except position p which is set to 1. You are also given an integer array banned containing restricted positions. Perform the following operation on arr:\n\t- Reverse a subarray with size k if the single 1 is not set to a position in banned.\nReturn an integer array answer with n results where the ith result is the minimum number of operations needed to bring the single 1 to position i in arr, or -1 if it is impossible.\n",
        "provided_code_snippet": "class Solution:\r\n    def minReverseOperations(self, n: int, p: int, banned: List[int], k: int) -> List[int]:",
        "solution": "from sortedcontainers import SortedList\n\nclass Solution:\n    def minReverseOperations(self, n, p, banned_vals, K):\n        remaining = [SortedList(), SortedList()]\n        banned = set(banned_vals)\n        for u in range(n):\n            if u != p and u not in banned:\n                remaining[u & 1].add(u)\n\n        queue = [p]\n        dist = [-1] * n\n        dist[p] = 0\n        for node in queue:\n            lo = max(node - K + 1, 0)\n            lo = 2 * lo + K - 1 - node\n            hi = min(node + K - 1, n - 1) - (K - 1)\n            hi = 2 * hi + K - 1 - node\n\n            for nei in list(remaining[lo % 2].irange(lo, hi)):\n                queue.append(nei)\n                dist[nei] = dist[node] + 1\n                remaining[lo % 2].remove(nei)\n        \n        return dist",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2614": {
        "problem_id": 2614,
        "description": "You are given a 0-indexed two-dimensional integer array nums.\nReturn the largest prime number that lies on at least one of the diagonals of nums. In case, no prime is present on any of the diagonals, return 0.\nNote that:\n\t- An integer is prime if it is greater than 1 and has no positive integer divisors other than 1 and itself.\n\t- An integer val is on one of the diagonals of nums if there exists an integer i for which nums[i][i] = val or an i for which nums[i][nums.length - i - 1] = val.\n\nIn the above diagram, one diagonal is [1,5,9] and another diagonal is [3,5,7].\n",
        "provided_code_snippet": "class Solution:\r\n    def diagonalPrime(self, nums: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def diagonalPrime(self, nums: List[List[int]]) -> int:\n        def is_prime(num):\n            if num <= 1:\n                return False\n            for i in range(2, int(num ** 0.5) + 1):\n                if num % i == 0:\n                    return False\n            return True\n\n        largest_prime = 0\n        n = len(nums)\n        for i in range(n):\n            if is_prime(nums[i][i]):\n                largest_prime = max(largest_prime, nums[i][i])\n            if is_prime(nums[i][n-i-1]):\n                largest_prime = max(largest_prime, nums[i][n-i-1])\n        return largest_prime",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2615": {
        "problem_id": 2615,
        "description": "You are given a 0-indexed integer array nums. There exists an array arr of length nums.length, where arr[i] is the sum of |i - j| over all j such that nums[j] == nums[i] and j != i. If there is no such j, set arr[i] to be 0.\nReturn the array arr.\n",
        "provided_code_snippet": "class Solution:\r\n    def distance(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def distance(self, nums: List[int]) -> List[int]:\n        num_indices = dict()\n        occ=dict()\n        for i, num in enumerate(nums):\n            if num not in num_indices:\n                num_indices[num] = i\n                occ[num]=1\n            else:\n                num_indices[num]=num_indices[num]+i\n                occ[num]=occ[num]+1\n        arr = [0] * len(nums)\n        n=len(nums)\n        for i in range(n):\n            arr[i] = num_indices[nums[i]] - occ[nums[i]]*i     \n            num_indices[nums[i]]=num_indices[nums[i]]-2*i\n            occ[nums[i]]=occ[nums[i]]-2\n            \n        return arr",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2616": {
        "problem_id": 2616,
        "description": "You are given a 0-indexed integer array nums and an integer p. Find p pairs of indices of nums such that the maximum difference amongst all the pairs is minimized. Also, ensure no index appears more than once amongst the p pairs.\nNote that for a pair of elements at the index i and j, the difference of this pair is |nums[i] - nums[j]|, where |x| represents the absolute value of x.\nReturn the minimum maximum difference among all p pairs. We define the maximum of an empty set to be zero.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeMax(self, nums: List[int], p: int) -> int:",
        "solution": "class Solution:\n    def minimizeMax(self, nums: List[int], p: int) -> int:\n        \n        def can_form_pairs(mid):\n            count = 0\n            i = 0\n            while i < len(nums) - 1 and count < p:\n                if nums[i+1] - nums[i] <= mid:\n                    count += 1\n                    i += 2\n                else:\n                    i += 1\n            return count >= p\n        \n        nums.sort()\n        left, right = 0, nums[-1] - nums[0]\n        \n        while left < right:\n            mid = (left + right) // 2\n            if can_form_pairs(mid):\n                right = mid\n            else:\n                left = mid + 1\n                \n        return left",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2617": {
        "problem_id": 2617,
        "description": "You are given a 0-indexed m x n integer matrix grid. Your initial position is at the top-left cell (0, 0).\nStarting from the cell (i, j), you can move to one of the following cells:\n\t- Cells (i, k) with j < k <= grid[i][j] + j (rightward movement), or\n\t- Cells (k, j) with i < k <= grid[i][j] + i (downward movement).\nReturn the minimum number of cells you need to visit to reach the bottom-right cell (m - 1, n - 1). If there is no valid path, return -1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumVisitedCells(self, grid: List[List[int]]) -> int:",
        "solution": "from sortedcontainers import SortedList\nclass Solution:\n    def minimumVisitedCells(self, grid: List[List[int]]) -> int:\n        m, n = len(grid), len(grid[0])\n        s0 = [SortedList(range(n)) for _ in range(m)]\n        s1 = [SortedList(range(m)) for _ in range(n)]\n        q = deque([(0, 0, 1)])\n\n        while q:\n            i, j, d = q.popleft()\n            if (i, j) == (m-1, n-1):\n                return d\n            for k in list(s0[i].irange(j+1, min(j+1+grid[i][j], n) - 1)):\n                q.append((i, k, d+1))\n                s0[i].remove(k)\n                s1[k].remove(i)\n            for k in list(s1[j].irange(i+1, min(i+1+grid[i][j], m) - 1)):\n                q.append((k, j, d+1))\n                s1[j].remove(k)\n                s0[k].remove(j)\n        return -1",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2639": {
        "problem_id": 2639,
        "description": "You are given a 0-indexed m x n integer matrix grid. The width of a column is the maximum length of its integers.\n\t- For example, if grid = [[-10], [3], [12]], the width of the only column is 3 since -10 is of length 3.\nReturn an integer array ans of size n where ans[i] is the width of the ith column.\nThe length of an integer x with len digits is equal to len if x is non-negative, and len + 1 otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def findColumnWidth(self, grid: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def findColumnWidth(self, grid: List[List[int]]) -> List[int]:\n        m, n = len(grid), len(grid[0])\n        widths = [0] * n  \n        for j in range(n):\n            for i in range(m):\n                width = len(str(abs(grid[i][j])))\n                if grid[i][j] < 0:\n                    width += 1 \n                widths[j] = max(widths[j], width)\n        return widths",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2640": {
        "problem_id": 2640,
        "description": "We define the conversion array conver of an array arr as follows:\n\t- conver[i] = arr[i] + max(arr[0..i]) where max(arr[0..i]) is the maximum value of arr[j] over 0 <= j <= i.\nWe also define the score of an array arr as the sum of the values of the conversion array of arr.\nGiven a 0-indexed integer array nums of length n, return an array ans of length n where ans[i] is the score of the prefix nums[0..i].\n",
        "provided_code_snippet": "class Solution:\r\n    def findPrefixScore(self, nums: List[int]) -> List[int]:",
        "solution": "def findPrefixScore(self, nums: List[int]) -> List[int]:\n    m, conver = 0, []\n    for x in nums:\n        m = max(m, x)\n        conver.append(x + m)\n    return accumulate(conver)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2641": {
        "problem_id": 2641,
        "description": "Given the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins' values.\nTwo nodes of a binary tree are cousins if they have the same depth with different parents.\nReturn the root of the modified tree.\nNote that the depth of a node is the number of edges in the path from the root node to it.\n",
        "provided_code_snippet": "# Definition for a binary tree node.\r\n# class TreeNode:\r\n#     def __init__(self, val=0, left=None, right=None):\r\n#         self.val = val\r\n#         self.left = left\r\n#         self.right = right\r\nclass Solution:\r\n    def replaceValueInTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:",
        "solution": "def replaceValueInTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:\n    m = Counter()\n    def dfs(r, l):\n        if not r: return\n        m[l] += r.val\n        dfs(r.left, l + 1)\n        dfs(r.right, l + 1)\n    dfs(root, 0)\n    \n    def dfs1(r, l, curr):\n        sum_of_cousins = m[l + 1] - (r.left.val if r.left else 0) - (r.right.val if r.right else 0)\n        if r.left:\n            curr.left = TreeNode(sum_of_cousins)\n            dfs1(r.left, l + 1, curr.left)\n        if r.right:\n            curr.right = TreeNode(sum_of_cousins)\n            dfs1(r.right, l + 1, curr.right)\n        return curr\n    return dfs1(root, 0, TreeNode(0))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2643": {
        "problem_id": 2643,
        "description": "Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.\nIn case there are multiple rows that have the maximum count of ones, the row with the smallest row number should be selected.\nReturn an array containing the index of the row, and the number of ones in it.\n",
        "provided_code_snippet": "class Solution:\r\n    def rowAndMaximumOnes(self, mat: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def rowAndMaximumOnes(self, mat: List[List[int]]) -> List[int]:    \n        ones = 0 \n        index = 0\n        for it, row in enumerate(mat):\n            c = row.count(1)\n            if ones < c:\n                ones = c\n                index = it\n        \n        return [index,ones]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2644": {
        "problem_id": 2644,
        "description": "You are given two 0-indexed integer arrays nums and divisors.\nThe divisibility score of divisors[i] is the number of indices j such that nums[j] is divisible by divisors[i].\nReturn the integer divisors[i] with the maximum divisibility score. If there is more than one integer with the maximum score, return the minimum of them.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:",
        "solution": "class Solution:\n    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n        l=[]\n        divisors.sort()\n        for i in divisors:\n            c=0\n            for j in nums:\n                if j%i==0:\n                    c+=1\n            l.append(c)\n        return divisors[l.index(max(l))]",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2645": {
        "problem_id": 2645,
        "description": "Given a string word to which you can insert letters \"a\", \"b\" or \"c\" anywhere and any number of times, return the minimum number of letters that must be inserted so that word becomes valid.\nA string is called valid if it can be formed by concatenating the string \"abc\" several times.\n",
        "provided_code_snippet": "class Solution:\r\n    def addMinimum(self, word: str) -> int:",
        "solution": "class Solution:\n    def addMinimum(self, word: str) -> int:\n        n = len(word)\n        i = 0\n        res = 0\n        \n        while i < n:\n            count = 0\n            \n            if word[i] == 'a':\n                count += 1\n                i += 1\n             \n            if i < n and word[i] == 'b':\n                count += 1\n                i += 1\n            \n            if i < n and word[i] == 'c':\n                count += 1\n                i += 1\n            \n            res += 3 - count\n        \n        return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2646": {
        "problem_id": 2646,
        "description": "There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nEach node has an associated price. You are given an integer array price, where price[i] is the price of the ith node.\nThe price sum of a given path is the sum of the prices of all nodes lying on that path.\nAdditionally, you are given a 2D integer array trips, where trips[i] = [starti, endi] indicates that you start the ith trip from the node starti and travel to the node endi by any path you like.\nBefore performing your first trip, you can choose some non-adjacent nodes and halve the prices.\nReturn the minimum total price sum to perform all the given trips.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumTotalPrice(self, n: int, edges: List[List[int]], price: List[int], trips: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def minimumTotalPrice(self, n: int, edges: List[List[int]], price: List[int], trips: List[List[int]]) -> int:\n        tree = [[] for _ in range(n)] \n        for u, v in edges: \n            tree[u].append(v)\n            tree[v].append(u)\n        freq = [0]*n\n        for s, e in trips: \n            queue = deque([(s, -1)])\n            parent = {s : -1}\n            while queue: \n                u, p = queue.popleft()\n                if u == e: break \n                for v in tree[u]: \n                    if v != p: \n                        queue.append((v, u))\n                        parent[v] = u\n            u = e \n            while u >= 0: \n                freq[u] += 1\n                u = parent[u]\n            \n        def dfs(u, p):\n            \n            full = half = 0 \n            for v in tree[u]: \n                if v != p: \n                    ff, hh = dfs(v, u)\n                    full += ff\n                    half += min(ff, hh)\n            return price[u]*freq[u] + half, price[u]*freq[u]//2 + full\n            \n        return min(dfs(0, -1))",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2651": {
        "problem_id": 2651,
        "description": "You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours.\nReturn the time when the train will arrive at the station.\nNote that the time in this problem is in 24-hours format.\n",
        "provided_code_snippet": "class Solution:\r\n    def findDelayedArrivalTime(self, arrivalTime: int, delayedTime: int) -> int:",
        "solution": "class Solution:\n    def findDelayedArrivalTime(self, arrivalTime: int, delayedTime: int) -> int:\n        return (arrivalTime + delayedTime) % 24",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2652": {
        "problem_id": 2652,
        "description": "Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7.\nReturn an integer denoting the sum of all numbers in the given range satisfying the constraint.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumOfMultiples(self, n: int) -> int:",
        "solution": "class Solution:\n    def sumOfMultiples(self, n: int) -> int:\n\n        a, b, c, d, e, f, g = n//3, n//5, n//7, n//15, n//21, n//35, n//105\n\n        return (\n                  3*a*(a+1)     #\n                + 5*b*(b+1)     # <-- three venn circles\n                + 7*c*(c+1)     # \n\n                - 15*d*(d+1)    #\n                - 21*e*(e+1)    # <-- three venn lunes\n                - 35*f*(f+1)    #\n            \n                + 105*g*(g+1)   # <-- one venn circular triangle \n               )//2",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2653": {
        "problem_id": 2653,
        "description": "Given an integer array nums containing n integers, find the beauty of each subarray of size k.\nThe beauty of a subarray is the xth smallest integer in the subarray if it is negative, or 0 if there are fewer than x negative integers.\nReturn an integer array containing n - k + 1 integers, which denote the beauty of the subarrays in order from the first index in the array.\n\t- \tA subarray is a contiguous non-empty sequence of elements within an array.\n\t\n",
        "provided_code_snippet": "class Solution:\r\n    def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]:",
        "solution": "def getSubarrayBeauty(self, nums: List[int], k: int, x: int) -> List[int]:\n    counter, ans = [0] * 50, [0] * (len(nums) - k + 1)\n    for i in range(len(nums)):\n        if nums[i] < 0: counter[nums[i] + 50] += 1\n        if i - k >= 0 and nums[i - k] < 0: counter[nums[i - k] + 50] -= 1\n        if i - k + 1 < 0: continue\n        count = 0\n        for j in range(50):\n            count += counter[j]\n            if count >= x:\n                ans[i - k + 1] = j - 50\n                break\n    return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2654": {
        "problem_id": 2654,
        "description": "You are given a 0-indexed array nums consisiting of positive integers. You can do the following operation on the array any number of times:\n\t- Select an index i such that 0 <= i < n - 1 and replace either of nums[i] or nums[i+1] with their gcd value.\nReturn the minimum number of operations to make all elements of nums equal to 1. If it is impossible, return -1.\nThe gcd of two integers is the greatest common divisor of the two integers.\n",
        "provided_code_snippet": "class Solution:\r\n    def minOperations(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def minOperations(self, nums: List[int]) -> int:\n        ones = nums.count(1)\n        if ones: return len(nums)-ones\n        diff = inf \n        for i in range(len(nums)): \n            g = nums[i]\n            for j in range(i+1, len(nums)):\n                g = gcd(g, nums[j])\n                if g == 1: diff = min(diff, j-i)\n        return -1 if diff == inf else diff + len(nums) - 1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2656": {
        "problem_id": 2656,
        "description": "You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your score:\n\t1. Select an element m from nums.\n\t2. Remove the selected element m from the array.\n\t3. Add a new element with a value of m + 1 to the array.\n\t4. Increase your score by m.\nReturn the maximum score you can achieve after performing the operation exactly k times.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximizeSum(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximizeSum(self, nums: List[int], k: int) -> int:\n        \n        n = max(nums)\n\n        return k*(2*n+k-1)//2",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2657": {
        "problem_id": 2657,
        "description": "You are given two 0-indexed integer permutations A and B of length n.\nA prefix common array of A and B is an array C such that C[i] is equal to the count of numbers that are present at or before the index i in both A and B.\nReturn the prefix common array of A and B.\nA sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.\n",
        "provided_code_snippet": "class Solution:\r\n    def findThePrefixCommonArray(self, A: List[int], B: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def findThePrefixCommonArray(self, A: List[int], B: List[int]) -> List[int]:\n        n = len(A)\n        m1, m2 = {}, {}\n        for i in range(n):\n            m1[A[i]] = i\n            m2[B[i]] = i\n        c = [0] * n\n        for i in range(n):\n            cnt = 0\n            for j in range(i + 1):\n                if m1[A[j]] <= i and m2[A[j]] <= i:\n                    cnt += 1\n            c[i] = cnt\n        return c",
        "submission_passed": true,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2658": {
        "problem_id": 2658,
        "description": "You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents:\n\t- A land cell if grid[r][c] = 0, or\n\t- A water cell containing grid[r][c] fish, if grid[r][c] > 0.\nA fisher can start at any water cell (r, c) and can do the following operations any number of times:\n\t- Catch all the fish at cell (r, c), or\n\t- Move to any adjacent water cell.\nReturn the maximum number of fish the fisher can catch if he chooses his starting cell optimally, or 0 if no water cell exists.\nAn adjacent cell of the cell (r, c), is one of the cells (r, c + 1), (r, c - 1), (r + 1, c) or (r - 1, c) if it exists.\n",
        "provided_code_snippet": "class Solution:\r\n    def findMaxFish(self, grid: List[List[int]]) -> int:",
        "solution": "def findMaxFish(self, grid: List[List[int]]) -> int:\n    n = len(grid)\n    m = len(grid[0])\n    ans = 0\n    for i in range(n):\n        for j in range(m):\n            if grid[i][j] > 0:\n                ans = max(ans, self.dfs(i, j, grid, n, m))\n    return ans\n\ndef dfs(self, i: int, j: int, grid: List[List[int]], n: int, m: int) -> int:\n    f = grid[i][j]\n    grid[i][j] = 0\n    dr = [0, 1, 0, -1, 0]\n    for k in range(4):\n        nr = i + dr[k]\n        nc = j + dr[k + 1]\n        if nr >= 0 and nr < n and nc >= 0 and nc < m and grid[nr][nc] > 0:\n            f += self.dfs(nr, nc, grid, n, m)\n    return f",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2659": {
        "problem_id": 2659,
        "description": "You are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty:\n\t- If the first element has the smallest value, remove it\n\t- Otherwise, put the first element at the end of the array.\nReturn an integer denoting the number of operations it takes to make nums empty.\n",
        "provided_code_snippet": "class Solution:\r\n    def countOperationsToEmptyArray(self, nums: List[int]) -> int:",
        "solution": "def countOperationsToEmptyArray(self, nums: List[int]) -> int:\n    n = len(nums)\n    map = {nums[i]: i for i in range(n)}\n    nums.sort()\n    ans = 1\n    for i in range(n - 2, -1, -1):\n        ans += (map[nums[i]] > map[nums[i+1]]) * (n - i) + (map[nums[i]] <= map[nums[i+1]])\n    return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2660": {
        "problem_id": 2660,
        "description": "You are given two 0-indexed integer arrays player1 and player2, representing the number of pins that player 1 and player 2 hit in a bowling game, respectively.\nThe bowling game consists of n turns, and the number of pins in each turn is exactly 10.\nAssume a player hits xi pins in the ith turn. The value of the ith turn for the player is:\n\t- 2xi if the player hits 10 pins in either (i - 1)th or (i - 2)th turn.\n\t- Otherwise, it is xi.\nThe score of the player is the sum of the values of their n turns.\nReturn\n\t- 1 if the score of player 1 is more than the score of player 2,\n\t- 2 if the score of player 2 is more than the score of player 1, and\n\t- 0 in case of a draw.\n",
        "provided_code_snippet": "class Solution:\r\n    def isWinner(self, player1: List[int], player2: List[int]) -> int:",
        "solution": "def isWinner(p1: List[int], p2: List[int]) -> int:\n    ans, s1, s2 = 0, 0, 0\n    n = len(p1)\n    for i in range(n):\n        s1 += p1[i]\n        s2 += p2[i]\n    if n > 1:\n        for i in range(1, n):\n            if p1[i - 1] == 10 or ((i >= 2) and p1[i - 2] == 10):\n                s1 += p1[i]\n            if p2[i - 1] == 10 or ((i >= 2) and p2[i - 2] == 10):\n                s2 += p2[i]\n    if s1 == s2:\n        ans = 0\n    elif s1 > s2:\n        ans = 1\n    else:\n        ans = 2\n    return ans",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2661": {
        "problem_id": 2661,
        "description": "You are given a 0-indexed integer array arr, and an m x n integer matrix mat. arr and mat both contain all the integers in the range [1, m * n].\nGo through each index i in arr starting from index 0 and paint the cell in mat containing the integer arr[i].\nReturn the smallest index i at which either a row or a column will be completely painted in mat.\n",
        "provided_code_snippet": "class Solution:\r\n    def firstCompleteIndex(self, arr: List[int], mat: List[List[int]]) -> int:",
        "solution": "def firstCompleteIndex(arr: List[int], mat: List[List[int]]) -> int:\n    m = len(mat)\n    n = len(mat[0])\n    map = {}\n    for i in range(m):\n        for j in range(n):\n            map[mat[i][j]] = [i, j]\n    row = [0] * m\n    col = [0] * n\n    for i in range(len(arr)):\n        x = map[arr[i]]\n        row[x[0]] += 1\n        col[x[1]] += 1\n        if row[x[0]] == n or col[x[1]] == m:\n            return i\n    return -1",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2662": {
        "problem_id": 2662,
        "description": "You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the array target where target = [targetX, targetY] represents your target position (targetX, targetY).\nThe cost of going from a position (x1, y1) to any other position in the space (x2, y2) is |x2 - x1| + |y2 - y1|.\nThere are also some special roads. You are given a 2D array specialRoads where specialRoads[i] = [x1i, y1i, x2i, y2i, costi] indicates that the ith special road can take you from (x1i, y1i) to (x2i, y2i) with a cost equal to costi. You can use each special road any number of times.\nReturn the minimum cost required to go from (startX, startY) to (targetX, targetY).\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumCost(self, start: List[int], target: List[int], specialRoads: List[List[int]]) -> int:",
        "solution": "import heapq\ndef minimumCost(start, target, specialRoads):\n    filteredRoads = []\n    for road in specialRoads:\n        a, b, c, d, cost = road\n        if cost < abs(a - c) + abs(b - d):\n            filteredRoads.append([a, b, c, d, cost])\n    dist = {(start[0], start[1]): 0}\n    heap = [(0, start[0], start[1])]\n    while heap:\n        currdist, x, y = heapq.heappop(heap)\n        for road in filteredRoads:\n            a, b, c, d, cost = road\n            if dist.get((c, d), float('inf')) > currdist + abs(x - a) + abs(y - b) + cost:\n                dist[(c, d)] = currdist + abs(x - a) + abs(y - b) + cost\n                heapq.heappush(heap, (dist[(c, d)], c, d))\n    res = abs(target[0] - start[0]) + abs(target[1] - start[1])\n    for road in filteredRoads:\n        a, b, c, d, cost = road\n        res = min(res, dist.get((c, d), float('inf')) + abs(target[0] - c) + abs(target[1] - d))\n    return res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2663": {
        "problem_id": 2663,
        "description": "A string is beautiful if:\n\t- It consists of the first k letters of the English lowercase alphabet.\n\t- It does not contain any substring of length 2 or more which is a palindrome.\nYou are given a beautiful string s of length n and a positive integer k.\nReturn the lexicographically smallest string of length n, which is larger than s and is beautiful. If there is no such string, return an empty string.\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b.\n\t- For example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestBeautifulString(self, s: str, k: int) -> str:",
        "solution": "class Solution:\n    def smallestBeautifulString(self, s: str, k: int) -> str:\n        s = list(s)\n        i = len(s) - 1\n        s[i] = chr(ord(s[i]) + 1)\n        while 0 <= i < len(s):\n            if ord(s[i]) - ord('a') >= k:\n                s[i] = 'a'\n                i -= 1\n                s[i] = chr(ord(s[i]) + 1)\n            elif (i >= 1 and s[i] == s[i - 1]) or (i >= 2 and s[i] == s[i - 2]):\n                s[i] = chr(ord(s[i]) + 1)\n            else:\n                i += 1\n        return '' if i < 0 else ''.join(s)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2670": {
        "problem_id": 2670,
        "description": "You are given a 0-indexed array nums of length n.\nThe distinct difference array of nums is an array diff of length n such that diff[i] is equal to the number of distinct elements in the suffix nums[i + 1, ..., n - 1] subtracted from the number of distinct elements in the prefix nums[0, ..., i].\nReturn the distinct difference array of nums.\nNote that nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j inclusive. Particularly, if i > j then nums[i, ..., j] denotes an empty subarray.\n",
        "provided_code_snippet": "class Solution:\r\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def distinctDifferenceArray(self, nums: List[int]) -> List[int]:\n        # One liner\n        # return [len(Counter(nums[:i + 1])) - len(Counter(nums[i + 1:])) for i in range(len(nums))]\n        prefix = defaultdict(int)\n        suffix = Counter(nums)\n        result = []\n        for x in nums:\n            prefix[x] += 1\n            suffix[x] -= 1\n            if suffix[x] == 0:\n                del suffix[x]\n            result.append(len(prefix) - len(suffix))\n        return result",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2672": {
        "problem_id": 2672,
        "description": "You are given an integer n representing an array colors of length n where all elements are set to 0's meaning uncolored. You are also given a 2D integer array queries where queries[i] = [indexi, colori]. For the ith query:\n\t- Set colors[indexi] to colori.\n\t- Count adjacent pairs in colors set to the same color (regardless of colori).\nReturn an array answer of the same length as queries where answer[i] is the answer to the ith query.\n",
        "provided_code_snippet": "class Solution:\r\n    def colorTheArray(self, n: int, queries: List[List[int]]) -> List[int]:",
        "solution": "def colorTheArray(self, n: int, queries):\n    nums, c = [0] * n, 0\n    for index, color in queries:\n        pre, nex = nums[index - 1] if index > 0 else 0, nums[index + 1] if index < n-1 else 0\n        if nums[index] and nums[index] == pre: c -= 1\n        if nums[index] and nums[index] == nex: c -= 1\n        nums[index] = color\n        if nums[index] == pre: c += 1\n        if nums[index] == nex: c += 1\n        yield c",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2673": {
        "problem_id": 2673,
        "description": "You are given an integer n representing the number of nodes in a perfect binary tree consisting of nodes numbered from 1 to n. The root of the tree is node 1 and each node i in the tree has two children where the left child is the node 2 * i and the right child is 2 * i + 1.\nEach node in the tree also has a cost represented by a given 0-indexed integer array cost of size n where cost[i] is the cost of node i + 1. You are allowed to increment the cost of any node by 1 any number of times.\nReturn the minimum number of increments you need to make the cost of paths from the root to each leaf node equal.\nNote:\n\t- A perfect binary tree is a tree where each node, except the leaf nodes, has exactly 2 children.\n\t- The cost of a path is the sum of costs of nodes in the path.\n",
        "provided_code_snippet": "class Solution:\r\n    def minIncrements(self, n: int, cost: List[int]) -> int:",
        "solution": "def minIncrements(self, n, cost):\n    self.res = 0\n    def dfs(i):\n        if i >= len(cost): return 0\n        a, b = dfs(2 * i + 1), dfs(2 * i + 2)\n        self.res += abs(a - b)\n        return cost[i] + max(a, b)\n    dfs(0)\n    return self.res",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2678": {
        "problem_id": 2678,
        "description": "You are given a 0-indexed array of strings details. Each element of details provides information about a given passenger compressed into a string of length 15. The system is such that:\n\t- The first ten characters consist of the phone number of passengers.\n\t- The next character denotes the gender of the person.\n\t- The following two characters are used to indicate the age of the person.\n\t- The last two characters determine the seat allotted to that person.\nReturn the number of passengers who are strictly more than 60 years old.\n",
        "provided_code_snippet": "class Solution:\r\n    def countSeniors(self, details: List[str]) -> int:",
        "solution": "class Solution:\n    def countSeniors(self, details: List[str]) -> int:\n        return sum(int(x[11:13]) > 60 for x in details)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2679": {
        "problem_id": 2679,
        "description": "You are given a 0-indexed 2D integer array nums. Initially, your score is 0. Perform the following operations until the matrix becomes empty:\n\t1. From each row in the matrix, select the largest number and remove it. In the case of a tie, it does not matter which number is chosen.\n\t2. Identify the highest number amongst all those removed in step 1. Add that number to your score.\nReturn the final score.\n",
        "provided_code_snippet": "class Solution:\r\n    def matrixSum(self, nums: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def matrixSum(self, nums: List[List[int]]) -> int:\n        return sum(max(col) for col in zip(*[sorted(row) for row in nums]))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2680": {
        "problem_id": 2680,
        "description": "You are given a 0-indexed integer array nums of length n and an integer k. In an operation, you can choose an element and multiply it by 2.\nReturn the maximum possible value of nums[0] | nums[1] | ... | nums[n - 1] that can be obtained after applying the operation on nums at most k times.\nNote that a | b denotes the bitwise or between two integers a and b.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumOr(self, nums: List[int], k: int) -> int:",
        "solution": "class Solution:\n    def maximumOr(self, nums: List[int], k: int) -> int:\n        n, result = len(nums), 0\n        prefix, suffix = [0] * (n + 1), [0] * (n + 1)\n        for i in range(1, n):\n            prefix[i] = prefix[i - 1] | nums[i - 1]\n            suffix[n - i - 1] = suffix[n - i] | nums[n - i]\n        for i in range(n):\n            result = max(result, prefix[i] | (nums[i] << k) | suffix[i])\n        return result",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2681": {
        "problem_id": 2681,
        "description": "You are given a 0-indexed integer array nums representing the strength of some heroes. The power of a group of heroes is defined as follows:\n\t- Let i0, i1, ... ,ik be the indices of the heroes in a group. Then, the power of this group is max(nums[i0], nums[i1], ... ,nums[ik])2 * min(nums[i0], nums[i1], ... ,nums[ik]).\nReturn the sum of the power of all non-empty groups of heroes possible. Since the sum could be very large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def sumOfPower(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def sumOfPower(self, nums: List[int]) -> int:\n        ans, t, base = 0, 0, 10**9 + 7\n        for c in sorted(nums):\n            ans = (ans + (t + c) * c * c) % base\n            t = (2 * t + c) % base\n        return ans",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2682": {
        "problem_id": 2682,
        "description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.\nThe rules of the game are as follows:\n1st friend receives the ball.\n\t- After that, 1st friend passes it to the friend who is k steps away from them in the clockwise direction.\n\t- After that, the friend who receives the ball should pass it to the friend who is 2 * k steps away from them in the clockwise direction.\n\t- After that, the friend who receives the ball should pass it to the friend who is 3 * k steps away from them in the clockwise direction, and so on and so forth.\nIn other words, on the ith turn, the friend holding the ball should pass it to the friend who is i * k steps away from them in the clockwise direction.\nThe game is finished when some friend receives the ball for the second time.\nThe losers of the game are friends who did not receive the ball in the entire game.\nGiven the number of friends, n, and an integer k, return the array answer, which contains the losers of the game in the ascending order.\n",
        "provided_code_snippet": "class Solution:\r\n    def circularGameLosers(self, n: int, k: int) -> List[int]:",
        "solution": "class Solution:\n    def circularGameLosers(self, n: int, k: int) -> List[int]:\n        s = set([i for i in range(1, n + 1)])\n        for mul in accumulate([i for i in range(n)]):\n            if k * mul % n + 1 not in s:\n                break\n            s.remove(k * mul % n + 1)\n        return s",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2684": {
        "problem_id": 2684,
        "description": "You are given a 0-indexed m x n matrix grid consisting of positive integers.\nYou can start at any cell in the first column of the matrix, and traverse the grid in the following way:\n\t- From a cell (row, col), you can move to any of the cells: (row - 1, col + 1), (row, col + 1) and (row + 1, col + 1) such that the value of the cell you move to, should be strictly bigger than the value of the current cell.\nReturn the maximum number of moves that you can perform.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxMoves(self, grid: List[List[int]]) -> int:",
        "solution": "def maxMoves(self, grid: List[List[int]]) -> int:\n    m, n, dirs = len(grid), len(grid[0]), [(0, 1), (1, 1), (-1, 1)]\n    @cache\n    def dp(i, j):\n        ans = 0\n        for x, y in dirs:\n            ni, nj = i + x, j + y\n            if 0 <= ni < m and nj < n and grid[i][j] < grid[ni][nj]:\n                ans = max(ans, 1 + dp(ni, nj))\n        return ans\n    return max(dp(i, 0) for i in range(m))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2685": {
        "problem_id": 2685,
        "description": "You are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i] = [ai, bi] denotes that there exists an undirected edge connecting vertices ai and bi.\nReturn the number of complete connected components of the graph.\nA connected component is a subgraph of a graph in which there exists a path between any two vertices, and no vertex of the subgraph shares an edge with a vertex outside of the subgraph.\nA connected component is said to be complete if there exists an edge between every pair of its vertices.\n",
        "provided_code_snippet": "class Solution:\r\n    def countCompleteComponents(self, n: int, edges: List[List[int]]) -> int:",
        "solution": "class DSU:\n    def __init__(self, n):\n        self.p = list(range(n))\n        self.rank = [0] * n\n        self.count = [1] * n\n    def find(self, x):\n        if x != self.p[x]:\n            self.p[x] = self.find(self.p[x])\n        return self.p[x]\n    def union(self, x, y):\n        xx, yy = self.find(x), self.find(y)\n        if xx == yy: return\n        self.count[xx] = self.count[yy] = self.count[xx] + self.count[yy]\n        if self.rank[xx] < self.rank[yy]: self.p[xx] = yy\n        else: self.p[yy] = xx\n        if self.rank[xx] == self.rank[yy]: self.rank[xx] += 1\n    def size_of_group_that_x_is_a_part_of(self, x):\n        return self.count[self.find(x)]\n\nclass Solution:\n    def countCompleteComponents(self, n, edges):\n        uf, counter = DSU(n), Counter()\n        for x, y in edges: \n            uf.union(x, y)\n            counter[x] += 1\n            counter[y] += 1\n\n        groups = set(uf.find(i) for i in range(n))\n\n        for i in range(n):\n            if uf.size_of_group_that_x_is_a_part_of(i) != counter[i] + 1:\n                groups.discard(uf.find(i))\n\n        return len(groups)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2696": {
        "problem_id": 2696,
        "description": "You are given a string s consisting only of uppercase English letters.\nYou can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings \"AB\" or \"CD\" from s.\nReturn the minimum possible length of the resulting string that you can obtain.\nNote that the string concatenates after removing the substring and could produce new \"AB\" or \"CD\" substrings.\n",
        "provided_code_snippet": "class Solution:\r\n    def minLength(self, s: str) -> int:",
        "solution": "class Solution:\n    def minLength(self, s: str) -> int:\n        stack = []\n        for c in s:\n            if not stack:\n                stack.append(c)\n                continue\n            if c == \"B\" and stack[-1] == \"A\":\n                stack.pop()\n            elif c == \"D\" and stack[-1] == \"C\":\n                stack.pop()\n            else:\n                stack.append(c)\n        return len(stack)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2697": {
        "problem_id": 2697,
        "description": "You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a character in s with another lowercase English letter.\nYour task is to make s a palindrome with the minimum number of operations possible. If there are multiple palindromes that can be made using the minimum number of operations, make the lexicographically smallest one.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\nReturn the resulting palindrome string.\n",
        "provided_code_snippet": "class Solution:\r\n    def makeSmallestPalindrome(self, s: str) -> str:",
        "solution": "class Solution:\n    def makeSmallestPalindrome(self, s: str) -> str:\n        letters = list(s)\n\n        for i in range(len(s) // 2):\n            letters[i] = letters[~i] = min(letters[i], letters[~i])\n\n        return ''.join(letters)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2698": {
        "problem_id": 2698,
        "description": "Given a positive integer n, return the punishment number of n.\nThe punishment number of n is defined as the sum of the squares of all integers i such that:\n\t- 1 <= i <= n\n\t- The decimal representation of i * i can be partitioned into contiguous substrings such that the sum of the integer values of these substrings equals i.\n",
        "provided_code_snippet": "class Solution:\r\n    def punishmentNumber(self, n: int) -> int:",
        "solution": "class Solution:\n    def check(self, idx, p, target):\n        if idx == len(p):\n            return target == 0\n        if target < 0:\n            return False\n        for i in range(idx, len(p)):\n            x = p[idx:i + 1]\n            y = int(x)\n            if self.check(i + 1, p, target - y):\n                return True\n        return False\n\n    def punishmentNumber(self, n):\n        ans = 0\n        for i in range(1, n + 1):\n            x = i * i\n            p = str(x)\n            if self.check(0, p, i):\n                ans += (i * i)\n        return ans\n\n\nsolution = Solution()\nresult = solution.punishmentNumber(10)\nprint(result)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2699": {
        "problem_id": 2699,
        "description": "You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi.\nSome edges have a weight of -1 (wi = -1), while others have a positive weight (wi > 0).\nYour task is to modify all edges with a weight of -1 by assigning them positive integer values in the range [1, 2 * 109] so that the shortest distance between the nodes source and destination becomes equal to an integer target. If there are multiple modifications that make the shortest distance between source and destination equal to target, any of them will be considered correct.\nReturn an array containing all edges (even unmodified ones) in any order if it is possible to make the shortest distance from source to destination equal to target, or an empty array if it's impossible.\nNote: You are not allowed to modify the weights of edges with initial positive weights.\n",
        "provided_code_snippet": "class Solution:\r\n    def modifiedGraphEdges(self, n: int, edges: List[List[int]], source: int, destination: int, target: int) -> List[List[int]]:",
        "solution": "class Solution:\n    def modifiedGraphEdges(self, n, edges, source, destination, target):\n        adjacency_list = [[] for _ in range(n)]\n        for i, (nodeA, nodeB, weight) in enumerate(edges):\n            adjacency_list[nodeA].append((nodeB, i))\n            adjacency_list[nodeB].append((nodeA, i))\n\n        distances = [[float('inf')] * 2 for _ in range(n)]\n        distances[source][0] = distances[source][1] = 0\n\n        self.run_dijkstra(adjacency_list, edges, distances, source, 0, 0)\n        difference = target - distances[destination][0]\n\n        if difference < 0:\n            return []\n\n        self.run_dijkstra(adjacency_list, edges, distances, source, difference, 1)\n\n        if distances[destination][1] < target:\n            return []\n\n        for edge in edges:\n            if edge[2] == -1:\n                edge[2] = 1\n\n        return edges\n\n    def run_dijkstra(self, adjacency_list, edges, distances, source, difference, run):\n        n = len(adjacency_list)\n        priority_queue = [(0, source)]\n        distances[source][run] = 0\n\n        while priority_queue:\n            current_distance, current_node = heapq.heappop(priority_queue)\n            if current_distance > distances[current_node][run]:\n                continue\n\n            for next_node, edge_index in adjacency_list[current_node]:\n                weight = edges[edge_index][2]\n                if weight == -1:\n                    weight = 1\n                if run == 1 and edges[edge_index][2] == -1:\n                    new_weight = difference + distances[next_node][0] - distances[current_node][1]\n                    if new_weight > weight:\n                        edges[edge_index][2] = weight = new_weight\n\n                if distances[next_node][run] > distances[current_node][run] + weight:\n                    distances[next_node][run] = distances[current_node][run] + weight\n                    heapq.heappush(priority_queue, (distances[next_node][run], next_node))\n\ndef main():\n    input_data = sys.stdin.read().strip()\n    lines = input_data.splitlines()\n    \n    num_test_cases = len(lines) // 5\n    results = []\n\n    for i in range(num_test_cases):\n        n = int(lines[i*5])\n        edges = json.loads(lines[i*5 + 1])\n        source = int(lines[i*5 + 2])\n        destination = int(lines[i*5 + 3])\n        target = int(lines[i*5 + 4])\n        \n        result = Solution().modifiedGraphEdges(n, edges, source, destination, target)\n        results.append(json.dumps(result))\n\n    with open('user.out', 'w') as f:\n        for result in results:\n            f.write(f\"{result}\")\n\nif __name__ == \"__main__\":\n    main()\n    exit(0)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2706": {
        "problem_id": 2706,
        "description": "You are given an integer array prices representing the prices of various chocolates in a store. You are also given a single integer money, which represents your initial amount of money.\nYou must buy exactly two chocolates in such a way that you still have some non-negative leftover money. You would like to minimize the sum of the prices of the two chocolates you buy.\nReturn the amount of money you will have leftover after buying the two chocolates. If there is no way for you to buy two chocolates without ending up in debt, return money. Note that the leftover must be non-negative.\n",
        "provided_code_snippet": "class Solution:\r\n    def buyChoco(self, prices: List[int], money: int) -> int:",
        "solution": "class Solution:\n    def buyChoco(self, prices: List[int], money: int) -> int:\n        first_min_cost = second_min_cost = float(\"inf\")\n\n        for p in prices:\n            if p < first_min_cost:\n                second_min_cost, first_min_cost = first_min_cost, p\n            else:\n                second_min_cost = min(second_min_cost, p)\n\n        leftover = money - (first_min_cost + second_min_cost)\n\n        return leftover if leftover >= 0 else money",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2707": {
        "problem_id": 2707,
        "description": "You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings.\nReturn the minimum number of extra characters left over if you break up s optimally.\n",
        "provided_code_snippet": "class Solution:\r\n    def minExtraChar(self, s: str, dictionary: List[str]) -> int:",
        "solution": "class Solution:\n    def __init__(self):\n        self.dp = [-1] * 51  # Initialize dp array with -1 values\n        \n    def minExtraChar(self, s, dictionary):\n        return self.minExtraCharHelper(s, dictionary, 0)\n    \n    def minExtraCharHelper(self, s, dictionary, i):\n        if i == len(s):\n            return 0\n\n        if self.dp[i] == -1:\n            self.dp[i] = 1 + self.minExtraCharHelper(s, dictionary, i + 1)  # Initialize with one extra character.\n\n            for w in dictionary:\n                if s[i:i+len(w)] == w:\n                    self.dp[i] = min(self.dp[i], self.minExtraCharHelper(s, dictionary, i + len(w)))  # Update if a word in the dictionary is found.\n\n        return self.dp[i]  # Return the minimum extra characters starting from position i",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2708": {
        "problem_id": 2708,
        "description": "You are given a 0-indexed integer array nums representing the score of students in an exam. The teacher would like to form one non-empty group of students with maximal strength, where the strength of a group of students of indices i0, i1, i2, ... , ik is defined as nums[i0] * nums[i1] * nums[i2] * ... * nums[ik].\nReturn the maximum strength of a group the teacher can create.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxStrength(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def maxStrength(self, nums: List[int]) -> int:\n        contains_zero = False\n        positive = []\n        negative = []\n\n        for num in nums:\n            if num > 0:\n                positive.append(num)\n            elif num < 0:\n                negative.append(num)\n            else:\n                contains_zero = True\n\n        # If the product of negative numbers is negative\n        if len(negative) & 1:\n            # If there is more than one negative number,\n            # then their product can be positive.\n            if len(negative) > 1:\n                negative.remove(max(negative))\n            # If not, then the product of positive numbers is sufficient\n            elif positive:\n                return prod(positive)\n            # If not again, then zero is greater than negative numbers.\n            elif contains_zero:\n                return 0\n            # If again not, then return the maximum among the negative\n            else:\n                return max(negative)\n\n        # Consists of zeros only\n        if not (negative or positive):\n            return 0\n\n        return prod(negative) * prod(positive)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2709": {
        "problem_id": 2709,
        "description": "You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices. You can traverse between index i and index j, i != j, if and only if gcd(nums[i], nums[j]) > 1, where gcd is the greatest common divisor.\nYour task is to determine if for every pair of indices i and j in nums, where i < j, there exists a sequence of traversals that can take us from i to j.\nReturn true if it is possible to traverse between all such pairs of indices, or false otherwise.\n",
        "provided_code_snippet": "class Solution:\r\n    def canTraverseAllPairs(self, nums: List[int]) -> bool:",
        "solution": "class Solution:\n    def dfs(self, index, visitedIndex, visitedPrime):\n        if visitedIndex[index]:\n            return\n        visitedIndex[index] = True\n\n        for prime in self.index2prime[index]:\n            if visitedPrime.get(prime, False):\n                continue\n            visitedPrime[prime] = True\n            for index1 in self.prime2index[prime]:\n                if visitedIndex[index1]:\n                    continue\n                self.dfs(index1, visitedIndex, visitedPrime)\n\n    def canTraverseAllPairs(self, nums: List[int]) -> bool:\n        self.prime2index = {}\n        self.index2prime = {}\n        for i, num in enumerate(nums):\n            temp = num\n            for j in range(2, int(num ** 0.5) + 1):\n                if temp % j == 0:\n                    self.prime2index.setdefault(j, []).append(i)\n                    self.index2prime.setdefault(i, []).append(j)\n                    while temp % j == 0:\n                        temp //= j\n            if temp > 1:\n                self.prime2index.setdefault(temp, []).append(i)\n                self.index2prime.setdefault(i, []).append(temp)\n\n        visitedIndex = [False] * len(nums)\n        visitedPrime = {}\n        self.dfs(0, visitedIndex, visitedPrime)\n\n        return all(visitedIndex)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2710": {
        "problem_id": 2710,
        "description": "Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def removeTrailingZeros(self, num: str) -> str:",
        "solution": "class Solution:\n    def removeTrailingZeros(self, num: str) -> str:\n        return num.rstrip('0')",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2711": {
        "problem_id": 2711,
        "description": "Given a 2D grid of size m x n, you should find the matrix answer of size m x n.\nThe cell answer[r][c] is calculated by looking at the diagonal values of the cell grid[r][c]:\n\t- Let leftAbove[r][c] be the number of distinct values on the diagonal to the left and above the cell grid[r][c] not including the cell grid[r][c] itself.\n\t- Let rightBelow[r][c] be the number of distinct values on the diagonal to the right and below the cell grid[r][c], not including the cell grid[r][c] itself.\n\t- Then answer[r][c] = |leftAbove[r][c] - rightBelow[r][c]|.\nA matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until the end of the matrix is reached.\n\t- For example, in the below diagram the diagonal is highlighted using the cell with indices (2, 3) colored gray:\t\t\t- Red-colored cells are left and above the cell.\n\t\t- Blue-colored cells are right and below the cell.\n\t\t\n\nReturn the matrix answer.\n",
        "provided_code_snippet": "class Solution:\r\n    def differenceOfDistinctValues(self, grid: List[List[int]]) -> List[List[int]]:",
        "solution": "class Solution:\n    def differenceOfDistinctValues(self, grid: List[List[int]]) -> List[List[int]]:\n\n        d = defaultdict(list)                      \n\n        for i, j in product(range(len(grid)),        \n                            range(len(grid[0]))):\n            d[i-j].append((i,j))                        # <-- Construct dict of diagonals; i - j\n                                                        #     remains constant on a '\\\\' diag. \n        for diag in d:\n            arr = [grid[i][j] for i,j in d[diag]]       # <-- Construct an arr of the elements\n                                                        #     on the diagonal.\n\n            for idx, (i,j) in enumerate(d[diag]):       # <-- Overwrite each element in the diagonal.   \n                grid[i][j] = abs(len(set(arr[:idx])) -  #     in the array with its score.\n                                 len(set(arr[idx+1:])))\n            \n        return grid                                     # <-- Return the overwritten 'grid' as the\n                                                        #     'answer' matrix.",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2712": {
        "problem_id": 2712,
        "description": "You are given a 0-indexed binary string s of length n on which you can apply two types of operations:\n\t- Choose an index i and invert all characters from index 0 to index i (both inclusive), with a cost of i + 1\n\t- Choose an index i and invert all characters from index i to index n - 1 (both inclusive), with a cost of n - i\nReturn the minimum cost to make all characters of the string equal.\nInvert a character means if its value is '0' it becomes '1' and vice-versa.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimumCost(self, s: str) -> int:",
        "solution": "class Solution:\r\n    def minimumCost(self, s: str) -> int:\r\n        ans = 0\r\n        n = len(s)\r\n        for i in range(n - 1):\r\n            if s[i] != s[i + 1]:\r\n                if i + 1 <= n - i - 1:\r\n                    ans += i + 1\r\n                else:\r\n                    ans += n - i - 1\r\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2713": {
        "problem_id": 2713,
        "description": "Given a 1-indexed m x n integer matrix mat, you can select any cell in the matrix as your starting cell.\nFrom the starting cell, you can move to any other cell in the same row or column, but only if the value of the destination cell is strictly greater than the value of the current cell. You can repeat this process as many times as possible, moving from cell to cell until you can no longer make any moves.\nYour task is to find the maximum number of cells that you can visit in the matrix by starting from some cell.\nReturn an integer denoting the maximum number of cells that can be visited.\n",
        "provided_code_snippet": "class Solution:\r\n    def maxIncreasingCells(self, mat: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def maxIncreasingCells(self, mat: List[List[int]]) -> int:\n        m, n = len(mat), len(mat[0])\n        r, c = [0] * m, [0] * n\n        vmap = {}\n        from sortedcontainers import SortedSet\n        s = SortedSet()\n        for i in range(0, m):\n            for j in range(0, n):\n                if not -mat[i][j] in vmap:\n                    vmap[-mat[i][j]] = []\n                vmap[-mat[i][j]].append([i, j])\n                s.add(-mat[i][j])\n        temp = [[0] * n for _ in range(m)]\n        for x in s:\n            for v in vmap.get(x):\n                temp[v[0]][v[1]] = max(r[v[0]], c[v[1]]) + 1\n            for v in vmap.get(x):\n                r[v[0]] = max(r[v[0]], temp[v[0]][v[1]])\n                c[v[1]] = max(c[v[1]], temp[v[0]][v[1]])\n        return max(max(r), max(c))",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2716": {
        "problem_id": 2716,
        "description": "Given a string s, you have two types of operation:\n\t1. Choose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the left of i (if exists).\n\t2. Choose an index i in the string, and let c be the character in position i. Delete the closest occurrence of c to the right of i (if exists).\nYour task is to minimize the length of s by performing the above operations zero or more times.\nReturn an integer denoting the length of the minimized string.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizedStringLength(self, s: str) -> int:",
        "solution": "class Solution:\n    def minimizedStringLength(self, s: str) -> int:\n        return len(set((s)))",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2717": {
        "problem_id": 2717,
        "description": "You are given a 0-indexed permutation of n integers nums.\nA permutation is called semi-ordered if the first number equals 1 and the last number equals n. You can perform the below operation as many times as you want until you make nums a semi-ordered permutation:\n\t- Pick two adjacent elements in nums, then swap them.\nReturn the minimum number of operations to make nums a semi-ordered permutation.\nA permutation is a sequence of integers from 1 to n of length n containing each number exactly once.\n",
        "provided_code_snippet": "class Solution:\r\n    def semiOrderedPermutation(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def semiOrderedPermutation(self, nums: List[int]) -> int:\n        \n        mn, mx = nums.index(1) , nums.index(n:= len(nums))     \n        return mn - mx + n - 1 - (mn > mx)",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2718": {
        "problem_id": 2718,
        "description": "You are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali].\nInitially, there is a 0-indexed n x n matrix filled with 0's. For each query, you must apply one of the following changes:\n\t- if typei == 0, set the values in the row with indexi to vali, overwriting any previous values.\n\t- if typei == 1, set the values in the column with indexi to vali, overwriting any previous values.\nReturn the sum of integers in the matrix after all queries are applied.\n",
        "provided_code_snippet": "class Solution:\r\n    def matrixSumQueries(self, n: int, queries: List[List[int]]) -> int:",
        "solution": "class Solution:\n    def matrixSumQueries(self, n: int, queries: List[List[int]]) -> int:\n        rowSeenCount, colSeenCount, total = 0, 0, 0\n        rowSeen, colSeen = [False] * n, [False] * n\n        for qi in range(len(queries) - 1, -1, -1):\n            typei, index, val = queries[qi][0], queries[qi][1], queries[qi][2]\n            if typei == 0 and not rowSeen[index]:\n                rowSeenCount += 1\n                rowSeen[index] = True\n                total += (n - colSeenCount) * val\n            if typei == 1 and not colSeen[index]:\n                colSeenCount += 1\n                colSeen[index] = True\n                total += (n - rowSeenCount) * val\n        return total",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2719": {
        "problem_id": 2719,
        "description": "You are given two numeric strings num1 and num2 and two integers max_sum and min_sum. We denote an integer x to be good if:\n\t- num1 <= x <= num2\n\t- min_sum <= digit_sum(x) <= max_sum.\nReturn the number of good integers. Since the answer may be large, return it modulo 109 + 7.\nNote that digit_sum(x) denotes the sum of the digits of x.\n",
        "provided_code_snippet": "class Solution:\r\n    def count(self, num1: str, num2: str, min_sum: int, max_sum: int) -> int:",
        "solution": "class Solution:\n    M = 1000000007\n\n\n    def add(self, x, y) -> int:\n        x += y\n        if x >= self.M:\n            x -= self.M\n        return x\n\n\n    def sub(self, x, y) -> int:\n        x -= y\n        if x < 0:\n            x += self.M\n        return x\n\n\n    def count_strings(self, s, min_sum, max_sum) -> int:\n        n = len(s)\n        m = min(max_sum, 9 * n)\n        dp = [[[0 for _ in range(m + 1)] for _ in range(2)] for _ in range(2)]\n        dp[0][0][0] = 1\n        last = 0\n        for i in range(n):\n            p = i * 9\n            now = last ^ 1\n            dp[now] = [[0 for _ in range(m + 1)] for _ in range(2)]\n            for j in range(2):\n                for k in range(min(m, p) + 1):\n                    if dp[last][j][k] == 0:\n                        continue\n                    for c in range(ord('9') if j else ord(s[i]), ord('0') - 1, -1):\n                        q = k + c - ord('0')\n                        if q <= m:\n                            dp[now][j or (c < ord(s[i]))][q] = self.add(\n                                dp[now][j or (c < ord(s[i]))][q], dp[last][j][k]\n                            )\n            last ^= 1\n        r = 0\n        for i in range(2):\n            for j in range(min_sum, m + 1):\n                r = self.add(r, dp[last][i][j])\n        return r\n\n\n    def count(self, num1, num2, min_sum, max_sum) -> int:\n        s = sum(int(c) for c in num1)\n        r = self.count_strings(num2, min_sum, max_sum)\n        r = self.sub(r, self.count_strings(num1, min_sum, max_sum))\n        if min_sum <= s <= max_sum:\n            r = self.add(r, 1)\n        return r",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2729": {
        "problem_id": 2729,
        "description": "You are given an integer n that consists of exactly 3 digits.\nWe call the number n fascinating if, after the following modification, the resulting number contains all the digits from 1 to 9 exactly once and does not contain any 0's:\n\t- Concatenate n with the numbers 2 * n and 3 * n.\nReturn true if n is fascinating, or false otherwise.\nConcatenating two numbers means joining them together. For example, the concatenation of 121 and 371 is 121371.\n",
        "provided_code_snippet": "class Solution:\r\n    def isFascinating(self, n: int) -> bool:",
        "solution": "class Solution:\n    def isFascinating(self, n: int) -> bool:\n        def pan(num):\n            if sorted(list(num))==[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]:\n                return(True)\n            else:\n                return False\n        n=str(n)+str(n*2)+str(n*3)\n        return pan(n)",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2730": {
        "problem_id": 2730,
        "description": "You are given a 0-indexed string s that consists of digits from 0 to 9.\nA string t is called a semi-repetitive if there is at most one consecutive pair of the same digits inside t. For example, 0010, 002020, 0123, 2002, and 54944 are semi-repetitive while 00101022, and 1101234883 are not.\nReturn the length of the longest semi-repetitive substring inside s.\nA substring is a contiguous non-empty sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestSemiRepetitiveSubstring(self, s: str) -> int:",
        "solution": "class Solution:\n    def longestSemiRepetitiveSubstring(self, s: str) -> int:\n        res=0\n        tab=[1]\n        for i in range(1,len(s)):\n            if ( s[i]==s[i-1]):\n                tab.append(1)\n            else:\n                tab[-1]=tab[-1]+1\n        for j in range(1,len(tab)):\n            res=max(res,tab[j]+tab[j-1])\n        \n        return max(res,tab[0])",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2731": {
        "problem_id": 2731,
        "description": "Some robots are standing on an infinite number line with their initial coordinates given by a 0-indexed integer array nums and will start moving once given the command to move. The robots will move a unit distance each second.\nYou are given a string s denoting the direction in which robots will move on command. 'L' means the robot will move towards the left side or negative side of the number line, whereas 'R' means the robot will move towards the right side or positive side of the number line.\nIf two robots collide, they will start moving in opposite directions.\nReturn the sum of distances between all the pairs of robots d seconds after the command. Since the sum can be very large, return it modulo 109 + 7.\nNote: \n\t- For two robots at the index i and j, pair (i,j) and pair (j,i) are considered the same pair.\n\t- When robots collide, they instantly change their directions without wasting any time.\n\t- Collision happens when two robots share the same place in a moment.\t\t\t- For example, if a robot is positioned in 0 going to the right and another is positioned in 2 going to the left, the next second they'll be both in 1 and they will change direction and the next second the first one will be in 0, heading left, and another will be in 2, heading right.\n\t\t- For example, if a robot is positioned in 0 going to the right and another is positioned in 1 going to the left, the next second the first one will be in 0, heading left, and another will be in 1, heading right.\n\t\t\n",
        "provided_code_snippet": "class Solution:\r\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:",
        "solution": "class Solution:\n    def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n        n, m = len(nums), int(1e9 + 7)\n        # Ignore the Collisions\n        for i in range(n):\n            if s[i] == 'L':\n                nums[i] -= d\n            else: \n                nums[i] += d\n        \n        # Sort according to position to calculate abs sum of each pair in O(N)\n        nums.sort()\n\n        pre = nums.copy()\n        # Calculate Prefix Sum\n        for i in range(1, n):\n            pre[i] += pre[i - 1]\n            pre[i] %= m\n\n        ans = 0\n        for i in range(1, n):\n            # each jth index contributes to j * nums[j] - pre[j - 1]\n            ans += i * nums[i] - pre[i - 1]\n            ans %= m\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2732": {
        "problem_id": 2732,
        "description": "You are given a 0-indexed m x n binary matrix grid.\nLet us call a non-empty subset of rows good if the sum of each column of the subset is at most half of the length of the subset.\nMore formally, if the length of the chosen subset of rows is k, then the sum of each column should be at most floor(k / 2).\nReturn an integer array that contains row indices of a good subset sorted in ascending order.\nIf there are multiple good subsets, you can return any of them. If there are no good subsets, return an empty array.\nA subset of rows of the matrix grid is any matrix that can be obtained by deleting some (possibly none or all) rows from grid.\n",
        "provided_code_snippet": "class Solution:\r\n    def goodSubsetofBinaryMatrix(self, grid: List[List[int]]) -> List[int]:",
        "solution": "def goodSubsetofBinaryMatrix(self, grid: List[List[int]]) -> List[int]:\n        if len(grid) == 1:\n            return [0] if all(num == 0 for num in grid[0]) else []\n        d = {}\n        for r, row in enumerate(grid):\n            num = sum(cell << c for c, cell in enumerate(row))\n            for i in range(32):\n                if (i & num) == 0 and i in d:\n                    return [d[i], r]\n            d.setdefault(num, r)    \n        return []",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2733": {
        "problem_id": 2733,
        "description": "Given an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1 if there is no such number.\nReturn the selected integer.\n",
        "provided_code_snippet": "class Solution:\r\n    def findNonMinOrMax(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findNonMinOrMax(self, nums: List[int]) -> int:\n        minVal, maxVal = min(nums), max(nums)\n        for n in nums:\n            if n != minVal and n != maxVal:\n                return n\n        return -1",
        "submission_passed": true,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2734": {
        "problem_id": 2734,
        "description": "Given a string s consisting of lowercase English letters. Perform the following operation:\n\t- Select any non-empty substring then replace every letter of the substring with the preceding letter of the English alphabet. For example, 'b' is converted to 'a', and 'a' is converted to 'z'.\nReturn the lexicographically smallest string after performing the operation.\n",
        "provided_code_snippet": "class Solution:\r\n    def smallestString(self, s: str) -> str:",
        "solution": "class Solution:\n    def smallestString(self, s: str) -> str:\n\n        arr = s.split('a')\n\n        for i, ss in enumerate(arr):\n            if ss:\n                arr[i] = ''.join([chr(ord(ch)-1) for ch in ss])\n                break\n\n        else: return s[:-1] + 'z'\n        \n        return 'a'.join(arr)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2735": {
        "problem_id": 2735,
        "description": "You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates. The cost of collecting the chocolate at the index i is nums[i]. Each chocolate is of a different type, and initially, the chocolate at the index i is of ith type.\nIn one operation, you can do the following with an incurred cost of x:\n\t- Simultaneously change the chocolate of ith type to ((i + 1) mod n)th type for all chocolates.\nReturn the minimum cost to collect chocolates of all types, given that you can perform as many operations as you would like.\n",
        "provided_code_snippet": "class Solution:\r\n    def minCost(self, nums: List[int], x: int) -> int:",
        "solution": "class Solution:\n    def minCost(self, A: List[int], X: int) -> int:\n        ans = sum(A)\n        for rotations in range(1, len(A)):\n            A = [min(A[i], A[i-1]) for i in range(len(A))]\n            ans = min(ans, rotations * X + sum(A))\n        return ans",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2736": {
        "problem_id": 2736,
        "description": "You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi].\nFor the ith query, find the maximum value of nums1[j] + nums2[j] among all indices j (0 <= j < n), where nums1[j] >= xi and nums2[j] >= yi, or -1 if there is no j satisfying the constraints.\nReturn an array answer where answer[i] is the answer to the ith query.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumSumQueries(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:",
        "solution": "class Solution:\n    def query(self, tree: List[int], ind: int, left: int, right: int, x: int, y: int) -> int:\n        if left >= x and right <= y:\n            return tree[ind]\n        mid = (left + right) >> 1\n        r = -1\n        if x <= mid:\n            r = self.query(tree, ind << 1, left, mid, x, y)\n        if y > mid:\n            r = max(r, self.query(tree, (ind << 1) | 1, mid + 1, right, x, y))\n        return r\n\n    def update(self, tree: List[int], ind: int, left: int, right: int, x: int, y: int) -> None:\n        tree[ind] = max(tree[ind], y)\n        if left >= x and right <= x:\n            return\n        mid = (left + right) >> 1\n        if x <= mid:\n            self.update(tree, ind << 1, left, mid, x, y)\n        else:\n            self.update(tree, (ind << 1) | 1, mid + 1, right, x, y)\n\n    def maximumSumQueries(self, nums1: List[int], nums2: List[int], queries: List[List[int]]) -> List[int]:\n        n = len(nums1)\n        all_nums = defaultdict(int)\n        v = [(nums1[i], nums2[i]) for i in range(n)]\n        for num in nums2:\n            all_nums[num] += 1\n        v.sort()\n        m = len(queries)\n        ind = [i for i in range(m)]\n        for query in queries:\n            all_nums[query[1]] += 1\n        ind.sort(key=lambda x: queries[x][0], reverse=True)\n        mv = 0\n        for key in sorted(all_nums.keys()):\n            mv += 1\n            all_nums[key] = mv\n        tree = [-1] * (mv << 2)\n        r = [0] * m\n        j = n - 1\n        for i in ind:\n            while j >= 0 and v[j][0] >= queries[i][0]:\n                self.update(tree, 1, 1, mv, all_nums[v[j][1]], v[j][0] + v[j][1])\n                j -= 1\n            r[i] = self.query(tree, 1, 1, mv, all_nums[queries[i][1]], mv)\n        return r",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2739": {
        "problem_id": 2739,
        "description": "A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank representing the fuel present in the additional tank in liters.\nThe truck has a mileage of 10 km per liter. Whenever 5 liters of fuel get used up in the main tank, if the additional tank has at least 1 liters of fuel, 1 liters of fuel will be transferred from the additional tank to the main tank.\nReturn the maximum distance which can be traveled.\nNote: Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed.\n",
        "provided_code_snippet": "class Solution:\r\n    def distanceTraveled(self, mainTank: int, additionalTank: int) -> int:",
        "solution": "class Solution:\n    def distanceTraveled(self, mainTank: int, additionalTank: int) -> int:\n        \n        return 10*(mainTank + min((mainTank-1)//4,additionalTank))",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2740": {
        "problem_id": 2740,
        "description": "You are given a positive integer array nums.\nPartition nums into two arrays, nums1 and nums2, such that:\n\t- Each element of the array nums belongs to either the array nums1 or the array nums2.\n\t- Both arrays are non-empty.\n\t- The value of the partition is minimized.\nThe value of the partition is |max(nums1) - min(nums2)|.\nHere, max(nums1) denotes the maximum element of the array nums1, and min(nums2) denotes the minimum element of the array nums2.\nReturn the integer denoting the value of such partition.\n",
        "provided_code_snippet": "class Solution:\r\n    def findValueOfPartition(self, nums: List[int]) -> int:",
        "solution": "class Solution:\n    def findValueOfPartition(self, nums: List[int]) -> int:\n        \n        nums.sort()\n\n        return min(nums[i] - nums[i-1] for i in range(1,len(nums)))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2741": {
        "problem_id": 2741,
        "description": "You are given a 0-indexed integer array nums containing n distinct positive integers. A permutation of nums is called special if:\n\t- For all indexes 0 <= i < n - 1, either nums[i] % nums[i+1] == 0 or nums[i+1] % nums[i] == 0.\nReturn the total number of special permutations. As the answer could be large, return it modulo 109 + 7.\n",
        "provided_code_snippet": "class Solution:\r\n    def specialPerm(self, nums: List[int]) -> int:",
        "solution": "def specialPerm(self, nums: List[int]) -> int:\n    n, MOD = len(nums), 10**9 + 7\n    @cache\n    def dfs(prev, mask):\n        if mask == (1 << n) - 1: return 1\n        count = 0\n        for i in range(n):\n            if not (mask & (1 << i)) and (nums[i] % prev == 0 or prev % nums[i] == 0):\n                count += dfs(nums[i], mask | (1 << i))\n        return count % MOD\n    return dfs(1, 0)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2742": {
        "problem_id": 2742,
        "description": "You are given two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively. There are two painters available:\n\t- A paid painter that paints the ith wall in time[i] units of time and takes cost[i] units of money.\n\t- A free painter that paints any wall in 1 unit of time at a cost of 0. But the free painter can only be used if the paid painter is already occupied.\nReturn the minimum amount of money required to paint the n walls.\n",
        "provided_code_snippet": "class Solution:\r\n    def paintWalls(self, cost: List[int], time: List[int]) -> int:",
        "solution": "class Solution:\n    def paintWalls(self, cost: List[int], time: List[int]) -> int:\n        postfix_times = time.copy()\n\n        for i in range(len(postfix_times) - 2, -1, -1):\n            postfix_times[i] += postfix_times[i +1]\n\n        visited = {}\n\n        def dp(index, time_painted):\n            if index == len(cost):\n                return 0 if time_painted >= 0 else float(\"inf\")\n\n            if time_painted >= len(cost) - index:\n                return 0\n\n            if time_painted + postfix_times[index] < 0:\n                return float(\"inf\")\n\n            if (index, time_painted) in visited:\n                return visited[(index, time_painted)]\n            \n            visited[(index, time_painted)] = min(\n                dp(index + 1, time_painted - 1),\n                cost[index] + dp(index + 1,\n                time_painted + time[index]))\n            return visited[(index, time_painted)]\n        \n        return dp(0, 0)",
        "submission_passed": false,
        "difficulty": "Hard",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2744": {
        "problem_id": 2744,
        "description": "You are given a 0-indexed array words consisting of distinct strings.\nThe string words[i] can be paired with the string words[j] if:\n\t- The string words[i] is equal to the reversed string of words[j].\n\t- 0 <= i < j < words.length.\nReturn the maximum number of pairs that can be formed from the array words.\nNote that each string can belong in at most one pair.\n",
        "provided_code_snippet": "class Solution:\r\n    def maximumNumberOfStringPairs(self, words: List[str]) -> int:",
        "solution": "class Solution:\n    def maximumNumberOfStringPairs(self, words: List[str]) -> int:\n        strings = set()\n        ans = 0\n        for w in words:\n            if w in strings:\n                ans += 1\n            else:\n                strings.add(w[::-1])\n        return ans",
        "submission_passed": false,
        "difficulty": "Easy",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2745": {
        "problem_id": 2745,
        "description": "You are given three integers x, y, and z.\nYou have x strings equal to \"AA\", y strings equal to \"BB\", and z strings equal to \"AB\". You want to choose some (possibly all or none) of these strings and concactenate them in some order to form a new string. This new string must not contain \"AAA\" or \"BBB\" as a substring.\nReturn the maximum possible length of the new string.\nA substring is a contiguous non-empty sequence of characters within a string.\n",
        "provided_code_snippet": "class Solution:\r\n    def longestString(self, x: int, y: int, z: int) -> int:",
        "solution": "class Solution:\n    def longestString(self, x: int, y: int, z: int) -> int:\n        return 2 * (2 * min(x, y) + z + (1 if x != y else 0))",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2746": {
        "problem_id": 2746,
        "description": "You are given a 0-indexed array words containing n strings.\nLet's define a join operation join(x, y) between two strings x and y as concatenating them into xy. However, if the last character of x is equal to the first character of y, one of them is deleted.\nFor example join(\"ab\", \"ba\") = \"aba\" and join(\"ab\", \"cde\") = \"abcde\".\nYou are to perform n - 1 join operations. Let str0 = words[0]. Starting from i = 1 up to i = n - 1, for the ith operation, you can do one of the following:\n\t- Make stri = join(stri - 1, words[i])\n\t- Make stri = join(words[i], stri - 1)\nYour task is to minimize the length of strn - 1.\nReturn an integer denoting the minimum possible length of strn - 1.\n",
        "provided_code_snippet": "class Solution:\r\n    def minimizeConcatenatedLength(self, words: List[str]) -> int:",
        "solution": "class Solution:\n    def minimizeConcatenatedLength(self, words: List[str]) -> int:\n        \n        @lru_cache(None)\n        def dp(aLft,aRgt,idx):\n\n            if idx == len(words): return 0\n\n            wLft, wRgt = words[idx][0], words[idx][-1]\n            \n            return max((wRgt==aLft) + dp(wLft,aRgt,idx+1), \n                       (aRgt==wLft) + dp(aLft,wRgt,idx+1))\n        \n        return sum(map(len, words)) - dp(words[0][0],words[0][-1],1)",
        "submission_passed": false,
        "difficulty": "Medium",
        "problem_tags": [],
        "solution_tags": [],
        "categories": []
    },
    "2747": {
        "problem_id": 2747,
        "description": "You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the server with id server_id received a request at time time.\nYou are also given an integer x and a 0-indexed integer array queries.\nReturn a 0-indexed integer array arr of length queries.length where arr[i] represents the number of servers that did not receive any requests during the time interval [queries[i] - x, queries[i]].\nNote that the time intervals are inclusive.\n",
        "provided_code_snippet": "class Solution:\r\n    def countServers(self, n: int, logs: List[List[int]], x: int, queries: List[int]) -> List[int]:",
        "solution": "class Solution:\n    def countServers(self, n: int, logs: List[List[int]], x: int, queries: List[int]) -> List[int]:\n        dico={i:0 for i in range (1,n+1)}\n        logs=sorted(logs,key=lambda x:x[1])\n        queries=sorted([query,i] for i,query in enumerate(queries))\n        p=len(logs)\n        right,left=0,-1\n        countNull=n\n        res=[0]*len(queries)\n        for query,i in queries:\n            while right 

int:", "solution": "class Solution:\n def countBeautifulPairs(self, nums: List[int]) -> int:\n\n ans = 0\n\n frst = list(map(lambda x: int(str(x)[0]), nums))\n last = list(map(lambda x: x %10, nums))\n\n for i,n1 in enumerate(frst):\n for n2 in last[i+1:]: ans+= gcd(n1, n2) == 1\n\n return ans", "submission_passed": true, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2749": { "problem_id": 2749, "description": "You are given two integers num1 and num2.\nIn one operation, you can choose integer i in the range [0, 60] and subtract 2i + num2 from num1.\nReturn the integer denoting the minimum number of operations needed to make num1 equal to 0.\nIf it is impossible to make num1 equal to 0, return -1.\n", "provided_code_snippet": "class Solution:\r\n def makeTheIntegerZero(self, num1: int, num2: int) -> int:", "solution": "class Solution:\n def makeTheIntegerZero(self, num1: int, num2: int) -> int:\n for k in range(61):\n target = num1 - k * num2\n if target >= 0 and target.bit_count() <= k <= target:\n return k\n return -1", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2750": { "problem_id": 2750, "description": "You are given a binary array nums.\nA subarray of an array is good if it contains exactly one element with the value 1.\nReturn an integer denoting the number of ways to split the array nums into good subarrays. As the number may be too large, return it modulo 109 + 7.\nA subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:", "solution": "def numberOfGoodSubarraySplits(self, nums: List[int]) -> int:\n cnt = 0\n lo = -1\n for hi, b in enumerate(nums):\n if b == 1:\n if cnt == 0:\n cnt = 1\n else:\n cnt *= hi - lo\n cnt %= 10 ** 9 + 7\n lo = hi\n return cnt", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2751": { "problem_id": 2751, "description": "There are n 1-indexed robots, each having a position on a line, health, and movement direction.\nYou are given 0-indexed integer arrays positions, healths, and a string directions (directions[i] is either 'L' for left or 'R' for right). All integers in positions are unique.\nAll robots start moving on the line simultaneously at the same speed in their given directions. If two robots ever share the same position while moving, they will collide.\nIf two robots collide, the robot with lower health is removed from the line, and the health of the other robot decreases by one. The surviving robot continues in the same direction it was going. If both robots have the same health, they are both removed from the line.\nYour task is to determine the health of the robots that survive the collisions, in the same order that the robots were given, i.e. final heath of robot 1 (if survived), final health of robot 2 (if survived), and so on. If there are no survivors, return an empty array.\nReturn an array containing the health of the remaining robots (in the order they were given in the input), after no further collisions can occur.\nNote: The positions may be unsorted.\n", "provided_code_snippet": "class Solution:\r\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:", "solution": "class Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n n = len(positions)\n robots = [[positions[ind], healths[ind], directions[ind], ind] for ind in range(n)]\n robots.sort()\n stack = []\n\n for robot in robots:\n if robot[2] == \"R\" or not stack or stack[-1][2] == \"L\":\n stack.append(robot)\n continue\n\n if robot[2] == \"L\":\n add = True\n while stack and stack[-1][2] == \"R\" and add:\n last_health = stack[-1][1]\n if robot[1] > last_health:\n stack.pop()\n robot[1] -= 1\n elif robot[1] < last_health:\n stack[-1][1] -= 1\n add = False\n else:\n stack.pop()\n add = False\n\n if add:\n stack.append(robot)\n\n return [robot[1] for robot in sorted(stack, key=lambda robot: robot[3])]", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2760": { "problem_id": 2760, "description": "You are given a 0-indexed integer array nums and an integer threshold.\nFind the length of the longest subarray of nums starting at index l and ending at index r (0 <= l <= r < nums.length) that satisfies the following conditions:\n\t- nums[l] % 2 == 0\n\t- For all indices i in the range [l, r - 1], nums[i] % 2 != nums[i + 1] % 2\n\t- For all indices i in the range [l, r], nums[i] <= threshold\nReturn an integer denoting the length of the longest such subarray.\nNote: A subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def longestAlternatingSubarray(self, nums: List[int], threshold: int) -> int:", "solution": "class Solution:\n def longestAlternatingSubarray(self, v, k):\n ans = 0\n for i in range(len(v)):\n ct = 0\n if (v[i] % 2 == 0) and (v[i] <= k):\n ct = 1\n for j in range(i + 1, len(v)):\n if (v[j] % 2 == v[j - 1] % 2) or v[j] > k:\n break\n ct += 1\n ans = max(ans, ct)\n return ans", "submission_passed": false, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2761": { "problem_id": 2761, "description": "You are given an integer n. We say that two integers x and y form a prime number pair if:\n\t- 1 <= x <= y <= n\n\t- x + y == n\n\t- x and y are prime numbers\nReturn the 2D sorted list of prime number pairs [xi, yi]. The list should be sorted in increasing order of xi. If there are no prime number pairs at all, return an empty array.\nNote: A prime number is a natural number greater than 1 with only two factors, itself and 1.\n", "provided_code_snippet": "class Solution:\r\n def findPrimePairs(self, n: int) -> List[List[int]]:", "solution": "primes = [False,False] + [True] * 999_999 #\n #\nfor i in range(2, 1001): # <-- sieve construction\n if primes[i]: # \n for j in range(i + i, 1000_000, i): #\n primes[j] = False #\n\nclass Solution:\n def findPrimePairs(self, n: int) -> List[List[int]]:\n\n if n < 4: return [] # \n # <-- edge cases\n if n%2 or n == 4: #\n return [[2,n-2]] if primes[n-2] else [] #\n\n return [[i, n - i] for i in range(3,(n+3)//2) # <-- find pairs\n if primes[i] and primes[n - i]] #", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2762": { "problem_id": 2762, "description": "You are given a 0-indexed integer array nums. A subarray of nums is called continuous if:\n\t- Let i, i + 1, ..., j be the indices in the subarray. Then, for each pair of indices i <= i1, i2 <= j, 0 <= |nums[i1] - nums[i2]| <= 2.\nReturn the total number of continuous subarrays.\nA subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def continuousSubarrays(self, nums: List[int]) -> int:", "solution": "class Solution:\n def continuousSubarrays(self, nums: List[int]) -> int:\n i = res = 0\n d = dict()\n for j, num in enumerate(nums):\n t = d.copy()\n for k, v in t.items():\n if abs(k - num) > 2:\n i = max(i, v + 1)\n d.pop(k)\n d[num] = j\n res += j - i + 1\n return res", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2763": { "problem_id": 2763, "description": "The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that:\n\t- 0 <= i < n - 1, and\n\t- sarr[i+1] - sarr[i] > 1\nHere, sorted(arr) is the function that returns the sorted version of arr.\nGiven a 0-indexed integer array nums, return the sum of imbalance numbers of all its subarrays.\nA subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def sumImbalanceNumbers(self, nums: List[int]) -> int:", "solution": "def sumImbalanceNumbers(self, nums):\n n = len(nums)\n ans = 0\n for i in range(n):\n s = set()\n curr = 0\n for x in nums[i:]:\n if x in s: \n pass\n elif (x - 1 in s) and (x + 1 in s):\n curr -= 1\n elif (x - 1 not in s) and (x + 1 not in s) and s:\n curr += 1\n s.add(x)\n ans += curr\n return ans", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2765": { "problem_id": 2765, "description": "You are given a 0-indexed integer array nums. A subarray s of length m is called alternating if:\n\t- m is greater than 1.\n\t- s1 = s0 + 1.\n\t- The 0-indexed subarray s looks like [s0, s1, s0, s1,...,s(m-1) % 2]. In other words, s1 - s0 = 1, s2 - s1 = -1, s3 - s2 = 1, s4 - s3 = -1, and so on up to s[m - 1] - s[m - 2] = (-1)m.\nReturn the maximum length of all alternating subarrays present in nums or -1 if no such subarray exists.\nA subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def alternatingSubarray(self, nums: List[int]) -> int:", "solution": "class Solution(object):\n def alternatingSubarray(self, nums):\n res=-1\n for i in range(len(nums)): \n for j in range(i+1,len(nums)):\n if nums[j-1]!=nums[j]+(-1)**(j-i):\n break\n res=max(res, j-i+1)\n return res", "submission_passed": false, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2766": { "problem_id": 2766, "description": "You are given a 0-indexed integer array nums representing the initial positions of some marbles. You are also given two 0-indexed integer arrays moveFrom and moveTo of equal length.\nThroughout moveFrom.length steps, you will change the positions of the marbles. On the ith step, you will move all marbles at position moveFrom[i] to position moveTo[i].\nAfter completing all the steps, return the sorted list of occupied positions.\nNotes:\n\t- We call a position occupied if there is at least one marble in that position.\n\t- There may be multiple marbles in a single position.\n", "provided_code_snippet": "class Solution:\r\n def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:", "solution": "class Solution:\n def relocateMarbles(self, nums: List[int], moveFrom: List[int], moveTo: List[int]) -> List[int]:\n s = set(nums)\n for f, t in zip(moveFrom, moveTo):\n s.remove(f)\n s.add(t)\n return sorted(s)", "submission_passed": true, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2767": { "problem_id": 2767, "description": "Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.\nA string is beautiful if:\n\t- It doesn't contain leading zeros.\n\t- It's the binary representation of a number that is a power of 5.\nReturn the minimum number of substrings in such partition. If it is impossible to partition the string s into beautiful substrings, return -1.\nA substring is a contiguous sequence of characters in a string.\n", "provided_code_snippet": "class Solution:\r\n def minimumBeautifulSubstrings(self, s: str) -> int:", "solution": "class Solution:\n def minimumBeautifulSubstrings(self, s: str) -> int:\n \n def isBeautiful(string):\n if string[0] == \"0\":\n return False\n num = int(string, 2)\n while num % 5 == 0:\n num /= 5\n return num == 1\n\n def dfs(string):\n if string in cache:\n return cache[string]\n if isBeautiful(string):\n return 1\n minCount = float('inf')\n for i in range(1, len(string)):\n minCount = min(minCount, dfs(string[:i]) + dfs(string[i:]))\n cache[string] = minCount\n return minCount\n\n cache = {}\n res = dfs(s)\n return res if res != float('inf') else -1", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2768": { "problem_id": 2768, "description": "You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.\nYou are also given a 0-indexed 2D integer matrix coordinates, where coordinates[i] = [x, y] indicates that the cell with coordinates [x, y] is colored black. All cells in the grid that do not appear in coordinates are white.\nA block is defined as a 2 x 2 submatrix of the grid. More formally, a block with cell [x, y] as its top-left corner where 0 <= x < m - 1 and 0 <= y < n - 1 contains the coordinates [x, y], [x + 1, y], [x, y + 1], and [x + 1, y + 1].\nReturn a 0-indexed integer array arr of size 5 such that arr[i] is the number of blocks that contains exactly i black cells.\n", "provided_code_snippet": "class Solution:\r\n def countBlackBlocks(self, m: int, n: int, coordinates: List[List[int]]) -> List[int]:", "solution": "class Solution:\n def countBlackBlocks(self, m: int, n: int, coordinates: List[List[int]]) -> List[int]:\n counts=defaultdict(int)\n for x,y in coordinates:\n for i in range(max(0,x-1),min(m-1,x+1)):\n for j in range(max(0,y-1),min(n-1,y+1)):\n counts[(i,j)]+=1\n\n\n ans=[0]*5 \n for count in counts.values():\n ans[count]+=1\n\n ans[0]=(m-1)*(n-1)-sum(ans)\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2769": { "problem_id": 2769, "description": "Given two integers, num and t. A number is achievable if it can become equal to num after applying the following operation:\n\t- Increase or decrease the number by 1, and simultaneously increase or decrease num by 1.\nReturn the maximum achievable number after applying the operation at most t times.\n", "provided_code_snippet": "class Solution:\r\n def theMaximumAchievableX(self, num: int, t: int) -> int:", "solution": "class Solution:\n def theMaximumAchievableX(self, num: int, t: int) -> int:\n return num + t * 2", "submission_passed": false, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2770": { "problem_id": 2770, "description": "You are given a 0-indexed array nums of n integers and an integer target.\nYou are initially positioned at index 0. In one step, you can jump from index i to any index j such that:\n\t- 0 <= i < j < n\n\t- -target <= nums[j] - nums[i] <= target\nReturn the maximum number of jumps you can make to reach index n - 1.\nIf there is no way to reach index n - 1, return -1.\n", "provided_code_snippet": "class Solution:\r\n def maximumJumps(self, nums: List[int], target: int) -> int:", "solution": "class Solution:\n def maximumJumps(self, nums: List[int], target: int) -> int:\n dp = [-1] * len(nums)\n dp[0] = 0\n\n for i in range(1, len(nums)):\n for j in range(i - 1, -1, -1):\n if -target <= nums[i] - nums[j] and nums[i] - nums[j] <= target:\n if dp[j] > -1:\n dp[i] = max(dp[i], dp[j] + 1)\n\n return dp[-1]", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2771": { "problem_id": 2771, "description": "You are given two 0-indexed integer arrays nums1 and nums2 of length n.\nLet's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i].\nYour task is to maximize the length of the longest non-decreasing subarray in nums3 by choosing its values optimally.\nReturn an integer representing the length of the longest non-decreasing subarray in nums3.\nNote: A subarray is a contiguous non-empty sequence of elements within an array.\n", "provided_code_snippet": "class Solution:\r\n def maxNonDecreasingLength(self, nums1: List[int], nums2: List[int]) -> int:", "solution": "class Solution:\n def maxNonDecreasingLength(self, nums1, nums2):\n @cache\n def dp(i, prev):\n if i == len(nums1):\n return 0\n\n res = 0\n if not prev:\n res = dp(i + 1, prev)\n\n if prev <= nums1[i]:\n res = max(res, 1 + dp(i + 1, nums1[i]))\n if prev <= nums2[i]:\n res = max(res, 1 + dp(i + 1, nums2[i]))\n\n return res\n\n return dp(0, 0)", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2772": { "problem_id": 2772, "description": "You are given a 0-indexed integer array nums and a positive integer k.\nYou can apply the following operation on the array any number of times:\n\t- Choose any subarray of size k from the array and decrease all its elements by 1.\nReturn true if you can make all the array elements equal to 0, or false otherwise.\nA subarray is a contiguous non-empty part of an array.\n", "provided_code_snippet": "class Solution:\r\n def checkArray(self, nums: List[int], k: int) -> bool:", "solution": "class Solution:\n def checkArray(self, nums: List[int], k: int) -> bool:\n n = len(nums)\n pref = [0]*(n+1)\n ac = 0\n for i in range(0,n):\n ac-=pref[i]\n nums[i]-=ac\n\n if nums[i]<0:\n return False\n if i+k<=n:\n ac+=nums[i]\n pref[i+k]+=nums[i]\n nums[i] = 0\n elif nums[i]>0:\n return False\n\n return True", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2778": { "problem_id": 2778, "description": "You are given a 1-indexed integer array nums of length n.\nAn element nums[i] of nums is called special if i divides n, i.e. n % i == 0.\nReturn the sum of the squares of all special elements of nums.\n", "provided_code_snippet": "class Solution:\r\n def sumOfSquares(self, nums: List[int]) -> int:", "solution": "class Solution:\n def sumOfSquares(self, nums: List[int]) -> int:\n #count of the sum of squares\n count=0\n #length of nums\n n=len(nums) \n for i in range(0,n) :\n if n%(i+1)==0:\n count+=nums[i]**2\n return count", "submission_passed": true, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2779": { "problem_id": 2779, "description": "You are given a 0-indexed array nums and a non-negative integer k.\nIn one operation, you can do the following:\n\t- Choose an index i that hasn't been chosen before from the range [0, nums.length - 1].\n\t- Replace nums[i] with any integer from the range [nums[i] - k, nums[i] + k].\nThe beauty of the array is the length of the longest subsequence consisting of equal elements.\nReturn the maximum possible beauty of the array nums after applying the operation any number of times.\nNote that you can apply the operation to each index only once.\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the order of the remaining elements.\n", "provided_code_snippet": "class Solution:\r\n def maximumBeauty(self, nums: List[int], k: int) -> int:", "solution": "class Solution:\n def maximumBeauty(self, nums: List[int], k: int) -> int:\n cnt = [0] * (max(nums) + 2)\n for v in nums:\n cnt[max(0, v - k)] += 1\n cnt[min(len(cnt) - 1, v + k + 1)] -= 1\n \n res, curr = 0, 0\n for v in cnt:\n curr += v\n res = max(res, curr)\n return res", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2780": { "problem_id": 2780, "description": "An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definition implies that arr can have at most one dominant element.\nYou are given a 0-indexed integer array nums of length n with one dominant element.\nYou can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:\n\t- 0 <= i < n - 1\n\t- nums[0, ..., i], and nums[i + 1, ..., n - 1] have the same dominant element.\nHere, nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j, both ends being inclusive. Particularly, if j < i then nums[i, ..., j] denotes an empty subarray.\nReturn the minimum index of a valid split. If no valid split exists, return -1.\n", "provided_code_snippet": "class Solution:\r\n def minimumIndex(self, nums: List[int]) -> int:", "solution": "class Solution:\n def minimumIndex(self, nums: List[int]) -> int:\n\n dom, cnt = max(Counter(nums).items(), key = lambda x: x[1])\n left, cut = 0, 2*cnt - len(nums)\n\n if cut < 2: return -1\n\n for i, num in enumerate(nums):\n\n left+= 2*(num == dom)\n if 1 < left - i <= cut: return i", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2781": { "problem_id": 2781, "description": "You are given a string word and an array of strings forbidden.\nA string is called valid if none of its substrings are present in forbidden.\nReturn the length of the longest valid substring of the string word.\nA substring is a contiguous sequence of characters in a string, possibly empty.\n", "provided_code_snippet": "class Solution:\r\n def longestValidSubstring(self, word: str, forbidden: List[str]) -> int:", "solution": "class Solution:\n def longestValidSubstring(self, word: str, forbidden: List[str]) -> int:\n forbidden_set = set(forbidden)\n res = 0\n right = len(word) - 1\n for left in range(len(word) - 1, -1, -1):\n for k in range(left, min(left + 10, right + 1)):\n if word[left:k+1] in forbidden_set:\n right = k - 1\n break\n res = max(res, right - left + 1)\n return res", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2784": { "problem_id": 2784, "description": "You are given an integer array nums. We consider an array good if it is a permutation of an array base[n].\nbase[n] = [1, 2, ..., n - 1, n, n] (in other words, it is an array of length n + 1 which contains 1 to n - 1 exactly once, plus two occurrences of n). For example, base[1] = [1, 1] and base[3] = [1, 2, 3, 3].\nReturn true if the given array is good, otherwise return false.\nNote: A permutation of integers represents an arrangement of these numbers.\n", "provided_code_snippet": "class Solution:\r\n def isGood(self, nums: List[int]) -> bool:", "solution": "class Solution:\n def isGood(self, nums: List[int]) -> bool:\n \n n = len(nums)\n\n return sorted(nums) == list(range(1,n))+[n-1]", "submission_passed": false, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2785": { "problem_id": 2785, "description": "Given a 0-indexed string s, permute s to get a new string t such that:\n\t- All consonants remain in their original places. More formally, if there is an index i with 0 <= i < s.length such that s[i] is a consonant, then t[i] = s[i].\n\t- The vowels must be sorted in the nondecreasing order of their ASCII values. More formally, for pairs of indices i, j with 0 <= i < j < s.length such that s[i] and s[j] are vowels, then t[i] must not have a higher ASCII value than t[j].\nReturn the resulting string.\nThe vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in lowercase or uppercase. Consonants comprise all letters that are not vowels.\n", "provided_code_snippet": "class Solution:\r\n def sortVowels(self, s: str) -> str:", "solution": "class Solution:\n def sortVowels(self, s: str) -> str:\n vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u']\n count_char = Counter(s)\n s_vowels = []\n for char in count_char.keys():\n if char in vowels:\n s_vowels.append(char) \n s = s.replace(char, '_') \n s_vowels.sort()\n for char in s_vowels:\n s = s.replace('_', char, count_char[char])\n return s", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2786": { "problem_id": 2786, "description": "You are given a 0-indexed integer array nums and a positive integer x.\nYou are initially at position 0 in the array and you can visit other positions according to the following rules:\n\t- If you are currently in position i, then you can move to any position j such that i < j.\n\t- For each position i that you visit, you get a score of nums[i].\n\t- If you move from a position i to a position j and the parities of nums[i] and nums[j] differ, then you lose a score of x.\nReturn the maximum total score you can get.\nNote that initially you have nums[0] points.\n", "provided_code_snippet": "class Solution:\r\n def maxScore(self, nums: List[int], x: int) -> int:", "solution": "class Solution:\n def solve(self, nums, x, i, p, dp) -> int:\n if i > len(nums) - 1:\n return 0\n\n if dp[i][p] != -1:\n return dp[i][p]\n\n y = nums[i] % 2\n if p == y:\n include = nums[i] + self.solve(nums, x, i + 1, y, dp)\n else:\n include = nums[i] - x + self.solve(nums, x, i + 1, y, dp)\n\n exculde = self.solve(nums, x, i + 1, p, dp)\n\n dp[i][p] = max(include,exculde)\n return dp[i][p]\n\n def maxScore(self, nums: List[int], x: int) -> int:\n p = nums[0] % 2\n n = len(nums)\n dp = [[-1 for _ in range(2)] for _ in range(n)]\n return nums[0] + self.solve(nums, x, 1, p, dp)", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2787": { "problem_id": 2787, "description": "Given two positive integers n and x.\nReturn the number of ways n can be expressed as the sum of the xth power of unique positive integers, in other words, the number of sets of unique integers [n1, n2, ..., nk] where n = n1x + n2x + ... + nkx.\nSince the result can be very large, return it modulo 109 + 7.\nFor example, if n = 160 and x = 3, one way to express n is n = 23 + 33 + 53.\n", "provided_code_snippet": "class Solution:\r\n def numberOfWays(self, n: int, x: int) -> int:", "solution": "class Solution:\n def numberOfWays(self, n: int, x: int) -> int:\n MOD = 10**9 + 7 \n max_num = int(n**(1.0/x)) + 1 \n dp = [[0 for _ in range(n+1)] for _ in range(max_num+1)] \n for i in range(max_num+1): \n dp[i][0] = 1 \n for i in range(1, max_num+1): \n for j in range(1, n+1): \n if j < i**x: \n dp[i][j] = dp[i-1][j] \n else: \n dp[i][j] = (dp[i-1][j] + dp[i-1][j-i**x]) % MOD \n return dp[max_num][n]", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2788": { "problem_id": 2788, "description": "Given an array of strings words and a character separator, split each string in words by separator.\nReturn an array of strings containing the new strings formed after the splits, excluding empty strings.\nNotes\n\t- separator is used to determine where the split should occur, but it is not included as part of the resulting strings.\n\t- A split may result in more than two strings.\n\t- The resulting strings must maintain the same order as they were initially given.\n", "provided_code_snippet": "class Solution:\r\n def splitWordsBySeparator(self, words: List[str], separator: str) -> List[str]:", "solution": "class Solution:\n def splitWordsBySeparator(self, words: List[str], separator: str) -> List[str]:\n return [w for word in words for w in word.split(separator) if w]", "submission_passed": true, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2789": { "problem_id": 2789, "description": "You are given a 0-indexed array nums consisting of positive integers.\nYou can do the following operation on the array any number of times:\n\t- Choose an integer i such that 0 <= i < nums.length - 1 and nums[i] <= nums[i + 1]. Replace the element nums[i + 1] with nums[i] + nums[i + 1] and delete the element nums[i] from the array.\nReturn the value of the largest element that you can possibly obtain in the final array.\n", "provided_code_snippet": "class Solution:\r\n def maxArrayValue(self, nums: List[int]) -> int:", "solution": "class Solution:\n def maxArrayValue(self, nums: List[int]) -> int:\n n = len(nums) - 1\n sum = nums[n]\n\n for i in range(n-1, -1, -1):\n sum = sum + nums[i] if nums[i] <= sum else nums[i]\n\n return sum", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2790": { "problem_id": 2790, "description": "You are given a 0-indexed array usageLimits of length n.\nYour task is to create groups using numbers from 0 to n - 1, ensuring that each number, i, is used no more than usageLimits[i] times in total across all groups. You must also satisfy the following conditions:\n\t- Each group must consist of distinct numbers, meaning that no duplicate numbers are allowed within a single group.\n\t- Each group (except the first one) must have a length strictly greater than the previous group.\nReturn an integer denoting the maximum number of groups you can create while satisfying these conditions.\n", "provided_code_snippet": "class Solution:\r\n def maxIncreasingGroups(self, usageLimits: List[int]) -> int:", "solution": "class Solution:\n def maxIncreasingGroups(self, usageLimits: List[int]) -> int:\n usageLimits.sort()\n \n total, count = 0, 0\n for i in range(len(usageLimits)):\n total += usageLimits[i]\n if total >= ((count+1)*(count+2))//2:\n count += 1\n \n return count", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2791": { "problem_id": 2791, "description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree is represented by a 0-indexed array parent of size n, where parent[i] is the parent of node i. Since node 0 is the root, parent[0] == -1.\nYou are also given a string s of length n, where s[i] is the character assigned to the edge between i and parent[i]. s[0] can be ignored.\nReturn the number of pairs of nodes (u, v) such that u < v and the characters assigned to edges on the path from u to v can be rearranged to form a palindrome.\nA string is a palindrome when it reads the same backwards as forwards.\n", "provided_code_snippet": "class Solution:\r\n def countPalindromePaths(self, parent: List[int], s: str) -> int:", "solution": "class Solution:\n\n def dfs(self, x: int, mask: int, s: str, con: List[List[int]], have: Dict[int, int]) -> int:\n r: int = 0\n if x:\n mask ^= 1 << (ord(s[x]) - ord('a'))\n i: int = 1 << 25\n while i:\n if mask ^ i in have:\n r += have[mask ^ i]\n i >>= 1\n r += have.get(mask, 0)\n have[mask] = have.get(mask, 0) + 1\n for y in con[x]:\n r += self.dfs(y, mask, s, con, have)\n return r\n\n def countPalindromePaths(self, parent: List[int], s: str) -> int:\n n: int = len(s)\n con: List[List[int]] = [[] for _ in range(n)]\n for i in range(1, n):\n con[parent[i]].append(i)\n have: Dict[int, int] = {0: 1}\n return self.dfs(0, 0, s, con, have)", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2798": { "problem_id": 2798, "description": "There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.\nThe company requires each employee to work for at least target hours.\nYou are given a 0-indexed array of non-negative integers hours of length n and a non-negative integer target.\nReturn the integer denoting the number of employees who worked at least target hours.\n", "provided_code_snippet": "class Solution:\r\n def numberOfEmployeesWhoMetTarget(self, hours: List[int], target: int) -> int:", "solution": "class Solution:\n def numberOfEmployeesWhoMetTarget(self, hours: List[int], target: int) -> int:\n return sum(h >= target for h in hours)", "submission_passed": true, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2799": { "problem_id": 2799, "description": "You are given an array nums consisting of positive integers.\nWe call a subarray of an array complete if the following condition is satisfied:\n\t- The number of distinct elements in the subarray is equal to the number of distinct elements in the whole array.\nReturn the number of complete subarrays.\nA subarray is a contiguous non-empty part of an array.\n", "provided_code_snippet": "class Solution:\r\n def countCompleteSubarrays(self, nums: List[int]) -> int:", "solution": "class Solution:\n def countCompleteSubarrays(self, nums: List[int]) -> int:\n n = len(nums) \n distinct_elements = len(set(nums)) \n count = 0 \n left = 0 \n right = 0 \n counter = Counter() \n\n while right < n: \n counter[nums[right]] += 1 \n while len(counter) == distinct_elements: \n counter[nums[left]] -= 1 \n if counter[nums[left]] == 0: \n del counter[nums[left]] \n left += 1 \n count += n - right \n right += 1 \n\n return count", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2800": { "problem_id": 2800, "description": "Given three strings a, b, and c, your task is to find a string that has the minimum length and contains all three strings as substrings.If there are multiple such strings, return the lexicographically smallest one.\nReturn a string denoting the answer to the problem.\nNotes\n\t- A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\n\t- A substring is a contiguous sequence of characters within a string.\n", "provided_code_snippet": "class Solution:\r\n def minimumString(self, a: str, b: str, c: str) -> str:", "solution": "class Solution:\n\n def merge(self, s1, s2):\n if s2 in s1:\n return s1\n \n for i in range(len(s1)):\n if s2.startswith(s1[i:]):\n return s1[:i] + s2\n\n return s1 + s2\n\n def minimumString(self, a: str, b: str, c: str) -> str:\n res, l = '', float('inf')\n for s in [\n self.merge(self.merge(a, b), c),\n self.merge(self.merge(b, a), c),\n self.merge(self.merge(c, b), a),\n self.merge(self.merge(b, c), a),\n self.merge(self.merge(a, c), b),\n self.merge(self.merge(c, a), b),\n ]:\n if len(s) < l:\n res, l = s, len(s)\n elif len(s) == l:\n res = min(res, s)\n\n return res", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2801": { "problem_id": 2801, "description": "Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high].\nA stepping number is an integer such that all of its adjacent digits have an absolute difference of exactly 1.\nReturn an integer denoting the count of stepping numbers in the inclusive range [low, high].\nSince the answer may be very large, return it modulo 109 + 7.\nNote: A stepping number should not have a leading zero.\n", "provided_code_snippet": "class Solution:\r\n def countSteppingNumbers(self, low: str, high: str) -> int:", "solution": "class Solution:\n def countSteppingNumbers(self, low, hgh):\n\n mod, n = 1_000_000_007, len(hgh) \n low = low.rjust(n, '0') # pad low w/ \"0\"s to length of high\n \n @lru_cache(None)\n def dfs(idx, prev, aboveLow, belowHgh, init0):\n\n if idx == n: return 1\n\n res, l, h = 0, int(low[idx]), int(hgh[idx])\n \n for next in range( 0 if aboveLow else l, # handle the tight occurrences\n 10 if belowHgh else h + 1):\n\n if not init0 or abs(prev - next) == 1:\n\n res += dfs(idx + 1, # move idx to next digit\n next, # prev becomes next\n aboveLow or next > l, # is it tight below?\n belowHgh or next < h, # is it tight above?\n init0 or next != 0) # do we have an initial zero\n \n return res %mod\n\n return dfs(0 ,-1, False, False, False)", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2806": { "problem_id": 2806, "description": "Initially, you have a bank account balance of 100 dollars.\nYou are given an integer purchaseAmount representing the amount you will spend on a purchase in dollars, in other words, its price.\nWhen making the purchase, first the purchaseAmount is rounded to the nearest multiple of 10. Let us call this value roundedAmount. Then, roundedAmount dollars are removed from your bank account.\nReturn an integer denoting your final bank account balance after this purchase.\nNotes:\n\t- 0 is considered to be a multiple of 10 in this problem.\n\t- When rounding, 5 is rounded upward (5 is rounded to 10, 15 is rounded to 20, 25 to 30, and so on).\n", "provided_code_snippet": "class Solution:\r\n def accountBalanceAfterPurchase(self, purchaseAmount: int) -> int:", "solution": "class Solution:\n def accountBalanceAfterPurchase(self, purchaseAmount: int) -> int:\n\n return (104 -purchaseAmount)//10*10", "submission_passed": false, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2807": { "problem_id": 2807, "description": "Given the head of a linked list head, in which each node contains an integer value.\nBetween every pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor of them.\nReturn the linked list after insertion.\nThe greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.\n", "provided_code_snippet": "# Definition for singly-linked list.\r\n# class ListNode:\r\n# def __init__(self, val=0, next=None):\r\n# self.val = val\r\n# self.next = next\r\nclass Solution:\r\n def insertGreatestCommonDivisors(self, head: Optional[ListNode]) -> Optional[ListNode]:", "solution": "class Solution:\n def insertGreatestCommonDivisors(self, head: ListNode) -> ListNode:\n\n node = head\n \n while node.next:\n node.next, node = ListNode(gcd(node.val, node.next.val\n ), node.next), node.next\n return head", "submission_passed": true, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2808": { "problem_id": 2808, "description": "You are given a 0-indexed array nums containing n integers.\nAt each second, you perform the following operation on the array:\n\t- For every index i in the range [0, n - 1], replace nums[i] with either nums[i], nums[(i - 1 + n) % n], or nums[(i + 1) % n].\nNote that all the elements get replaced simultaneously.\nReturn the minimum number of seconds needed to make all elements in the array nums equal.\n", "provided_code_snippet": "class Solution:\r\n def minimumSeconds(self, nums: List[int]) -> int:", "solution": "def minimumSeconds(self, nums: List[int]) -> int:\n n, indices = len(nums), defaultdict(list)\n for i, num in enumerate(nums):\n indices[num].append(i)\n ans = n \n for l in indices.values():\n l.append(l[0] + n)\n ans = min(ans, max(y - x for x, y in pairwise(l)) // 2)\n return ans", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2809": { "problem_id": 2809, "description": "You are given two 0-indexed integer arrays nums1 and nums2 of equal length. Every second, for all indices 0 <= i < nums1.length, value of nums1[i] is incremented by nums2[i]. After this is done, you can do the following operation:\n\t- Choose an index 0 <= i < nums1.length and make nums1[i] = 0.\nYou are also given an integer x.\nReturn the minimum time in which you can make the sum of all elements of nums1 to be less than or equal to x, or -1 if this is not possible.\n", "provided_code_snippet": "class Solution:\r\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:", "solution": "class Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n n = len(nums1)\n ind = list(range(n))\n s, d = 0, 0\n for i in range(n):\n s += nums1[i]\n d += nums2[i]\n if s <= x:\n return 0\n\n # Custom comparator for sorting ind based on nums2 values\n ind.sort(key=lambda i: nums2[i])\n\n dp = [0] * (n + 1)\n r = n + 1\n for i in range(1, n + 1):\n for j in range(min(i, r - 1), 0, -1):\n dp[j] = max(dp[j], dp[j - 1] + nums2[ind[i - 1]] * j + nums1[ind[i - 1]])\n if s + j * d - dp[j] <= x:\n r = j\n return r if r <= n else -1", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] }, "2810": { "problem_id": 2810, "description": "Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as expected.\nYou are given a 0-indexed string s, and you type each character of s using your faulty keyboard.\nReturn the final string that will be present on your laptop screen.\n", "provided_code_snippet": "class Solution:\r\n def finalString(self, s: str) -> str:", "solution": "class Solution:\n def finalString(self, s: str) -> str:\n while \"i\" in s:\n index=s.index(\"i\")\n\n #first half and second half\n first=s[:index][::-1]\n second=s[index+1:]\n\n s=\"\".join([first,second])\n return s", "submission_passed": true, "difficulty": "Easy", "problem_tags": [], "solution_tags": [], "categories": [] }, "2811": { "problem_id": 2811, "description": "You are given an array nums of length n and an integer m. You need to determine if it is possible to split the array into n arrays of size 1 by performing a series of steps.\nAn array is called good if:\n\t- The length of the array is one, or\n\t- The sum of the elements of the array is greater than or equal to m.\nIn each step, you can select an existing array (which may be the result of previous steps) with a length of at least two and split it into two arrays, if both resulting arrays are good.\nReturn true if you can split the given array into n arrays, otherwise return false.\n", "provided_code_snippet": "class Solution:\r\n def canSplitArray(self, nums: List[int], m: int) -> bool:", "solution": "class Solution:\n def canSplitArray(self, nums: List[int], m: int) -> bool:\n\n return len(nums) < 3 or max(map(sum, pairwise(nums))) >= m", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2812": { "problem_id": 2812, "description": "You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents:\n\t- A cell containing a thief if grid[r][c] = 1\n\t- An empty cell if grid[r][c] = 0\nYou are initially positioned at cell (0, 0). In one move, you can move to any adjacent cell in the grid, including cells containing thieves.\nThe safeness factor of a path on the grid is defined as the minimum manhattan distance from any cell in the path to any thief in the grid.\nReturn the maximum safeness factor of all paths leading to cell (n - 1, n - 1).\nAn adjacent cell of cell (r, c), is one of the cells (r, c + 1), (r, c - 1), (r + 1, c) and (r - 1, c) if it exists.\nThe Manhattan distance between two cells (a, b) and (x, y) is equal to |a - x| + |b - y|, where |val| denotes the absolute value of val.\n", "provided_code_snippet": "class Solution:\r\n def maximumSafenessFactor(self, grid: List[List[int]]) -> int:", "solution": "class Solution:\n def __init__(self):\n self.roww = [0, 0, -1, 1]\n self.coll = [-1, 1, 0, 0]\n\n def bfs(self, grid, score, n):\n q = deque()\n\n for i in range(n):\n for j in range(n):\n if grid[i][j]:\n score[i][j] = 0\n q.append((i, j))\n\n while q:\n x, y = q.popleft()\n s = score[x][y]\n\n for i in range(4):\n new_x = x + self.roww[i]\n new_y = y + self.coll[i]\n\n if 0 <= new_x < n and 0 <= new_y < n and score[new_x][new_y] > s + 1:\n score[new_x][new_y] = s + 1\n q.append((new_x, new_y))\n\n def maximumSafenessFactor(self, grid):\n n = len(grid)\n if grid[0][0] or grid[n - 1][n - 1]:\n return 0\n\n score = [[float('inf')] * n for _ in range(n)]\n self.bfs(grid, score, n)\n\n vis = [[False] * n for _ in range(n)]\n pq = [(-score[0][0], 0, 0)]\n heapq.heapify(pq)\n\n while pq:\n safe, x, y = heapq.heappop(pq)\n safe = -safe\n\n if x == n - 1 and y == n - 1:\n return safe\n\n vis[x][y] = True\n\n for i in range(4):\n new_x = x + self.roww[i]\n new_y = y + self.coll[i]\n\n if 0 <= new_x < n and 0 <= new_y < n and not vis[new_x][new_y]:\n s = min(safe, score[new_x][new_y])\n heapq.heappush(pq, (-s, new_x, new_y))\n vis[new_x][new_y] = True\n\n return -1", "submission_passed": false, "difficulty": "Medium", "problem_tags": [], "solution_tags": [], "categories": [] }, "2813": { "problem_id": 2813, "description": "You are given a 0-indexed 2D integer array items of length n and an integer k.\nitems[i] = [profiti, categoryi], where profiti and categoryi denote the profit and category of the ith item respectively.\nLet's define the elegance of a subsequence of items as total_profit + distinct_categories2, where total_profit is the sum of all profits in the subsequence, and distinct_categories is the number of distinct categories from all the categories in the selected subsequence.\nYour task is to find the maximum elegance from all subsequences of size k in items.\nReturn an integer denoting the maximum elegance of a subsequence of items with size exactly k.\nNote: A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order.\n", "provided_code_snippet": "class Solution:\r\n def findMaximumElegance(self, items: List[List[int]], k: int) -> int:", "solution": "class Solution:\n def findMaximumElegance(self, items, K):\n items.sort(reverse=True)\n \n dupes = []\n cates = set()\n ans = cur = 0\n for p, c in items:\n cur += p\n if c not in cates:\n cates.add(c)\n else:\n dupes.append(p)\n\n while dupes and len(dupes) + len(cates) > K:\n cur -= dupes.pop()\n if len(dupes) + len(cates) <= K:\n ans = max(ans, cur + len(cates) ** 2)\n \n return ans", "submission_passed": false, "difficulty": "Hard", "problem_tags": [], "solution_tags": [], "categories": [] } }