question_id int64 1 3.24k | task_id stringlengths 3 77 | difficulty stringclasses 3
values | problem_description stringlengths 193 3.69k | canonical_tests dict | public_tests listlengths 1 5 | hints listlengths 0 8 | metadata dict | language stringclasses 9
values | interface dict |
|---|---|---|---|---|---|---|---|---|---|
1,925 | count-square-sum-triples | Easy | A square triple (a,b,c) is a triple where a, b, and c are integers and a^2 + b^2 = c^2.
Given an integer n, return the number of square triples such that 1 <= a, b, c <= n.
Example 1:
Input: n = 5
Output: 2
Explanation: The square triples are (3,4,5) and (4,3,5).
Example 2:
Input: n = 10
Output: 4
Explanation: The... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 250) == 330\n assert candidate(n = 5) == 2\n assert candidate(n = 15) == 8\n assert candidate(n = 200) == 254\n assert candidate(n = 20) == 12\n assert candidate(n = 100) == 104\n assert candidate(n = 50) == 40\n ... | [
"5",
"10"
] | [
"Iterate over all possible pairs (a,b) and check that the square root of a * a + b * b is an integers less than or equal n",
"You can check that the square root of an integer is an integer using binary seach or a builtin function like sqrt"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().countTriples",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:14",
"tests_total": 23,
"tests_droppe... | cpp | {
"raw_signature": "int countTriples(int n) {",
"container": "Solution",
"callable": "countTriples",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,927 | sum-game | Medium | Alice and Bob take turns playing a game, with Alice starting first.
You are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:
1. Choose an index i where num[i] == '?'.
2. Replace num[i] with any digit betw... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"1???2???\") == True\n assert candidate(num = \"9?8?7?6?\") == True\n assert candidate(num = \"????2222\") == True\n assert candidate(num = \"98765432\") == True\n assert candidate(num = \"???45678\") == True\n asse... | [
"\"5023\"",
"\"25??\"",
"\"?3295???\""
] | [
"Bob can always make the total sum of both sides equal in mod 9.",
"Why does the difference between the number of question marks on the left and right side matter?"
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().sumGame",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:19",
"tests_total": 168,
"tests_dropped"... | cpp | {
"raw_signature": "bool sumGame(string num) {",
"container": "Solution",
"callable": "sumGame",
"parameters": [
{
"name": "num",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,928 | minimum-cost-to-reach-destination-in-time | Hard | There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [x_i, y_i, time_i] denotes a road between cities x_i and y_i that takes time_i minutes to travel. There may be multiple roads of diff... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [2, 3, 5], [3, 4, 5]],passingFees = [10, 10,... | [
"30\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]",
"29\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]",
"25\n[[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]]\n[5,1,2,20,20,3]"
] | [
"Consider a new graph where each node is one of the old nodes at a specific time. For example, node 0 at time 5.",
"You need to find the shortest path in the new graph."
] | {
"canonical_parameter_names": [
"maxTime",
"edges",
"passingFees"
],
"leetcode_dataset_entry_point": "Solution().minCost",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:21",
"... | cpp | {
"raw_signature": "int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {",
"container": "Solution",
"callable": "minCost",
"parameters": [
{
"name": "maxTime",
"type": "int"
},
{
"name": "edges",
"type": "vector<vector<int>>&"
},
{
"n... |
1,929 | concatenation-of-array | Easy | Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).
Specifically, ans is the concatenation of two nums arrays.
Return the array ans.
Example 1:
Input: nums = [1,2,1]
Output: [1,2,1,1,2,1]
Explanation: The... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [5, 6, 7]) == [5, 6, 7, 5, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1... | [
"[1,2,1]",
"[1,3,2,1]"
] | [
"Build an array of size 2 * n and assign nums[i] to ans[i] and ans[i + n]"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().getConcatenation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:23",
"tests_total": 71,
"tests... | cpp | {
"raw_signature": "vector<int> getConcatenation(vector<int>& nums) {",
"container": "Solution",
"callable": "getConcatenation",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_source": "le... |
1,930 | unique-length-3-palindromic-subsequences | Medium | Given a string s, return the number of unique palindromes of length three that are a subsequence of s.
Note that even if there are multiple ways to obtain the same subsequence, it is still only counted once.
A palindrome is a string that reads the same forwards and backwards.
A subsequence of a string is a new strin... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abcba\") == 3\n assert candidate(s = \"madam\") == 3\n assert candidate(s = \"abcdedcba\") == 10\n assert candidate(s = \"aaaaa\") == 1\n assert candidate(s = \"adc\") == 0\n assert candidate(s = \"abcabcabc\") == 9\... | [
"\"aabca\"",
"\"adc\"",
"\"bbcbaba\""
] | [
"What is the maximum number of length-3 palindromic strings?",
"How can we keep track of the characters that appeared to the left of a given position?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countPalindromicSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:25",
"tests_total": 75,
... | cpp | {
"raw_signature": "int countPalindromicSubsequence(string s) {",
"container": "Solution",
"callable": "countPalindromicSubsequence",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeS... |
1,931 | painting-a-grid-with-three-different-colors | Hard | You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.
Return the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 10^9 ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 2,n = 4) == 162\n assert candidate(m = 4,n = 3) == 1122\n assert candidate(m = 5,n = 1) == 48\n assert candidate(m = 1,n = 2) == 6\n assert candidate(m = 5,n = 5) == 580986\n assert candidate(m = 3,n = 4) == 1122\n ... | [
"1\n1",
"1\n2",
"5\n5"
] | [
"Represent each colored column by a bitmask based on each cell color.",
"Use bitmasks DP with state (currentCell, prevColumn)."
] | {
"canonical_parameter_names": [
"m",
"n"
],
"leetcode_dataset_entry_point": "Solution().colorTheGrid",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:28",
"tests_total": 61,
"tes... | cpp | {
"raw_signature": "int colorTheGrid(int m, int n) {",
"container": "Solution",
"callable": "colorTheGrid",
"parameters": [
{
"name": "m",
"type": "int"
},
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_s... |
1,935 | maximum-number-of-words-you-can-type | Easy | There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.
Given a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you ca... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(text = \"jumped over the lazy dog\",brokenLetters = \"zg\") == 3\n assert candidate(text = \"nopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"xyzzzz\",brokenLetters = \"x\") == 0\n assert candidate(text ... | [
"\"hello world\"\n\"ad\"",
"\"leet code\"\n\"lt\"",
"\"leet code\"\n\"e\""
] | [
"Check each word separately if it can be typed.",
"A word can be typed if all its letters are not broken."
] | {
"canonical_parameter_names": [
"text",
"brokenLetters"
],
"leetcode_dataset_entry_point": "Solution().canBeTypedWords",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:32",
"tests_... | cpp | {
"raw_signature": "int canBeTypedWords(string text, string brokenLetters) {",
"container": "Solution",
"callable": "canBeTypedWords",
"parameters": [
{
"name": "text",
"type": "string"
},
{
"name": "brokenLetters",
"type": "string"
}
],
"return_type": "int",
"signa... |
1,936 | add-minimum-number-of-rungs | Medium | You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.
You are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rungs = [1, 3, 5, 10],dist = 2) == 2\n assert candidate(rungs = [1, 2, 3, 4, 5],dist = 1) == 0\n assert candidate(rungs = [3, 6, 8, 10],dist = 3) == 0\n assert candidate(rungs = [10],dist = 10) == 0\n assert candidate(rungs =... | [
"[1,3,5,10]\n2",
"[3,6,8,10]\n3",
"[3,4,6,7]\n2"
] | [
"Go as far as you can on the available rungs before adding new rungs.",
"If you have to add a new rung, add it as high up as possible.",
"Try using division to decrease the number of computations."
] | {
"canonical_parameter_names": [
"rungs",
"dist"
],
"leetcode_dataset_entry_point": "Solution().addRungs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:34",
"tests_total": 102,
... | cpp | {
"raw_signature": "int addRungs(vector<int>& rungs, int dist) {",
"container": "Solution",
"callable": "addRungs",
"parameters": [
{
"name": "rungs",
"type": "vector<int>&"
},
{
"name": "dist",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/... |
1,937 | maximum-number-of-points-with-cost | Medium | You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.
To gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.
However, you will lose points if you ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(points = [[5, 10], [10, 5]]) == 19\n assert candidate(points = [[5, 2], [1, 2]]) == 6\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 15\n assert candidate(points = [[1, 2, 3], [1, 5, 1], [3, ... | [
"[[1,2,3],[1,5,1],[3,1,1]]",
"[[1,5],[2,3],[4,2]]"
] | [
"Try using dynamic programming.",
"dp[i][j] is the maximum number of points you can have if points[i][j] is the most recent cell you picked."
] | {
"canonical_parameter_names": [
"points"
],
"leetcode_dataset_entry_point": "Solution().maxPoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:37",
"tests_total": 91,
"tests_drop... | cpp | {
"raw_signature": "long long maxPoints(vector<vector<int>>& points) {",
"container": "Solution",
"callable": "maxPoints",
"parameters": [
{
"name": "points",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "... |
1,938 | maximum-genetic-difference-query | Hard | There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [2, 1], [3, 4], [4, 5]]) == [3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[4, 5], [7, 10], [2, 15]]) == [5, 13, 15]\n assert candidate(parents = [3, ... | [
"[-1,0,1,1]\n[[0,2],[3,2],[2,5]]",
"[3,7,-1,2,0,7,0,2]\n[[4,6],[1,15],[0,5]]"
] | [
"How can we use a trie to store all the XOR values in the path from a node to the root?",
"How can we dynamically add the XOR values with a DFS search?"
] | {
"canonical_parameter_names": [
"parents",
"queries"
],
"leetcode_dataset_entry_point": "Solution().maxGeneticDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:40",
"test... | cpp | {
"raw_signature": "vector<int> maxGeneticDifference(vector<int>& parents, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "maxGeneticDifference",
"parameters": [
{
"name": "parents",
"type": "vector<int>&"
},
{
"name": "queries",
"type": "vector<vector... |
1,941 | check-if-all-characters-have-equal-number-of-occurrences | Easy | Given a string s, return true if s is a good string, or false otherwise.
A string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).
Example 1:
Input: s = "abacbc"
Output: true
Explanation: The characters that appear in s are 'a', 'b', and 'c'. All charac... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aabbccc\") == False\n assert candidate(s = \"abacbc\") == True\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"qqqq\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = ... | [
"\"abacbc\"",
"\"aaabb\""
] | [
"Build a dictionary containing the frequency of each character appearing in s",
"Check if all values in the dictionary are the same."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().areOccurrencesEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:44",
"tests_total": 91,
"tests... | cpp | {
"raw_signature": "bool areOccurrencesEqual(string s) {",
"container": "Solution",
"callable": "areOccurrencesEqual",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,942 | the-number-of-the-smallest-unoccupied-chair | Medium | There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.
- For example, if chairs 0, 1, and 5 are occupied when a frie... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(times = [[5, 10], [1, 3], [2, 6], [7, 8]],targetFriend = 1) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 8]],targetFriend = 2) == 0\n assert candidate(times = [[2, 7], [7, 9], [1, 5]],targetFriend = 2) == 0\n assert can... | [
"[[1,4],[2,3],[4,6]]\n1",
"[[3,10],[1,5],[2,6]]\n0"
] | [
"Sort times by arrival time.",
"for each arrival_i find the smallest unoccupied chair and mark it as occupied until leaving_i."
] | {
"canonical_parameter_names": [
"times",
"targetFriend"
],
"leetcode_dataset_entry_point": "Solution().smallestChair",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:47",
"tests_to... | cpp | {
"raw_signature": "int smallestChair(vector<vector<int>>& times, int targetFriend) {",
"container": "Solution",
"callable": "smallestChair",
"parameters": [
{
"name": "times",
"type": "vector<vector<int>>&"
},
{
"name": "targetFriend",
"type": "int"
}
],
"return_type... |
1,943 | describe-the-painting | Medium | There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [start_i, end_i, color_i] represents the half-closed segment [start_i... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[[1,4,5],[4,7,7],[1,7,9]]",
"[[1,7,9],[6,8,15],[8,10,7]]",
"[[1,4,5],[1,4,7],[4,7,1],[4,7,11]]"
] | [
"Can we sort the segments in a way to help solve the problem?",
"How can we dynamically keep track of the sum of the current segment(s)?"
] | {
"canonical_parameter_names": [
"segments"
],
"leetcode_dataset_entry_point": "Solution().splitPainting",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:49",
"tests_total": 98,
"test... | cpp | {
"raw_signature": "vector<vector<long long>> splitPainting(vector<vector<int>>& segments) {",
"container": "Solution",
"callable": "splitPainting",
"parameters": [
{
"name": "segments",
"type": "vector<vector<int>>&"
}
],
"return_type": "vector<vector<long long>>",
"signature_source":... |
1,944 | number-of-visible-people-in-a-queue | Hard | There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the i^th person.
A person can see another person to their right in the queue if everybody in between is shorter than both of th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(heights = [1]) == [0]\n assert candidate(heights = [1, 2, 3, 6, 5, 4, 10, 9, 8, 7]) == [1, 1, 1, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 2, 3, 10]) == [4, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, ... | [
"[10,6,8,5,11,9]",
"[5,1,2,3,10]"
] | [
"How to solve this problem in quadratic complexity ?",
"For every subarray start at index i, keep finding new maximum values until a value larger than arr[i] is found.",
"Since the limits are high, you need a linear solution.",
"Use a stack to keep the values of the array sorted as you iterate the array from ... | {
"canonical_parameter_names": [
"heights"
],
"leetcode_dataset_entry_point": "Solution().canSeePersonsCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:52",
"tests_total": 123,
... | cpp | {
"raw_signature": "vector<int> canSeePersonsCount(vector<int>& heights) {",
"container": "Solution",
"callable": "canSeePersonsCount",
"parameters": [
{
"name": "heights",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_so... |
1,945 | sum-of-digits-of-string-after-convert | Easy | You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps:
1. Convert s into an integer by replacing each let... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"zzzz\",k = 1) == 32\n assert candidate(s = \"zzz\",k = 10) == 6\n assert candidate(s = \"programming\",k = 1) == 68\n assert candidate(s = \"abz\",k = 5) == 2\n assert candidate(s = \"a\",k = 1) == 1\n assert candida... | [
"\"iiii\"\n1",
"\"leetcode\"\n2",
"\"zbax\"\n2"
] | [
"First, let's note that after the first transform the value will be at most 100 * 10 which is not much",
"After The first transform, we can just do the rest of the transforms by brute force"
] | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().getLucky",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:54",
"tests_total": 93,
"tests_d... | cpp | {
"raw_signature": "int getLucky(string s, int k) {",
"container": "Solution",
"callable": "getLucky",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
1,946 | largest-number-after-mutating-substring | Medium | You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].
You may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"132\",change = [9, 8, 5, 0, 3, 6, 4, 2, 6, 8]) == \"832\"\n assert candidate(num = \"1111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999\"\n assert candidate(num = \"5\",change = [1, 4, 7, 5, 3, 2, 5, 6, 9, 4]) == \"5... | [
"\"132\"\n[9,8,5,0,3,6,4,2,6,8]",
"\"021\"\n[9,4,3,5,7,2,1,9,0,6]",
"\"5\"\n[1,4,7,5,3,2,5,6,9,4]"
] | [
"Should you change a digit if the new digit is smaller than the original?",
"If changing the first digit and the last digit both make the number bigger, but you can only change one of them; which one should you change?",
"Changing numbers closer to the front is always better"
] | {
"canonical_parameter_names": [
"num",
"change"
],
"leetcode_dataset_entry_point": "Solution().maximumNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:56",
"tests_total": 12... | cpp | {
"raw_signature": "string maximumNumber(string num, vector<int>& change) {",
"container": "Solution",
"callable": "maximumNumber",
"parameters": [
{
"name": "num",
"type": "string"
},
{
"name": "change",
"type": "vector<int>&"
}
],
"return_type": "string",
"signatu... |
1,947 | maximum-compatibility-score-sum | Medium | There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).
The survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(students = [[1, 1], [0, 0]],mentors = [[0, 0], [1, 1]]) == 4\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[1, 0], ... | [
"[[1,1,0],[1,0,1],[0,0,1]]\n[[1,0,0],[0,0,1],[1,1,0]]",
"[[0,0],[0,0],[0,0]]\n[[1,1],[1,1],[1,1]]"
] | [
"Calculate the compatibility score for each student-mentor pair.",
"Try every permutation of students with the original mentors array."
] | {
"canonical_parameter_names": [
"students",
"mentors"
],
"leetcode_dataset_entry_point": "Solution().maxCompatibilitySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:35:58",
"test... | cpp | {
"raw_signature": "int maxCompatibilitySum(vector<vector<int>>& students, vector<vector<int>>& mentors) {",
"container": "Solution",
"callable": "maxCompatibilitySum",
"parameters": [
{
"name": "students",
"type": "vector<vector<int>>&"
},
{
"name": "mentors",
"type": "vecto... |
1,948 | delete-duplicate-folders-in-system | Hard | Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the i^th folder in the file system.
- For example, ["one", "two", "three"] represents the path "/one/two/three".
Two folders (not necessarily on the same level) ... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[[\"a\"],[\"c\"],[\"d\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"d\",\"a\"]]",
"[[\"a\"],[\"c\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"a\",\"b\",\"x\"],[\"a\",\"b\",\"x\",\"y\"],[\"w\"],[\"w\",\"y\"]]",
"[[\"a\",\"b\"],[\"c\",\"d\"],[\"c\"],[\"a\"]]"
] | [
"Can we use a trie to build the folder structure?",
"Can we utilize hashing to hash the folder structures?"
] | {
"canonical_parameter_names": [
"paths"
],
"leetcode_dataset_entry_point": "Solution().deleteDuplicateFolder",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:01",
"tests_total": 76,
... | cpp | {
"raw_signature": "vector<vector<string>> deleteDuplicateFolder(vector<vector<string>>& paths) {",
"container": "Solution",
"callable": "deleteDuplicateFolder",
"parameters": [
{
"name": "paths",
"type": "vector<vector<string>>&"
}
],
"return_type": "vector<vector<string>>",
"signatur... |
1,952 | three-divisors | Easy | Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.
An integer m is a divisor of n if there exists an integer k such that n = k * m.
Example 1:
Input: n = 2
Output: false
Explantion: 2 has only two divisors: 1 and 2.
Example 2:
Input: n = 4
Output: true
Explantion: 4 ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 625) == False\n assert candidate(n = 3) == False\n assert candidate(n = 576) == False\n assert candidate(n = 729) == False\n assert candidate(n = 144) == False\n assert candidate(n = 49) == True\n assert candidate(n... | [
"2",
"4"
] | [
"You can count the number of divisors and just check that they are 3",
"Beware of the case of n equal 1 as some solutions might fail in it"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().isThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:06",
"tests_total": 144,
"tests_dropped": ... | cpp | {
"raw_signature": "bool isThree(int n) {",
"container": "Solution",
"callable": "isThree",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,953 | maximum-number-of-weeks-for-which-you-can-work | Medium | There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the i^th project has.
You can work on the projects following these two rules:
- Every week, you will finish exactly one milestone of one project. You must work every week.... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [3, 3, 3]) == 9\n assert candidate(milestones = [1, 1, 1, 1, 1]) == 5\n assert candidate(milestones = [10, 5, 1]) == 13\n assert candidate(mi... | [
"[1,2,3]",
"[5,2,1]"
] | [
"Work on the project with the largest number of milestones as long as it is possible.",
"Does the project with the largest number of milestones affect the number of weeks?"
] | {
"canonical_parameter_names": [
"milestones"
],
"leetcode_dataset_entry_point": "Solution().numberOfWeeks",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:09",
"tests_total": 80,
"te... | cpp | {
"raw_signature": "long long numberOfWeeks(vector<int>& milestones) {",
"container": "Solution",
"callable": "numberOfWeeks",
"parameters": [
{
"name": "milestones",
"type": "vector<int>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "... |
1,954 | minimum-garden-perimeter-to-collect-enough-apples | Medium | In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.
You will buy an axis-aligned square plot of land that is centered at (0, 0).
Given an integer neededApples, return the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(neededApples = 10000000000) == 10856\n assert candidate(neededApples = 10) == 8\n assert candidate(neededApples = 50) == 16\n assert candidate(neededApples = 1000000) == 504\n assert candidate(neededApples = 13) == 16\n as... | [
"1",
"13",
"1000000000"
] | [
"Find a formula for the number of apples inside a square with a side length L.",
"Iterate over the possible lengths of the square until enough apples are collected."
] | {
"canonical_parameter_names": [
"neededApples"
],
"leetcode_dataset_entry_point": "Solution().minimumPerimeter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:11",
"tests_total": 68,
... | cpp | {
"raw_signature": "long long minimumPerimeter(long long neededApples) {",
"container": "Solution",
"callable": "minimumPerimeter",
"parameters": [
{
"name": "neededApples",
"type": "long long"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source... |
1,955 | count-number-of-special-subsequences | Hard | A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.
- For example, [0,1,2] and [0,0,1,1,1,2] are special.
- In contrast, [2,1,0], [1], and [0,1,2,0] are not special.
Given an array nums (consisting of only integers 0, 1, and 2), return th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 2]) == 9\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2]) == 21\n assert candidate(nums = [2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 2]) == 3\... | [
"[0,1,2,2]",
"[2,2,0,0]",
"[0,1,2,0,1,2]"
] | [
"Can we first solve a simpler problem? Counting the number of subsequences with 1s followed by 0s.",
"How can we keep track of the partially matched subsequences to help us find the answer?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countSpecialSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:14",
"tests_total": 128,... | cpp | {
"raw_signature": "int countSpecialSubsequences(vector<int>& nums) {",
"container": "Solution",
"callable": "countSpecialSubsequences",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "le... |
1,957 | delete-characters-to-make-fancy-string | Easy | A fancy string is a string where no three consecutive characters are equal.
Given a string s, delete the minimum possible number of characters from s to make it fancy.
Return the final string after the deletion. It can be shown that the answer will always be unique.
Example 1:
Input: s = "leeetcode"
Output: "leetco... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == \"zz\"\n assert candidate(s = \"aaabbbccc\") == \"aabbcc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbaa\") == \"aabbaa\"\n asse... | [
"\"leeetcode\"",
"\"aaabaaaa\"",
"\"aab\""
] | [
"What's the optimal way to delete characters if three or more consecutive characters are equal?",
"If three or more consecutive characters are equal, keep two of them and delete the rest."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().makeFancyString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:19",
"tests_total": 34,
"tests_dro... | cpp | {
"raw_signature": "string makeFancyString(string s) {",
"container": "Solution",
"callable": "makeFancyString",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,959 | minimum-total-space-wasted-with-k-resizing-operations | Medium | You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).
The size of the array at time t, size_t, m... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3) == 10\n assert candidate(nums = [10, 20, 30],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 45\n ... | [
"[10,20]\n0",
"[10,20,30]\n1",
"[10,20,15,30,20]\n2"
] | [
"Given a range, how can you find the minimum waste if you can't perform any resize operations?",
"Can we build our solution using dynamic programming using the current index and the number of resizing operations performed as the states?"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minSpaceWastedKResizing",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:23",
"tests_tota... | cpp | {
"raw_signature": "int minSpaceWastedKResizing(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "minSpaceWastedKResizing",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signatu... |
1,960 | maximum-product-of-the-length-of-two-palindromic-substrings | Hard | You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.
More formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"mnoonmmon\") == 1\n assert candidate(s = \"mamadmim\") == 9\n assert candidate(s = \"abcdcba\") == 5\n assert candidate(s = \"abcdedcba\") == 7\n assert candidate(s = \"mamad\") == 3\n assert candidate(s = \"aaaaa\")... | [
"\"ababbb\"",
"\"zaaaxbbby\""
] | [
"You can use Manacher's algorithm to get the maximum palindromic substring centered at each index",
"After using Manacher's for each center use a line sweep from the center to the left and from the center to the right to find for each index the farthest center to it with distance ≤ palin[center]",
"After that, ... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:25",
"tests_total": 173,
"tests_dropped... | cpp | {
"raw_signature": "long long maxProduct(string s) {",
"container": "Solution",
"callable": "maxProduct",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,961 | check-if-string-is-a-prefix-of-array | Easy | Given a string s and an array of strings words, determine whether s is a prefix string of words.
A string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.
Return true if s is a prefix string of words, or false otherwise.
Exa... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aaaa\",words = ['aa', 'aa']) == True\n assert candidate(s = \"hello\",words = ['he', 'll', 'o']) == True\n assert candidate(s = \"abc\",words = ['a']) == False\n assert candidate(s = \"abc\",words = ['a', 'bc']) == True\n ... | [
"\"iloveleetcode\"\n[\"i\",\"love\",\"leetcode\",\"apples\"]",
"\"iloveleetcode\"\n[\"apples\",\"i\",\"love\",\"leetcode\"]"
] | [
"There are only words.length prefix strings.",
"Create all of them and see if s is one of them."
] | {
"canonical_parameter_names": [
"s",
"words"
],
"leetcode_dataset_entry_point": "Solution().isPrefixString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:27",
"tests_total": 125,... | cpp | {
"raw_signature": "bool isPrefixString(string s, vector<string>& words) {",
"container": "Solution",
"callable": "isPrefixString",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "words",
"type": "vector<string>&"
}
],
"return_type": "bool",
"signature... |
1,962 | remove-stones-to-minimize-the-total | Medium | You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the i^th pile, and an integer k. You should apply the following operation exactly k times:
- Choose any piles[i] and remove floor(piles[i] / 2) stones from it.
Notice that you can apply the operation on the same pile more... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(piles = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(piles = [10, 10, 10, 10],k = 4) == 20\n assert candidate(piles = [5, 4, 9],k = 2) == 12\n assert candidate(piles = [10, 10, 10],k = 1) == 25\n assert candidate(piles = [... | [
"[5,4,9]\n2",
"[4,3,6,7]\n3"
] | [
"Choose the pile with the maximum number of stones each time.",
"Use a data structure that helps you find the mentioned pile each time efficiently.",
"One such data structure is a Priority Queue."
] | {
"canonical_parameter_names": [
"piles",
"k"
],
"leetcode_dataset_entry_point": "Solution().minStoneSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:30",
"tests_total": 83,
"... | cpp | {
"raw_signature": "int minStoneSum(vector<int>& piles, int k) {",
"container": "Solution",
"callable": "minStoneSum",
"parameters": [
{
"name": "piles",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/... |
1,963 | minimum-number-of-swaps-to-make-the-string-balanced | Medium | You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.
A string is called balanced if and only if:
- It is the empty string, or
- It can be written as AB, where both A and B are balanced strings, or
- It can be written as [C], whe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"[]][[]\") == 1\n assert candidate(s = \"[[[[]]]]\") == 0\n assert candidate(s = \"]][[[]]]\") == 0\n assert candidate(s = \"][][\") == 1\n assert candidate(s = \"]]][[][[\") == 2\n assert candidate(s = \"]]]][[[[\") ... | [
"\"][][\"",
"\"]]][[[\"",
"\"[]\""
] | [
"Iterate over the string and keep track of the number of opening and closing brackets on each step.",
"If the number of closing brackets is ever larger, you need to make a swap.",
"Swap it with the opening bracket closest to the end of s."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minSwaps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:33",
"tests_total": 91,
"tests_dropped": ... | cpp | {
"raw_signature": "int minSwaps(string s) {",
"container": "Solution",
"callable": "minSwaps",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,964 | find-the-longest-valid-obstacle-course-at-each-position | Hard | You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the i^th obstacle.
For every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:
- You choose any number of obs... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(obstacles = [1]) == [1]\n assert candidate(obstacles = [3, 1, 5, 6, 4, 2]) == [1, 1, 2, 3, 2, 2]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n... | [
"[1,2,3,2]",
"[2,2,1]",
"[3,1,5,6,4,2]"
] | [
"Can you keep track of the minimum height for each obstacle course length?",
"You can use binary search to find the longest previous obstacle course length that satisfies the conditions."
] | {
"canonical_parameter_names": [
"obstacles"
],
"leetcode_dataset_entry_point": "Solution().longestObstacleCourseAtEachPosition",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:35",
"te... | cpp | {
"raw_signature": "vector<int> longestObstacleCourseAtEachPosition(vector<int>& obstacles) {",
"container": "Solution",
"callable": "longestObstacleCourseAtEachPosition",
"parameters": [
{
"name": "obstacles",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source... |
1,967 | number-of-strings-that-appear-as-substrings-in-word | Easy | Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.
A substring is a contiguous sequence of characters within a string.
Example 1:
Input: patterns = ["a","abc","bc","d"], word = "abc"
Output: 3
Explanation:
- "a" appears as a substring in ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(patterns = ['a', 'b', 'c'],word = \"aaaaabbbbb\") == 2\n assert candidate(patterns = ['aa', 'bb', 'cc'],word = \"abcabc\") == 0\n assert candidate(patterns = ['a', 'abc', 'bc', 'd'],word = \"abc\") == 3\n assert candidate(patter... | [
"[\"a\",\"abc\",\"bc\",\"d\"]\n\"abc\"",
"[\"a\",\"b\",\"c\"]\n\"aaaaabbbbb\"",
"[\"a\",\"a\",\"a\"]\n\"ab\""
] | [
"Deal with each of the patterns individually.",
"Use the built-in function in the language you are using to find if the pattern exists as a substring in word."
] | {
"canonical_parameter_names": [
"patterns",
"word"
],
"leetcode_dataset_entry_point": "Solution().numOfStrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:40",
"tests_total": ... | cpp | {
"raw_signature": "int numOfStrings(vector<string>& patterns, string word) {",
"container": "Solution",
"callable": "numOfStrings",
"parameters": [
{
"name": "patterns",
"type": "vector<string>&"
},
{
"name": "word",
"type": "string"
}
],
"return_type": "int",
"sig... |
1,968 | array-with-elements-not-equal-to-average-of-neighbors | Medium | You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.
More formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length -... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 100000, 50000, 25000, 75000]) == [0, 75000, 25000, 100000, 50000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == [1, 9, 3, 11, 5, 13,... | [
"[1,2,3,4,5]",
"[6,2,0,9,7]"
] | [
"A number can be the average of its neighbors if one neighbor is smaller than the number and the other is greater than the number.",
"We can put numbers smaller than the median on odd indices and the rest on even indices."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().rearrangeArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:43",
"tests_total": 115,
"tests_... | cpp | {
"raw_signature": "vector<int> rearrangeArray(vector<int>& nums) {",
"container": "Solution",
"callable": "rearrangeArray",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetco... |
1,970 | last-day-where-you-can-still-cross | Hard | There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.
Initially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(row = 3,col = 3,cells = [[1, 2], [2, 1], [3, 3], [2, 2], [1, 1], [1, 3], [2, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 3,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3],... | [
"2\n2\n[[1,1],[2,1],[1,2],[2,2]]",
"2\n2\n[[1,1],[1,2],[2,1],[2,2]]",
"3\n3\n[[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]"
] | [
"What graph algorithm allows us to find whether a path exists?",
"Can we use binary search to help us solve the problem?"
] | {
"canonical_parameter_names": [
"row",
"col",
"cells"
],
"leetcode_dataset_entry_point": "Solution().latestDayToCross",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:46",
"tes... | cpp | {
"raw_signature": "int latestDayToCross(int row, int col, vector<vector<int>>& cells) {",
"container": "Solution",
"callable": "latestDayToCross",
"parameters": [
{
"name": "row",
"type": "int"
},
{
"name": "col",
"type": "int"
},
{
"name": "cells",
"type... |
1,974 | minimum-time-to-type-word-using-special-typewriter | Easy | There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.
Each second, you may perform one of the following operations:
- Move the poin... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aaabbbccc\") == 11\n assert candidate(word = \"zyxwvut\") == 14\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 178\n assert candidate(wo... | [
"\"abc\"",
"\"bza\"",
"\"zjpc\""
] | [
"There are only two possible directions you can go when you move to the next letter.",
"When moving to the next letter, you will always go in the direction that takes the least amount of time."
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().minTimeToType",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:53",
"tests_total": 129,
"tests_d... | cpp | {
"raw_signature": "int minTimeToType(string word) {",
"container": "Solution",
"callable": "minTimeToType",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,975 | maximum-matrix-sum | Medium | You are given an n x n integer matrix. You can do the following operation any number of times:
- Choose any two adjacent elements of matrix and multiply each of them by -1.
Two elements are considered adjacent if and only if they share a border.
Your goal is to maximize the summation of the matrix's elements. Return... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [3, 4]]) == 10\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2], [3, -4]]) == 8\n assert candidate(matrix = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]... | [
"[[1,-1],[-1,1]]",
"[[1,2,3],[-1,-2,-3],[1,2,3]]"
] | [
"Try to use the operation so that each row has only one negative number.",
"If you have only one negative element you cannot convert it to positive."
] | {
"canonical_parameter_names": [
"matrix"
],
"leetcode_dataset_entry_point": "Solution().maxMatrixSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:55",
"tests_total": 85,
"tests_d... | cpp | {
"raw_signature": "long long maxMatrixSum(vector<vector<int>>& matrix) {",
"container": "Solution",
"callable": "maxMatrixSum",
"parameters": [
{
"name": "matrix",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_sour... |
1,976 | number-of-ways-to-arrive-at-destination | Medium | You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.
You are given an integer n an... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 4], [0, 3, 3], [0, 4, 10], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 3], [2, 4, 5], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) == 1\n as... | [
"7\n[[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]",
"2\n[[1,0,10]]"
] | [
"First use any shortest path algorithm to get edges where dist[u] + weight = dist[v], here dist[x] is the shortest distance between node 0 and x",
"Using those edges only the graph turns into a dag now we just need to know the number of ways to get from node 0 to node n - 1 on a dag using dp"
] | {
"canonical_parameter_names": [
"n",
"roads"
],
"leetcode_dataset_entry_point": "Solution().countPaths",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:36:58",
"tests_total": 64,
"t... | cpp | {
"raw_signature": "int countPaths(int n, vector<vector<int>>& roads) {",
"container": "Solution",
"callable": "countPaths",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "roads",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_sourc... |
1,977 | number-of-ways-to-separate-numbers | Hard | You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.
Return the number of possible lists of integers that you could have writt... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = \"327\") == 2\n assert candidate(num = \"11110000111100001111\") == 30\n assert candidate(num = \"3333333333\") == 42\n assert candidate(num = \"123456789012345678901234567890\") == 1451\n assert candidate(num = \"0\") ... | [
"\"327\"",
"\"094\"",
"\"0\""
] | [
"If we know the current number has d digits, how many digits can the previous number have?",
"Is there a quick way of calculating the number of possibilities for the previous number if we know that it must have less than or equal to d digits? Try to do some pre-processing."
] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().numberOfCombinations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:00",
"tests_total": 105,
"t... | cpp | {
"raw_signature": "int numberOfCombinations(string num) {",
"container": "Solution",
"callable": "numberOfCombinations",
"parameters": [
{
"name": "num",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,979 | find-greatest-common-divisor-of-array | Easy | Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.
The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.
Example 1:
Input: nums = [2,5,6,9,10]
Output: 2
Explanation:
The smallest number in nums is 2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [42, 56, 14]) == 14\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 23, 37, 41]) == 1\n assert candidate(nums = [3, 3]) == 3\n assert candidate(nums = [7, 5, 6, 8, 3]) == 1\n assert candidat... | [
"[2,5,6,9,10]",
"[7,5,6,8,3]",
"[3,3]"
] | [
"Find the minimum and maximum in one iteration. Let them be mn and mx.",
"Try all the numbers in the range [1, mn] and check the largest number which divides both of them."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findGCD",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:02",
"tests_total": 117,
"tests_dropped... | cpp | {
"raw_signature": "int findGCD(vector<int>& nums) {",
"container": "Solution",
"callable": "findGCD",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
1,980 | find-unique-binary-string | Medium | Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.
Example 1:
Input: nums = ["01","10"]
Output: "11"
Explanation: "11" does not appear in nums. "00" would also b... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = ['01', '10']) == \"00\"\n assert candidate(nums = ['00', '01']) == \"11\"\n assert candidate(nums = ['111', '011', '001']) == \"000\"\n assert candidate(nums = ['1101', '1011', '0111', '0011']) == \"0000\"\n assert can... | [
"[\"01\",\"10\"]",
"[\"00\",\"01\"]",
"[\"111\",\"011\",\"001\"]"
] | [
"We can convert the given strings into base 10 integers.",
"Can we use recursion to generate all possible strings?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findDifferentBinaryString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:04",
"tests_total": 54,... | cpp | {
"raw_signature": "string findDifferentBinaryString(vector<string>& nums) {",
"container": "Solution",
"callable": "findDifferentBinaryString",
"parameters": [
{
"name": "nums",
"type": "vector<string>&"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"typ... |
1,981 | minimize-the-difference-between-target-and-chosen-elements | Medium | You are given an m x n integer matrix mat and an integer target.
Choose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.
Return the minimum absolute difference.
The absolute difference between two numbers a and b is the absolute... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1], [2], [3]],target = 100) == 94\n assert candidate(mat = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 13) == 0\n assert candidate(mat = [[7, 8,... | [
"[[1,2,3],[4,5,6],[7,8,9]]\n13",
"[[1],[2],[3]]\n100",
"[[1,2,9,8,7]]\n6"
] | [
"The sum of chosen elements will not be too large. Consider using a hash set to record all possible sums while iterating each row.",
"Instead of keeping track of all possible sums, since in each row, we are adding positive numbers, only keep those that can be a candidate, not exceeding the target by too much."
] | {
"canonical_parameter_names": [
"mat",
"target"
],
"leetcode_dataset_entry_point": "Solution().minimizeTheDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:07",
"tests_to... | cpp | {
"raw_signature": "int minimizeTheDifference(vector<vector<int>>& mat, int target) {",
"container": "Solution",
"callable": "minimizeTheDifference",
"parameters": [
{
"name": "mat",
"type": "vector<vector<int>>&"
},
{
"name": "target",
"type": "int"
}
],
"return_type... |
1,982 | find-array-given-subset-sums | Hard | You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2^n subset sums of the unknown array (in no particular order).
Return the array ans of length n representing the unknown array. If multiple answers exist,... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3,sums = [-3, -2, -1, 0, 0, 1, 2, 3]) == [-1, -2, 3]\n assert candidate(n = 2,sums = [0, 0, 0, 0]) == [0, 0]\n assert candidate(n = 1,sums = [0, 5]) == [5]\n assert candidate(n = 3,sums = [3, 1, 2, 0, 4, 5, 6, 8]) == [1, 2, ... | [
"3\n[-3,-2,-1,0,0,1,2,3]",
"2\n[0,0,0,0]",
"4\n[0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]"
] | [
"What information do the two largest elements tell us?",
"Can we use recursion to check all possible states?"
] | {
"canonical_parameter_names": [
"n",
"sums"
],
"leetcode_dataset_entry_point": "Solution().recoverArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:09",
"tests_total": 89,
"... | cpp | {
"raw_signature": "vector<int> recoverArray(int n, vector<int>& sums) {",
"container": "Solution",
"callable": "recoverArray",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "sums",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_sou... |
1,984 | minimum-difference-between-highest-and-lowest-of-k-scores | Easy | You are given a 0-indexed integer array nums, where nums[i] represents the score of the i^th student. You are also given an integer k.
Pick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.
Return the minimum possible difference.
Examp... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [4, 9, 1, 32, 13],k = 3) == 8\n assert candidate(nums = [1, 5, 6, 14, 15],k = 3) == 5\n assert candidate(nums = [9, 4, 1, 7],k = 2) == 2\n assert candidate(nums = [8, 10, 2],k = 2) == 2\n assert candidate(nums = [1, 5,... | [
"[90]\n1",
"[9,4,1,7]\n2"
] | [
"For the difference between the highest and lowest element to be minimized, the k chosen scores need to be as close to each other as possible.",
"What if the array was sorted?",
"After sorting the scores, any contiguous k scores are as close to each other as possible.",
"Apply a sliding window solution to ite... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().minimumDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:14",
"tests_total": 95... | cpp | {
"raw_signature": "int minimumDifference(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "minimumDifference",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": ... |
1,985 | find-the-kth-largest-integer-in-the-array | Medium | You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.
Return the string that represents the k^th largest integer in nums.
Note: Duplicate numbers should be counted distinctly. For example, if nums is ["1","2","2"], "2" is the first largest integer, "... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = ['100', '200', '300', '400', '500'],k = 2) == \"400\"\n assert candidate(nums = ['2', '21', '12', '1'],k = 3) == \"2\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 5) == \"5\"\n assert candi... | [
"[\"3\",\"6\",\"7\",\"10\"]\n4",
"[\"2\",\"21\",\"12\",\"1\"]\n3",
"[\"0\",\"0\"]\n2"
] | [
"If two numbers have different lengths, which one will be larger?",
"The longer number is the larger number.",
"If two numbers have the same length, which one will be larger?",
"Compare the two numbers starting from the most significant digit. Once you have found the first digit that differs, the one with the... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().kthLargestNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:16",
"tests_total": 113... | cpp | {
"raw_signature": "string kthLargestNumber(vector<string>& nums, int k) {",
"container": "Solution",
"callable": "kthLargestNumber",
"parameters": [
{
"name": "nums",
"type": "vector<string>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "string",
"signature... |
1,986 | minimum-number-of-work-sessions-to-finish-the-tasks | Medium | There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the i^th task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.
You should finish the given tasks in a way that satisfies the fol... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tasks = [1, 3, 2, 4],sessionTime = 5) == 2\n assert candidate(tasks = [5, 7, 4, 2, 6],sessionTime = 10) == 3\n assert candidate(tasks = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 3],... | [
"[1,2,3]\n3",
"[3,1,3,1,1]\n8",
"[1,2,3,4,5]\n15"
] | [
"Try all possible ways of assignment.",
"If we can store the assignments in form of a state then we can reuse that state and solve the problem in a faster way."
] | {
"canonical_parameter_names": [
"tasks",
"sessionTime"
],
"leetcode_dataset_entry_point": "Solution().minSessions",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:19",
"tests_total... | cpp | {
"raw_signature": "int minSessions(vector<int>& tasks, int sessionTime) {",
"container": "Solution",
"callable": "minSessions",
"parameters": [
{
"name": "tasks",
"type": "vector<int>&"
},
{
"name": "sessionTime",
"type": "int"
}
],
"return_type": "int",
"signature... |
1,987 | number-of-unique-good-subsequences | Hard | You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of "0").
Find the number of unique good subsequences of binary.
- For example, if binary = "001", then all the good subsequences are ["0", "0", "1"], so the unique good subs... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(binary = \"101\") == 5\n assert candidate(binary = \"1111\") == 4\n assert candidate(binary = \"1\") == 1\n assert candidate(binary = \"010101\") == 13\n assert candidate(binary = \"111000111\") == 43\n assert candidate(bi... | [
"\"001\"",
"\"11\"",
"\"101\""
] | [
"The number of unique good subsequences is equal to the number of unique decimal values there are for all possible subsequences.",
"Find the answer at each index based on the previous indexes' answers."
] | {
"canonical_parameter_names": [
"binary"
],
"leetcode_dataset_entry_point": "Solution().numberOfUniqueGoodSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:21",
"tests_tota... | cpp | {
"raw_signature": "int numberOfUniqueGoodSubsequences(string binary) {",
"container": "Solution",
"callable": "numberOfUniqueGoodSubsequences",
"parameters": [
{
"name": "binary",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source":... |
1,991 | find-the-middle-index-in-array | Easy | Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).
A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].
If middleIndex == 0, the left side sum is cons... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, -1, 4]) == 2\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 100]) == -1\n assert candidate(nums = [0, 1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [... | [
"[2,3,-1,8,4]",
"[1,-1,4]",
"[2,5]"
] | [
"Could we go from left to right and check to see if an index is a middle index?",
"Do we need to sum every number to the left and right of an index each time?",
"Use a prefix sum array where prefix[i] = nums[0] + nums[1] + ... + nums[i]."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findMiddleIndex",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:25",
"tests_total": 94,
"tests_... | cpp | {
"raw_signature": "int findMiddleIndex(vector<int>& nums) {",
"container": "Solution",
"callable": "findMiddleIndex",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippet... |
1,992 | find-all-groups-of-farmland | Medium | You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.
To keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adj... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[[1,0,0],[0,1,1],[0,1,1]]",
"[[1,1],[1,1]]",
"[[0]]"
] | [
"Since every group of farmland is rectangular, the top left corner of each group will have the smallest x-coordinate and y-coordinate of any farmland in the group.",
"Similarly, the bottom right corner of each group will have the largest x-coordinate and y-coordinate of any farmland in the group.",
"Use DFS to ... | {
"canonical_parameter_names": [
"land"
],
"leetcode_dataset_entry_point": "Solution().findFarmland",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:28",
"tests_total": 74,
"tests_dro... | cpp | {
"raw_signature": "vector<vector<int>> findFarmland(vector<vector<int>>& land) {",
"container": "Solution",
"callable": "findFarmland",
"parameters": [
{
"name": "land",
"type": "vector<vector<int>>&"
}
],
"return_type": "vector<vector<int>>",
"signature_source": "leetcode/codeSnippet... |
1,994 | the-number-of-good-subsets | Hard | You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.
- For example, if nums = [1, 2, 3, 4]:
- [2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.
- [1, 4] and [4] a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]... | [
"[1,2,3,4]",
"[4,2,3,15]"
] | [
"Consider only the numbers which have a good prime factorization.",
"Use brute force to find all possible good subsets and then calculate its frequency in nums."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().numberOfGoodSubsets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:30",
"tests_total": 108,
"t... | cpp | {
"raw_signature": "int numberOfGoodSubsets(vector<int>& nums) {",
"container": "Solution",
"callable": "numberOfGoodSubsets",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/cod... |
1,995 | count-special-quadruplets | Easy | Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:
- nums[a] + nums[b] + nums[c] == nums[d], and
- a < b < c < d
Example 1:
Input: nums = [1,2,3,6]
Output: 1
Explanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.
E... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 6]) == 1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(... | [
"[1,2,3,6]",
"[3,3,6,4,5]",
"[1,1,1,3,5]"
] | [
"N is very small, how can we use that?",
"Can we check every possible quadruplet?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countQuadruplets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:32",
"tests_total": 107,
"test... | cpp | {
"raw_signature": "int countQuadruplets(vector<int>& nums) {",
"container": "Solution",
"callable": "countQuadruplets",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnipp... |
1,996 | the-number-of-weak-characters-in-the-game | Medium | You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attack_i, defense_i] represents the properties of the i^th character in the game.
A character is said to be weak if any ot... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1]]) == 2\n assert candidate(properties = [[2, 2], [3, 3]]) == 1\n assert candidate(properties = [[5, 1], [5, 10], [4, 10], [4, 4], [3, 14], [3, 6], [2, 10], [1, 14], [1, 4]]) == 4\... | [
"[[5,5],[6,3],[3,6]]",
"[[2,2],[3,3]]",
"[[1,5],[10,4],[4,3]]"
] | [
"Sort the array on the basis of the attack values and group characters with the same attack together. How can you use these groups?",
"Characters in one group will always have a lesser attack value than the characters of the next group. Hence, we will only need to check if there is a higher defense value present ... | {
"canonical_parameter_names": [
"properties"
],
"leetcode_dataset_entry_point": "Solution().numberOfWeakCharacters",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:35",
"tests_total": ... | cpp | {
"raw_signature": "int numberOfWeakCharacters(vector<vector<int>>& properties) {",
"container": "Solution",
"callable": "numberOfWeakCharacters",
"parameters": [
{
"name": "properties",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippet... |
1,997 | first-day-where-you-have-been-in-all-the-rooms | Medium | There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.
Initially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:
-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nextVisit = [0, 0, 2]) == 6\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5]) == 10\n assert candidate(nextVisit = [0, 1, 1, 1, 1]) == 16\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candid... | [
"[0,0]",
"[0,0,2]",
"[0,1,2,0]"
] | [
"The only way to get to room i+1 is when you are visiting room i and room i has been visited an even number of times.",
"After visiting room i an odd number of times, you are required to visit room nextVisit[i] where nextVisit[i] <= i. It takes a fixed amount of days for you to come back from room nextVisit[i] to... | {
"canonical_parameter_names": [
"nextVisit"
],
"leetcode_dataset_entry_point": "Solution().firstDayBeenInAllRooms",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:38",
"tests_total": 1... | cpp | {
"raw_signature": "int firstDayBeenInAllRooms(vector<int>& nextVisit) {",
"container": "Solution",
"callable": "firstDayBeenInAllRooms",
"parameters": [
{
"name": "nextVisit",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source... |
1,998 | gcd-sort-of-an-array | Hard | You are given an integer array nums, and you can perform the following operation any number of times on nums:
- Swap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].
Return true if it is possible to sort n... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [12, 15, 18, 20, 25]) == True\n assert candidate(nums = [7, 21, 3]) == True\n assert candidate(nums = [8, 4, 12, 6]) == True\n assert candidate(nums = [2, 3, 5, 7, 11]) == True\n assert candidate(nums = [2, 4, 6, 8, 10... | [
"[7,21,3]",
"[5,2,6,2]",
"[10,5,9,3,15]"
] | [
"Can we build a graph with all the prime numbers and the original array?",
"We can use union-find to determine which indices are connected (i.e., which indices can be swapped)."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().gcdSort",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:40",
"tests_total": 168,
"tests_dropped... | cpp | {
"raw_signature": "bool gcdSort(vector<int>& nums) {",
"container": "Solution",
"callable": "gcdSort",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,000 | reverse-prefix-of-word | Easy | Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.
- For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that starts ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"abcdef\",ch = \"f\") == \"fedcba\"\n assert candidate(word = \"madam\",ch = \"d\") == \"damam\"\n assert candidate(word = \"abcdefd\",ch = \"d\") == \"dcbaefd\"\n assert candidate(word = \"abcd\",ch = \"z\") == \"abcd\"... | [
"\"abcdefd\"\n\"d\"",
"\"xyxzxe\"\n\"z\"",
"\"abcd\"\n\"z\""
] | [
"Find the first index where ch appears.",
"Find a way to reverse a substring of word."
] | {
"canonical_parameter_names": [
"word",
"ch"
],
"leetcode_dataset_entry_point": "Solution().reversePrefix",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:44",
"tests_total": 133,
... | cpp | {
"raw_signature": "string reversePrefix(string word, char ch) {",
"container": "Solution",
"callable": "reversePrefix",
"parameters": [
{
"name": "word",
"type": "string"
},
{
"name": "ch",
"type": "char"
}
],
"return_type": "string",
"signature_source": "leetcode/... |
2,001 | number-of-pairs-of-interchangeable-rectangles | Medium | You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [width_i, height_i] denotes the width and height of the i^th rectangle.
Two rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [20, 40], [40, 80]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate... | [
"[[4,8],[3,6],[10,20],[15,30]]",
"[[4,5],[7,8]]"
] | [
"Store the rectangle height and width ratio in a hashmap.",
"Traverse the ratios, and for each ratio, use the frequency of the ratio to add to the total pair count."
] | {
"canonical_parameter_names": [
"rectangles"
],
"leetcode_dataset_entry_point": "Solution().interchangeableRectangles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:47",
"tests_total... | cpp | {
"raw_signature": "long long interchangeableRectangles(vector<vector<int>>& rectangles) {",
"container": "Solution",
"callable": "interchangeableRectangles",
"parameters": [
{
"name": "rectangles",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "le... |
2,002 | maximum-product-of-the-length-of-two-palindromic-subsequences | Medium | Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.
Return the maximum possible product of the lengths of the two palindromic subsequences.
A subsequence is a st... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"xyzyx\") == 6\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaa\") == 4\n assert candidate(s = \"accbcaxxcxx\") == 25\n assert candidate(s = \"madam\") == 6\n assert candidate(s = \"noon\") == 4\n... | [
"\"leetcodecom\"",
"\"bb\"",
"\"accbcaxxcxx\""
] | [
"Could you generate all possible pairs of disjoint subsequences?",
"Could you find the maximum length palindrome in each subsequence for a pair of disjoint subsequences?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().maxProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:49",
"tests_total": 81,
"tests_dropped"... | cpp | {
"raw_signature": "int maxProduct(string s) {",
"container": "Solution",
"callable": "maxProduct",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,003 | smallest-missing-genetic-value-in-each-subtree | Hard | There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.
There are 10^5 genetic values, each represented by an integer in the inclusive range [1, 10^5]. You are g... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2],nums = [1, 2, 3, 4]) == [5, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3],nums = [5, 4, 6, 2, 1, 3]) == [7, 1, 1, 4, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],nums = [1, 2, 3, 4, ... | [
"[-1,0,0,2]\n[1,2,3,4]",
"[-1,0,1,0,3,3]\n[5,4,6,2,1,3]",
"[-1,2,3,0,2,4,1]\n[2,3,4,5,6,7,8]"
] | [
"If the subtree doesn't contain 1, then the missing value will always be 1.",
"What data structure allows us to dynamically update the values that are currently not present?"
] | {
"canonical_parameter_names": [
"parents",
"nums"
],
"leetcode_dataset_entry_point": "Solution().smallestMissingValueSubtree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:52",
"... | cpp | {
"raw_signature": "vector<int> smallestMissingValueSubtree(vector<int>& parents, vector<int>& nums) {",
"container": "Solution",
"callable": "smallestMissingValueSubtree",
"parameters": [
{
"name": "parents",
"type": "vector<int>&"
},
{
"name": "nums",
"type": "vector<int>&"... |
2,006 | count-number-of-pairs-with-absolute-difference-k | Easy | Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.
The value of |x| is defined as:
- x if x >= 0.
- -x if x < 0.
Example 1:
Input: nums = [1,2,2,1], k = 1
Output: 4
Explanation: The pairs with an absolute difference of 1 are:
- [1,2,2,1]
-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [100, 1, 100, 1, 100],k = 99) == 6\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == 1\n assert candidate(nums = [3, 2, 1, 5, 4],k = 2) == 3\n assert candidate(nums = [5, 1, 4, 1],k = 2) == 0\n assert candidate(nums ... | [
"[1,2,2,1]\n1",
"[1,3]\n3",
"[3,2,1,5,4]\n2"
] | [
"Can we check every possible pair?",
"Can we use a nested for loop to solve this problem?"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().countKDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:56",
"tests_total": 106... | cpp | {
"raw_signature": "int countKDifference(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "countKDifference",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "l... |
2,007 | find-original-array-from-doubled-array | Medium | An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.
Given an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[1,3,4,2,6,8]",
"[6,3,0,1]",
"[1]"
] | [
"If changed is a doubled array, you should be able to delete elements and their doubled values until the array is empty.",
"Which element is guaranteed to not be a doubled value? It is the smallest element.",
"After removing the smallest element and its double from changed, is there another number that is guara... | {
"canonical_parameter_names": [
"changed"
],
"leetcode_dataset_entry_point": "Solution().findOriginalArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:37:59",
"tests_total": 124,
"... | cpp | {
"raw_signature": "vector<int> findOriginalArray(vector<int>& changed) {",
"container": "Solution",
"callable": "findOriginalArray",
"parameters": [
{
"name": "changed",
"type": "vector<int>&"
}
],
"return_type": "vector<int>",
"signature_source": "leetcode/codeSnippets",
"type_sour... |
2,008 | maximum-earnings-from-taxi | Medium | There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.
The passengers are represented by a 0-indexed 2D... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 100,rides = [[1, 10, 50], [20, 30, 25], [50, 60, 100], [70, 80, 75], [90, 100, 200]]) == 499\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 6, 1]]) == 7\n assert candidate(n = 30,rides = [[1, 10, 10], [10, 20, 10]... | [
"5\n[[2,5,4],[1,5,1]]",
"20\n[[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]"
] | [
"Can we sort the array to help us solve the problem?",
"We can use dynamic programming to keep track of the maximum at each position."
] | {
"canonical_parameter_names": [
"n",
"rides"
],
"leetcode_dataset_entry_point": "Solution().maxTaxiEarnings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:02",
"tests_total": 71,... | cpp | {
"raw_signature": "long long maxTaxiEarnings(int n, vector<vector<int>>& rides) {",
"container": "Solution",
"callable": "maxTaxiEarnings",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "rides",
"type": "vector<vector<int>>&"
}
],
"return_type": "long lon... |
2,009 | minimum-number-of-operations-to-make-array-continuous | Hard | You are given an integer array nums. In one operation, you can replace any element in nums with any integer.
nums is considered continuous if both of the following conditions are fulfilled:
- All elements in nums are unique.
- The difference between the maximum element and the minimum element in nums equals nums.leng... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 3\n assert candidate(nums = [4, 2, 5, 3]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = ... | [
"[4,2,5,3]",
"[1,2,3,5,6]",
"[1,10,100,1000]"
] | [
"Sort the array.",
"For every index do a binary search to get the possible right end of the window and calculate the possible answer."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:04",
"tests_total": 136,
"tests_d... | cpp | {
"raw_signature": "int minOperations(vector<int>& nums) {",
"container": "Solution",
"callable": "minOperations",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,011 | final-value-of-variable-after-performing-operations | Easy | There is a programming language with only four operations and one variable X:
- ++X and X++ increments the value of the variable X by 1.
- --X and X-- decrements the value of the variable X by 1.
Initially, the value of X is 0.
Given an array of strings operations containing a list of operations, return the final va... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(operations = ['X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++']) == 5\n assert candidate(operations = ['--X', '--X', 'X--', 'X--']) == -4\n assert candidate(operations = ['++X'... | [
"[\"--X\",\"X++\",\"X++\"]",
"[\"++X\",\"++X\",\"X++\"]",
"[\"X++\",\"++X\",\"--X\",\"X--\"]"
] | [
"There are only two operations to keep track of.",
"Use a variable to store the value after each operation."
] | {
"canonical_parameter_names": [
"operations"
],
"leetcode_dataset_entry_point": "Solution().finalValueAfterOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:07",
"tests_total... | cpp | {
"raw_signature": "int finalValueAfterOperations(vector<string>& operations) {",
"container": "Solution",
"callable": "finalValueAfterOperations",
"parameters": [
{
"name": "operations",
"type": "vector<string>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
... |
2,012 | sum-of-beauty-in-the-array | Medium | You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:
- 2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.
- 1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.
- 0, if none o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 100, 8, 6, 90, 101]) == 1\n assert candidate(nums = [9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candida... | [
"[1,2,3]",
"[2,4,6,4]",
"[3,2,1]"
] | [
"Use suffix/prefix arrays.",
"prefix[i] records the maximum value in range (0, i - 1) inclusive.",
"suffix[i] records the minimum value in range (i + 1, n - 1) inclusive."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().sumOfBeauties",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:09",
"tests_total": 136,
"tests_d... | cpp | {
"raw_signature": "int sumOfBeauties(vector<int>& nums) {",
"container": "Solution",
"callable": "sumOfBeauties",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,014 | longest-subsequence-repeated-k-times | Hard | You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.
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.
A subsequence seq is repeated... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"aabbcc\",k = 3) == \"\"\n assert candidate(s = \"zzzzzzzzz\",k = 4) == \"zz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"abcabcabcabc\",k = 4) == \"abc\"\n assert candidate(s = \"abc... | [
"\"letsleetcode\"\n2",
"\"bb\"\n2",
"\"ab\"\n2"
] | [
"The length of the longest subsequence does not exceed n/k. Do you know why?",
"Find the characters that could be included in the potential answer. A character occurring more than or equal to k times can be used in the answer up to (count of the character / k) times.",
"Try all possible candidates in reverse le... | {
"canonical_parameter_names": [
"s",
"k"
],
"leetcode_dataset_entry_point": "Solution().longestSubsequenceRepeatedK",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:11",
"tests_tot... | cpp | {
"raw_signature": "string longestSubsequenceRepeatedK(string s, int k) {",
"container": "Solution",
"callable": "longestSubsequenceRepeatedK",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "string",
"signature_s... |
2,016 | maximum-difference-between-increasing-elements | Easy | Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].
Return the maximum difference. If no such i and j exists, return -1.
Example 1:
Input: nums = [7,1,5,4]
Output: 4
Explanation:
The maximum... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [9, 4, 3, 2]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 999999999]) == 999999998\n assert candidate(nums = [1, 100, 1, 100, 1]) == 99\n assert candidate(nums = [100, 90, 80... | [
"[7,1,5,4]",
"[9,4,3,2]",
"[1,5,2,10]"
] | [
"Could you keep track of the minimum element visited while traversing?",
"We have a potential candidate for the answer if the prefix min is less than nums[i]."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maximumDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:16",
"tests_total": 118,
"tes... | cpp | {
"raw_signature": "int maximumDifference(vector<int>& nums) {",
"container": "Solution",
"callable": "maximumDifference",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSni... |
2,017 | grid-game | Medium | You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.
Both robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[1, 3, 1, 15], [1, 3, 3, 1]]) == 7\n assert candidate(grid = [[2, 5, 4], [1, 5, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [1, 1, 1]]) == 2\n ... | [
"[[2,5,4],[1,5,1]]",
"[[3,3,1],[8,5,2]]",
"[[1,3,1,15],[1,3,3,1]]"
] | [
"There are n choices for when the first robot moves to the second row.",
"Can we use prefix sums to help solve this problem?"
] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().gridGame",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:19",
"tests_total": 75,
"tests_dropped... | cpp | {
"raw_signature": "long long gridGame(vector<vector<int>>& grid) {",
"container": "Solution",
"callable": "gridGame",
"parameters": [
{
"name": "grid",
"type": "vector<vector<int>>&"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetco... |
2,018 | check-if-word-can-be-placed-in-crossword | Medium | You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.
A word can be placed horizontally (left to right or right to left) or vertically (to... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a'], ['b'], ['c'], ['d'], ['e']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'... | [
"[[\"#\",\" \",\"#\"],[\" \",\" \",\"#\"],[\"#\",\"c\",\" \"]]\n\"abc\"",
"[[\" \",\"#\",\"a\"],[\" \",\"#\", \"c\"],[\" \",\"#\",\"a\"]]\n\"ac\"",
"[[\"#\",\" \",\"#\"],[\" \",\" \",\"#\"],[\"#\",\" \",\"c\"]]\n\"ca\""
] | [
"Check all possible placements for the word.",
"There is a limited number of places where a word can start."
] | {
"canonical_parameter_names": [
"board",
"word"
],
"leetcode_dataset_entry_point": "Solution().placeWordInCrossword",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:22",
"tests_tot... | cpp | {
"raw_signature": "bool placeWordInCrossword(vector<vector<char>>& board, string word) {",
"container": "Solution",
"callable": "placeWordInCrossword",
"parameters": [
{
"name": "board",
"type": "vector<vector<char>>&"
},
{
"name": "word",
"type": "string"
}
],
"retu... |
2,019 | the-score-of-students-solving-math-expression | Hard | You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by followi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"3+5*2\",answers = [13, 0, 10, 13, 13, 16, 16]) == 19\n assert candidate(s = \"1+2*3+4*5\",answers = [14, 23, 13, 47, 23, 53]) == 2\n assert candidate(s = \"7+3*1*2\",answers = [20, 13, 42]) == 7\n assert candidate(s = \"5*... | [
"\"7+3*1*2\"\n[20,13,42]",
"\"3+5*2\"\n[13,0,10,13,13,16,16]",
"\"6+0*1\"\n[12,9,6,4,8,6]"
] | [
"The number of operators in the equation is less. Could you find the right answer then generate all possible answers using different orders of operations?",
"Divide the equation into blocks separated by the operators, and use memoization on the results of blocks for optimization.",
"Use set and the max limit of... | {
"canonical_parameter_names": [
"s",
"answers"
],
"leetcode_dataset_entry_point": "Solution().scoreOfStudents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:24",
"tests_total": 1... | cpp | {
"raw_signature": "int scoreOfStudents(string s, vector<int>& answers) {",
"container": "Solution",
"callable": "scoreOfStudents",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "answers",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_s... |
2,022 | convert-1d-array-into-2d-array | Easy | You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.
The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the construc... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12],m = 4,n = 2) == [[5, 6], [7, 8], [9, 10], [11, 12]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,n = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(original = [9... | [
"[1,2,3,4]\n2\n2",
"[1,2,3]\n1\n3",
"[1,2]\n1\n1"
] | [
"When is it possible to convert original into a 2D array and when is it impossible?",
"It is possible if and only if m * n == original.length",
"If it is possible to convert original to a 2D array, keep an index i such that original[i] is the next element to add to the 2D array."
] | {
"canonical_parameter_names": [
"original",
"m",
"n"
],
"leetcode_dataset_entry_point": "Solution().construct2DArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:29",
"test... | cpp | {
"raw_signature": "vector<vector<int>> construct2DArray(vector<int>& original, int m, int n) {",
"container": "Solution",
"callable": "construct2DArray",
"parameters": [
{
"name": "original",
"type": "vector<int>&"
},
{
"name": "m",
"type": "int"
},
{
"name": "... |
2,023 | number-of-pairs-of-strings-with-concatenation-equal-to-target | Medium | Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.
Example 1:
Input: nums = ["777","7","77","77"], target = "7777"
Output: 4
Explanation: Valid pairs are:
- (0, 1): "777" + "7"
- (1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = ['777', '7', '77', '77'],target = \"7777\") == 4\n assert candidate(nums = ['10', '11', '1'],target = \"101\") == 1\n assert candidate(nums = ['1234', '56', '78', '9'],target = \"123456\") == 1\n assert candidate(nums = [... | [
"[\"777\",\"7\",\"77\",\"77\"]\n\"7777\"",
"[\"123\",\"4\",\"12\",\"34\"]\n\"1234\"",
"[\"1\",\"1\",\"1\"]\n\"11\""
] | [
"Try to concatenate every two different strings from the list.",
"Count the number of pairs with concatenation equals to target."
] | {
"canonical_parameter_names": [
"nums",
"target"
],
"leetcode_dataset_entry_point": "Solution().numOfPairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:31",
"tests_total": 127,... | cpp | {
"raw_signature": "int numOfPairs(vector<string>& nums, string target) {",
"container": "Solution",
"callable": "numOfPairs",
"parameters": [
{
"name": "nums",
"type": "vector<string>&"
},
{
"name": "target",
"type": "string"
}
],
"return_type": "int",
"signature_s... |
2,024 | maximize-the-confusion-of-an-exam | Medium | A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).
You are given a string answerKey, where answerKey[i] is the origi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(answerKey = \"TTTTFFFF\",k = 2) == 6\n assert candidate(answerKey = \"FFFFFF\",k = 3) == 6\n assert candidate(answerKey = \"TFFTFFTFFTFT\",k = 3) == 10\n assert candidate(answerKey = \"TFTFTFTF\",k = 2) == 5\n assert candidat... | [
"\"TTFF\"\n2",
"\"TFFT\"\n1",
"\"TTFTTFTT\"\n1"
] | [
"Can we use the maximum length at the previous position to help us find the answer for the current position?",
"Can we use binary search to find the maximum consecutive same answer at every position?"
] | {
"canonical_parameter_names": [
"answerKey",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxConsecutiveAnswers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:34",
"tests_t... | cpp | {
"raw_signature": "int maxConsecutiveAnswers(string answerKey, int k) {",
"container": "Solution",
"callable": "maxConsecutiveAnswers",
"parameters": [
{
"name": "answerKey",
"type": "string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_sou... |
2,025 | maximum-number-of-ways-to-partition-an-array | Hard | You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:
- 1 <= pivot < n
- nums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]
You are also given an integer k. You can choose ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0],k = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100000, -100000, 100000, -100000],k = 0) == 1\n assert candid... | [
"[2,-1,2]\n3",
"[0,0,0]\n1",
"[22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14]\n-33"
] | [
"A pivot point splits the array into equal prefix and suffix. If no change is made to the array, the goal is to find the number of pivot p such that prefix[p-1] == suffix[p].",
"Consider how prefix and suffix will change when we change a number nums[i] to k.",
"When sweeping through each element, can you find t... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().waysToPartition",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:36",
"tests_total": 117,... | cpp | {
"raw_signature": "int waysToPartition(vector<int>& nums, int k) {",
"container": "Solution",
"callable": "waysToPartition",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "lee... |
2,027 | minimum-moves-to-convert-string | Easy | You are given a string s consisting of n characters which are either 'X' or 'O'.
A move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.
Return the minimum number of moves required so that all the characte... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"XXXXXXXXXX\") == 4\n assert candidate(s = \"OOXOOX\") == 2\n assert candidate(s = \"OOXOOXOOXO\") == 3\n assert candidate(s = \"OOXXOOXXOO\") == 2\n assert candidate(s = \"XXOX\") == 2\n assert candidate(s = \"OXOXOX... | [
"\"XXX\"",
"\"XXOX\"",
"\"OOOO\""
] | [
"Find the smallest substring you need to consider at a time.",
"Try delaying a move as long as possible."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().minimumMoves",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:39",
"tests_total": 166,
"tests_dropp... | cpp | {
"raw_signature": "int minimumMoves(string s) {",
"container": "Solution",
"callable": "minimumMoves",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,028 | find-missing-observations | Medium | You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.
You are given an integer array rolls of length m where rolls[i] is the va... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(rolls = [1, 2],mean = 3,n = 2) == [5, 4]\n assert candidate(rolls = [1, 3, 5],mean = 2,n = 2) == []\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 4) == [5, 5, 5, 5]\n assert candidate(rolls = [5, 6, 6, 6],mean = 5,n = 3) ... | [
"[3,2,4,3]\n4\n2",
"[1,5,6]\n3\n4",
"[1,2,3,4]\n6\n4"
] | [
"What should the sum of the n rolls be?",
"Could you generate an array of size n such that each element is between 1 and 6?"
] | {
"canonical_parameter_names": [
"rolls",
"mean",
"n"
],
"leetcode_dataset_entry_point": "Solution().missingRolls",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:41",
"tests_to... | cpp | {
"raw_signature": "vector<int> missingRolls(vector<int>& rolls, int mean, int n) {",
"container": "Solution",
"callable": "missingRolls",
"parameters": [
{
"name": "rolls",
"type": "vector<int>&"
},
{
"name": "mean",
"type": "int"
},
{
"name": "n",
"type"... |
2,029 | stone-game-ix | Medium | Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the i^th stone.
Alice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15]) == False\n assert candidate... | [
"[2,1]",
"[2]",
"[5,1,2,4,3]"
] | [
"There are limited outcomes given the current sum and the stones remaining.",
"Can we greedily simulate starting with taking a stone with remainder 1 or 2 divided by 3?"
] | {
"canonical_parameter_names": [
"stones"
],
"leetcode_dataset_entry_point": "Solution().stoneGameIX",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:44",
"tests_total": 108,
"tests_d... | cpp | {
"raw_signature": "bool stoneGameIX(vector<int>& stones) {",
"container": "Solution",
"callable": "stoneGameIX",
"parameters": [
{
"name": "stones",
"type": "vector<int>&"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"... |
2,030 | smallest-k-length-subsequence-with-occurrences-of-a-letter | Hard | You are given a string s, an integer k, a letter letter, and an integer repetition.
Return the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.
A subsequence is a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"bb\",k = 2,letter = \"b\",repetition = 2) == \"bb\"\n assert candidate(s = \"leetcode\",k = 4,letter = \"e\",repetition = 2) == \"ecde\"\n assert candidate(s = \"leet\",k = 3,letter = \"e\",repetition = 1) == \"eet\"\n ass... | [
"\"leet\"\n3\n\"e\"\n1",
"\"leetcode\"\n4\n\"e\"\n2",
"\"bb\"\n2\n\"b\"\n2"
] | [
"Use stack. For every character to be appended, decide how many character(s) from the stack needs to get popped based on the stack length and the count of the required character.",
"Pop the extra characters out from the stack and return the characters in the stack (reversed)."
] | {
"canonical_parameter_names": [
"s",
"k",
"letter",
"repetition"
],
"leetcode_dataset_entry_point": "Solution().smallestSubsequence",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30... | cpp | {
"raw_signature": "string smallestSubsequence(string s, int k, char letter, int repetition) {",
"container": "Solution",
"callable": "smallestSubsequence",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "k",
"type": "int"
},
{
"name": "letter",
... |
2,032 | two-out-of-three | Easy | Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.
Example 1:
Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]
Output: [3,2]
Explanation: The values that are present... | {
"language": "python",
"source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ... | [
"[1,1,3,2]\n[2,3]\n[3]",
"[3,1]\n[2,3]\n[1,2]",
"[1,2,2]\n[4,3,3]\n[5]"
] | [
"What data structure can we use to help us quickly find whether an element belongs in an array?",
"Can we count the frequencies of the elements in each array?"
] | {
"canonical_parameter_names": [
"nums1",
"nums2",
"nums3"
],
"leetcode_dataset_entry_point": "Solution().twoOutOfThree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:50",
"te... | cpp | {
"raw_signature": "vector<int> twoOutOfThree(vector<int>& nums1, vector<int>& nums2, vector<int>& nums3) {",
"container": "Solution",
"callable": "twoOutOfThree",
"parameters": [
{
"name": "nums1",
"type": "vector<int>&"
},
{
"name": "nums2",
"type": "vector<int>&"
},
... |
2,033 | minimum-operations-to-make-a-uni-value-grid | Medium | You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.
A uni-value grid is a grid where all the elements of it are equal.
Return the minimum number of operations to make the grid uni-value. If it is not possible, return -1.
Examp... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[1, 5], [2, 3]],x = 1) == 5\n assert candidate(grid = [[10, 10], [10, 10]],x = 5) == 0\n assert candidate(grid = [[10, 10], [10, 10]],x = 3) == 0\n assert candidate(grid = [[10, 12], [14, 16]],x = 2) == 4\n assert can... | [
"[[2,4],[6,8]]\n2",
"[[1,5],[2,3]]\n1",
"[[1,2],[3,4]]\n2"
] | [
"Is it possible to make two integers a and b equal if they have different remainders dividing by x?",
"If it is possible, which number should you select to minimize the number of operations?",
"What if the elements are sorted?"
] | {
"canonical_parameter_names": [
"grid",
"x"
],
"leetcode_dataset_entry_point": "Solution().minOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:53",
"tests_total": 95,
... | cpp | {
"raw_signature": "int minOperations(vector<vector<int>>& grid, int x) {",
"container": "Solution",
"callable": "minOperations",
"parameters": [
{
"name": "grid",
"type": "vector<vector<int>>&"
},
{
"name": "x",
"type": "int"
}
],
"return_type": "int",
"signature_s... |
2,035 | partition-array-into-two-arrays-to-minimize-sum-difference | Hard | You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.
Return the minimum possible absolute difference.
Example 1:
Input: nums ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [3, 9, 7, 3]) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0... | [
"[3,9,7,3]",
"[-36,36]",
"[2,-1,0,4,-2,-9]"
] | [
"The target sum for the two partitions is sum(nums) / 2.",
"Could you reduce the time complexity if you arbitrarily divide nums into two halves (two arrays)? Meet-in-the-Middle?",
"For both halves, pre-calculate a 2D array where the kth index will store all possible sum values if only k elements from this half ... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().minimumDifference",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:38:55",
"tests_total": 88,
"test... | cpp | {
"raw_signature": "int minimumDifference(vector<int>& nums) {",
"container": "Solution",
"callable": "minimumDifference",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSni... |
2,037 | minimum-number-of-moves-to-seat-everyone | Easy | There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the i^th seat. You are also given the array students of length n, where students[j] is the position of the j^th student.
You may perform the following move any number of times:
- I... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(seats = [5, 5, 5, 5],students = [5, 5, 5, 5]) == 0\n assert candidate(seats = [10, 20, 30],students = [5, 15, 25]) == 15\n assert candidate(seats = [4, 1, 5, 9],students = [1, 3, 2, 6]) == 7\n assert candidate(seats = [1, 1, 1, ... | [
"[3,1,5]\n[2,7,4]",
"[4,1,5,9]\n[1,3,2,6]",
"[2,2,6,6]\n[1,3,2,6]"
] | [
"Can we sort the arrays to help solve the problem?",
"Can we greedily match each student to a seat?",
"The smallest positioned student will go to the smallest positioned chair, and then the next smallest positioned student will go to the next smallest positioned chair, and so on."
] | {
"canonical_parameter_names": [
"seats",
"students"
],
"leetcode_dataset_entry_point": "Solution().minMovesToSeat",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:00",
"tests_total... | cpp | {
"raw_signature": "int minMovesToSeat(vector<int>& seats, vector<int>& students) {",
"container": "Solution",
"callable": "minMovesToSeat",
"parameters": [
{
"name": "seats",
"type": "vector<int>&"
},
{
"name": "students",
"type": "vector<int>&"
}
],
"return_type": "... |
2,038 | remove-colored-pieces-if-both-neighbors-are-the-same-color | Medium | There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the i^th piece.
Alice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.
- Alice... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(colors = \"AABBAABB\") == False\n assert candidate(colors = \"AAAAAAAAA\") == True\n assert candidate(colors = \"AAABAAAAABBBB\") == True\n assert candidate(colors = \"ABABABABAB\") == False\n assert candidate(colors = \"AABB... | [
"\"AAABABB\"",
"\"AA\"",
"\"ABBBBBBBAAA\""
] | [
"Does the number of moves a player can make depend on what the other player does? No",
"How many moves can Alice make if colors == \"AAAAAA\"",
"If a group of n consecutive pieces has the same color, the player can take n - 2 of those pieces if n is greater than or equal to 3"
] | {
"canonical_parameter_names": [
"colors"
],
"leetcode_dataset_entry_point": "Solution().winnerOfGame",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:02",
"tests_total": 182,
"tests_... | cpp | {
"raw_signature": "bool winnerOfGame(string colors) {",
"container": "Solution",
"callable": "winnerOfGame",
"parameters": [
{
"name": "colors",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,039 | the-time-when-the-network-becomes-idle | Medium | There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [u_i, v_i] indicates there is a message channel between servers u_i and v_i, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array pati... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2]],patience = [0, 2, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]],patience = [0, 5, 5, 5]) == 3\n assert candidate(edges = [[0, 1], [1, 3], [3, 4], [2, 4]],patience = [0... | [
"[[0,1],[1,2]]\n[0,2,1]",
"[[0,1],[0,2],[1,2]]\n[0,10,10]"
] | [
"What method can you use to find the shortest time taken for a message from a data server to reach the master server? How can you use this value and the server's patience value to determine the time at which the server sends its last message?",
"What is the time when the last message sent from a server gets back ... | {
"canonical_parameter_names": [
"edges",
"patience"
],
"leetcode_dataset_entry_point": "Solution().networkBecomesIdle",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:05",
"tests_t... | cpp | {
"raw_signature": "int networkBecomesIdle(vector<vector<int>>& edges, vector<int>& patience) {",
"container": "Solution",
"callable": "networkBecomesIdle",
"parameters": [
{
"name": "edges",
"type": "vector<vector<int>>&"
},
{
"name": "patience",
"type": "vector<int>&"
}... |
2,040 | kth-smallest-product-of-two-sorted-arrays | Hard | Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the k^th (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length.
Example 1:
Input: nums1 = [2,5], nums2 = [3,4], k = 2
Output: 8
Explanation: The 2 smallest products are:
- nums1[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 1) == -10000000000\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [-100000, -50000, 0, 50000, 100000],nums2 = [-100000, -50000... | [
"[2,5]\n[3,4]\n2",
"[-4,-2,0,3]\n[2,4]\n6",
"[-2,-1,0,1,2]\n[-3,-1,2,4,5]\n3"
] | [
"Can we split this problem into four cases depending on the sign of the numbers?",
"Can we binary search the value?"
] | {
"canonical_parameter_names": [
"nums1",
"nums2",
"k"
],
"leetcode_dataset_entry_point": "Solution().kthSmallestProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:07",
"t... | cpp | {
"raw_signature": "long long kthSmallestProduct(vector<int>& nums1, vector<int>& nums2, long long k) {",
"container": "Solution",
"callable": "kthSmallestProduct",
"parameters": [
{
"name": "nums1",
"type": "vector<int>&"
},
{
"name": "nums2",
"type": "vector<int>&"
},
... |
2,042 | check-if-numbers-are-ascending-in-a-sentence | Easy | A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.
- For example, "a puppy has 2 eyes 4 legs" is a sentence with seven tokens: "2" and "... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"start 99 end 100\") == True\n assert candidate(s = \"1 apple 2 banana 3 cherry 4 date\") == True\n assert candidate(s = \"100 99 98 97 96\") == False\n assert candidate(s = \"5 15 25 35 45 55\") == True\n assert candida... | [
"\"1 box has 3 blue 4 red 6 green and 12 yellow marbles\"",
"\"hello world 5 x 5\"",
"\"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\""
] | [
"Use string tokenization of your language to extract all the tokens of the string easily.",
"For each token extracted, how can you tell if it is a number? Does the first letter being a digit mean something?",
"Compare the number with the previously occurring number to check if ascending order is maintained."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().areNumbersAscending",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:09",
"tests_total": 204,
"test... | cpp | {
"raw_signature": "bool areNumbersAscending(string s) {",
"container": "Solution",
"callable": "areNumbersAscending",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,044 | count-number-of-maximum-bitwise-or-subsets | Medium | Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.
An array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different i... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [15, 15, 15]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 255\n assert candidate(nums = [3, 2, 1, 5]) == 6\n assert candidate(nums = [6, 2, 1, 3, 4]) == 17\n assert candidate(nums = [6, 2, 1, 5, 4]) == ... | [
"[3,1]",
"[2,2,2]",
"[3,2,1,5]"
] | [
"Can we enumerate all possible subsets?",
"The maximum bitwise-OR is the bitwise-OR of the whole array."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().countMaxOrSubsets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:12",
"tests_total": 113,
"tes... | cpp | {
"raw_signature": "int countMaxOrSubsets(vector<int>& nums) {",
"container": "Solution",
"callable": "countMaxOrSubsets",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSni... |
2,045 | second-minimum-time-to-reach-destination | Hard | A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [u_i, v_i] denotes a bi-directional edge between vertex u_i and vertex v_i. Every vertex pair is conne... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 2,edges = [[1, 2]],time = 3,change = 2) == 11\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 2,change = 3) == 10\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 5,change = 5) == 35\n assert candidate(n = 6... | [
"5\n[[1,2],[1,3],[1,4],[3,4],[4,5]]\n3\n5",
"2\n[[1,2]]\n3\n2"
] | [
"How much is change actually necessary while calculating the required path?",
"How many extra edges do we need to add to the shortest path?"
] | {
"canonical_parameter_names": [
"n",
"edges",
"time",
"change"
],
"leetcode_dataset_entry_point": "Solution().secondMinimum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:1... | cpp | {
"raw_signature": "int secondMinimum(int n, vector<vector<int>>& edges, int time, int change) {",
"container": "Solution",
"callable": "secondMinimum",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "edges",
"type": "vector<vector<int>>&"
},
{
"name"... |
2,047 | number-of-valid-words-in-a-sentence | Easy | A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '.
A token is a valid word if all three of the following are true:
- It on... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(sentence = \"no-digits123 or symbols#allowed\") == 2\n assert candidate(sentence = \"a.b.c\") == 0\n assert candidate(sentence = \"hello-world, this-is-a-test\") == 1\n assert candidate(sentence = \"hello-\") == 0\n assert ca... | [
"\"cat and dog\"",
"\"!this 1-s b8d!\"",
"\"alice and bob are playing stone-game10\""
] | [
"Iterate through the string to split it by spaces.",
"Count the number of characters of each type (letters, numbers, hyphens, and punctuations)."
] | {
"canonical_parameter_names": [
"sentence"
],
"leetcode_dataset_entry_point": "Solution().countValidWords",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:19",
"tests_total": 377,
"t... | cpp | {
"raw_signature": "int countValidWords(string sentence) {",
"container": "Solution",
"callable": "countValidWords",
"parameters": [
{
"name": "sentence",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,048 | next-greater-numerically-balanced-number | Medium | An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.
Given an integer n, return the smallest numerically balanced number strictly greater than n.
Example 1:
Input: n = 1
Output: 22
Explanation:
22 is numerically balanced since:
- The digit 2 o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 122333) == 123233\n assert candidate(n = 3000) == 3133\n assert candidate(n = 1222) == 1333\n assert candidate(n = 55555) == 122333\n assert candidate(n = 1234) == 1333\n assert candid... | [
"1",
"1000",
"3000"
] | [
"How far away can the next greater numerically balanced number be from n?",
"With the given constraints, what is the largest numerically balanced number?"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().nextBeautifulNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:21",
"tests_total": 58,
"tests... | cpp | {
"raw_signature": "int nextBeautifulNumber(int n) {",
"container": "Solution",
"callable": "nextBeautifulNumber",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,049 | count-nodes-with-the-highest-score | Medium | There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since node 0 is the root, parents[0] == -1.
Each node has a score. To find the score of a node, consider if t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3]) == 5\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2]) == 1\n assert candidate(parents = [-1, 2, 0, 2, 0]) == 3\n assert candidate(parents = [-1, 0, 1, 2, 3]) == 3\n assert candidate(paren... | [
"[-1,2,0,2,0]",
"[-1,2,0]"
] | [
"For each node, you need to find the sizes of the subtrees rooted in each of its children. Maybe DFS?",
"How to determine the number of nodes in the rest of the tree? Can you subtract the size of the subtree rooted at the node from the total number of nodes of the tree?",
"Use these values to compute the score ... | {
"canonical_parameter_names": [
"parents"
],
"leetcode_dataset_entry_point": "Solution().countHighestScoreNodes",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:23",
"tests_total": 79,... | cpp | {
"raw_signature": "int countHighestScoreNodes(vector<int>& parents) {",
"container": "Solution",
"callable": "countHighestScoreNodes",
"parameters": [
{
"name": "parents",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "... |
2,050 | parallel-courses-iii | Hard | You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCourse_j, nextCourse_j] denotes that course prevCourse_j has to be completed before course nextCourse_j (prerequisite relationship). Furthermore, you are gi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 4,relations = [[1, 2], [1, 3], [2, 4], [3, 4]],time = [4, 2, 3, 1]) == 8\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],time = [3, 2, 5]) == 8\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6],... | [
"3\n[[1,3],[2,3]]\n[3,2,5]",
"5\n[[1,5],[2,5],[3,5],[3,4],[4,5]]\n[1,2,3,4,5]"
] | [
"What is the earliest time a course can be taken?",
"How would you solve the problem if all courses take equal time?",
"How would you generalize this approach?"
] | {
"canonical_parameter_names": [
"n",
"relations",
"time"
],
"leetcode_dataset_entry_point": "Solution().minimumTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:26",
"tests... | cpp | {
"raw_signature": "int minimumTime(int n, vector<vector<int>>& relations, vector<int>& time) {",
"container": "Solution",
"callable": "minimumTime",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "relations",
"type": "vector<vector<int>>&"
},
{
"name... |
2,053 | kth-distinct-string-in-an-array | Easy | A distinct string is a string that is present only once in an array.
Given an array of strings arr, and an integer k, return the k^th distinct string present in arr. If there are fewer than k distinct strings, return an empty string "".
Note that the strings are considered in the order in which they appear in the arr... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = ['a'],k = 1) == \"a\"\n assert candidate(arr = ['a', 'a', 'b', 'b', 'c', 'c', 'd'],k = 1) == \"d\"\n assert candidate(arr = ['aaa', 'aa', 'a'],k = 1) == \"aaa\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f'],k = 6... | [
"[\"d\",\"b\",\"c\",\"b\",\"c\",\"a\"]\n2",
"[\"aaa\",\"aa\",\"a\"]\n1",
"[\"a\",\"b\",\"a\"]\n3"
] | [
"Try 'mapping' the strings to check if they are unique or not."
] | {
"canonical_parameter_names": [
"arr",
"k"
],
"leetcode_dataset_entry_point": "Solution().kthDistinct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:30",
"tests_total": 110,
"t... | cpp | {
"raw_signature": "string kthDistinct(vector<string>& arr, int k) {",
"container": "Solution",
"callable": "kthDistinct",
"parameters": [
{
"name": "arr",
"type": "vector<string>&"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "string",
"signature_source": "l... |
2,054 | two-best-non-overlapping-events | Medium | You are given a 0-indexed 2D integer array of events where events[i] = [startTime_i, endTime_i, value_i]. The i^th event starts at startTime_iand ends at endTime_i, and if you attend this event, you will receive a value of value_i. You can choose at most two non-overlapping events to attend such that the sum of their v... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(events = [[1, 1000000000, 1000000], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 10, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3,... | [
"[[1,3,2],[4,5,2],[2,4,3]]",
"[[1,3,2],[4,5,2],[1,5,5]]",
"[[1,5,3],[1,5,1],[6,6,5]]"
] | [
"How can sorting the events on the basis of their start times help? How about end times?",
"How can we quickly get the maximum score of an interval not intersecting with the interval we chose?"
] | {
"canonical_parameter_names": [
"events"
],
"leetcode_dataset_entry_point": "Solution().maxTwoEvents",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:33",
"tests_total": 97,
"tests_d... | cpp | {
"raw_signature": "int maxTwoEvents(vector<vector<int>>& events) {",
"container": "Solution",
"callable": "maxTwoEvents",
"parameters": [
{
"name": "events",
"type": "vector<vector<int>>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetco... |
2,055 | plates-between-candles | Medium | There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle.
You are also given a 0-indexed 2D integer array queries where queries[i] = [left_i, right_i] denotes... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"**|**|***|\",queries = [[2, 5], [5, 9]]) == [2, 3]\n assert candidate(s = \"***||***\",queries = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|\",queries = [[0, 7], [1, 6], [2, 5]]) == [3, 2, 1]\n asse... | [
"\"**|**|***|\"\n[[2,5],[5,9]]",
"\"***|**|*****|**||**|*\"\n[[1,17],[4,5],[14,17],[5,11],[15,16]]"
] | [
"Can you find the indices of the most left and right candles for a given substring, perhaps by using binary search (or better) over an array of indices of all the bars?",
"Once the indices of the most left and right bars are determined, how can you efficiently count the number of plates within the range? Prefix s... | {
"canonical_parameter_names": [
"s",
"queries"
],
"leetcode_dataset_entry_point": "Solution().platesBetweenCandles",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:35",
"tests_tota... | cpp | {
"raw_signature": "vector<int> platesBetweenCandles(string s, vector<vector<int>>& queries) {",
"container": "Solution",
"callable": "platesBetweenCandles",
"parameters": [
{
"name": "s",
"type": "string"
},
{
"name": "queries",
"type": "vector<vector<int>>&"
}
],
"r... |
2,056 | number-of-valid-move-combinations-on-chessboard | Hard | There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the i^th piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [r_i, c_i] indicate... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(pieces = ['bishop'],positions = [[4, 3]]) == 12\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [2, 2]]) == 309\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [8, 8]]) == 223\n assert candid... | [
"[\"rook\"]\n[[1,1]]",
"[\"queen\"]\n[[1,1]]",
"[\"bishop\"]\n[[4,3]]"
] | [
"N is small, we can generate all possible move combinations.",
"For each possible move combination, determine which ones are valid."
] | {
"canonical_parameter_names": [
"pieces",
"positions"
],
"leetcode_dataset_entry_point": "Solution().countCombinations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:38",
"tests_... | cpp | {
"raw_signature": "int countCombinations(vector<string>& pieces, vector<vector<int>>& positions) {",
"container": "Solution",
"callable": "countCombinations",
"parameters": [
{
"name": "pieces",
"type": "vector<string>&"
},
{
"name": "positions",
"type": "vector<vector<int>>... |
2,057 | smallest-index-with-equal-value | Easy | Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.
x mod y denotes the remainder when x is divided by y.
Example 1:
Input: nums = [0,1,2]
Output: 0
Explanation:
i=0: 0 mod 10 = 0 == nums[0].
i=1: 1 mod 10 = 1 == nums[1].
i=2: 2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(nums = [4, 3, 2, 1]) == 2\n assert candidate(nums = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert ... | [
"[0,1,2]",
"[4,3,2,1]",
"[1,2,3,4,5,6,7,8,9,0]"
] | [
"Starting with i=0, check the condition for each index. The first one you find to be true is the smallest index."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().smallestEqual",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:40",
"tests_total": 98,
"tests_dr... | cpp | {
"raw_signature": "int smallestEqual(vector<int>& nums) {",
"container": "Solution",
"callable": "smallestEqual",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,059 | minimum-operations-to-convert-number | Medium | You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:
If 0 <= x... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],start = 100,goal = 50) == 2\n assert candidate(nums = [5, 15, 25],start = 10,goal = 30) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 300) == 7\n assert candidate(nums = [1, 3, 5, 7, 9],start... | [
"[2,4,12]\n2\n12",
"[3,5,7]\n0\n-4",
"[2,8,16]\n0\n1"
] | [
"Once x drops below 0 or goes above 1000, is it possible to continue performing operations on x?",
"How can you use BFS to find the minimum operations?"
] | {
"canonical_parameter_names": [
"nums",
"start",
"goal"
],
"leetcode_dataset_entry_point": "Solution().minimumOperations",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:44",
"... | cpp | {
"raw_signature": "int minimumOperations(vector<int>& nums, int start, int goal) {",
"container": "Solution",
"callable": "minimumOperations",
"parameters": [
{
"name": "nums",
"type": "vector<int>&"
},
{
"name": "start",
"type": "int"
},
{
"name": "goal",
... |
2,060 | check-if-an-original-string-exists-given-two-encoded-strings | Hard | An original string, consisting of lowercase English letters, can be encoded by the following steps:
- Arbitrarily split it into a sequence of some number of non-empty substrings.
- Arbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).
- Concatenate th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"a1b\",s2 = \"a1b1\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"a3bcd\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"abc5\") == False\n assert candidate(s1 = \"123\",s2 = \"onetwothree\") == False\n as... | [
"\"internationalization\"\n\"i18n\"",
"\"l123e\"\n\"44\"",
"\"a5b\"\n\"c5b\""
] | [
"For s1 and s2, divide each into a sequence of single alphabet strings and digital strings. The problem now becomes comparing if two sequences are equal.",
"A single alphabet string has no variation, but a digital string has variations. For example: \"124\" can be interpreted as 1+2+4, 12+4, 1+24, and 124 wildcar... | {
"canonical_parameter_names": [
"s1",
"s2"
],
"leetcode_dataset_entry_point": "Solution().possiblyEquals",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:47",
"tests_total": 195,
... | cpp | {
"raw_signature": "bool possiblyEquals(string s1, string s2) {",
"container": "Solution",
"callable": "possiblyEquals",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/co... |
2,062 | count-vowel-substrings-of-a-string | Easy | A substring is a contiguous (non-empty) sequence of characters within a string.
A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.
Given a string word, return the number of vowel substrings in word.
Example 1:
Input: word = "aeiouu"
Out... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"aeiou\") == 1\n assert candidate(word = \"aeiofvuaeiou\") == 3\n assert candidate(word = \"uoiea\") == 1\n assert candidate(word = \"aeiouxaeeiaouoieua\") == 28\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauua... | [
"\"aeiouu\"",
"\"unicornarihan\"",
"\"cuaieuouac\""
] | [
"While generating substrings starting at any index, do you need to continue generating larger substrings if you encounter a consonant?",
"Can you store the count of characters to avoid generating substrings altogether?"
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().countVowelSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:51",
"tests_total": 110,
"... | cpp | {
"raw_signature": "int countVowelSubstrings(string word) {",
"container": "Solution",
"callable": "countVowelSubstrings",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"... |
2,063 | vowels-of-all-substrings | Medium | Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.
A substring is a contiguous (non-empty) sequence of characters within a string.
Note: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calc... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word = \"e\") == 1\n assert candidate(word = \"aeiou\") == 35\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiaai... | [
"\"aba\"",
"\"abc\"",
"\"ltcd\""
] | [
"Since generating substrings is not an option, can we count the number of substrings a vowel appears in?",
"How much does each vowel contribute to the total sum?"
] | {
"canonical_parameter_names": [
"word"
],
"leetcode_dataset_entry_point": "Solution().countVowels",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:53",
"tests_total": 80,
"tests_drop... | cpp | {
"raw_signature": "long long countVowels(string word) {",
"container": "Solution",
"callable": "countVowels",
"parameters": [
{
"name": "word",
"type": "string"
}
],
"return_type": "long long",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
2,064 | minimized-maximum-of-products-distributed-to-any-store | Medium | 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 i^th product type.
You need to distribute all products to the retail stores foll... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 5,quantities = [10, 20, 30, 40, 50]) == 50\n assert candidate(n = 3,quantities = [100, 100, 100]) == 100\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 100000\n assert candidate(n = 3,quantiti... | [
"6\n[11,6]",
"7\n[15,10,10]",
"1\n[100000]"
] | [
"There exists a monotonic nature such that when x is smaller than some number, there will be no way to distribute, and when x is not smaller than that number, there will always be a way to distribute.",
"If you are given a number k, where the number of products given to any store does not exceed k, could you dete... | {
"canonical_parameter_names": [
"n",
"quantities"
],
"leetcode_dataset_entry_point": "Solution().minimizedMaximum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:56",
"tests_total... | cpp | {
"raw_signature": "int minimizedMaximum(int n, vector<int>& quantities) {",
"container": "Solution",
"callable": "minimizedMaximum",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "quantities",
"type": "vector<int>&"
}
],
"return_type": "int",
"signature... |
2,065 | maximum-path-quality-of-a-graph | Hard | 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 i^th node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [u_j, v_j, time_j] indicates that there is an undirected edge between... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40]],maxTime = 100) == 70\n assert candidate(values = [100, 200, 300, 400],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],maxTime = 50) == 100... | [
"[0,32,10,43]\n[[0,1,10],[1,2,15],[0,3,10]]\n49",
"[5,10,15,20]\n[[0,1,10],[1,2,10],[0,3,10]]\n30",
"[1,2,3,4]\n[[0,1,10],[1,2,11],[2,3,12],[1,3,13]]\n50"
] | [
"How many nodes can you visit within maxTime seconds?",
"Can you try every valid path?"
] | {
"canonical_parameter_names": [
"values",
"edges",
"maxTime"
],
"leetcode_dataset_entry_point": "Solution().maximalPathQuality",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:39:58... | cpp | {
"raw_signature": "int maximalPathQuality(vector<int>& values, vector<vector<int>>& edges, int maxTime) {",
"container": "Solution",
"callable": "maximalPathQuality",
"parameters": [
{
"name": "values",
"type": "vector<int>&"
},
{
"name": "edges",
"type": "vector<vector<int>... |
2,068 | check-whether-two-strings-are-almost-equivalent | Easy | Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.
Given two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.
The frequency of a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"cccddabba\",word2 = \"babababab\") == True\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrst... | [
"\"aaaa\"\n\"bccb\"",
"\"abcdeef\"\n\"abaaacc\"",
"\"cccddabba\"\n\"babababab\""
] | [
"What data structure can we use to count the frequency of each character?",
"Are there edge cases where a character is present in one string but not the other?"
] | {
"canonical_parameter_names": [
"word1",
"word2"
],
"leetcode_dataset_entry_point": "Solution().checkAlmostEquivalent",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T20:40:02",
"tests_t... | cpp | {
"raw_signature": "bool checkAlmostEquivalent(string word1, string word2) {",
"container": "Solution",
"callable": "checkAlmostEquivalent",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "bool",
"signa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.