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
756
pyramid-transition-matrix
Medium
You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block than the row beneath it and is centered on top. To make the pyramid aesthetically pleasing, there are only specific triangular patterns that are allowed. A triangular p...
{ "language": "python", "source": "def check(candidate):\n assert candidate(bottom = \"FFFA\",allowed = ['FFF', 'FFA', 'FAF', 'AFF']) == True\n assert candidate(bottom = \"ABC\",allowed = ['ABD', 'BDC', 'CDB', 'BDD', 'DEF', 'DEE']) == False\n assert candidate(bottom = \"ABC\",allowed = ['ABD', 'BCE', 'DEF'...
[ "\"BCD\"\n[\"BCC\",\"CDE\",\"CEA\",\"FFF\"]", "\"AAAA\"\n[\"AAB\",\"AAC\",\"BCD\",\"BBE\",\"DEF\"]" ]
[]
{ "canonical_parameter_names": [ "bottom", "allowed" ], "leetcode_dataset_entry_point": "Solution().pyramidTransition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:33", "tests_to...
cpp
{ "raw_signature": "bool pyramidTransition(string bottom, vector<string>& allowed) {", "container": "Solution", "callable": "pyramidTransition", "parameters": [ { "name": "bottom", "type": "string" }, { "name": "allowed", "type": "vector<string>&" } ], "return_type": ...
757
set-intersection-size-at-least-two
Hard
You are given a 2D integer array intervals where intervals[i] = [start_i, end_i] represents all the integers from start_i to end_i inclusively. A containing set is an array nums where each interval from intervals has at least two integers in nums. - For example, if intervals = [[1,3], [3,7], [8,9]], then [1,2,4,7,8,9...
{ "language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 10], [5, 10], [7, 15]]) == 2\n assert candidate(intervals = [[1, 2], [2, 3]]) == 3\n assert candidate(intervals = [[1, 3], [1, 4], [2, 5], [3, 5]]) == 3\n assert candidate(intervals = [[1, 3], [3, 7], [8, 9]]) =...
[ "[[1,3],[3,7],[8,9]]", "[[1,3],[1,4],[2,5],[3,5]]", "[[1,2],[2,3],[2,4],[4,5]]" ]
[]
{ "canonical_parameter_names": [ "intervals" ], "leetcode_dataset_entry_point": "Solution().intersectionSizeTwo", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:35", "tests_total": 90, ...
cpp
{ "raw_signature": "int intersectionSizeTwo(vector<vector<int>>& intervals) {", "container": "Solution", "callable": "intersectionSizeTwo", "parameters": [ { "name": "intervals", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "t...
761
special-binary-string
Hard
Special binary strings are binary strings with the following two properties: - The number of 0's is equal to the number of 1's. - Every prefix of the binary string has at least as many 1's as 0's. You are given a special binary string s. A move consists of choosing two consecutive, non-empty, special substrings of s...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"11010011\") == \"110100\"\n assert candidate(s = \"11011000\") == \"11100100\"\n assert candidate(s = \"11100100\") == \"11100100\"\n assert candidate(s = \"111000\") == \"111000\"\n assert candidate(s = \"101010\") == ...
[ "\"11011000\"", "\"10\"" ]
[ "Draw a line from (x, y) to (x+1, y+1) if we see a \"1\", else to (x+1, y-1). A special substring is just a line that starts and ends at the same y-coordinate, and that is the lowest y-coordinate reached. Call a mountain a special substring with no special prefixes - ie. only at the beginning and end is the lowest ...
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().makeLargestSpecial", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:42", "tests_total": 127, "tests...
cpp
{ "raw_signature": "string makeLargestSpecial(string s) {", "container": "Solution", "callable": "makeLargestSpecial", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
762
prime-number-of-set-bits-in-binary-representation
Easy
Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation. Recall that the number of set bits an integer has is the number of 1's present when written in binary. - For example, 21 written in binary is 10101, whi...
{ "language": "python", "source": "def check(candidate):\n assert candidate(left = 100,right = 105) == 3\n assert candidate(left = 500,right = 1000) == 253\n assert candidate(left = 1,right = 100) == 65\n assert candidate(left = 6,right = 10) == 4\n assert candidate(left = 999900,right = 1000000) == ...
[ "6\n10", "10\n15" ]
[ "Write a helper function to count the number of set bits in a number, then check whether the number of set bits is 2, 3, 5, 7, 11, 13, 17 or 19." ]
{ "canonical_parameter_names": [ "left", "right" ], "leetcode_dataset_entry_point": "Solution().countPrimeSetBits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:44", "tests_total"...
cpp
{ "raw_signature": "int countPrimeSetBits(int left, int right) {", "container": "Solution", "callable": "countPrimeSetBits", "parameters": [ { "name": "left", "type": "int" }, { "name": "right", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/...
763
partition-labels
Medium
You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid. Note that the partition is done so ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdabcde\") == [8, 1]\n assert candidate(s = \"aaaaaabbbbbccccc\") == [6, 5, 5]\n assert candidate(s = \"xyzxyzxyz\") == [9]\n assert candidate(s = \"aaaabbbbbccccc\") == [4, 5, 5]\n assert candidate(s = \"abcdabcdeabc...
[ "\"ababcbacadefegdehijhklij\"", "\"eccbbbbdec\"" ]
[ "Try to greedily choose the smallest partition that includes the first letter. If you have something like \"abaccbdeffed\", then you might need to add b. You can use an map like \"last['b'] = 5\" to help you expand the width of your partition." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().partitionLabels", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:46", "tests_total": 64, "tests_dro...
cpp
{ "raw_signature": "vector<int> partitionLabels(string s) {", "container": "Solution", "callable": "partitionLabels", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
764
largest-plus-sign
Medium
You are given an integer n. You have an n x n binary grid grid with all values initially 1's except for some indices given in the array mines. The i^th element of the array mines is defined as mines[i] = [x_i, y_i] where grid[x_i][y_i] == 0. Return the order of the largest axis-aligned plus sign of 1's contained in gr...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 7,mines = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 0], [1, 6], [2, 0], [2, 6], [3, 0], [3, 6], [4, 0], [4, 6], [5, 0], [5, 6], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 3\n assert candidate(n ...
[ "5\n[[4,2]]", "1\n[[0,0]]" ]
[ "For each direction such as \"left\", find left[r][c] = the number of 1s you will see before a zero starting at r, c and walking left. You can find this in N^2 time with a dp. The largest plus sign at r, c is just the minimum of left[r][c], up[r][c] etc." ]
{ "canonical_parameter_names": [ "n", "mines" ], "leetcode_dataset_entry_point": "Solution().orderOfLargestPlusSign", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:48", "tests_tota...
cpp
{ "raw_signature": "int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {", "container": "Solution", "callable": "orderOfLargestPlusSign", "parameters": [ { "name": "n", "type": "int" }, { "name": "mines", "type": "vector<vector<int>>&" } ], "return_type": "...
765
couples-holding-hands
Hard
There are n couples sitting in 2n seats arranged in a row and want to hold hands. The people and seats are represented by an integer array row where row[i] is the ID of the person sitting in the i^th seat. The couples are numbered in order, the first couple being (0, 1), the second couple being (2, 3), and so on with ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(row = [2, 0, 5, 4, 3, 1]) == 1\n assert candidate(row = [0, 1, 2, 3]) == 0\n assert candidate(row = [0, 2, 1, 3]) == 1\n assert candidate(row = [4, 3, 2, 1, 0, 5]) == 2\n assert candidate(row = [2, 0, 5, 4, 3, 6, 7, 1]) == 2\...
[ "[0,2,1,3]", "[3,2,0,1]" ]
[ "Say there are N two-seat couches. For each couple, draw an edge from the couch of one partner to the couch of the other partner." ]
{ "canonical_parameter_names": [ "row" ], "leetcode_dataset_entry_point": "Solution().minSwapsCouples", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:51", "tests_total": 81, "tests_d...
cpp
{ "raw_signature": "int minSwapsCouples(vector<int>& row) {", "container": "Solution", "callable": "minSwapsCouples", "parameters": [ { "name": "row", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
766
toeplitz-matrix
Easy
Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements. Example 1: Input: matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]] Output: true Explanation: In the above grid, the diagonals are: "[9]", "[5, 5]"...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[3, 4, 5], [6, 3, 4], [7, 6, 3]]) == True\n assert candidate(matrix = [[1, 2, 3], [4, 1, 2], [7, 4, 1]]) == True\n assert candidate(matrix = [[1]]) == True\n assert candidate(matrix = [[1, 2], [3, 4]]) == False\n as...
[ "[[1,2,3,4],[5,1,2,3],[9,5,1,2]]", "[[1,2],[2,2]]" ]
[ "Check whether each value is equal to the value of it's top-left neighbor." ]
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().isToeplitzMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:53", "tests_total": 84, "tes...
cpp
{ "raw_signature": "bool isToeplitzMatrix(vector<vector<int>>& matrix) {", "container": "Solution", "callable": "isToeplitzMatrix", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source...
767
reorganize-string
Medium
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any possible rearrangement of s or return "" if not possible. Example 1: Input: s = "aab" Output: "aba" Example 2: Input: s = "aaab" Output: "" Constraints: - 1 <= s.length <= 500 - s consists of lowercas...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabc\") == \"abaca\"\n assert candidate(s = \"aabbccc\") == \"cacbcba\"\n assert candidate(s = \"abcdefg\") == \"aebfcgd\"\n assert candidate(s = \"aaabbbccc\") == \"abacacbcb\"\n assert candidate(s = \"aabbccddeeffggh...
[ "\"aab\"", "\"aaab\"" ]
[ "Alternate placing the most common letters." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().reorganizeString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:55", "tests_total": 56, "tests_dr...
cpp
{ "raw_signature": "string reorganizeString(string s) {", "container": "Solution", "callable": "reorganizeString", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
768
max-chunks-to-make-sorted-ii
Hard
You are given an integer array arr. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array. Return the largest number of chunks we can make to sort the array. Example 1: Input: arr = [5,4,3,2,1] Output: 1 Expla...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [...
[ "[5,4,3,2,1]", "[2,1,3,4,4]" ]
[ "Each k for which some permutation of arr[:k] is equal to sorted(arr)[:k] is where we should cut each chunk." ]
{ "canonical_parameter_names": [ "arr" ], "leetcode_dataset_entry_point": "Solution().maxChunksToSorted", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:57", "tests_total": 149, "test...
cpp
{ "raw_signature": "int maxChunksToSorted(vector<int>& arr) {", "container": "Solution", "callable": "maxChunksToSorted", "parameters": [ { "name": "arr", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
769
max-chunks-to-make-sorted
Medium
You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1]. We split arr into some number of chunks (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array. Return the largest number of chunks we...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [1, 2, 0, 3, 4]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(arr = [3, 1, 0, 2, 4]) == 2\n assert candidate(arr = [2, 0, 1, 3, ...
[ "[4,3,2,1,0]", "[1,0,2,3,4]" ]
[ "The first chunk can be found as the smallest k for which A[:k+1] == [0, 1, 2, ...k]; then we repeat this process." ]
{ "canonical_parameter_names": [ "arr" ], "leetcode_dataset_entry_point": "Solution().maxChunksToSorted", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:58:59", "tests_total": 127, "test...
cpp
{ "raw_signature": "int maxChunksToSorted(vector<int>& arr) {", "container": "Solution", "callable": "maxChunksToSorted", "parameters": [ { "name": "arr", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
770
basic-calculator-iv
Hard
Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens representing the simplified expression, such as ["-1*a","14"] - An expression alternates chunks and symbols, with a space separating each chun...
{ "language": "python", "source": "def check(candidate):\n assert candidate(expression = \"1 + (2 * 3) + (4 * (5 + 6))\",evalvars = [],evalints = []) == ['51']\n assert candidate(expression = \"10 + 20 * (30 + 40) - 50\",evalvars = [],evalints = []) == ['1360']\n assert candidate(expression = \"(x + y) * (...
[ "\"e + 8 - a + 5\"\n[\"e\"]\n[1]", "\"e - 8 + temperature - pressure\"\n[\"e\", \"temperature\"]\n[1, 12]", "\"(e + 8) * (e - 8)\"\n[]\n[]" ]
[ "One way is with a Polynomial class. For example, * `Poly:add(this, that)` returns the result of `this + that`. * `Poly:sub(this, that)` returns the result of `this - that`. * `Poly:mul(this, that)` returns the result of `this * that`. * `Poly:evaluate(this, evalmap)` returns the polynomial after replacing all free...
{ "canonical_parameter_names": [ "expression", "evalvars", "evalints" ], "leetcode_dataset_entry_point": "Solution().basicCalculatorIV", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T1...
cpp
{ "raw_signature": "vector<string> basicCalculatorIV(string expression, vector<string>& evalvars, vector<int>& evalints) {", "container": "Solution", "callable": "basicCalculatorIV", "parameters": [ { "name": "expression", "type": "string" }, { "name": "evalvars", "type": "ve...
771
jewels-and-stones
Easy
You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. Letters are case sensitive, so "a" is considered a different type of stone f...
{ "language": "python", "source": "def check(candidate):\n assert candidate(jewels = \"aA\",stones = \"aAAbbbb\") == 3\n assert candidate(jewels = \"xyz\",stones = \"aabbcc\") == 0\n assert candidate(jewels = \"abcdefg\",stones = \"aghfbadcegf\") == 10\n assert candidate(jewels = \"abcdefg\",stones = \"...
[ "\"aA\"\n\"aAAbbbb\"", "\"z\"\n\"ZZ\"" ]
[ "For each stone, check if it is a jewel." ]
{ "canonical_parameter_names": [ "jewels", "stones" ], "leetcode_dataset_entry_point": "Solution().numJewelsInStones", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:04", "tests_tot...
cpp
{ "raw_signature": "int numJewelsInStones(string jewels, string stones) {", "container": "Solution", "callable": "numJewelsInStones", "parameters": [ { "name": "jewels", "type": "string" }, { "name": "stones", "type": "string" } ], "return_type": "int", "signature_s...
773
sliding-puzzle
Hard
On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0. A move consists of choosing 0 and a 4-directionally adjacent number and swapping it. The state of the board is solved if and only if the board is [[1,2,3],[4,5,0]]. Given the puzzle board board, return the least number ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [[4, 1, 2], [0, 5, 3]]) == 4\n assert candidate(board = [[3, 2, 4], [1, 5, 0]]) == 14\n assert candidate(board = [[0, 1, 2], [4, 5, 3]]) == 3\n assert candidate(board = [[1, 2, 3], [4, 0, 5]]) == 1\n assert candidate(...
[ "[[1,2,3],[4,0,5]]", "[[1,2,3],[5,4,0]]", "[[4,1,2],[5,0,3]]" ]
[ "Perform a breadth-first-search, where the nodes are the puzzle boards and edges are if two puzzle boards can be transformed into one another with one move." ]
{ "canonical_parameter_names": [ "board" ], "leetcode_dataset_entry_point": "Solution().slidingPuzzle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:08", "tests_total": 78, "tests_d...
cpp
{ "raw_signature": "int slidingPuzzle(vector<vector<int>>& board) {", "container": "Solution", "callable": "slidingPuzzle", "parameters": [ { "name": "board", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetco...
775
global-and-local-inversions
Medium
You are given an integer array nums of length n which represents a permutation of all the integers in the range [0, n - 1]. The number of global inversions is the number of the different pairs (i, j) where: - 0 <= i < j < n - nums[i] > nums[j] The number of local inversions is the number of indices i where: - 0 <= ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4]) == True\n assert candidate(nums = [4, 3, 2, 1, 0]) == False\n assert candidate(nums = [2, 0, 1, 3]) == False\n assert candidate(nums = [2, 1, 0, 3]) == False\n assert candidate(nums = [3, 2, 1, 0]) == ...
[ "[1,0,2]", "[1,2,0]" ]
[ "Where can the 0 be placed in an ideal permutation? What about the 1?" ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().isIdealPermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:13", "tests_total": 109, "te...
cpp
{ "raw_signature": "bool isIdealPermutation(vector<int>& nums) {", "container": "Solution", "callable": "isIdealPermutation", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
777
swap-adjacent-in-lr-string
Medium
In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string result, return True if and only if there exists a sequence of moves to transf...
{ "language": "python", "source": "def check(candidate):\n assert candidate(start = \"XXL\",result = \"LXX\") == True\n assert candidate(start = \"RXXLRXRXL\",result = \"XRLXXRRLX\") == True\n assert candidate(start = \"LLR\",result = \"RRL\") == False\n assert candidate(start = \"RXXL\",result = \"XRXL...
[ "\"RXXLRXRXL\"\n\"XRLXXRRLX\"", "\"X\"\n\"L\"" ]
[ "Think of the L and R's as people on a horizontal line, where X is a space. The people can't cross each other, and also you can't go from XRX to RXX." ]
{ "canonical_parameter_names": [ "start", "result" ], "leetcode_dataset_entry_point": "Solution().canTransform", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:15", "tests_total": 2...
cpp
{ "raw_signature": "bool canTransform(string start, string result) {", "container": "Solution", "callable": "canTransform", "parameters": [ { "name": "start", "type": "string" }, { "name": "result", "type": "string" } ], "return_type": "bool", "signature_source": "l...
778
swim-in-rising-water
Hard
You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j). It starts raining, and water gradually rises over time. At time t, the water level is t, meaning any cell with elevation less than equal to t is submerged or reachable. You can swim from a square to a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[3, 0, 8, 4], [2, 5, 1, 7], [9, 6, 10, 11], [13, 12, 14, 15]]) == 15\n assert candidate(grid = [[7, 1, 4, 0, 5], [2, 3, 6, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) == 24\n assert candidate(g...
[ "[[0,2],[1,3]]", "[[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]]" ]
[ "Use either Dijkstra's, or binary search for the best time T for which you can reach the end if you only step on squares at most T." ]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().swimInWater", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:17", "tests_total": 33, "tests_drop...
cpp
{ "raw_signature": "int swimInWater(vector<vector<int>>& grid) {", "container": "Solution", "callable": "swimInWater", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
779
k-th-symbol-in-grammar
Medium
We build a table of n rows (1-indexed). We start by writing 0 in the 1^st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10. - For example, for n = 3, the 1^st row is 0, the 2^nd row is 01, and the 3^rd row is 0110. Given two integ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 4,k = 8) == 1\n assert candidate(n = 30,k = 536870912) == 1\n assert candidate(n = 3,k = 2) == 1\n assert candidate(n = 1,k = 1) == 0\n assert candidate(n = 30,k = 536870911) == 0\n assert candidate(n = 4,k = 5) == 1\n...
[ "1\n1", "2\n1", "2\n2" ]
[ "Try to represent the current (N, K) in terms of some (N-1, prevK). What is prevK ?" ]
{ "canonical_parameter_names": [ "n", "k" ], "leetcode_dataset_entry_point": "Solution().kthGrammar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:20", "tests_total": 86, "tests...
cpp
{ "raw_signature": "int kthGrammar(int n, int k) {", "container": "Solution", "callable": "kthGrammar", "parameters": [ { "name": "n", "type": "int" }, { "name": "k", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_sourc...
780
reaching-points
Hard
Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise. The allowed operation on some point (x, y) is to convert it to either (x, x + y) or (x + y, y). Example 1: Input: sx = 1, sy = 1, tx = 3, ty = 5 Outpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(sx = 1,sy = 1,tx = 3,ty = 5) == True\n assert candidate(sx = 3,sy = 4,tx = 3,ty = 12) == False\n assert candidate(sx = 3,sy = 7,tx = 31,ty = 19) == False\n assert candidate(sx = 1,sy = 1,tx = 1000000000,ty = 1000000000) == False...
[ "1\n1\n3\n5", "1\n1\n2\n2", "1\n1\n1\n1" ]
[]
{ "canonical_parameter_names": [ "sx", "sy", "tx", "ty" ], "leetcode_dataset_entry_point": "Solution().reachingPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:22", "...
cpp
{ "raw_signature": "bool reachingPoints(int sx, int sy, int tx, int ty) {", "container": "Solution", "callable": "reachingPoints", "parameters": [ { "name": "sx", "type": "int" }, { "name": "sy", "type": "int" }, { "name": "tx", "type": "int" }, { ...
781
rabbits-in-forest
Medium
There is a forest with an unknown number of rabbits. We asked n rabbits "How many other rabbits have the same color as you?" and collected the answers in an integer array answers where answers[i] is the answer of the i^th rabbit. Given the array answers, return the minimum number of rabbits that could be in the forest...
{ "language": "python", "source": "def check(candidate):\n assert candidate(answers = [1, 2, 3, 4, 5]) == 20\n assert candidate(answers = [4, 4, 4, 4, 4, 4]) == 10\n assert candidate(answers = [1, 1, 2]) == 5\n assert candidate(answers = [0, 0, 1, 1, 1]) == 6\n assert candidate(answers = [999, 999, 9...
[ "[1,1,2]", "[10,10,10]" ]
[]
{ "canonical_parameter_names": [ "answers" ], "leetcode_dataset_entry_point": "Solution().numRabbits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:24", "tests_total": 66, "tests_dr...
cpp
{ "raw_signature": "int numRabbits(vector<int>& answers) {", "container": "Solution", "callable": "numRabbits", "parameters": [ { "name": "answers", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
782
transform-to-chessboard
Hard
You are given an n x n binary grid board. In each move, you can swap any two rows with each other, or any two columns with each other. Return the minimum number of moves to transform the board into a chessboard board. If the task is impossible, return -1. A chessboard board is a board where no 0's and no 1's are 4-di...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == 2\n assert candidate(board = [[1, 0], [1, 0]]) == -1\n assert candidate(board = [[0, 1], [1, 0]]) == 0\n assert candidate(board = [[0, 0, 1, 1], [1, 1, 0, 0], ...
[ "[[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]]", "[[0,1],[1,0]]", "[[1,0],[1,0]]" ]
[]
{ "canonical_parameter_names": [ "board" ], "leetcode_dataset_entry_point": "Solution().movesToChessboard", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:26", "tests_total": 75, "tes...
cpp
{ "raw_signature": "int movesToChessboard(vector<vector<int>>& board) {", "container": "Solution", "callable": "movesToChessboard", "parameters": [ { "name": "board", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source":...
784
letter-case-permutation
Medium
Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Return the output in any order. Example 1: Input: s = "a1b2" Output: ["a1b2","a1B2","A1b2","A1B2"] Example 2: Input: s = "3z4" Output: ["3z4","...
{ "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 ...
[ "\"a1b2\"", "\"3z4\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().letterCasePermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:31", "tests_total": 111, "te...
cpp
{ "raw_signature": "vector<string> letterCasePermutation(string s) {", "container": "Solution", "callable": "letterCasePermutation", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
785
is-graph-bipartite
Medium
There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the following properties...
{ "language": "python", "source": "def check(candidate):\n assert candidate(graph = [[], [3], [], [1]]) == True\n assert candidate(graph = [[], [2, 4, 6], [1, 4, 8, 9], [7, 8], [1, 2, 8, 9], [6, 9], [1, 5, 7, 8, 9], [3, 6, 9], [2, 3, 4, 6, 9], [2, 4, 5, 6, 7, 8]]) == False\n assert candidate(graph = [[1, 3...
[ "[[1,2,3],[0,2],[0,1,3],[0,2]]", "[[1,3],[0,2],[1,3],[0,2]]" ]
[]
{ "canonical_parameter_names": [ "graph" ], "leetcode_dataset_entry_point": "Solution().isBipartite", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:33", "tests_total": 103, "tests_dr...
cpp
{ "raw_signature": "bool isBipartite(vector<vector<int>>& graph) {", "container": "Solution", "callable": "isBipartite", "parameters": [ { "name": "graph", "type": "vector<vector<int>>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode...
786
k-th-smallest-prime-fraction
Medium
You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k. For every i and j where 0 <= i < j < arr.length, we consider the fraction arr[i] / arr[j]. Return the k^th smallest fraction considered. Return your answer as an array of...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 5, 13, 17, 19],k = 10) == [5, 13]\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 25) == [2, 7]\n assert candidate(arr = [1, 2, 3, 5],k = 3) == [2, 5]\n assert candidate(arr = [1, 2, 5, 7, 11, 1...
[ "[1,2,3,5]\n3", "[1,7]\n1" ]
[]
{ "canonical_parameter_names": [ "arr", "k" ], "leetcode_dataset_entry_point": "Solution().kthSmallestPrimeFraction", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:35", "tests_tota...
cpp
{ "raw_signature": "vector<int> kthSmallestPrimeFraction(vector<int>& arr, int k) {", "container": "Solution", "callable": "kthSmallestPrimeFraction", "parameters": [ { "name": "arr", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "vector<i...
787
cheapest-flights-within-k-stops
Medium
There are n cities connected by some number of flights. You are given an array flights where flights[i] = [from_i, to_i, price_i] indicates that there is a flight from city from_i to city to_i with cost price_i. You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 6,flights = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 20], [2, 3, 10], [3, 4, 10], [4, 5, 10]],src = 0,dst = 5,k = 2) == -1\n assert candidate(n = 3,flights = [[0, 1, 100], [1, 2, 100]],src = 0,dst = 2,k = 2) == 200\n assert c...
[ "4\n[[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]]\n0\n3\n1", "3\n[[0,1,100],[1,2,100],[0,2,500]]\n0\n2\n1", "3\n[[0,1,100],[1,2,100],[0,2,500]]\n0\n2\n0" ]
[]
{ "canonical_parameter_names": [ "n", "flights", "src", "dst", "k" ], "leetcode_dataset_entry_point": "Solution().findCheapestPrice", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09...
cpp
{ "raw_signature": "int findCheapestPrice(int n, vector<vector<int>>& flights, int src, int dst, int k) {", "container": "Solution", "callable": "findCheapestPrice", "parameters": [ { "name": "n", "type": "int" }, { "name": "flights", "type": "vector<vector<int>>&" }, ...
788
rotated-digits
Medium
An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x. Each digit must be rotated - we cannot choose to leave it alone. A number is valid if each digit remains a digit after rotation. For example: - 0, 1, and 8 rotate to themselves, - 2 and 5 r...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == 40\n assert candidate(n = 10000) == 2320\n assert candidate(n = 104) == 41\n assert candidate(n = 20) == 9\n assert candidate(n = 2) == 1\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 316\n ...
[ "10", "1", "2" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().rotatedDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:39", "tests_total": 55, "tests_dropp...
cpp
{ "raw_signature": "int rotatedDigits(int n) {", "container": "Solution", "callable": "rotatedDigits", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
789
escape-the-ghosts
Medium
You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point [0, 0], and you are given a destination point target = [x_target, y_target] that you are trying to get to. There are several ghosts on the map with their starting positions given as a 2D array ghosts, where ghosts[i] = [x_i, y_i] ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ghosts = [[0, 0], [0, 0]],target = [1, 1]) == False\n assert candidate(ghosts = [[-1, -1]],target = [0, 0]) == True\n assert candidate(ghosts = [[1, 1], [2, 2], [3, 3]],target = [4, 4]) == False\n assert candidate(ghosts = [[1, ...
[ "[[1,0],[0,3]]\n[0,1]", "[[1,0]]\n[2,0]", "[[2,0]]\n[1,0]" ]
[]
{ "canonical_parameter_names": [ "ghosts", "target" ], "leetcode_dataset_entry_point": "Solution().escapeGhosts", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:41", "tests_total": ...
cpp
{ "raw_signature": "bool escapeGhosts(vector<vector<int>>& ghosts, vector<int>& target) {", "container": "Solution", "callable": "escapeGhosts", "parameters": [ { "name": "ghosts", "type": "vector<vector<int>>&" }, { "name": "target", "type": "vector<int>&" } ], "retu...
790
domino-and-tromino-tiling
Medium
You have two types of tiles: a 2 x 1 domino shape and a tromino shape. You may rotate these shapes. Given an integer n, return the number of ways to tile an 2 x n board. Since the answer may be very large, return it modulo 10^9 + 7. In a tiling, every square must be covered by a tile. Two tilings are different if and...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 5\n assert candidate(n = 100) == 190242381\n assert candidate(n = 4) == 11\n assert candidate(n = 2) == 2\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 603582422\n assert candidate(n = 1000) ==...
[ "3", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().numTilings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:44", "tests_total": 30, "tests_dropped"...
cpp
{ "raw_signature": "int numTilings(int n) {", "container": "Solution", "callable": "numTilings", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
791
custom-sort-string
Medium
You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously. Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the pe...
{ "language": "python", "source": "def check(candidate):\n assert candidate(order = \"zyx\",s = \"zyxwvut\") == \"zwvutyx\"\n assert candidate(order = \"abcdefg\",s = \"gfedcba\") == \"abcdefg\"\n assert candidate(order = \"xyz\",s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n as...
[ "\"cba\"\n\"abcd\"", "\"bcafg\"\n\"abcd\"" ]
[]
{ "canonical_parameter_names": [ "order", "s" ], "leetcode_dataset_entry_point": "Solution().customSortString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:46", "tests_total": 11...
cpp
{ "raw_signature": "string customSortString(string order, string s) {", "container": "Solution", "callable": "customSortString", "parameters": [ { "name": "order", "type": "string" }, { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": ...
792
number-of-matching-subsequences
Medium
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. - For example, "ace" is a s...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"dsahjpjauf\",words = ['ahjpjau', 'ja', 'ahbwzgqnuk', 'tnmlanowax']) == 2\n assert candidate(s = \"abcde\",words = ['a', 'bb', 'acd', 'ace']) == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",words = ['qz', 'qp', 'qw'...
[ "\"abcde\"\n[\"a\",\"bb\",\"acd\",\"ace\"]", "\"dsahjpjauf\"\n[\"ahjpjau\",\"ja\",\"ahbwzgqnuk\",\"tnmlanowax\"]" ]
[]
{ "canonical_parameter_names": [ "s", "words" ], "leetcode_dataset_entry_point": "Solution().numMatchingSubseq", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:48", "tests_total": 5...
cpp
{ "raw_signature": "int numMatchingSubseq(string s, vector<string>& words) {", "container": "Solution", "callable": "numMatchingSubseq", "parameters": [ { "name": "s", "type": "string" }, { "name": "words", "type": "vector<string>&" } ], "return_type": "int", "signa...
793
preimage-size-of-factorial-zeroes-function
Hard
Let f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 * 3 * ... * x and by convention, 0! = 1. - For example, f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has two zeroes at the end. Given an integer k, return the number of non-negative integers x have th...
{ "language": "python", "source": "def check(candidate):\n assert candidate(k = 100) == 5\n assert candidate(k = 1) == 5\n assert candidate(k = 10000) == 5\n assert candidate(k = 1000000) == 5\n assert candidate(k = 3) == 5\n assert candidate(k = 0) == 5\n assert candidate(k = 1000) == 5\n a...
[ "0", "5", "3" ]
[]
{ "canonical_parameter_names": [ "k" ], "leetcode_dataset_entry_point": "Solution().preimageSizeFZF", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:50", "tests_total": 104, "tests_dr...
cpp
{ "raw_signature": "int preimageSizeFZF(int k) {", "container": "Solution", "callable": "preimageSizeFZF", "parameters": [ { "name": "k", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
794
valid-tic-tac-toe-state
Medium
Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game. The board is a 3 x 3 array that consists of characters ' ', 'X', and 'O'. The ' ' character represents an empty square. Here are the rules of Tic-Tac...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = ['XOX', 'O O', 'XOX']) == True\n assert candidate(board = ['X ', 'X ', 'X ']) == False\n assert candidate(board = ['XOX', 'O O', 'XOX']) == True\n assert candidate(board = ['XXX', ' ', 'O O']) == True\n assert ca...
[ "[\"O \",\" \",\" \"]", "[\"XOX\",\" X \",\" \"]", "[\"XOX\",\"O O\",\"XOX\"]" ]
[]
{ "canonical_parameter_names": [ "board" ], "leetcode_dataset_entry_point": "Solution().validTicTacToe", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:52", "tests_total": 91, "tests_...
cpp
{ "raw_signature": "bool validTicTacToe(vector<string>& board) {", "container": "Solution", "callable": "validTicTacToe", "parameters": [ { "name": "board", "type": "vector<string>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
795
number-of-subarrays-with-bounded-maximum
Medium
Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right]. The test cases are generated so that the answer will fit in a 32-bit integer. Example 1: Input: nums = [2,1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 2, 1],left = 1,right = 5) == 6\n assert candidate(nums = [73, 55, 36, 5, 55, 14, 9, 7, 72, 52],left = 32,right = 69) == 22\n assert candidate(nums = [2, 1, 4, 3],left = 2,right = 3) == 3\n assert candidate(nums = [8, ...
[ "[2,1,4,3]\n2\n3", "[2,9,2,5,6]\n2\n8" ]
[]
{ "canonical_parameter_names": [ "nums", "left", "right" ], "leetcode_dataset_entry_point": "Solution().numSubarrayBoundedMax", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:55",...
cpp
{ "raw_signature": "int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {", "container": "Solution", "callable": "numSubarrayBoundedMax", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "left", "type": "int" }, { "name": "righ...
796
rotate-string
Easy
Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s consists of moving the leftmost character of s to the rightmost position. - For example, if s = "abcde", then it will be "bcdea" after one shift. Example 1: Input: s = "abcde", goal = "cdeab" Ou...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaa\",goal = \"aaa\") == True\n assert candidate(s = \"abcdefg\",goal = \"efgabcd\") == True\n assert candidate(s = \"abab\",goal = \"abba\") == False\n assert candidate(s = \"abcd\",goal = \"dcba\") == False\n assert c...
[ "\"m\"\n\"f\"", "\"c\"\n\"w\"" ]
[]
{ "canonical_parameter_names": [ "s", "goal" ], "leetcode_dataset_entry_point": "Solution().rotateString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:57", "tests_total": 113, ...
cpp
{ "raw_signature": "bool rotateString(string s, string goal) {", "container": "Solution", "callable": "rotateString", "parameters": [ { "name": "s", "type": "string" }, { "name": "goal", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/code...
797
all-paths-from-source-to-target
Medium
Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order. The graph is given as follows: graph[i] is a list of all nodes you can visit from node i (i.e., there is a directed edge from node i to node graph[i][j]). Example 1:...
{ "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,2],[3],[3],[]]", "[[4,3,1],[3,2,4],[3],[4],[]]" ]
[]
{ "canonical_parameter_names": [ "graph" ], "leetcode_dataset_entry_point": "Solution().allPathsSourceTarget", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:59:59", "tests_total": 72, "...
cpp
{ "raw_signature": "vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {", "container": "Solution", "callable": "allPathsSourceTarget", "parameters": [ { "name": "graph", "type": "vector<vector<int>>&" } ], "return_type": "vector<vector<int>>", "signature_source": "le...
798
smallest-rotation-with-highest-score
Hard
You are given an array nums. You can rotate it by a non-negative integer k so that the array becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]. Afterward, any entries that are less than or equal to their index are worth one point. - For example, if we have nums = [2,4,1,3,0], ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 0, 2, 4]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4]) == 0\n assert candidate(nums = [1, 0, 3, 4, 2]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 0]) == 1\n assert candidate(nums = [1, 0, 2, 3, 4]) == 0\n...
[ "[2,3,1,4,0]", "[1,3,0,2,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().bestRotation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:01", "tests_total": 94, "tests_dro...
cpp
{ "raw_signature": "int bestRotation(vector<int>& nums) {", "container": "Solution", "callable": "bestRotation", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
799
champagne-tower
Medium
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100^th row. Each glass holds one cup of champagne. Then, some champagne is poured into the first glass at the top. When the topmost glass is full, any excess liquid poured will fall equally to the glass im...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "0\n0\n0", "0\n1\n0", "0\n1\n1" ]
[]
{ "canonical_parameter_names": [ "poured", "query_row", "query_glass" ], "leetcode_dataset_entry_point": "Solution().champagneTower", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:0...
cpp
{ "raw_signature": "double champagneTower(int poured, int query_row, int query_glass) {", "container": "Solution", "callable": "champagneTower", "parameters": [ { "name": "poured", "type": "int" }, { "name": "query_row", "type": "int" }, { "name": "query_glass",...
801
minimum-swaps-to-make-sequences-increasing
Hard
You are given two integer arrays of the same length nums1 and nums2. In one operation, you are allowed to swap nums1[i] with nums2[i]. - For example, if nums1 = [1,2,3,8], and nums2 = [5,6,7,4], you can swap the element at i = 3 to obtain nums1 = [1,2,3,4] and nums2 = [5,6,7,8]. Return the minimum number of needed op...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 19, 14, 6, 7],nums2 = [6, 5, 8, 11, 10]) == 2\n assert candidate(nums1 = [0, 4, 4, 5, 9],nums2 = [0, 1, 6, 8, 10]) == 1\n assert candidate(nums1 = [10, 19, 18, 3],nums2 = [5, 5, 5, 4]) == 2\n assert candidate(nums1 ...
[ "[1,3,5,4]\n[1,2,3,7]", "[0,3,5,8,9]\n[2,1,4,6,9]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().minSwap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:08", "tests_total": 107, ...
cpp
{ "raw_signature": "int minSwap(vector<int>& nums1, vector<int>& nums2) {", "container": "Solution", "callable": "minSwap", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" } ], "return_type": "int", "signature_s...
802
find-eventual-safe-states
Medium
There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nodes adjacent to node i, meaning there is an edge from node i to each node in graph[i]. A node is a terminal node if there are no outgoing e...
{ "language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 2, 3, 4], [1, 2], [3, 4], [0, 4], []]) == [4]\n assert candidate(graph = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], []]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,...
[ "[[1,2],[2,3],[5],[0],[5],[],[]]", "[[1,2,3,4],[1,2],[3,4],[0,4],[]]" ]
[]
{ "canonical_parameter_names": [ "graph" ], "leetcode_dataset_entry_point": "Solution().eventualSafeNodes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:11", "tests_total": 81, "tes...
cpp
{ "raw_signature": "vector<int> eventualSafeNodes(vector<vector<int>>& graph) {", "container": "Solution", "callable": "eventualSafeNodes", "parameters": [ { "name": "graph", "type": "vector<vector<int>>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", ...
803
bricks-falling-when-hit
Hard
You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if: - It is directly connected to the top of the grid, or - At least one other brick in its four adjacent cells is stable. You are also given an array hits, which is a sequence of erasures we want to...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 1, 0]],hits = [[0, 0], [1, 1], [2, 2]]) == [4, 0, 0]\n assert candidate(grid = [[1, 1, 1, 1], [0, 1, 0, 1], [1, 1, 1, 1]],hits = [[1, 0], [1, 2]]) == [0, 0]\n assert candidate(grid = [[1, ...
[ "[[1,0,0,0],[1,1,1,0]]\n[[1,0]]", "[[1,0,0,0],[1,1,0,0]]\n[[1,1],[1,0]]" ]
[]
{ "canonical_parameter_names": [ "grid", "hits" ], "leetcode_dataset_entry_point": "Solution().hitBricks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:13", "tests_total": 155, ...
cpp
{ "raw_signature": "vector<int> hitBricks(vector<vector<int>>& grid, vector<vector<int>>& hits) {", "container": "Solution", "callable": "hitBricks", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" }, { "name": "hits", "type": "vector<vector<int>>&" } ]...
804
unique-morse-code-words
Easy
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: - 'a' maps to ".-", - 'b' maps to "-...", - 'c' maps to "-.-.", and so on. For convenience, the full table for the 26 letters of the English alphabet is given below: [".-","-...","-.-.","-..",...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['s', 'u', 'n']) == 3\n assert candidate(words = ['mnop', 'qrst', 'uvwx', 'yz']) == 4\n assert candidate(words = ['hello', 'world']) == 2\n assert candidate(words = ['a']) == 1\n assert candidate(words = ['morse', 'co...
[ "[\"gin\",\"zen\",\"gig\",\"msg\"]", "[\"a\"]" ]
[]
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().uniqueMorseRepresentations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:15", "tests_total": 8...
cpp
{ "raw_signature": "int uniqueMorseRepresentations(vector<string>& words) {", "container": "Solution", "callable": "uniqueMorseRepresentations", "parameters": [ { "name": "words", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_...
805
split-array-with-same-average
Hard
You are given an integer array nums. You should move each element of nums into one of the two arrays A and B such that A and B are non-empty, and average(A) == average(B). Return true if it is possible to achieve that and false otherwise. Note that for an array arr, average(arr) is the sum of all the elements of arr...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [2, 4,...
[ "[1,2,3,4,5,6,7,8]", "[3,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().splitArraySameAverage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:17", "tests_total": 100, ...
cpp
{ "raw_signature": "bool splitArraySameAverage(vector<int>& nums) {", "container": "Solution", "callable": "splitArraySameAverage", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetco...
806
number-of-lines-to-write-string
Easy
You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is. Specifically, widths[0] is the width of 'a', widths[1] is the width of 'b', and so on. You are trying to write s across several lines, where each line is no longer than 100 pixels. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(widths = [4, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],s = \"bbbcccdddaaa\") == [2, 4]\n assert candidate(widths = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, ...
[ "[10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]\n\"abcdefghijklmnopqrstuvwxyz\"", "[4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10]\n\"bbbcccdddaaa\"" ]
[]
{ "canonical_parameter_names": [ "widths", "s" ], "leetcode_dataset_entry_point": "Solution().numberOfLines", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:19", "tests_total": 46, ...
cpp
{ "raw_signature": "vector<int> numberOfLines(vector<int>& widths, string s) {", "container": "Solution", "callable": "numberOfLines", "parameters": [ { "name": "widths", "type": "vector<int>&" }, { "name": "s", "type": "string" } ], "return_type": "vector<int>", "s...
807
max-increase-to-keep-city-skyline
Medium
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n integer matrix grid where grid[r][c] represents the height of the building located in the block at row r and column c. A city's skyline is the outer contour formed ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[3, 0, 8, 4], [2, 4, 5, 7], [9, 2, 6, 3], [0, 3, 1, 0]]) == 35\n assert candidate(grid = [[10, 0, 0, 0], [0, 10, 0, 0], [0, 0, 10, 0], [0, 0, 0, 10]]) == 120...
[ "[[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]", "[[0,0,0],[0,0,0],[0,0,0]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().maxIncreaseKeepingSkyline", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:22", "tests_total": 69,...
cpp
{ "raw_signature": "int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {", "container": "Solution", "callable": "maxIncreaseKeepingSkyline", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", ...
808
soup-servings
Medium
You have two soups, A and B, each starting with n mL. On every turn, one of the following four serving operations is chosen at random, each with probability 0.25 independent of all previous turns: - pour 100 mL from type A and 0 mL from type B - pour 75 mL from type A and 25 mL from type B - pour 50 mL from type A and...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "50", "100" ]
[ "For large n, the answer approaches a constant value.", "Which soup is more likely to deplete first if we are allowed to perform many operations without bias?" ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().soupServings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:24", "tests_total": 55, "tests_droppe...
cpp
{ "raw_signature": "double soupServings(int n) {", "container": "Solution", "callable": "soupServings", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
809
expressive-words
Medium
Sometimes people repeat letters to represent extra feeling. For example: - "hello" -> "heeellooo" - "hi" -> "hiiii" In these strings like "heeellooo", we have groups of adjacent letters that are all the same: "h", "eee", "ll", "ooo". You are given a string s and an array of query strings words. A query word is stret...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabaaa\",words = ['aa', 'aaa', 'aaaa', 'aabaaa']) == 1\n assert candidate(s = \"aaabaaa\",words = ['aaa', 'aab', 'aaaaa', 'aaabaa', 'aaaba']) == 2\n assert candidate(s = \"abcd\",words = ['abc', 'abcd', 'abdc', 'aabbccdd']) ...
[ "\"heeellooo\"\n[\"hello\", \"hi\", \"helo\"]", "\"zzzzzyyyyy\"\n[\"zzyy\",\"zy\",\"zyy\"]" ]
[]
{ "canonical_parameter_names": [ "s", "words" ], "leetcode_dataset_entry_point": "Solution().expressiveWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:26", "tests_total": 71,...
cpp
{ "raw_signature": "int expressiveWords(string s, vector<string>& words) {", "container": "Solution", "callable": "expressiveWords", "parameters": [ { "name": "s", "type": "string" }, { "name": "words", "type": "vector<string>&" } ], "return_type": "int", "signature...
810
chalkboard-xor-game
Hard
You are given an array of integers nums represents the numbers written on a chalkboard. Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. The bitwise X...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1, 1]) == True\n assert candidate(nums = [8, 15, 23, 42, 67]) == False\n assert candidate(nums = [1, 2, 2, 1]) == True\n assert candidate(nums = [1, 3, 5, 7, 9]) =...
[ "[1,1,2]", "[0,1]", "[1,2,3]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().xorGame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:28", "tests_total": 122, "tests_dropped...
cpp
{ "raw_signature": "bool xorGame(vector<int>& nums) {", "container": "Solution", "callable": "xorGame", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
811
subdomain-visit-count
Medium
A website domain "discuss.leetcode.com" consists of various subdomains. At the top level, we have "com", at the next level, we have "leetcode.com" and at the lowest level, "discuss.leetcode.com". When we visit a domain like "discuss.leetcode.com", we will also visit the parent domains "leetcode.com" and "com" implicitl...
{ "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 ...
[ "[\"9001 discuss.leetcode.com\"]", "[\"900 google.mail.com\", \"50 yahoo.com\", \"1 intel.mail.com\", \"5 wiki.org\"]" ]
[]
{ "canonical_parameter_names": [ "cpdomains" ], "leetcode_dataset_entry_point": "Solution().subdomainVisits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:30", "tests_total": 68, "t...
cpp
{ "raw_signature": "vector<string> subdomainVisits(vector<string>& cpdomains) {", "container": "Solution", "callable": "subdomainVisits", "parameters": [ { "name": "cpdomains", "type": "vector<string>&" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", ...
812
largest-triangle-area
Easy
Given an array of points on the X-Y plane points where points[i] = [x_i, y_i], return the area of the largest triangle that can be formed by any three different points. Answers within 10^-5 of the actual answer will be accepted. Example 1: Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] Output: 2.00000 Explanation: T...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "[[0,0],[0,1],[1,0],[0,2],[2,0]]", "[[1,0],[0,0],[0,1]]" ]
[]
{ "canonical_parameter_names": [ "points" ], "leetcode_dataset_entry_point": "Solution().largestTriangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:33", "tests_total": 113, ...
cpp
{ "raw_signature": "double largestTriangleArea(vector<vector<int>>& points) {", "container": "Solution", "callable": "largestTriangleArea", "parameters": [ { "name": "points", "type": "vector<vector<int>>&" } ], "return_type": "double", "signature_source": "leetcode/codeSnippets", "t...
813
largest-sum-of-averages
Medium
You are given an integer array nums and an integer k. You can partition the array into at most k non-empty adjacent subarrays. The score of a partition is the sum of the averages of each subarray. Note that the partition must use every integer in nums, and that the score is not necessarily an integer. Return the maxi...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "[9,1,2,3,9]\n3", "[1,2,3,4,5,6,7]\n4" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().largestSumOfAverages", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:35", "tests_total":...
cpp
{ "raw_signature": "double largestSumOfAverages(vector<int>& nums, int k) {", "container": "Solution", "callable": "largestSumOfAverages", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "double", "signatu...
815
bus-routes
Hard
You are given an array routes representing bus routes where routes[i] is a bus route that the i^th bus repeats forever. - For example, if routes[0] = [1, 5, 7], this means that the 0^th bus travels in the sequence 1 -> 5 -> 7 -> 1 -> 5 -> 7 -> 1 -> ... forever. You will start at the bus stop source (You are not on an...
{ "language": "python", "source": "def check(candidate):\n assert candidate(routes = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],source = 1,target = 9) == -1\n assert candidate(routes = [[1, 2, 3, 4, 5]],source = 1,target = 5) == 1\n assert candidate(routes = [[7, 12], [4, 5, 15], [6], [15, 19], [9, 12, 13]],source ...
[ "[[1,2,7],[3,6,7]]\n1\n6", "[[7,12],[4,5,15],[6],[15,19],[9,12,13]]\n15\n12" ]
[]
{ "canonical_parameter_names": [ "routes", "source", "target" ], "leetcode_dataset_entry_point": "Solution().numBusesToDestination", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00...
cpp
{ "raw_signature": "int numBusesToDestination(vector<vector<int>>& routes, int source, int target) {", "container": "Solution", "callable": "numBusesToDestination", "parameters": [ { "name": "routes", "type": "vector<vector<int>>&" }, { "name": "source", "type": "int" }, ...
816
ambiguous-coordinates
Medium
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)". Then, we removed all commas, decimal points, and spaces and ended up with the string s. - For example, "(1, 3)" becomes s = "(13)" and "(2, 0.5)" becomes s = "(205)". Return a list of strings representing all possibilities for what our original coord...
{ "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 ...
[ "\"(123)\"", "\"(0123)\"", "\"(00011)\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().ambiguousCoordinates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:41", "tests_total": 93, "test...
cpp
{ "raw_signature": "vector<string> ambiguousCoordinates(string s) {", "container": "Solution", "callable": "ambiguousCoordinates", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source": "leetco...
818
race-car
Hard
Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse): - When you get an instruction 'A', your car does the following: - position += speed - speed *= 2 ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(target = 3) == 2\n assert candidate(target = 6) == 5\n assert candidate(target = 4) == 5\n assert candidate(target = 10) == 7\n assert candidate(target = 1) == 1\n assert candidate(target = 100) == 19\n assert candidate...
[ "3", "6" ]
[]
{ "canonical_parameter_names": [ "target" ], "leetcode_dataset_entry_point": "Solution().racecar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:46", "tests_total": 49, "tests_droppe...
cpp
{ "raw_signature": "int racecar(int target) {", "container": "Solution", "callable": "racecar", "parameters": [ { "name": "target", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
820
short-encoding-of-words
Medium
A valid encoding of an array of words is any reference string s and array of indices indices such that: - words.length == indices.length - The reference string s ends with the '#' character. - For each index indices[i], the substring of s starting from indices[i] and up to (but not including) the next '#' character is...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl', 'mno']) == 20\n assert candidate(words = ['hello', 'hell', 'he', 'h']) == 16\n assert candidate(words = ['aaa', 'aa', 'a']) == 4\n assert candidate(words = ['one', 'two', 'three', 'four', 'fi...
[ "[\"time\",\"me\",\"bell\"]", "[\"t\"]" ]
[]
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().minimumLengthEncoding", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:48", "tests_total": 116, ...
cpp
{ "raw_signature": "int minimumLengthEncoding(vector<string>& words) {", "container": "Solution", "callable": "minimumLengthEncoding", "parameters": [ { "name": "words", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "...
821
shortest-distance-to-a-character
Easy
Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s. The distance between two indices i and j is abs(i - j), where abs is the absolute value function. Example 1:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abba\",c = \"a\") == [0, 1, 1, 0]\n assert candidate(s = \"loveleetcode\",c = \"e\") == [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]\n assert candidate(s = \"abcde\",c = \"e\") == [4, 3, 2, 1, 0]\n assert candidate(s = \"abcabcabc...
[ "\"loveleetcode\"\n\"e\"", "\"aaab\"\n\"b\"" ]
[]
{ "canonical_parameter_names": [ "s", "c" ], "leetcode_dataset_entry_point": "Solution().shortestToChar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:51", "tests_total": 118, "...
cpp
{ "raw_signature": "vector<int> shortestToChar(string s, char c) {", "container": "Solution", "callable": "shortestToChar", "parameters": [ { "name": "s", "type": "string" }, { "name": "c", "type": "char" } ], "return_type": "vector<int>", "signature_source": "leetc...
822
card-flipping-game
Medium
You are given two 0-indexed integer arrays fronts and backs of length n, where the i^th card has the positive integer fronts[i] printed on the front and backs[i] printed on the back. Initially, each card is placed on a table such that the front number is facing up and the other is facing down. You may flip over any num...
{ "language": "python", "source": "def check(candidate):\n assert candidate(fronts = [1, 3, 5, 7],backs = [2, 4, 6, 8]) == 1\n assert candidate(fronts = [1, 1, 2, 2],backs = [2, 2, 1, 1]) == 1\n assert candidate(fronts = [1, 3, 5, 7],backs = [2, 4, 6, 8]) == 1\n assert candidate(fronts = [1, 2, 3, 4, 5]...
[ "[1,2,4,4,7]\n[1,3,4,1,3]", "[1]\n[1]" ]
[]
{ "canonical_parameter_names": [ "fronts", "backs" ], "leetcode_dataset_entry_point": "Solution().flipgame", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:53", "tests_total": 107, ...
cpp
{ "raw_signature": "int flipgame(vector<int>& fronts, vector<int>& backs) {", "container": "Solution", "callable": "flipgame", "parameters": [ { "name": "fronts", "type": "vector<int>&" }, { "name": "backs", "type": "vector<int>&" } ], "return_type": "int", "signatu...
823
binary-trees-with-factors
Medium
Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1. We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of its children. Return the number of binary trees we c...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 40, 80]) == 4\n assert candidate(arr = [2, 4, 5, 10]) == 7\n assert candidate(arr = [2, 3, 6, 18]) == 12\n assert candidate(arr = [5, 10, 20, 40, 80]) == 5\n assert candidate(arr = [18, 3, 6, 2]) == 12\n ass...
[ "[2,4]", "[2,4,5,10]" ]
[]
{ "canonical_parameter_names": [ "arr" ], "leetcode_dataset_entry_point": "Solution().numFactoredBinaryTrees", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:55", "tests_total": 105, ...
cpp
{ "raw_signature": "int numFactoredBinaryTrees(vector<int>& arr) {", "container": "Solution", "callable": "numFactoredBinaryTrees", "parameters": [ { "name": "arr", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode...
824
goat-latin
Easy
You are given a string sentence that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only. We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows: - If a word begins with a vowel ('a', 'e', 'i'...
{ "language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"Convert this sentence\") == \"onvertCmaa histmaaa entencesmaaaa\"\n assert candidate(sentence = \"In the end\") == \"Inmaa hetmaaa endmaaaa\"\n assert candidate(sentence = \"a e i o u\") == \"amaa emaaa imaaaa omaaaaa ...
[ "\"I speak Goat Latin\"", "\"The quick brown fox jumped over the lazy dog\"" ]
[]
{ "canonical_parameter_names": [ "sentence" ], "leetcode_dataset_entry_point": "Solution().toGoatLatin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:57", "tests_total": 135, "tests...
cpp
{ "raw_signature": "string toGoatLatin(string sentence) {", "container": "Solution", "callable": "toGoatLatin", "parameters": [ { "name": "sentence", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
825
friends-of-appropriate-ages
Medium
There are n persons on a social media website. You are given an integer array ages where ages[i] is the age of the i^th person. A Person x will not send a friend request to a person y (x != y) if any of the following conditions is true: - age[y] <= 0.5 * age[x] + 7 - age[y] > age[x] - age[y] > 100 && age[x] < 100 Ot...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ages = [120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110]) == 55\n assert candidate(ages = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 90\n assert candidate(ages = [18, 18, 18, 18, 18, 18, 18, 18, 18, 18]) == 90\n assert c...
[ "[16,16]", "[16,17,18]", "[20,30,100,110,120]" ]
[]
{ "canonical_parameter_names": [ "ages" ], "leetcode_dataset_entry_point": "Solution().numFriendRequests", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:00:59", "tests_total": 102, "tes...
cpp
{ "raw_signature": "int numFriendRequests(vector<int>& ages) {", "container": "Solution", "callable": "numFriendRequests", "parameters": [ { "name": "ages", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSni...
826
most-profit-assigning-work
Medium
You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where: - difficulty[i] and profit[i] are the difficulty and the profit of the i^th job, and - worker[j] is the ability of j^th worker (i.e., the j^th worker can only complete a job with difficulty at most worker[j]). Every worke...
{ "language": "python", "source": "def check(candidate):\n assert candidate(difficulty = [68, 35, 52, 47, 86],profit = [67, 17, 17, 26, 86],worker = [68, 37, 50, 76, 33]) == 177\n assert candidate(difficulty = [10, 15, 25],profit = [100, 150, 250],worker = [20, 25, 30]) == 650\n assert candidate(difficulty...
[ "[2,4,6,8,10]\n[10,20,30,40,50]\n[4,5,6,7]", "[85,47,57]\n[24,66,99]\n[40,25,25]" ]
[]
{ "canonical_parameter_names": [ "difficulty", "profit", "worker" ], "leetcode_dataset_entry_point": "Solution().maxProfitAssignment", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:...
cpp
{ "raw_signature": "int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {", "container": "Solution", "callable": "maxProfitAssignment", "parameters": [ { "name": "difficulty", "type": "vector<int>&" }, { "name": "profit", "type": "vector...
827
making-a-large-island
Hard
You are given an n x n binary matrix grid. You are allowed to change at most one 0 to be 1. Return the size of the largest island in grid after applying this operation. An island is a 4-directionally connected group of 1s. Example 1: Input: grid = [[1,0],[0,1]] Output: 3 Explanation: Change one 0 to 1 and connect t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1], [1, 0]]) == 4\n assert candidate(grid = [[1, 0], [0, 1]]) == 3\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]])...
[ "[[1,0],[0,1]]", "[[1,1],[1,0]]", "[[1,1],[1,1]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().largestIsland", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:05", "tests_total": 81, "tests_dr...
cpp
{ "raw_signature": "int largestIsland(vector<vector<int>>& grid) {", "container": "Solution", "callable": "largestIsland", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode...
828
count-unique-characters-of-all-substrings-of-a-given-string
Hard
Let's define a function countUniqueChars(s) that returns the number of unique characters in s. - For example, calling countUniqueChars(s) if s = "LEETCODE" then "L", "T", "C", "O", "D" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5. Given a string s, return the sum of co...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"ABCDEFG\") == 84\n assert candidate(s = \"ABAC\") == 16\n assert candidate(s = \"ABAB\") == 12\n assert candidate(s = \"JXWTRVABFBJSFNWFTTTOWEJXSGZSWQSZSQXRXRJTSFO\") == 4609\n assert candidate(s = \"ABCABC\") == 36\n ...
[ "\"ABC\"", "\"ABA\"", "\"LEETCODE\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().uniqueLetterString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:08", "tests_total": 160, "tests...
cpp
{ "raw_signature": "int uniqueLetterString(string s) {", "container": "Solution", "callable": "uniqueLetterString", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
829
consecutive-numbers-sum
Hard
Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers. Example 1: Input: n = 5 Output: 2 Explanation: 5 = 2 + 3 Example 2: Input: n = 9 Output: 3 Explanation: 9 = 4 + 5 = 2 + 3 + 4 Example 3: Input: n = 15 Output: 4 Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == 3\n assert candidate(n = 15) == 4\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 7\n assert candidate(n = 25) == 3\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 10\n...
[ "5", "9", "15" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().consecutiveNumbersSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:10", "tests_total": 53, "tes...
cpp
{ "raw_signature": "int consecutiveNumbersSum(int n) {", "container": "Solution", "callable": "consecutiveNumbersSum", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
830
positions-of-large-groups
Easy
In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like s = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z", and "yy". A group is identified by an interval [start, end], where start and end denote the start and end indices (inclusive) of the group...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbbccccdddd\") == [[2, 4], [5, 8], [9, 12]]\n assert candidate(s = \"aabbbccccddeee\") == [[2, 4], [5, 8], [11, 13]]\n assert candidate(s = \"abcdefghijk\") == []\n assert candidate(s = \"aabbaa\") == []\n assert cand...
[ "\"abbxxxxzzy\"", "\"abc\"", "\"abcdddeeeeaabbbcd\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().largeGroupPositions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:12", "tests_total": 54, "tests...
cpp
{ "raw_signature": "vector<vector<int>> largeGroupPositions(string s) {", "container": "Solution", "callable": "largeGroupPositions", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source":...
831
masking-personal-information
Medium
You are given a personal information string s, representing either an email address or a phone number. Return the masked personal information using the below rules. Email address: An email address is: - A name consisting of at least two uppercase and lowercase English letters, followed by - The '@' symbol, followed ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"12345678901\") == \"+*-***-***-8901\"\n assert candidate(s = \"+11234567890\") == \"+*-***-***-7890\"\n assert candidate(s = \"123 456 7890\") == \"***-***-7890\"\n assert candidate(s = \"+1-800-555-0199\") == \"+*-***-***...
[ "\"LeetCode@LeetCode.com\"", "\"AB@qq.com\"", "\"1(234)567-890\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().maskPII", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:15", "tests_total": 187, "tests_dropped": ...
cpp
{ "raw_signature": "string maskPII(string s) {", "container": "Solution", "callable": "maskPII", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
832
flipping-an-image
Easy
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. - For example, flipping [1,1,0] horizontally results in [0,1,1]. To invert an image means that each 0 is replaced by 1, and each...
{ "language": "python", "source": "def check(candidate):\n assert candidate(image = [[1, 1], [1, 0]]) == [[0, 0], [1, 0]]\n assert candidate(image = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]]) == [[1, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1], [1, 0, 1, 0]]\n assert candidate(image = [[1, 0, 1], [...
[ "[[1,1,0],[1,0,1],[0,0,0]]", "[[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]]" ]
[]
{ "canonical_parameter_names": [ "image" ], "leetcode_dataset_entry_point": "Solution().flipAndInvertImage", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:17", "tests_total": 61, "te...
cpp
{ "raw_signature": "vector<vector<int>> flipAndInvertImage(vector<vector<int>>& image) {", "container": "Solution", "callable": "flipAndInvertImage", "parameters": [ { "name": "image", "type": "vector<vector<int>>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetco...
833
find-and-replace-in-string
Medium
You are given a 0-indexed string s that you must perform k replacement operations on. The replacement operations are given as three 0-indexed parallel arrays, indices, sources, and targets, all of length k. To complete the i^th replacement operation: 1. Check if the substring sources[i] occurs at index indices[i] in ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",indices = [0, 2],sources = ['a', 'cd'],targets = ['eee', 'ffff']) == \"eeebffff\"\n assert candidate(s = \"abcd\",indices = [0, 1, 2, 3],sources = ['a', 'b', 'c', 'd'],targets = ['aa', 'bb', 'cc', 'dd']) == \"aabbccdd\"\n...
[ "\"abcd\"\n[0, 2]\n[\"a\", \"cd\"]\n[\"eee\", \"ffff\"]", "\"abcd\"\n[0, 2]\n[\"ab\",\"ec\"]\n[\"eee\",\"ffff\"]" ]
[]
{ "canonical_parameter_names": [ "s", "indices", "sources", "targets" ], "leetcode_dataset_entry_point": "Solution().findReplaceString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-...
cpp
{ "raw_signature": "string findReplaceString(string s, vector<int>& indices, vector<string>& sources, vector<string>& targets) {", "container": "Solution", "callable": "findReplaceString", "parameters": [ { "name": "s", "type": "string" }, { "name": "indices", "type": "vector...
834
sum-of-distances-in-tree
Hard
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given the integer n and the array edges where edges[i] = [a_i, b_i] indicates that there is an edge between nodes a_i and b_i in the tree. Return an array answer of length n where answer[i] is the sum of the distances ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [15, 19, 19, 19, 27, 27, 27, 27, 27, 27]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [10, 11, 11, 16...
[ "6\n[[0,1],[0,2],[2,3],[2,4],[2,5]]", "1\n[]", "2\n[[1,0]]" ]
[]
{ "canonical_parameter_names": [ "n", "edges" ], "leetcode_dataset_entry_point": "Solution().sumOfDistancesInTree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:21", "tests_total"...
cpp
{ "raw_signature": "vector<int> sumOfDistancesInTree(int n, vector<vector<int>>& edges) {", "container": "Solution", "callable": "sumOfDistancesInTree", "parameters": [ { "name": "n", "type": "int" }, { "name": "edges", "type": "vector<vector<int>>&" } ], "return_type...
835
image-overlap
Medium
You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values. We translate one image however we choose by sliding all the 1 bits left, right, up, and/or down any number of units. We then place it on top of the other image. We can then calcu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(img1 = [[1, 1, 0], [0, 1, 0], [0, 1, 0]],img2 = [[0, 0, 0], [0, 1, 1], [0, 0, 1]]) == 3\n assert candidate(img1 = [[1, 0], [0, 1]],img2 = [[1, 1], [1, 1]]) == 2\n assert candidate(img1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],img2 = [[0...
[ "[[1,1,0],[0,1,0],[0,1,0]]\n[[0,0,0],[0,1,1],[0,0,1]]", "[[1]]\n[[1]]", "[[0]]\n[[0]]" ]
[]
{ "canonical_parameter_names": [ "img1", "img2" ], "leetcode_dataset_entry_point": "Solution().largestOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:23", "tests_total": 75...
cpp
{ "raw_signature": "int largestOverlap(vector<vector<int>>& img1, vector<vector<int>>& img2) {", "container": "Solution", "callable": "largestOverlap", "parameters": [ { "name": "img1", "type": "vector<vector<int>>&" }, { "name": "img2", "type": "vector<vector<int>>&" } ...
836
rectangle-overlap
Easy
An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are parallel to the Y-axis. Two rectangles overlap i...
{ "language": "python", "source": "def check(candidate):\n assert candidate(rec1 = [-5, -5, -3, -3],rec2 = [-4, -4, -2, -2]) == True\n assert candidate(rec1 = [1, 1, 5, 5],rec2 = [4, 4, 8, 8]) == True\n assert candidate(rec1 = [-5, -5, -2, -2],rec2 = [-4, -4, -1, -1]) == True\n assert candidate(rec1 = [...
[ "[0,0,2,2]\n[1,1,3,3]", "[0,0,1,1]\n[1,0,2,1]", "[0,0,1,1]\n[2,2,3,3]" ]
[]
{ "canonical_parameter_names": [ "rec1", "rec2" ], "leetcode_dataset_entry_point": "Solution().isRectangleOverlap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:26", "tests_total"...
cpp
{ "raw_signature": "bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {", "container": "Solution", "callable": "isRectangleOverlap", "parameters": [ { "name": "rec1", "type": "vector<int>&" }, { "name": "rec2", "type": "vector<int>&" } ], "return_type": "b...
837
new-21-game
Medium
Alice plays the following game, loosely based on the card game "21". Alice starts with 0 points and draws numbers while she has less than k points. During each draw, she gains an integer number of points randomly from the range [1, maxPts], where maxPts is an integer. Each draw is independent and the outcomes have equ...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "10\n1\n10", "6\n1\n10", "21\n17\n10" ]
[]
{ "canonical_parameter_names": [ "n", "k", "maxPts" ], "leetcode_dataset_entry_point": "Solution().new21Game", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:28", "tests_total":...
cpp
{ "raw_signature": "double new21Game(int n, int k, int maxPts) {", "container": "Solution", "callable": "new21Game", "parameters": [ { "name": "n", "type": "int" }, { "name": "k", "type": "int" }, { "name": "maxPts", "type": "int" } ], "return_type...
838
push-dominoes
Medium
There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right. After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(dominoes = \"R..L\") == \"RRLL\"\n assert candidate(dominoes = \"..R......L..\") == \"..RRRRLLLL..\"\n assert candidate(dominoes = \"RRRRRRRRRR\") == \"RRRRRRRRRR\"\n assert candidate(dominoes = \"L........R\") == \"L........R\"...
[ "\"RR.L\"", "\".L.R...LR..L..\"" ]
[]
{ "canonical_parameter_names": [ "dominoes" ], "leetcode_dataset_entry_point": "Solution().pushDominoes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:30", "tests_total": 162, "test...
cpp
{ "raw_signature": "string pushDominoes(string dominoes) {", "container": "Solution", "callable": "pushDominoes", "parameters": [ { "name": "dominoes", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
839
similar-string-groups
Hard
Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X. For example, "tars" and "rats" are similar (swapping at positions 0 and 2), and "rats" and "arts" are similar, but "star" is not similar ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(strs = ['abc', 'bca', 'cab', 'cba', 'bac', 'acb']) == 1\n assert candidate(strs = ['ab', 'ba', 'abc', 'cab', 'bca']) == 1\n assert candidate(strs = ['aaaaa', 'aaabb', 'aaabc', 'aaaba', 'aaaaa']) == 1\n assert candidate(strs = ['...
[ "[\"tars\",\"rats\",\"arts\",\"star\"]", "[\"omv\",\"ovm\"]" ]
[]
{ "canonical_parameter_names": [ "strs" ], "leetcode_dataset_entry_point": "Solution().numSimilarGroups", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:32", "tests_total": 57, "tests...
cpp
{ "raw_signature": "int numSimilarGroups(vector<string>& strs) {", "container": "Solution", "callable": "numSimilarGroups", "parameters": [ { "name": "strs", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
840
magic-squares-in-grid
Medium
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given a row x col grid of integers, how many 3 x 3 magic square subgrids are there? Note: while a magic square can only contain numbers from 1 to 9, grid may contain numb...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[4, 3, 8, 4, 0], [9, 5, 1, 9, 3], [2, 7, 6, 2, 4], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) == 1\n assert candidate(grid = [[7, 0, 5], [3, 5, 1], [6, 4, 3]]) == 0\n assert candidate(grid = [[8]]) == 0\n assert candidate(grid ...
[ "[[4,3,8,4],[9,5,1,9],[2,7,6,2]]", "[[8]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().numMagicSquaresInside", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:35", "tests_total": 82, "...
cpp
{ "raw_signature": "int numMagicSquaresInside(vector<vector<int>>& grid) {", "container": "Solution", "callable": "numMagicSquaresInside", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_so...
841
keys-and-rooms
Medium
There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. When you visit a room, you may find a set of distinct keys in it. Each key has a number on it, denoting which room it unlocks, a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(rooms = [[1], [2], [], [3]]) == False\n assert candidate(rooms = [[1], [1, 2], [2], []]) == False\n assert candidate(rooms = [[1], [2, 3], [3], []]) == True\n assert candidate(rooms = [[2, 3], [0, 1], [3], [0]]) == False\n as...
[ "[[1],[2],[3],[]]", "[[1,3],[3,0,1],[2],[0]]" ]
[]
{ "canonical_parameter_names": [ "rooms" ], "leetcode_dataset_entry_point": "Solution().canVisitAllRooms", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:37", "tests_total": 86, "test...
cpp
{ "raw_signature": "bool canVisitAllRooms(vector<vector<int>>& rooms) {", "container": "Solution", "callable": "canVisitAllRooms", "parameters": [ { "name": "rooms", "type": "vector<vector<int>>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source":...
842
split-array-into-fibonacci-sequence
Medium
You are given a string of digits num, such as "123456579". We can split it into a Fibonacci-like sequence [123, 456, 579]. Formally, a Fibonacci-like sequence is a list f of non-negative integers such that: - 0 <= f[i] < 2^31, (that is, each integer fits in a 32-bit signed integer type), - f.length >= 3, and - f[i] +...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = \"10\") == []\n assert candidate(num = \"1203\") == []\n assert candidate(num = \"101001011001101110000110011100011010011110000\") == []\n assert candidate(num = \"0123\") == []\n assert candidate(num = \"53983465721539...
[ "\"1101111\"", "\"112358130\"", "\"0123\"" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().splitIntoFibonacci", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:39", "tests_total": 78, "test...
cpp
{ "raw_signature": "vector<int> splitIntoFibonacci(string num) {", "container": "Solution", "callable": "splitIntoFibonacci", "parameters": [ { "name": "num", "type": "string" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
844
backspace-string-compare
Easy
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty. Example 1: Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Example 2: Inp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"#a#c\",t = \"c\") == True\n assert candidate(s = \"xywrrmp\",t = \"xywrrmu#p\") == True\n assert candidate(s = \"bbbextm#w\",t = \"bb#bbbextm#w\") == False\n assert candidate(s = \"ab\",t = \"a#b\") == False\n assert ca...
[ "\"ab#c\"\n\"ad#c\"", "\"ab##\"\n\"c#d#\"", "\"a#c\"\n\"b\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().backspaceCompare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:41", "tests_total": 109, ...
cpp
{ "raw_signature": "bool backspaceCompare(string s, string t) {", "container": "Solution", "callable": "backspaceCompare", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/co...
845
longest-mountain-in-array
Medium
You may recall that an array arr is a mountain array if and only if: - arr.length >= 3 - There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that: - arr[0] < arr[1] < ... < arr[i - 1] < arr[i] - arr[i] > arr[i + 1] > ... > arr[arr.length - 1] Given an integer array arr, return the length of the...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 11\n assert candidate(arr = [0, 1, 0, 2, 1, 0, 1, 3, 2, 1]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1]) == 0\n assert candidate(arr = [1, 3, 1, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 11\...
[ "[2,1,4,7,3,2,5]", "[2,2,2]" ]
[]
{ "canonical_parameter_names": [ "arr" ], "leetcode_dataset_entry_point": "Solution().longestMountain", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:43", "tests_total": 160, "tests_...
cpp
{ "raw_signature": "int longestMountain(vector<int>& arr) {", "container": "Solution", "callable": "longestMountain", "parameters": [ { "name": "arr", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
846
hand-of-straights
Medium
Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards. Given an integer array hand where hand[i] is the value written on the i^th card and an integer groupSize, return true if she can rearrange the cards, or ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(hand = [1, 2, 3, 4, 5, 6],groupSize = 2) == True\n assert candidate(hand = [1, 1, 2, 2, 3, 3],groupSize = 3) == True\n assert candidate(hand = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],groupSize = 4) == True\n assert candidate(han...
[ "[1,2,3,6,2,3,4,7,8]\n3", "[1,2,3,4,5]\n4" ]
[]
{ "canonical_parameter_names": [ "hand", "groupSize" ], "leetcode_dataset_entry_point": "Solution().isNStraightHand", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:46", "tests_tota...
cpp
{ "raw_signature": "bool isNStraightHand(vector<int>& hand, int groupSize) {", "container": "Solution", "callable": "isNStraightHand", "parameters": [ { "name": "hand", "type": "vector<int>&" }, { "name": "groupSize", "type": "int" } ], "return_type": "bool", "signa...
847
shortest-path-visiting-all-nodes
Hard
You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an edge. Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(graph = [[1, 2], [0, 2, 3], [0, 1], [1]]) == 3\n assert candidate(graph = [[2, 3, 4, 5], [3, 4, 5, 6], [0, 3, 4, 5], [0, 1, 2, 5], [0, 1, 2], [0, 1, 2, 3], [1]]) == 6\n assert candidate(graph = [[1, 3, 4, 5], [0, 2, 3, 4, 5], [1, 3...
[ "[[1,2,3],[0],[0],[0]]", "[[1],[0,2,4],[1,3,4],[2],[1,2]]" ]
[]
{ "canonical_parameter_names": [ "graph" ], "leetcode_dataset_entry_point": "Solution().shortestPathLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:48", "tests_total": 63, "te...
cpp
{ "raw_signature": "int shortestPathLength(vector<vector<int>>& graph) {", "container": "Solution", "callable": "shortestPathLength", "parameters": [ { "name": "graph", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source...
848
shifting-letters
Medium
You are given a string s of lowercase English letters and an integer array shifts of the same length. Call the shift() of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a'). - For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'. Now for each shifts[i] = x, we want ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaa\",shifts = [1, 2, 3]) == \"gfd\"\n assert candidate(s = \"abc\",shifts = [26, 52, 78]) == \"abc\"\n assert candidate(s = \"a\",shifts = [25]) == \"z\"\n assert candidate(s = \"abcdef\",shifts = [0, 0, 0, 0, 0, 0]) == \...
[ "\"abc\"\n[3,5,9]", "\"aaa\"\n[1,2,3]" ]
[]
{ "canonical_parameter_names": [ "s", "shifts" ], "leetcode_dataset_entry_point": "Solution().shiftingLetters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:50", "tests_total": 88...
cpp
{ "raw_signature": "string shiftingLetters(string s, vector<int>& shifts) {", "container": "Solution", "callable": "shiftingLetters", "parameters": [ { "name": "s", "type": "string" }, { "name": "shifts", "type": "vector<int>&" } ], "return_type": "string", "signatu...
849
maximize-distance-to-closest-person
Medium
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the i^th seat, and seats[i] = 0 represents that the i^th seat is empty (0-indexed). There is at least one empty seat, and at least one person sitting. Alex wants to sit in the seat such that the distance between him a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(seats = [0, 0, 0, 1, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [0, 0, 1, 0, 0, 0, 0, 1]) == 2\n assert candidate(seats = [0, 0, 0, 1, 0, 0, 0]) == 3\n assert candidate(seats = [1, 0, 0, 0]) == 3\n assert candidate(seats...
[ "[1,0,0,0,1,0,1]", "[1,0,0,0]", "[0,1]" ]
[]
{ "canonical_parameter_names": [ "seats" ], "leetcode_dataset_entry_point": "Solution().maxDistToClosest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:52", "tests_total": 120, "tes...
cpp
{ "raw_signature": "int maxDistToClosest(vector<int>& seats) {", "container": "Solution", "callable": "maxDistToClosest", "parameters": [ { "name": "seats", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSni...
850
rectangle-area-ii
Hard
You are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [x_i1, y_i1, x_i2, y_i2] denotes the i^th rectangle where (x_i1, y_i1) are the coordinates of the bottom-left corner, and (x_i2, y_i2) are the coordinates of the top-right corner. Calculate the total area covered by all rectangles in the plane. A...
{ "language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 1, 2, 2], [2, 2, 3, 3]]) == 3\n assert candidate(rectangles = [[0, 0, 1, 10], [0, 0, 10, 1], [1, 1, 2, 11], [1, 1, 11, 2]]) == 38\n assert candidate(rectangles = [[0, 0, 1, 1], [1, 0, 2, 1], [2, 0, 3...
[ "[[0,0,2,2],[1,0,2,3],[1,0,3,1]]", "[[0,0,1000000000,1000000000]]" ]
[]
{ "canonical_parameter_names": [ "rectangles" ], "leetcode_dataset_entry_point": "Solution().rectangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:54", "tests_total": 105, "t...
cpp
{ "raw_signature": "int rectangleArea(vector<vector<int>>& rectangles) {", "container": "Solution", "callable": "rectangleArea", "parameters": [ { "name": "rectangles", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source...
851
loud-and-rich
Medium
There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness. You are given an array richer where richer[i] = [a_i, b_i] indicates that a_i has more money than b_i and an integer array quiet where quiet[i] is the quietness of the i^th person....
{ "language": "python", "source": "def check(candidate):\n assert candidate(richer = [],quiet = [0]) == [0]\n assert candidate(richer = [[4, 3], [3, 2], [2, 1], [1, 0]],quiet = [4, 3, 2, 1, 0]) == [4, 4, 4, 4, 4]\n assert candidate(richer = [[1, 0], [2, 0], [3, 0]],quiet = [3, 2, 1, 0]) == [3, 1, 2, 3]\n ...
[ "[[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]]\n[3,2,5,4,6,1,7,0]", "[]\n[0]" ]
[]
{ "canonical_parameter_names": [ "richer", "quiet" ], "leetcode_dataset_entry_point": "Solution().loudAndRich", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:57", "tests_total": 10...
cpp
{ "raw_signature": "vector<int> loudAndRich(vector<vector<int>>& richer, vector<int>& quiet) {", "container": "Solution", "callable": "loudAndRich", "parameters": [ { "name": "richer", "type": "vector<vector<int>>&" }, { "name": "quiet", "type": "vector<int>&" } ], "r...
852
peak-index-in-a-mountain-array
Medium
You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease. Return the index of the peak element. Your task is to solve it in O(log(n)) time complexity. Example 1: Input: arr = [0,1,0] Output: 1 Example 2: Input: arr = [0,2,1,0] Output: 1 Example 3: Inp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 3, 5, 4, 2]) == 2\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 3, 1]) == 5\n assert candidate(arr = [0, 2, 1, 0]) == 1\n assert candidate(arr = [0, 10, 5, 2]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 1]) == 4...
[ "[0,1,0]", "[0,2,1,0]", "[0,10,5,2]" ]
[]
{ "canonical_parameter_names": [ "arr" ], "leetcode_dataset_entry_point": "Solution().peakIndexInMountainArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:01:59", "tests_total": 87, ...
cpp
{ "raw_signature": "int peakIndexInMountainArray(vector<int>& arr) {", "container": "Solution", "callable": "peakIndexInMountainArray", "parameters": [ { "name": "arr", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
853
car-fleet
Medium
There are n cars at given miles away from the starting mile 0, traveling to reach the mile target. You are given two integer arrays position and speed, both of length n, where position[i] is the starting mile of the i^th car and speed[i] is the speed of the i^th car in miles per hour. A car cannot pass another car, b...
{ "language": "python", "source": "def check(candidate):\n assert candidate(target = 1000,position = [100, 200, 300],speed = [100, 50, 25]) == 1\n assert candidate(target = 100,position = [0, 1, 2, 3, 4],speed = [100, 100, 100, 100, 100]) == 5\n assert candidate(target = 300,position = [0, 50, 100, 150, 20...
[ "12\n[10,8,0,5,3]\n[2,4,1,1,3]", "10\n[3]\n[3]", "100\n[0,2,4]\n[4,2,1]" ]
[]
{ "canonical_parameter_names": [ "target", "position", "speed" ], "leetcode_dataset_entry_point": "Solution().carFleet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:01", "tes...
cpp
{ "raw_signature": "int carFleet(int target, vector<int>& position, vector<int>& speed) {", "container": "Solution", "callable": "carFleet", "parameters": [ { "name": "target", "type": "int" }, { "name": "position", "type": "vector<int>&" }, { "name": "speed", ...
854
k-similar-strings
Hard
Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2. Given two anagrams s1 and s2, return the smallest k for which s1 and s2 are k-similar. Example 1: Input: s1 = "ab", s2 = "ba" Output: 1 Explanati...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == 2\n assert candidate(s1 = \"abac\",s2 = \"baca\") == 2\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == 2\n assert candidate(s1 = \"abc\",s2 = \"bca\") == 2\n assert candidate(s1 = \"abcd...
[ "\"ab\"\n\"ba\"", "\"abc\"\n\"bca\"" ]
[]
{ "canonical_parameter_names": [ "s1", "s2" ], "leetcode_dataset_entry_point": "Solution().kSimilarity", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:03", "tests_total": 47, "te...
cpp
{ "raw_signature": "int kSimilarity(string s1, string s2) {", "container": "Solution", "callable": "kSimilarity", "parameters": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippe...
856
score-of-parentheses
Medium
Given a balanced parentheses string s, return the score of the string. The score of a balanced parentheses string is based on the following rule: - "()" has score 1. - AB has score A + B, where A and B are balanced parentheses strings. - (A) has score 2 * A, where A is a balanced parentheses string. Example 1: Inpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()())\") == 4\n assert candidate(s = \"(()(()))\") == 6\n assert candidate(s = \"()\") == 1\n assert candidate(s = \"((()))\") == 4\n assert candidate(s = \"((()()()))\") == 12\n assert candidate(s = \"()()(())\") =...
[ "\"()\"", "\"(())\"", "\"()()\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().scoreOfParentheses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:05", "tests_total": 55, "tests_...
cpp
{ "raw_signature": "int scoreOfParentheses(string s) {", "container": "Solution", "callable": "scoreOfParentheses", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
857
minimum-cost-to-hire-k-workers
Hard
There are n workers. You are given two integer arrays quality and wage where quality[i] is the quality of the i^th worker and wage[i] is the minimum wage expectation for the i^th worker. We want to hire exactly k workers to form a paid group. To hire a group of k workers, we must pay them according to the following ru...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "[10,20,5]\n[70,50,30]\n2", "[3,1,10,10,1]\n[4,8,2,2,7]\n3" ]
[]
{ "canonical_parameter_names": [ "quality", "wage", "k" ], "leetcode_dataset_entry_point": "Solution().mincostToHireWorkers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:08", ...
cpp
{ "raw_signature": "double mincostToHireWorkers(vector<int>& quality, vector<int>& wage, int k) {", "container": "Solution", "callable": "mincostToHireWorkers", "parameters": [ { "name": "quality", "type": "vector<int>&" }, { "name": "wage", "type": "vector<int>&" }, ...
858
mirror-reflection
Medium
There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered 0, 1, and 2. The square room has walls of length p and a laser ray from the southwest corner first meets the east wall at a distance q from the 0^th rec...
{ "language": "python", "source": "def check(candidate):\n assert candidate(p = 2,q = 1) == 2\n assert candidate(p = 10,q = 3) == 2\n assert candidate(p = 6,q = 2) == 1\n assert candidate(p = 4,q = 2) == 2\n assert candidate(p = 10,q = 4) == 0\n assert candidate(p = 5,q = 3) == 1\n assert candi...
[ "2\n1", "3\n1" ]
[]
{ "canonical_parameter_names": [ "p", "q" ], "leetcode_dataset_entry_point": "Solution().mirrorReflection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:10", "tests_total": 84, ...
cpp
{ "raw_signature": "int mirrorReflection(int p, int q) {", "container": "Solution", "callable": "mirrorReflection", "parameters": [ { "name": "p", "type": "int" }, { "name": "q", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", ...
859
buddy-strings
Easy
Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false. Swapping letters is defined as taking two indices i and j (0-indexed) such that i != j and swapping the characters at s[i] and s[j]. - For example, swapping at indices 0 and 2 in "abcd" ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",goal = \"dcba\") == False\n assert candidate(s = \"xyy\",goal = \"xyx\") == False\n assert candidate(s = \"abac\",goal = \"abad\") == False\n assert candidate(s = \"aa\",goal = \"aa\") == True\n assert candidate(...
[ "\"ab\"\n\"ba\"", "\"ab\"\n\"ab\"", "\"aa\"\n\"aa\"" ]
[]
{ "canonical_parameter_names": [ "s", "goal" ], "leetcode_dataset_entry_point": "Solution().buddyStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:12", "tests_total": 126, ...
cpp
{ "raw_signature": "bool buddyStrings(string s, string goal) {", "container": "Solution", "callable": "buddyStrings", "parameters": [ { "name": "s", "type": "string" }, { "name": "goal", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/code...
860
lemonade-change
Easy
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must provide the correct change to each customer so that the net transaction ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(bills = [5, 5, 5, 5, 20, 20, 5, 5, 20, 5]) == False\n assert candidate(bills = [5, 5, 10, 10, 5, 20]) == True\n assert candidate(bills = [5, 5, 5, 5, 5, 5, 10, 10, 10, 20, 20, 20]) == True\n assert candidate(bills = [5, 5, 5, 5,...
[ "[5,5,5,10,20]", "[5,5,10,10,20]" ]
[]
{ "canonical_parameter_names": [ "bills" ], "leetcode_dataset_entry_point": "Solution().lemonadeChange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:15", "tests_total": 106, "tests...
cpp
{ "raw_signature": "bool lemonadeChange(vector<int>& bills) {", "container": "Solution", "callable": "lemonadeChange", "parameters": [ { "name": "bills", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
861
score-after-flipping-matrix
Medium
You are given an m x n binary matrix grid. A move consists of choosing any row or column and toggling each value in that row or column (i.e., changing all 0's to 1's, and all 1's to 0's). Every row of the matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. Return the hi...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1, 1], [1, 0, 1, 0], [1, 1, 0, 0]]) == 39\n assert candidate(grid = [[1, 0, 0], [0, 1, 1], [1, 1, 0]]) == 19\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0]]) == 83\n assert candidate(...
[ "[[0,0,1,1],[1,0,1,0],[1,1,0,0]]", "[[0]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().matrixScore", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:17", "tests_total": 80, "tests_drop...
cpp
{ "raw_signature": "int matrixScore(vector<vector<int>>& grid) {", "container": "Solution", "callable": "matrixScore", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
862
shortest-subarray-with-sum-at-least-k
Hard
Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1. A subarray is a contiguous part of an array. Example 1: Input: nums = [1], k = 1 Output: 1 Example 2: Input: nums = [1,2], k = 4 Output: -1 ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5],k = 3) == 1\n assert candidate(nums = [-1, 2],k = 2) == 1\n assert candidate(nums = [2, -1, 2],k = 3) == 3\n assert candidate(nums = [2, 1, 5, 1, 3, 2],k = 7) == 3\n assert candidate(nums = [-1, -2, ...
[ "[1]\n1", "[1,2]\n4", "[2,-1,2]\n3" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().shortestSubarray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:19", "tests_total": 127...
cpp
{ "raw_signature": "int shortestSubarray(vector<int>& nums, int k) {", "container": "Solution", "callable": "shortestSubarray", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "int", "signature_source": "l...
864
shortest-path-to-get-all-keys
Hard
You are given an m x n grid grid where: - '.' is an empty cell. - '#' is a wall. - '@' is the starting point. - Lowercase letters represent keys. - Uppercase letters represent locks. You start at the starting point and one move consists of walking one space in one of the four cardinal directions. You cannot walk outs...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = ['@.b..', '###.#', 'A.B.c']) == -1\n assert candidate(grid = ['@.b', '#.A', 'aBc']) == 8\n assert candidate(grid = ['@Aa']) == -1\n assert candidate(grid = ['@.b..', '#.A#.', 'a.c.C']) == 8\n assert candidate(grid = ['...
[ "[\"@.a..\",\"###.#\",\"b.A.B\"]", "[\"@..aA\",\"..B#.\",\"....b\"]", "[\"@Aa\"]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().shortestPathAllKeys", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:21", "tests_total": 60, "te...
cpp
{ "raw_signature": "int shortestPathAllKeys(vector<string>& grid) {", "container": "Solution", "callable": "shortestPathAllKeys", "parameters": [ { "name": "grid", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetco...
866
prime-palindrome
Medium
Given an integer n, return the smallest prime palindrome greater than or equal to n. An integer is prime if it has exactly two divisors: 1 and itself. Note that 1 is not a prime number. - For example, 2, 3, 5, 7, 11, and 13 are all primes. An integer is a palindrome if it reads the same from left to right as it does...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == 101\n assert candidate(n = 8) == 11\n assert candidate(n = 10000000) == 100030001\n assert candidate(n = 10007) == 10301\n assert candidate(n = 999) == 10301\n assert candidate(n = 6) == 7\n assert candidate...
[ "6", "8", "13" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().primePalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:25", "tests_total": 52, "tests_dro...
cpp
{ "raw_signature": "int primePalindrome(int n) {", "container": "Solution", "callable": "primePalindrome", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
867
transpose-matrix
Easy
Given a 2D integer array matrix, return the transpose of matrix. The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]] Example 2: Input: matrix = [[1,2,3],[4,5,6]]...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1]]) == [(1,)]\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]]) == [(1, 3, 5), (2, 4, 6)]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [(1, 4, 7), (2, 5, 8), (3, 6, 9)]\n assert candidate(mat...
[ "[[1,2,3],[4,5,6],[7,8,9]]", "[[1,2,3],[4,5,6]]" ]
[ "We don't need any special algorithms to do this. You just need to know what the transpose of a matrix looks like. Rows become columns and vice versa!" ]
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().transpose", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:28", "tests_total": 74, "tests_drop...
cpp
{ "raw_signature": "vector<vector<int>> transpose(vector<vector<int>>& matrix) {", "container": "Solution", "callable": "transpose", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets"...
868
binary-gap
Easy
Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n. If there are no two adjacent 1's, return 0. Two 1's are adjacent if there are only 0's separating them (possibly no 0's). The distance between two 1's is the absolute difference between thei...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 0\n assert candidate(n = 3) == 1\n assert candidate(n = 1041) == 6\n assert candidate(n = 15) == 1\n assert candidate(n = 22) == 2\n assert candidate(n = 32) == 0\n assert candidate(n = 6) == 1\n assert can...
[ "22", "8", "5" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().binaryGap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:30", "tests_total": 65, "tests_dropped":...
cpp
{ "raw_signature": "int binaryGap(int n) {", "container": "Solution", "callable": "binaryGap", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
869
reordered-power-of-2
Medium
You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero. Return true if and only if we can do this so that the resulting number is a power of two. Example 1: Input: n = 1 Output: true Example 2: Input: n = 10 Output: false Constraints: ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 46875) == False\n assert candidate(n = 3245) == False\n assert candidate(n = 86) == False\n assert candidate(n = 10) == False\n assert candidate(n = 4326) == False\n assert candidate(n = 16) == True\n assert candida...
[ "1", "10" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().reorderedPowerOf2", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:32", "tests_total": 87, "tests_d...
cpp
{ "raw_signature": "bool reorderedPowerOf2(int n) {", "container": "Solution", "callable": "reorderedPowerOf2", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
870
advantage-shuffle
Medium
You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i]. Return any permutation of nums1 that maximizes its advantage with respect to nums2. Example 1: Input: nums1 = [2,7,11,15], nums2 = [1,10,4,1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == [10, 20, 30, 40, 50]\n assert candidate(nums1 = [5, 15, 25, 35],nums2 = [10, 20, 30, 40]) == [15, 25, 35, 5]\n assert candidate(nums1 = [2, 7, 11, 15],nums2 = [1, 10, 4, ...
[ "[2,7,11,15]\n[1,10,4,11]", "[12,24,8,32]\n[13,25,32,11]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().advantageCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T20:02:34", "tests_total": ...
cpp
{ "raw_signature": "vector<int> advantageCount(vector<int>& nums1, vector<int>& nums2) {", "container": "Solution", "callable": "advantageCount", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" } ], "return_type":...