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
171
excel-sheet-column-number
Easy
Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: columnTitle = "A" Output: 1 Example 2: Input: columnTitle = "AB" Output: 28 Example 3: Input: co...
{ "language": "python", "source": "def check(candidate):\n assert candidate(columnTitle = \"MAD\") == 8818\n assert candidate(columnTitle = \"AAA\") == 703\n assert candidate(columnTitle = \"ZY\") == 701\n assert candidate(columnTitle = \"AC\") == 29\n assert candidate(columnTitle = \"Z\") == 26\n ...
[ "\"A\"", "\"AB\"", "\"ZY\"" ]
[]
{ "canonical_parameter_names": [ "columnTitle" ], "leetcode_dataset_entry_point": "Solution().titleToNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:24", "tests_total": 201, "...
cpp
{ "raw_signature": "int titleToNumber(string columnTitle) {", "container": "Solution", "callable": "titleToNumber", "parameters": [ { "name": "columnTitle", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
172
factorial-trailing-zeroes
Medium
Given an integer n, return the number of trailing zeroes in n!. Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. Example 1: Input: n = 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: n = 5 Output: 1 Explanation: 5! = 120, one trailing zero. Example 3: Input: n = 0 Output: 0 Constrain...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 0\n assert candidate(n = 10000) == 2499\n assert candidate(n = 25) == 6\n assert candidate(n = 100) == 24\n assert candidate(n = 1000) == 249\n assert candidate(n = 10) == 2\n ...
[ "3", "5", "0" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().trailingZeroes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:27", "tests_total": 71, "tests_drop...
cpp
{ "raw_signature": "int trailingZeroes(int n) {", "container": "Solution", "callable": "trailingZeroes", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
174
dungeon-game
Hard
The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially positioned in the top-left room and must fight his way through dungeon to rescue the princess. The knight has an initial health po...
{ "language": "python", "source": "def check(candidate):\n assert candidate(dungeon = [[1, -3, 3], [0, -2, 0], [-3, -3, -3]]) == 3\n assert candidate(dungeon = [[-5, -4, -6], [-6, -5, -8], [3, 3, 1]]) == 12\n assert candidate(dungeon = [[-2, -3, 3], [-5, -10, 1], [10, 30, -5]]) == 7\n assert candidate(d...
[ "[[-2,-3,3],[-5,-10,1],[10,30,-5]]", "[[0]]" ]
[]
{ "canonical_parameter_names": [ "dungeon" ], "leetcode_dataset_entry_point": "Solution().calculateMinimumHP", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:29", "tests_total": 98, "...
cpp
{ "raw_signature": "int calculateMinimumHP(vector<vector<int>>& dungeon) {", "container": "Solution", "callable": "calculateMinimumHP", "parameters": [ { "name": "dungeon", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_so...
179
largest-number
Medium
Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. Since the result may be very large, so you need to return a string instead of an integer. Example 1: Input: nums = [10,2] Output: "210" Example 2: Input: nums = [3,30,34,5,9] Output: "9534330" Constraint...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0]) == \"0\"\n assert candidate(nums = [1]) == \"1\"\n assert candidate(nums = [3, 30, 34, 5, 9]) == \"9534330\"\n assert candidate(nums = [10, 2]) == \"210\"\n assert candidate(nums = [111311, 1113]) == \"11131113...
[ "[10,2]", "[3,30,34,5,9]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().largestNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:31", "tests_total": 150, "tests_d...
cpp
{ "raw_signature": "string largestNumber(vector<int>& nums) {", "container": "Solution", "callable": "largestNumber", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
187
repeated-dna-sequences
Medium
The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. - For example, "ACGAATTCCG" is a DNA sequence. When studying DNA, it is useful to identify repeated sequences within the DNA. Given a string s that represents a DNA sequence, return all the 10-letter-long sequences (substr...
{ "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 ...
[ "\"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT\"", "\"AAAAAAAAAAAAA\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().findRepeatedDnaSequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:36", "tests_total": 137, ...
cpp
{ "raw_signature": "vector<string> findRepeatedDnaSequences(string s) {", "container": "Solution", "callable": "findRepeatedDnaSequences", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source":...
188
best-time-to-buy-and-sell-stock-iv
Hard
You are given an integer array prices where prices[i] is the price of a given stock on the i^th day, and an integer k. Find the maximum profit you can achieve. You may complete at most k transactions: i.e. you may buy at most k times and sell at most k times. Note: You may not engage in multiple transactions simultan...
{ "language": "python", "source": "def check(candidate):\n assert candidate(k = 2,prices = [10, 22, 5, 75, 65, 80]) == 87\n assert candidate(k = 5,prices = [1, 2, 3, 4, 5]) == 4\n assert candidate(k = 2,prices = [2, 4, 1]) == 2\n assert candidate(k = 1,prices = [7, 1, 5, 3, 6, 4]) == 5\n assert candi...
[ "2\n[2,4,1]", "2\n[3,2,6,5,0,3]" ]
[]
{ "canonical_parameter_names": [ "k", "prices" ], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:38", "tests_total": 97, "t...
cpp
{ "raw_signature": "int maxProfit(int k, vector<int>& prices) {", "container": "Solution", "callable": "maxProfit", "parameters": [ { "name": "k", "type": "int" }, { "name": "prices", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/co...
191
number-of-1-bits
Easy
Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight). Example 1: Input: n = 11 Output: 3 Explanation: The input binary string 1011 has a total of three set bits. Example 2: Input: n = 128 Output: 1 Explanation: The input bin...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 4095) == 12\n assert candidate(n = 11) == 3\n assert candidate(n = 15) == 4\n assert candidate(n = 2147483647) == 31\n assert candidate(n = 32) == 1\n assert candidate(n = 1023) == 10\n assert candidate(n = 21474836...
[ "11", "128", "2147483645" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().hammingWeight", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:45", "tests_total": 139, "tests_drop...
cpp
{ "raw_signature": "int hammingWeight(int n) {", "container": "Solution", "callable": "hammingWeight", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
198
house-robber
Medium
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems connected and it will automatically contact the police if two adjacent houses were broken into o...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 1]) == 4\n assert candidate(nums = [2, 1, 1, 2]) == 4\n assert candidate(nums = [5, 2, 6, 3, 4, 1]) == 15\n assert candidate(nums = [5, 2, 6, 3, 1, 8, 9, 4, 7]) == 28\n ...
[ "[1,2,3,1]", "[2,7,9,3,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().rob", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:47", "tests_total": 117, "tests_dropped": 7...
cpp
{ "raw_signature": "int rob(vector<int>& nums) {", "container": "Solution", "callable": "rob", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
200
number-of-islands
Medium
Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Example 1: Input: gri...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [['1', '1', '1', '1', '0'], ['1', '1', '0', '1', '0'], ['1', '1', '0', '0', '0'], ['0', '0', '0', '0', '0']]) == 1\n assert candidate(grid = [['0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0'], ['0', '0', '0', '0', '0'], ['0'...
[ "[[\"1\",\"1\",\"1\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]]", "[[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\",\"1\"]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().numIslands", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:51", "tests_total": 59, "tests_dropp...
cpp
{ "raw_signature": "int numIslands(vector<vector<char>>& grid) {", "container": "Solution", "callable": "numIslands", "parameters": [ { "name": "grid", "type": "vector<vector<char>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
201
bitwise-and-of-numbers-range
Medium
Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: left = 5, right = 7 Output: 4 Example 2: Input: left = 0, right = 0 Output: 0 Example 3: Input: left = 1, right = 2147483647 Output: 0 Constraints: - 0 <= l...
{ "language": "python", "source": "def check(candidate):\n assert candidate(left = 5,right = 7) == 4\n assert candidate(left = 100,right = 105) == 96\n assert candidate(left = 16,right = 31) == 16\n assert candidate(left = 123456,right = 654321) == 0\n assert candidate(left = 8,right = 12) == 8\n ...
[ "5\n7", "0\n0", "1\n2147483647" ]
[]
{ "canonical_parameter_names": [ "left", "right" ], "leetcode_dataset_entry_point": "Solution().rangeBitwiseAnd", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:53", "tests_total": ...
cpp
{ "raw_signature": "int rangeBitwiseAnd(int left, int right) {", "container": "Solution", "callable": "rangeBitwiseAnd", "parameters": [ { "name": "left", "type": "int" }, { "name": "right", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/code...
202
happy-number
Easy
Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: - Starting with any positive integer, replace the number by the sum of the squares of its digits. - Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle w...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == True\n assert candidate(n = 4) == False\n assert candidate(n = 20) == False\n assert candidate(n = 2) == False\n assert candidate(n = 1111111) == True\n assert candidate(n = 19) == True\n assert candidate(n ...
[ "19", "2" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().isHappy", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:56", "tests_total": 55, "tests_dropped": 2...
cpp
{ "raw_signature": "bool isHappy(int n) {", "container": "Solution", "callable": "isHappy", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
204
count-primes
Medium
Given an integer n, return the number of prime numbers that are strictly less than n. Example 1: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. Example 2: Input: n = 0 Output: 0 Example 3: Input: n = 1 Output: 0 Constraints: - 0 <= n <= 5 * 10^6
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 5000000) == 348513\n assert candidate(n = 1000) == 168\n assert candidate(n = 100) == 25\n assert candidate(n = 30) == 10\n assert candidate(n = 1500000) == 114155\n assert candidate(n...
[ "10", "0", "1" ]
[ "Checking all the integers in the range [1, n - 1] is not efficient. Think about a better approach.", "Since most of the numbers are not primes, we need a fast approach to exclude the non-prime integers.", "Use Sieve of Eratosthenes." ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().countPrimes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:00", "tests_total": 33, "tests_dropped...
cpp
{ "raw_signature": "int countPrimes(int n) {", "container": "Solution", "callable": "countPrimes", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
205
isomorphic-strings
Easy
Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a chara...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"hello\",t = \"world\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"paper\",t = \"title\") == True\n assert candidate(s = \"#a@C\",t = ...
[ "\"egg\"\n\"add\"", "\"foo\"\n\"bar\"", "\"paper\"\n\"title\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().isIsomorphic", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:02", "tests_total": 131, "te...
cpp
{ "raw_signature": "bool isIsomorphic(string s, string t) {", "container": "Solution", "callable": "isIsomorphic", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippe...
207
course-schedule
Medium
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [a_i, b_i] indicates that you must take course b_i first if you want to take course a_i. - For example, the pair [0, 1], indicates that to take course 0 you have to ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(numCourses = 2,prerequisites = [[1, 0], [0, 1]]) == False\n assert candidate(numCourses = 5,prerequisites = [[1, 4], [2, 4], [3, 1], [3, 2]]) == True\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]...
[ "2\n[[1,0]]", "2\n[[1,0],[0,1]]" ]
[ "This problem is equivalent to finding if a cycle exists in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses.", "Topological Sort via DFS - A great tutorial explaining the basic concepts of Topological Sort.", "Topological sort could als...
{ "canonical_parameter_names": [ "numCourses", "prerequisites" ], "leetcode_dataset_entry_point": "Solution().canFinish", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:07", "tests_...
cpp
{ "raw_signature": "bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {", "container": "Solution", "callable": "canFinish", "parameters": [ { "name": "numCourses", "type": "int" }, { "name": "prerequisites", "type": "vector<vector<int>>&" } ], "return...
209
minimum-size-subarray-sum
Medium
Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: The subarray [4,3] has the minimal len...
{ "language": "python", "source": "def check(candidate):\n assert candidate(target = 8,nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(target = 9,nums = [4, 3, 3, 2, 1]) == 3\n assert candidate(target = 11,nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(target = 100,nums = [10, 20, 30, 40, 50])...
[ "7\n[2,3,1,2,4,3]", "4\n[1,4,4]", "11\n[1,1,1,1,1,1,1,1]" ]
[]
{ "canonical_parameter_names": [ "target", "nums" ], "leetcode_dataset_entry_point": "Solution().minSubArrayLen", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:09", "tests_total": ...
cpp
{ "raw_signature": "int minSubArrayLen(int target, vector<int>& nums) {", "container": "Solution", "callable": "minSubArrayLen", "parameters": [ { "name": "target", "type": "int" }, { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_sourc...
210
course-schedule-ii
Medium
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [a_i, b_i] indicates that you must take course b_i first if you want to take course a_i. - For example, the pair [0, 1], indicates that to take course 0 you have to ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1]]) == [0, 1, 2, 3]\n assert candidate(numCourses = 7,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(numCourses = 5...
[ "2\n[[1,0]]", "4\n[[1,0],[2,0],[3,1],[3,2]]", "1\n[]" ]
[ "This problem is equivalent to finding the topological order in a directed graph. If a cycle exists, no topological ordering exists and therefore it will be impossible to take all courses.", "Topological Sort via DFS - A great video tutorial (21 minutes) on Coursera explaining the basic concepts of Topological So...
{ "canonical_parameter_names": [ "numCourses", "prerequisites" ], "leetcode_dataset_entry_point": "Solution().findOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:11", "tests_...
cpp
{ "raw_signature": "vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) {", "container": "Solution", "callable": "findOrder", "parameters": [ { "name": "numCourses", "type": "int" }, { "name": "prerequisites", "type": "vector<vector<int>>&" } ], ...
212
word-search-ii
Hard
Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. Example 1: Input: b...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [['o', 'a', 'a', 'n'], ['e', 't', 'a', 'e'], ['i', 'h', 'k', 'r'], ['i', 'f', 'l', 'v']],words = ['oath', 'pea', 'eat', 'rain']) == ['oath', 'eat']\n assert candidate(board = [['a', 'a']],words = ['a']) == ['a']\n assert ca...
[ "[[\"o\",\"a\",\"a\",\"n\"],[\"e\",\"t\",\"a\",\"e\"],[\"i\",\"h\",\"k\",\"r\"],[\"i\",\"f\",\"l\",\"v\"]]\n[\"oath\",\"pea\",\"eat\",\"rain\"]", "[[\"a\",\"b\"],[\"c\",\"d\"]]\n[\"abcb\"]" ]
[ "You would need to optimize your backtracking to pass the larger test. Could you stop backtracking earlier?", "If the current candidate does not exist in all words' prefix, you could stop backtracking immediately. What kind of data structure could answer such query efficiently? Does a hash table work? Why or why ...
{ "canonical_parameter_names": [ "board", "words" ], "leetcode_dataset_entry_point": "Solution().findWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:13", "tests_total": 83, ...
cpp
{ "raw_signature": "vector<string> findWords(vector<vector<char>>& board, vector<string>& words) {", "container": "Solution", "callable": "findWords", "parameters": [ { "name": "board", "type": "vector<vector<char>>&" }, { "name": "words", "type": "vector<string>&" } ],...
213
house-robber-ii
Medium
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and it will automatically con...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [5, 1, 2, 4, 7, 8]) == 14\n assert candidate(nums = [5, 3, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, ...
[ "[2,3,2]", "[1,2,3,1]", "[1,2,3]" ]
[ "Since House[1] and House[n] are adjacent, they cannot be robbed together. Therefore, the problem becomes to rob either House[1]-House[n-1] or House[2]-House[n], depending on which choice offers more money. Now the problem has degenerated to the House Robber, which is already been solved." ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().rob", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:15", "tests_total": 122, "tests_dropped": 0...
cpp
{ "raw_signature": "int rob(vector<int>& nums) {", "container": "Solution", "callable": "rob", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
214
shortest-palindrome
Hard
You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation. Example 1: Input: s = "aacecaaa" Output: "aaacecaaa" Example 2: Input: s = "abcd" Output: "dcbabcd" Constraints: - 0 <= s.length <= 5 * 1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == \"abcba\"\n assert candidate(s = \"madam\") == \"madam\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abac\") == \"c...
[ "\"aacecaaa\"", "\"abcd\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().shortestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:18", "tests_total": 157, "tests...
cpp
{ "raw_signature": "string shortestPalindrome(string s) {", "container": "Solution", "callable": "shortestPalindrome", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
215
kth-largest-element-in-an-array
Medium
Given an integer array nums and an integer k, return the k^th largest element in the array. Note that it is the k^th largest element in the sorted order, not the k^th distinct element. Can you solve it without sorting? Example 1: Input: nums = [3,2,1,5,6,4], k = 2 Output: 5 Example 2: Input: nums = [3,2,3,1,2,4,5...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 5) == 3\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 3) == 5\n assert candidate(nums = [10000, -10000, 0],k = 2) == 0\n assert candidate(nums = [3, 2, 1, 5, 6, 4],k = 2) == 5\n assert c...
[ "[3,2,1,5,6,4]\n2", "[3,2,3,1,2,4,5,5,6]\n4" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().findKthLargest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:20", "tests_total": 78, ...
cpp
{ "raw_signature": "int findKthLargest(vector<int>& nums, int k) {", "container": "Solution", "callable": "findKthLargest", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "int", "signature_source": "leetc...
216
combination-sum-iii
Medium
Find all valid combinations of k numbers that sum up to n such that the following conditions are true: - Only numbers 1 through 9 are used. - Each number is used at most once. Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned i...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "3\n7", "3\n9", "4\n1" ]
[]
{ "canonical_parameter_names": [ "k", "n" ], "leetcode_dataset_entry_point": "Solution().combinationSum3", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:22", "tests_total": 62, "...
cpp
{ "raw_signature": "vector<vector<int>> combinationSum3(int k, int n) {", "container": "Solution", "callable": "combinationSum3", "parameters": [ { "name": "k", "type": "int" }, { "name": "n", "type": "int" } ], "return_type": "vector<vector<int>>", "signature_sourc...
217
contains-duplicate
Easy
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Explanation: The element 1 occurs at the indices 0 and 3. Example 2: Input: nums = [1,2,3,4] Output: false Explanation: All elemen...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == False\n assert candidate(nums = [1, 2, 3, 1]) == True\n assert candidate(nums = [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(nums ...
[ "[1,2,3,1]", "[1,2,3,4]", "[1,1,1,3,3,4,3,2,4,2]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().containsDuplicate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:24", "tests_total": 94, "test...
cpp
{ "raw_signature": "bool containsDuplicate(vector<int>& nums) {", "container": "Solution", "callable": "containsDuplicate", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
218
the-skyline-problem
Hard
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return the skyline formed by these buildings collectively. The geometric information of each building is given in the array buildings where...
{ "language": "python", "source": "def check(candidate):\n assert candidate(buildings = [[0, 5, 7], [5, 10, 3], [5, 10, 12], [10, 15, 15], [15, 20, 10], [15, 20, 10], [20, 25, 10]]) == [[0, 7], [5, 12], [10, 15], [15, 10], [25, 0]]\n assert candidate(buildings = [[1, 2, 1], [1, 2, 2], [1, 2, 3]]) == [[1, 3], ...
[ "[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]", "[[0,2,3],[2,5,3]]" ]
[]
{ "canonical_parameter_names": [ "buildings" ], "leetcode_dataset_entry_point": "Solution().getSkyline", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:27", "tests_total": 101, "tests...
cpp
{ "raw_signature": "vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {", "container": "Solution", "callable": "getSkyline", "parameters": [ { "name": "buildings", "type": "vector<vector<int>>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeS...
219
contains-duplicate-ii
Easy
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. Example 1: Input: nums = [1,2,3,1], k = 3 Output: true Example 2: Input: nums = [1,0,1,1], k = 1 Output: true Example 3: Input: nums = [1,2,3,1,2,3], k...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000],k = 2) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 8) == False\n assert candidate(nums = [1, 0, 1, 1],k = 1) == True\n assert candidate(nums = [...
[ "[1,2,3,1]\n3", "[1,0,1,1]\n1", "[1,2,3,1,2,3]\n2" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().containsNearbyDuplicate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:29", "tests_tota...
cpp
{ "raw_signature": "bool containsNearbyDuplicate(vector<int>& nums, int k) {", "container": "Solution", "callable": "containsNearbyDuplicate", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "bool", "signa...
220
contains-duplicate-iii
Hard
You are given an integer array nums and two integers indexDiff and valueDiff. Find a pair of indices (i, j) such that: - i != j, - abs(i - j) <= indexDiff. - abs(nums[i] - nums[j]) <= valueDiff, and Return true if such pair exists or false otherwise. Example 1: Input: nums = [1,2,3,1], indexDiff = 3, valueDiff = 0...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 1, 3, 1, 3],indexDiff = 2,valueDiff = 1) == True\n assert candidate(nums = [8, 2, 4, 2, 0, 1, 4, 1, 3],indexDiff = 5,valueDiff = 2) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10],indexDiff = 3,valueDiff = ...
[ "[1,2,3,1]\n3\n0", "[1,5,9,1,5,9]\n2\n3" ]
[ "Time complexity O(n logk) - This will give an indication that sorting is involved for k elements.", "Use already existing state to evaluate next state - Like, a set of k sorted numbers are only needed to be tracked. When we are processing the next number in array, then we can utilize the existing sorted state an...
{ "canonical_parameter_names": [ "nums", "indexDiff", "valueDiff" ], "leetcode_dataset_entry_point": "Solution().containsNearbyAlmostDuplicate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026...
cpp
{ "raw_signature": "bool containsNearbyAlmostDuplicate(vector<int>& nums, int indexDiff, int valueDiff) {", "container": "Solution", "callable": "containsNearbyAlmostDuplicate", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "indexDiff", "type": "int" ...
221
maximal-square
Medium
Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 4 Example 2: Input: matrix = [["0","1"],["1","0"]] Output: 1 Example 3:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [['0', '1'], ['1', '0']]) == 1\n assert candidate(matrix = [['1', '0', '1'], ['1', '1', '0'], ['1', '1', '1']]) == 4\n assert candidate(matrix = [['1', '1'], ['1', '1']]) == 4\n assert candidate(matrix = [['0']]) == 0\n...
[ "[[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\",\"1\",\"1\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]]", "[[\"0\",\"1\"],[\"1\",\"0\"]]", "[[\"0\"]]" ]
[]
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().maximalSquare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:34", "tests_total": 68, "tests_...
cpp
{ "raw_signature": "int maximalSquare(vector<vector<char>>& matrix) {", "container": "Solution", "callable": "maximalSquare", "parameters": [ { "name": "matrix", "type": "vector<vector<char>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "le...
223
rectangle-area
Medium
Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles. The first rectangle is defined by its bottom-left corner (ax1, ay1) and its top-right corner (ax2, ay2). The second rectangle is defined by its bottom-left corner (bx1, by1) and its top-right corner...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ax1 = -2,ay1 = -2,ax2 = 2,ay2 = 2,bx1 = -2,by1 = -2,bx2 = 2,by2 = 2) == 16\n assert candidate(ax1 = 1,ay1 = 1,ax2 = 3,ay2 = 3,bx1 = 2,by1 = 2,bx2 = 4,by2 = 4) == 7\n assert candidate(ax1 = 0,ay1 = 0,ax2 = 5,ay2 = 5,bx1 = 5,by1 = 5,...
[ "-3\n0\n3\n4\n0\n-1\n9\n2", "-2\n-2\n2\n2\n-2\n-2\n2\n2" ]
[]
{ "canonical_parameter_names": [ "ax1", "ay1", "ax2", "ay2", "bx1", "by1", "bx2", "by2" ], "leetcode_dataset_entry_point": "Solution().computeArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets...
cpp
{ "raw_signature": "int computeArea(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2) {", "container": "Solution", "callable": "computeArea", "parameters": [ { "name": "ax1", "type": "int" }, { "name": "ay1", "type": "int" }, { "name": "ax2...
224
basic-calculator
Hard
Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation. Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval(). Example 1: Input: s = "1 + 1" Output: 2 Example 2: Inpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"30 - (5 + (10 - 15) + 20)\") == 10\n assert candidate(s = \"2147483647\") == 2147483647\n assert candidate(s = \"-2147483647\") == -2147483647\n assert candidate(s = \"- (3 + (2 - 1))\") == -4\n assert candidate(s = \"1...
[ "\"1 + 1\"", "\" 2-1 + 2 \"", "\"(1+(4+5+2)-3)+(6+8)\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().calculate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:40", "tests_total": 174, "tests_dropped"...
cpp
{ "raw_signature": "int calculate(string s) {", "container": "Solution", "callable": "calculate", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
227
basic-calculator-ii
Medium
Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of [-2^31, 2^31 - 1]. Note: You are not allowed to use any built-in...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"2 - 3 + 4\") == 3\n assert candidate(s = \" 1000000000 - 500000000 + 250000000\") == 750000000\n assert candidate(s = \"1 + 1 * 1 + 1\") == 3\n assert candidate(s = \"2*3+4/5\") == 6\n assert candidate(s = \"0 + 0\") ==...
[ "\"3+2*2\"", "\" 3/2 \"", "\" 3+5 / 2 \"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().calculate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:45", "tests_total": 171, "tests_dropped"...
cpp
{ "raw_signature": "int calculate(string s) {", "container": "Solution", "callable": "calculate", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
228
summary-ranges
Easy
You are given a sorted unique integer array nums. A range [a,b] is the set of all integers from a to b (inclusive). Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element of nums is covered by exactly one of the ranges, and there is no integer x such that x is...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == ['0->5']\n assert candidate(nums = [-1, 0, 1, 2, 3, 5, 6, 7, 8, 10]) == ['-1->3', '5->8', '10']\n assert candidate(nums = [-2147483648, -2147483647, -2147483646]) == ['-2147483648->-2147483646']\n a...
[ "[0,1,2,4,5,7]", "[0,2,3,4,6,8,9]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().summaryRanges", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:48", "tests_total": 120, "tests_d...
cpp
{ "raw_signature": "vector<string> summaryRanges(vector<int>& nums) {", "container": "Solution", "callable": "summaryRanges", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source": "le...
229
majority-element-ii
Medium
Given an integer array of size n, find all elements that appear more than ⌊n / 3⌋ times. Example 1: Input: nums = [3,2,3] Output: [3] Example 2: Input: nums = [1] Output: [1] Example 3: Input: nums = [1,2] Output: [1,2] Constraints: - 1 <= nums.length <= 5 * 10^4 - -10^9 <= nums[i] <= 10^9 Follow up: Could you...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 2, 3]) == [3]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1, 2]) == [2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(num...
[ "[3,2,3]", "[1]", "[1,2]" ]
[ "Think about the possible number of elements that can appear more than ⌊ n/3 ⌋ times in the array.", "It can be at most two. Why?", "Consider using Boyer-Moore Voting Algorithm, which is efficient for finding elements that appear more than a certain threshold." ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().majorityElement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:50", "tests_total": 77, "tests_...
cpp
{ "raw_signature": "vector<int> majorityElement(vector<int>& nums) {", "container": "Solution", "callable": "majorityElement", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
231
power-of-two
Easy
Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such that n == 2^x. Example 1: Input: n = 1 Output: true Explanation: 2^0 = 1 Example 2: Input: n = 16 Output: true Explanation: 2^4 = 16 Example 3: Input: n = 3 Output: ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == False\n assert candidate(n = 2097152) == True\n assert candidate(n = -16) == False\n assert candidate(n = 67108864) == True\n assert candidate(n = 4096) == True\n assert candidate(n = 2147483647) == False\n as...
[ "1", "16", "3" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().isPowerOfTwo", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:55", "tests_total": 103, "tests_dropp...
cpp
{ "raw_signature": "bool isPowerOfTwo(int n) {", "container": "Solution", "callable": "isPowerOfTwo", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
233
number-of-digit-one
Hard
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. Example 1: Input: n = 13 Output: 6 Example 2: Input: n = 0 Output: 0 Constraints: - 0 <= n <= 10^9
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 987654321) == 891632373\n assert candidate(n = 100000) == 50001\n assert candidate(n = 999999999) == 900000000\n assert candidate(n = 999) == 300\n assert candidate(n = 1000000) == 600001...
[ "13", "0" ]
[ "Beware of overflow." ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().countDigitOne", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:42:57", "tests_total": 76, "tests_dropp...
cpp
{ "raw_signature": "int countDigitOne(int n) {", "container": "Solution", "callable": "countDigitOne", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
238
product-of-array-except-self
Medium
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation....
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 3, 0, 2, 1]) == [0, 0, 30, 0, 0]\n assert candidate(nums = [1, 0, -1, 2, -2]) == [0, 4, 0, 0, 0]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [-36, 36, -18, 18, -12, 12]\n assert candidate(nums = [5, 3, 2, 4, 1...
[ "[1,2,3,4]", "[-1,1,0,-3,3]" ]
[ "Think how you can efficiently utilize prefix and suffix products to calculate the product of all elements except self for each index. Can you pre-compute the prefix and suffix products in linear time to avoid redundant calculations?", "Can you minimize additional space usage by reusing memory or modifying the in...
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().productExceptSelf", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:04", "tests_total": 100, "tes...
cpp
{ "raw_signature": "vector<int> productExceptSelf(vector<int>& nums) {", "container": "Solution", "callable": "productExceptSelf", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "...
239
sliding-window-maximum
Hard
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window. Example 1: Input: nums = [1,3,-1,-3,5,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, -1, -3, 5, 3, 6, 7],k = 3) == [3, 3, 5, 5, 6, 7]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(nums = [4, -2],k = 2) == [4]\n assert candidate(nums = [9, 8, 7, 6...
[ "[1,3,-1,-3,5,3,6,7]\n3", "[1]\n1" ]
[ "How about using a data structure such as deque (double-ended queue)?", "The queue size need not be the same as the window’s size.", "Remove redundant elements and the queue should store only elements that need to be considered." ]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().maxSlidingWindow", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:06", "tests_total": 104...
cpp
{ "raw_signature": "vector<int> maxSlidingWindow(vector<int>& nums, int k) {", "container": "Solution", "callable": "maxSlidingWindow", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "vector<int>", "signa...
240
search-a-2d-matrix-ii
Medium
Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: - Integers in each row are sorted in ascending from left to right. - Integers in each column are sorted in ascending from top to bottom. Example 1: Input: matrix = [[1,4,7,11,15]...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [5, 6, 7, 8, 9], [15, 16, 17, 18, 19], [25, 26, 27, 28, 29], [35, 36, 37, 38, 39]],target = 0) == False\n assert candidate(matrix = [[1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14,...
[ "[[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]]\n5", "[[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]]\n20" ]
[]
{ "canonical_parameter_names": [ "matrix", "target" ], "leetcode_dataset_entry_point": "Solution().searchMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:08", "tests_total": ...
cpp
{ "raw_signature": "bool searchMatrix(vector<vector<int>>& matrix, int target) {", "container": "Solution", "callable": "searchMatrix", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" }, { "name": "target", "type": "int" } ], "return_type": "bool", ...
241
different-ways-to-add-parentheses
Medium
Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order. The test cases are generated such that the output values fit in a 32-bit integer and the number of different results doe...
{ "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 ...
[ "\"2-1-1\"", "\"2*3-4*5\"" ]
[]
{ "canonical_parameter_names": [ "expression" ], "leetcode_dataset_entry_point": "Solution().diffWaysToCompute", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:11", "tests_total": 189, ...
cpp
{ "raw_signature": "vector<int> diffWaysToCompute(string expression) {", "container": "Solution", "callable": "diffWaysToCompute", "parameters": [ { "name": "expression", "type": "string" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "...
242
valid-anagram
Easy
Given two strings s and t, return true if t is an anagram of s, and false otherwise. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 2: Input: s = "rat", t = "car" Output: false Constraints: - 1 <= s.length, t.length <= 5 * 10^4 - s and t consist of lowercase English letters. Follow up: What ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"abcde\",t = \"edcba\") == True\n assert candidate(s = \"abc\",t = \"abcd\") == False\n assert candidate(s = \"apple\",t = \"...
[ "\"anagram\"\n\"nagaram\"", "\"rat\"\n\"car\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().isAnagram", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:13", "tests_total": 107, "tests...
cpp
{ "raw_signature": "bool isAnagram(string s, string t) {", "container": "Solution", "callable": "isAnagram", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", ...
258
add-digits
Easy
Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. Example 1: Input: num = 38 Output: 2 Explanation: The process is 38 --> 3 + 8 --> 11 11 --> 1 + 1 --> 2 Since 2 has only one digit, return it. Example 2: Input: num = 0 Output: 0 Constraints: - 0 <= num <= 2^31...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 10) == 1\n assert candidate(num = 9) == 9\n assert candidate(num = 111111111) == 9\n assert candidate(num = 47) == 2\n assert candidate(num = 456789) == 3\n assert candidate(num = 38) == 2\n assert candidate(num =...
[ "38", "0" ]
[ "A naive implementation of the above process is trivial. Could you come up with other methods?", "What are all the possible results?", "How do they occur, periodically or randomly?", "You may find this Wikipedia article useful." ]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().addDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:44", "tests_total": 75, "tests_dropped...
cpp
{ "raw_signature": "int addDigits(int num) {", "container": "Solution", "callable": "addDigits", "parameters": [ { "name": "num", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
260
single-number-iii
Medium
Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in any order. You must write an algorithm that runs in linear runtime complexity and uses only constant extra space. Examp...
{ "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,1,3,2,5]", "[-1,0]", "[0,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().singleNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:48", "tests_total": 102, "tests_dr...
cpp
{ "raw_signature": "vector<int> singleNumber(vector<int>& nums) {", "container": "Solution", "callable": "singleNumber", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/c...
263
ugly-number
Easy
An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5. Given an integer n, return true if n is an ugly number. Example 1: Input: n = 6 Output: true Explanation: 6 = 2 × 3 Example 2: Input: n = 1 Output: true Explanation: 1 has no prime factors. Example 3: Input: n = 14 Ou...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == False\n assert candidate(n = 8) == True\n assert candidate(n = -2147483648) == False\n assert candidate(n = 100000) == True\n assert candidate(n = 100) == True\n assert candidate(n = 30) == True\n assert candi...
[ "6", "1", "14" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().isUgly", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:53", "tests_total": 74, "tests_dropped": 13...
cpp
{ "raw_signature": "bool isUgly(int n) {", "container": "Solution", "callable": "isUgly", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
264
ugly-number-ii
Medium
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Given an integer n, return the n^th ugly number. Example 1: Input: n = 10 Output: 12 Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers. Example 2: Input: n = 1 Output: 1 Explanation: 1 has ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 15) == 24\n assert candidate(n = 200) == 16200\n assert candidate(n = 1690) == 2123366400\n assert candidate(n = 1) == 1\n assert candidate(n = 50) == 243\n assert candidate(n = 10) == 12\n assert candidate(n = 5) =...
[ "10", "1" ]
[ "The naive approach is to call isUgly for every number until you reach the n^th one. Most numbers are not ugly. Try to focus your effort on generating only the ugly ones.", "An ugly number must be multiplied by either 2, 3, or 5 from a smaller ugly number.", "The key is how to maintain the order of the ugly num...
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().nthUglyNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:43:55", "tests_total": 38, "tests_dropp...
cpp
{ "raw_signature": "int nthUglyNumber(int n) {", "container": "Solution", "callable": "nthUglyNumber", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
268
missing-number
Easy
Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [3, 0, 1]) == 2\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums =...
[ "[3,0,1]", "[0,1]", "[9,6,4,2,3,5,7,0,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().missingNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:04", "tests_total": 47, "tests_dr...
cpp
{ "raw_signature": "int missingNumber(vector<int>& nums) {", "container": "Solution", "callable": "missingNumber", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
273
integer-to-english-words
Hard
Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Input: num = 12345 Output: "Twelve Thousand Three Hundred Forty Five" Example 3: Input: num = 1234567 Output: "One Million Two Hundred Thirty Four Thousand Five Hundred...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 9) == \"Nine\"\n assert candidate(num = 10) == \"Ten\"\n assert candidate(num = 100000000) == \"One Hundred Million\"\n assert candidate(num = 1234567) == \"One Million Two Hundred Thirty Four Thousand Five Hundred Sixty S...
[ "123", "12345", "1234567" ]
[ "Did you see a pattern in dividing the number into chunk of words? For example, 123 and 123000.", "Group the number by thousands (3 digits). You can write a helper function that takes a number less than 1000 and convert just that chunk to words.", "There are many edge cases. What are some good test cases? Does ...
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().numberToWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:14", "tests_total": 74, "tests_dro...
cpp
{ "raw_signature": "string numberToWords(int num) {", "container": "Solution", "callable": "numberToWords", "parameters": [ { "name": "num", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
274
h-index
Medium
Given an array of integers citations where citations[i] is the number of citations a researcher received for their i^th paper, return the researcher's h-index. According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that the given researcher has published at least h p...
{ "language": "python", "source": "def check(candidate):\n assert candidate(citations = [10, 8, 5, 4, 3]) == 4\n assert candidate(citations = [1]) == 1\n assert candidate(citations = [3, 0, 6, 1, 5]) == 3\n assert candidate(citations = [0, 1, 2, 3, 4]) == 2\n assert candidate(citations = [1000, 999, ...
[ "[3,0,6,1,5]", "[1,3,1]" ]
[ "An easy approach is to sort the array first.", "What are the possible values of h-index?", "A faster approach is to use extra space." ]
{ "canonical_parameter_names": [ "citations" ], "leetcode_dataset_entry_point": "Solution().hIndex", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:16", "tests_total": 79, "tests_drop...
cpp
{ "raw_signature": "int hIndex(vector<int>& citations) {", "container": "Solution", "callable": "hIndex", "parameters": [ { "name": "citations", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
275
h-index-ii
Medium
Given an array of integers citations where citations[i] is the number of citations a researcher received for their i^th paper and citations is sorted in non-descending order, return the researcher's h-index. According to the definition of h-index on Wikipedia: The h-index is defined as the maximum value of h such that...
{ "language": "python", "source": "def check(candidate):\n assert candidate(citations = [1]) == 1\n assert candidate(citations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(citations = [100]) == 1\n assert candidate(citations = [0, 0, 0, 0, 0]) == 0\n assert candidate(citations = [100, 1...
[ "[0,1,3,5,6]", "[1,2,100]" ]
[ "Expected runtime complexity is in O(log n) and the input is sorted." ]
{ "canonical_parameter_names": [ "citations" ], "leetcode_dataset_entry_point": "Solution().hIndex", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:18", "tests_total": 80, "tests_drop...
cpp
{ "raw_signature": "int hIndex(vector<int>& citations) {", "container": "Solution", "callable": "hIndex", "parameters": [ { "name": "citations", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
279
perfect-squares
Medium
Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not. Example 1: Input: n = 12 Output...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 625) == 1\n assert candidate(n = 8) == 2\n assert candidate(n = 100) == 1\n assert candidate(n = 4) == 1\n assert candidate(n = 12) == 3\n assert candidate(n = 16) == 1\n assert candidate(n = 17) == 2\n assert ca...
[ "12", "13" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().numSquares", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:25", "tests_total": 75, "tests_dropped"...
cpp
{ "raw_signature": "int numSquares(int n) {", "container": "Solution", "callable": "numSquares", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
282
expression-add-operators
Hard
Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that the resultant expression evaluates to the target value. Note that operands in the returned expressions should not contain leading zeros. No...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = \"232\",target = 8) == ['2+3*2', '2*3+2']\n assert candidate(num = \"123\",target = 6) == ['1+2+3', '1*2*3']\n assert candidate(num = \"00\",target = 0) == ['0+0', '0-0', '0*0']\n assert candidate(num = \"105\",target = 5)...
[ "\"123\"\n6", "\"232\"\n8", "\"3456237490\"\n9191" ]
[ "Note that a number can contain multiple digits.", "Since the question asks us to find all of the valid expressions, we need a way to iterate over all of them. (Hint: Recursion!)", "We can keep track of the expression string and evaluate it at the very end. But that would take a lot of time. Can we keep track o...
{ "canonical_parameter_names": [ "num", "target" ], "leetcode_dataset_entry_point": "Solution().addOperators", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:29", "tests_total": 67,...
cpp
{ "raw_signature": "vector<string> addOperators(string num, int target) {", "container": "Solution", "callable": "addOperators", "parameters": [ { "name": "num", "type": "string" }, { "name": "target", "type": "int" } ], "return_type": "vector<string>", "signature_s...
287
find-the-duplicate-number
Medium
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve the problem without modifying the array nums and using only constant extra space. Example 1: Input: nums = [1,3,4,2,2]...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4]) == 2\n assert candidate(nums = [7, 9, 7, 4, 6, 2, 3, 8, 5, 1]) == 7\n assert candidate(nums = [3, 1, 3, 4, 2]) == 3\n assert candidate(nums = [1, 2, 3...
[ "[1,3,4,2,2]", "[3,1,3,4,2]", "[3,3,3,3,3]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findDuplicate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:36", "tests_total": 87, "tests_dr...
cpp
{ "raw_signature": "int findDuplicate(vector<int>& nums) {", "container": "Solution", "callable": "findDuplicate", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
290
word-pattern
Easy
Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Specifically: - Each letter in pattern maps to exactly one unique word in s. - Each unique word in s maps to exactly one letter in p...
{ "language": "python", "source": "def check(candidate):\n assert candidate(pattern = \"aaaa\",s = \"dog cat cat dog\") == False\n assert candidate(pattern = \"abc\",s = \"dog dog dog\") == False\n assert candidate(pattern = \"abcd\",s = \"dog cat elephant fish\") == True\n assert candidate(pattern = \"...
[ "\"abba\"\n\"dog cat cat dog\"", "\"abba\"\n\"dog cat cat fish\"", "\"aaaa\"\n\"dog cat cat dog\"" ]
[]
{ "canonical_parameter_names": [ "pattern", "s" ], "leetcode_dataset_entry_point": "Solution().wordPattern", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:41", "tests_total": 147, ...
cpp
{ "raw_signature": "bool wordPattern(string pattern, string s) {", "container": "Solution", "callable": "wordPattern", "parameters": [ { "name": "pattern", "type": "string" }, { "name": "s", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/...
292
nim-game
Easy
You are playing the following Nim Game with your friend: - Initially, there is a heap of stones on the table. - You and your friend will alternate taking turns, and you go first. - On each turn, the person whose turn it is will remove 1 to 3 stones from the heap. - The one who removes the last stone is the winner. Gi...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == True\n assert candidate(n = 21) == True\n assert candidate(n = 2147483647) == True\n assert candidate(n = 104) == False\n assert candidate(n = 100) == False\n assert candidate(n = 10) == True\n assert candidat...
[ "4", "1", "2" ]
[ "If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?" ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().canWinNim", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:45", "tests_total": 114, "tests_dropped"...
cpp
{ "raw_signature": "bool canWinNim(int n) {", "container": "Solution", "callable": "canWinNim", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
299
bulls-and-cows
Medium
You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info: - The number of "bulls", which are digits in the guess that are in the correct position. - The number of...
{ "language": "python", "source": "def check(candidate):\n assert candidate(secret = \"1010101010\",guess = \"0101010101\") == \"0A10B\"\n assert candidate(secret = \"1234567890\",guess = \"1111111111\") == \"1A0B\"\n assert candidate(secret = \"0000\",guess = \"1111\") == \"0A0B\"\n assert candidate(se...
[ "\"1807\"\n\"7810\"", "\"1123\"\n\"0111\"" ]
[]
{ "canonical_parameter_names": [ "secret", "guess" ], "leetcode_dataset_entry_point": "Solution().getHint", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:56", "tests_total": 115, ...
cpp
{ "raw_signature": "string getHint(string secret, string guess) {", "container": "Solution", "callable": "getHint", "parameters": [ { "name": "secret", "type": "string" }, { "name": "guess", "type": "string" } ], "return_type": "string", "signature_source": "leetcod...
300
longest-increasing-subsequence
Medium
Given an integer array nums, return the length of the longest strictly increasing subsequence. Example 1: Input: nums = [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. Example 2: Input: nums = [0,1,0,3,2,3] Output: 4 Example 3: Input: nums...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [1, 2, 2, 4, 5, 3]) == 4\n assert candidate(nums = [0, -1, 1]) == 2\n assert ...
[ "[10,9,2,5,3,7,101,18]", "[0,1,0,3,2,3]", "[7,7,7,7,7,7,7]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().lengthOfLIS", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:44:59", "tests_total": 134, "tests_dro...
cpp
{ "raw_signature": "int lengthOfLIS(vector<int>& nums) {", "container": "Solution", "callable": "lengthOfLIS", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
306
additive-number
Medium
An additive number is a string whose digits can form an additive sequence. A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the sequence must be the sum of the preceding two. Given a string containing only digits, return true if it is an addi...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = \"1203\") == False\n assert candidate(num = \"000\") == True\n assert candidate(num = \"112358\") == True\n assert candidate(num = \"101\") == True\n assert candidate(num = \"1023\") == False\n assert candidate(num =...
[ "\"112358\"", "\"199100199\"" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().isAdditiveNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:06", "tests_total": 93, "tests_...
cpp
{ "raw_signature": "bool isAdditiveNumber(string num) {", "container": "Solution", "callable": "isAdditiveNumber", "parameters": [ { "name": "num", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
309
best-time-to-buy-and-sell-stock-with-cooldown
Medium
You are given an array prices where prices[i] is the price of a given stock on the i^th day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times) with the following restrictions: - After you sell your stock, you canno...
{ "language": "python", "source": "def check(candidate):\n assert candidate(prices = [1, 2, 4]) == 3\n assert candidate(prices = [1, 2, 3, 0, 2, 3, 1, 4, 2, 5]) == 7\n assert candidate(prices = [2, 1, 4, 5, 2, 9, 7]) == 10\n assert candidate(prices = [1]) == 0\n assert candidate(prices = [3, 2, 6, 5,...
[ "[1,2,3,0,2]", "[1]" ]
[]
{ "canonical_parameter_names": [ "prices" ], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:10", "tests_total": 108, "tests_dro...
cpp
{ "raw_signature": "int maxProfit(vector<int>& prices) {", "container": "Solution", "callable": "maxProfit", "parameters": [ { "name": "prices", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
310
minimum-height-trees
Medium
A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes labelled from 0 to n - 1, and an array of n - 1 edges where edges[i] = [a_i, b_i] indicates that there is an undirected edge between th...
{ "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 ...
[ "4\n[[1,0],[1,2],[1,3]]", "6\n[[3,0],[3,1],[3,2],[3,4],[5,4]]" ]
[ "How many MHTs can a graph have at most?" ]
{ "canonical_parameter_names": [ "n", "edges" ], "leetcode_dataset_entry_point": "Solution().findMinHeightTrees", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:12", "tests_total": ...
cpp
{ "raw_signature": "vector<int> findMinHeightTrees(int n, vector<vector<int>>& edges) {", "container": "Solution", "callable": "findMinHeightTrees", "parameters": [ { "name": "n", "type": "int" }, { "name": "edges", "type": "vector<vector<int>>&" } ], "return_type": "...
312
burst-balloons
Hard
You are given n balloons, indexed from 0 to n - 1. Each balloon is painted with a number on it represented by an array nums. You are asked to burst all the balloons. If you burst the i^th balloon, you will get nums[i - 1] * nums[i] * nums[i + 1] coins. If i - 1 or i + 1 goes out of bounds of the array, then treat it a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 110\n assert candidate(nums = [1, 5]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 9, 8, 0, 7, 1, 3, 5, 5, 2, 3]) == 1654\n assert candidate(nums = [7, 9, 8, 0, 7, 1, 3, 5...
[ "[3,1,5,8]", "[1,5]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().maxCoins", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:17", "tests_total": 96, "tests_dropped...
cpp
{ "raw_signature": "int maxCoins(vector<int>& nums) {", "container": "Solution", "callable": "maxCoins", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
313
super-ugly-number
Medium
A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of integers primes, return the n^th super ugly number. The n^th super ugly number is guaranteed to fit in a 32-bit signed integer. Example 1: Input: n = 12, primes = [2,7,13,19] Output: 32 Explanat...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 5,primes = [2, 7, 11]) == 8\n assert candidate(n = 5,primes = [2, 11, 13, 17, 19]) == 11\n assert candidate(n = 3,primes = [2, 3, 5, 7]) == 3\n assert candidate(n = 15,primes = [3, 5, 7]) == 81\n assert candidate(n = 10,p...
[ "12\n[2,7,13,19]", "1\n[2,3,5]" ]
[]
{ "canonical_parameter_names": [ "n", "primes" ], "leetcode_dataset_entry_point": "Solution().nthSuperUglyNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:19", "tests_total":...
cpp
{ "raw_signature": "int nthSuperUglyNumber(int n, vector<int>& primes) {", "container": "Solution", "callable": "nthSuperUglyNumber", "parameters": [ { "name": "n", "type": "int" }, { "name": "primes", "type": "vector<int>&" } ], "return_type": "int", "signature_sou...
315
count-of-smaller-numbers-after-self
Hard
Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i]. Example 1: Input: nums = [5,2,6,1] Output: [2,1,1,0] Explanation: To the right of 5 there are 2 smaller elements (2 and 1). To the right of 2 there is only 1 smaller element (1). To t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -1]) == [0, 0]\n assert candidate(nums = [10000, -10000, 5000, 0, 5000]) == [4, 0, 1, 0, 0]\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == ...
[ "[5,2,6,1]", "[-1]", "[-1,-1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().countSmaller", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:24", "tests_total": 135, "tests_dr...
cpp
{ "raw_signature": "vector<int> countSmaller(vector<int>& nums) {", "container": "Solution", "callable": "countSmaller", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/c...
316
remove-duplicate-letters
Medium
Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. Example 1: Input: s = "bcabc" Output: "abc" Example 2: Input: s = "cbacdcbc" Output: "acdb" Constraints: - 1 <= s.length <...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"rumeblidofervobenly\") == \"rumbidfevonly\"\n assert candidate(s = \"thesqtitxyetpxooxlqskyae\") == \"heitpoxlqskya\"\n assert candid...
[ "\"bcabc\"", "\"cbacdcbc\"" ]
[ "Greedily try to add one missing character. How to check if adding some character will not cause problems ? Use bit-masks to check whether you will be able to complete the sub-sequence if you add the character at some index i." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().removeDuplicateLetters", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:26", "tests_total": 99, "te...
cpp
{ "raw_signature": "string removeDuplicateLetters(string s) {", "container": "Solution", "callable": "removeDuplicateLetters", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
318
maximum-product-of-word-lengths
Medium
Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such two words exist, return 0. Example 1: Input: words = ["abcw","baz","foo","bar","xtfn","abcdef"] Output: 16 Explanation: The two words can be "abcw", "xtfn". Example 2:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'ab', 'abc', 'd', 'cd', 'bcd', 'abcd']) == 4\n assert candidate(words = ['eae', 'eaecbaaa', 'aadcba', 'bae', 'abc', 'abcbb', 'cba', 'abcd', 'ac', 'ba', 'aaaa', 'd', 'abac', 'ababc', 'abcabc', 'a', 'bc', 'b']) == 8\n a...
[ "[\"abcw\",\"baz\",\"foo\",\"bar\",\"xtfn\",\"abcdef\"]", "[\"a\",\"ab\",\"abc\",\"d\",\"cd\",\"bcd\",\"abcd\"]", "[\"a\",\"aa\",\"aaa\",\"aaaa\"]" ]
[]
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:31", "tests_total": 67, "tests_drop...
cpp
{ "raw_signature": "int maxProduct(vector<string>& words) {", "container": "Solution", "callable": "maxProduct", "parameters": [ { "name": "words", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
319
bulb-switcher
Medium
There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the i^th round, you toggle every i bulb. For the n^th round, you only toggle the last bulb. Return the...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 1\n assert candidate(n = 100) == 10\n assert candidate(n = 4) == 2\n assert candidate(n = 16) == 4\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 1000\n ass...
[ "3", "0", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().bulbSwitch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:33", "tests_total": 85, "tests_dropped"...
cpp
{ "raw_signature": "int bulbSwitch(int n) {", "container": "Solution", "callable": "bulbSwitch", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
321
create-maximum-number
Hard
You are given two integer arrays nums1 and nums2 of lengths m and n respectively. nums1 and nums2 represent the digits of two numbers. You are also given an integer k. Create the maximum number of length k <= m + n from digits of the two numbers. The relative order of the digits from the same array must be preserved. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5],k = 7) == [5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums1 = [3, 4, 6, 5],nums2 = [9, 1, 2, 5, 8, ...
[ "[3,4,6,5]\n[9,1,2,5,8,3]\n5", "[6,7]\n[6,0,4]\n5", "[3,9]\n[8,9]\n3" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2", "k" ], "leetcode_dataset_entry_point": "Solution().maxNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:38", "tests_tota...
cpp
{ "raw_signature": "vector<int> maxNumber(vector<int>& nums1, vector<int>& nums2, int k) {", "container": "Solution", "callable": "maxNumber", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" }, { "name": "k"...
322
coin-change
Medium
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1. You may assume th...
{ "language": "python", "source": "def check(candidate):\n assert candidate(coins = [186, 419, 83, 408],amount = 6249) == 20\n assert candidate(coins = [3, 7, 405, 436],amount = 8839) == 25\n assert candidate(coins = [3, 7, 405],amount = 8839) == 71\n assert candidate(coins = [2, 5, 10, 1],amount = 27) ...
[ "[1,2,5]\n11", "[2]\n3", "[1]\n0" ]
[]
{ "canonical_parameter_names": [ "coins", "amount" ], "leetcode_dataset_entry_point": "Solution().coinChange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:40", "tests_total": 127...
cpp
{ "raw_signature": "int coinChange(vector<int>& coins, int amount) {", "container": "Solution", "callable": "coinChange", "parameters": [ { "name": "coins", "type": "vector<int>&" }, { "name": "amount", "type": "int" } ], "return_type": "int", "signature_source": "l...
326
power-of-three
Easy
Given an integer n, return true if it is a power of three. Otherwise, return false. An integer n is a power of three, if there exists an integer x such that n == 3^x. Example 1: Input: n = 27 Output: true Explanation: 27 = 3^3 Example 2: Input: n = 0 Output: false Explanation: There is no x where 3^x = 0. Example...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == True\n assert candidate(n = 45) == False\n assert candidate(n = 729) == True\n assert candidate(n = 2147483647) == False\n assert candidate(n = 19683) == True\n assert candidate(n = 100) == False\n assert cand...
[ "27", "0", "-1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().isPowerOfThree", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:50", "tests_total": 76, "tests_drop...
cpp
{ "raw_signature": "bool isPowerOfThree(int n) {", "container": "Solution", "callable": "isPowerOfThree", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
327
count-of-range-sum
Hard
Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j inclusive, where i <= j. Example 1: Input: nums = [-2,5,-1], lower = -2, upper = 2 Output: 3 Expl...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3],lower = -5,upper = 5) == 24\n assert candidate(nums = [100, 200, 300, 400, 500],lower = 150,upper = 1000) == 11\n assert candidate(nums = [-1, -2, -3, -4, -5],lower = -10,upper = -5) == 7\n assert...
[ "[-2,5,-1]\n-2\n2", "[0]\n0\n0" ]
[]
{ "canonical_parameter_names": [ "nums", "lower", "upper" ], "leetcode_dataset_entry_point": "Solution().countRangeSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:53", "tes...
cpp
{ "raw_signature": "int countRangeSum(vector<int>& nums, int lower, int upper) {", "container": "Solution", "callable": "countRangeSum", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "lower", "type": "int" }, { "name": "upper", "typ...
329
longest-increasing-path-in-a-matrix
Hard
Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or down. You may not move diagonally or move outside the boundary (i.e., wrap-around is not allowed). Example 1: Input: matrix = [[9,9,4],[6,6,8],[2,1,1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == 9\n assert candidate(matrix = [[7, 8, 9], [9, 7, 8], [8, 9, 7]]) == 3\n assert candidate(matrix = [[1]]) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5], [16, 17, 24, 23, 6], [15,...
[ "[[9,9,4],[6,6,8],[2,1,1]]", "[[3,4,5],[3,2,6],[2,2,1]]", "[[1]]" ]
[]
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().longestIncreasingPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:45:58", "tests_total": 88, ...
cpp
{ "raw_signature": "int longestIncreasingPath(vector<vector<int>>& matrix) {", "container": "Solution", "callable": "longestIncreasingPath", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "typ...
330
patching-array
Hard
Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in the array. Return the minimum number of patches required. Example 1: Input: nums = [1,3], n = 6 Output: 1 Explanation: Combinations of nu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 8],n = 8) == 1\n assert candidate(nums = [1],n = 2) == 1\n assert candidate(nums = [1, 2, 4, 13],n = 30) == 2\n assert candidate(nums = [1, 2, 4, 13, 43],n = 100) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, ...
[ "[1,3]\n6", "[1,5,10]\n20", "[1,2,2]\n5" ]
[]
{ "canonical_parameter_names": [ "nums", "n" ], "leetcode_dataset_entry_point": "Solution().minPatches", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:01", "tests_total": 105, "t...
cpp
{ "raw_signature": "int minPatches(vector<int>& nums, int n) {", "container": "Solution", "callable": "minPatches", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/code...
331
verify-preorder-serialization-of-a-binary-tree
Medium
One way to serialize a binary tree is to use preorder traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as '#'. For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where '#' represents a null...
{ "language": "python", "source": "def check(candidate):\n assert candidate(preorder = \"1,2,#,#,3,4,#,#,5,#,#\") == True\n assert candidate(preorder = \"1,2,3,#,#,4,#,#,5,6,#,#,#,#\") == False\n assert candidate(preorder = \"1,2,3,#,#,4,5,#,#,#,#,6,7,#,#,#,#\") == False\n assert candidate(preorder = \"...
[ "\"9,3,4,#,#,1,#,#,2,#,6,#,#\"", "\"1,#\"", "\"9,#,#,1\"" ]
[]
{ "canonical_parameter_names": [ "preorder" ], "leetcode_dataset_entry_point": "Solution().isValidSerialization", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:03", "tests_total": 145,...
cpp
{ "raw_signature": "bool isValidSerialization(string preorder) {", "container": "Solution", "callable": "isValidSerialization", "parameters": [ { "name": "preorder", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
332
reconstruct-itinerary
Hard
You are given a list of airline tickets where tickets[i] = [from_i, to_i] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from "JFK", thus, the itinerary must begin with "JFK". If there are multiple valid i...
{ "language": "python", "source": "def check(candidate):\n assert candidate(tickets = [['JFK', 'NRT'], ['NRT', 'JFK']]) == ['JFK', 'NRT', 'JFK']\n assert candidate(tickets = [['JFK', 'MUC'], ['MUC', 'LHR'], ['LHR', 'SFO'], ['SFO', 'SJC']]) == ['JFK', 'MUC', 'LHR', 'SFO', 'SJC']\n assert candidate(tickets =...
[ "[[\"MUC\",\"LHR\"],[\"JFK\",\"MUC\"],[\"SFO\",\"SJC\"],[\"LHR\",\"SFO\"]]", "[[\"JFK\",\"SFO\"],[\"JFK\",\"ATL\"],[\"SFO\",\"ATL\"],[\"ATL\",\"JFK\"],[\"ATL\",\"SFO\"]]" ]
[]
{ "canonical_parameter_names": [ "tickets" ], "leetcode_dataset_entry_point": "Solution().findItinerary", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:06", "tests_total": 69, "tests...
cpp
{ "raw_signature": "vector<string> findItinerary(vector<vector<string>>& tickets) {", "container": "Solution", "callable": "findItinerary", "parameters": [ { "name": "tickets", "type": "vector<vector<string>>&" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSni...
334
increasing-triplet-subsequence
Medium
Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false. Example 1: Input: nums = [1,2,3,4,5] Output: true Explanation: Any triplet where i < j < k is valid. Example 2: Input: nums = [5,4,3,2,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == False\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7]) == True\n assert candidate(nums = [-1, 0, 1, 2, -1, -4]) == True\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1]) == False\n asser...
[ "[1,2,3,4,5]", "[5,4,3,2,1]", "[2,1,5,0,4,6]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().increasingTriplet", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:11", "tests_total": 124, "tes...
cpp
{ "raw_signature": "bool increasingTriplet(vector<int>& nums) {", "container": "Solution", "callable": "increasingTriplet", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
335
self-crossing
Hard
You are given an array of integers distance. You start at the point (0, 0) on an X-Y plane, and you move distance[0] meters to the north, then distance[1] meters to the west, distance[2] meters to the south, distance[3] meters to the east, and so on. In other words, after each move, your direction changes counter-cloc...
{ "language": "python", "source": "def check(candidate):\n assert candidate(distance = [3, 5, 3, 4, 3, 4]) == True\n assert candidate(distance = [3, 3, 3, 2, 1]) == False\n assert candidate(distance = [1, 2, 3, 4, 1, 2, 3, 4]) == True\n assert candidate(distance = [1, 1, 1, 2, 1]) == True\n assert ca...
[ "[2,1,1,2]", "[1,2,3,4]", "[1,1,1,2,1]" ]
[]
{ "canonical_parameter_names": [ "distance" ], "leetcode_dataset_entry_point": "Solution().isSelfCrossing", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:13", "tests_total": 113, "te...
cpp
{ "raw_signature": "bool isSelfCrossing(vector<int>& distance) {", "container": "Solution", "callable": "isSelfCrossing", "parameters": [ { "name": "distance", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
336
palindrome-pairs
Hard
You are given a 0-indexed array of unique strings words. A palindrome pair is a pair of integers (i, j) such that: - 0 <= i, j < words.length, - i != j, and - words[i] + words[j] (the concatenation of the two strings) is a palindrome. Return an array of all the palindrome pairs of words. You must write an algorithm...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['aabb', 'bbaa', 'abc', 'cba']) == [[0, 1], [1, 0], [2, 3], [3, 2]]\n assert candidate(words = ['bat', 'tab', 'cat']) == [[0, 1], [1, 0]]\n assert candidate(words = ['abc', 'cba', 'bca', 'xyz', 'zyx']) == [[0, 1], [1, 0], [...
[ "[\"abcd\",\"dcba\",\"lls\",\"s\",\"sssll\"]", "[\"bat\",\"tab\",\"cat\"]", "[\"a\",\"\"]" ]
[ "Checking every two pairs will exceed the time limit. It will be O(n^2 * k). We need a faster way.", "If we hash every string in the array, how can we check if two pairs form a palindrome after the concatenation?", "We can check every string in words and consider it as words[j] (i.e., the suffix of the target p...
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().palindromePairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:16", "tests_total": 91, "tests...
cpp
{ "raw_signature": "vector<vector<int>> palindromePairs(vector<string>& words) {", "container": "Solution", "callable": "palindromePairs", "parameters": [ { "name": "words", "type": "vector<string>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets"...
338
counting-bits
Easy
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i. Do not solve it with built-in functions (i.e., like __builtin_popcount in C++). Example 1: Input: n = 2 Output: [0,1,1] Explanation: 0 --> 0 1 --> 1 2 --> 10 Exa...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == [0]\n assert candidate(n = 10000) == [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, ...
[ "2", "5" ]
[ "You should make use of what you have produced already.", "Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous.", "Or does the odd/even status of the number help you in calculating the number of 1s?" ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().countBits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:21", "tests_total": 33, "tests_dropped":...
cpp
{ "raw_signature": "vector<int> countBits(int n) {", "container": "Solution", "callable": "countBits", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
342
power-of-four
Easy
Given an integer n, return true if it is a power of four. Otherwise, return false. An integer n is a power of four, if there exists an integer x such that n == 4^x. Example 1: Input: n = 16 Output: true Example 2: Input: n = 5 Output: false Example 3: Input: n = 1 Output: true Constraints: - -2^31 <= n <= 2^31...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == False\n assert candidate(n = -16) == False\n assert candidate(n = 2147483647) == False\n assert candidate(n = 536870912) == False\n assert candidate(n = 268435456) == True\n assert candidate(n = 5) == False\n ...
[ "16", "5", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().isPowerOfFour", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:26", "tests_total": 58, "tests_dropp...
cpp
{ "raw_signature": "bool isPowerOfFour(int n) {", "container": "Solution", "callable": "isPowerOfFour", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
343
integer-break
Medium
Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: n = 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input: n = 10 Output: 36 Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 11) == 54\n assert candidate(n = 30) == 59049\n assert candidate(n = 20) == 1458\n assert candidate(n = 2) == 1\n assert candidate(n = 10) == 36\n assert candidate(n = 58) == 1549681956\n assert candidate(n = 29) ==...
[ "2", "10" ]
[ "There is a simple O(n) solution to this problem.", "You may check the breaking results of n ranging from 7 to 10 to discover the regularities." ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().integerBreak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:28", "tests_total": 30, "tests_droppe...
cpp
{ "raw_signature": "int integerBreak(int n) {", "container": "Solution", "callable": "integerBreak", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
347
top-k-frequent-elements
Medium
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input: nums = [1], k = 1 Output: [1] Example 3: Input: nums = [1,2,1,2,1,2,3,1,3,2], k = 2 Output: [1,2] Constraints: ...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[1,1,1,2,2,3]\n2", "[1]\n1", "[1,2,1,2,1,2,3,1,3,2]\n2" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().topKFrequent", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:35", "tests_total": 34, "...
cpp
{ "raw_signature": "vector<int> topKFrequent(vector<int>& nums, int k) {", "container": "Solution", "callable": "topKFrequent", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "k", "type": "int" } ], "return_type": "vector<int>", "signature_sou...
349
intersection-of-two-arrays
Easy
Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] Output: [9,4] Explanation: [4,9...
{ "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,2,1]\n[2,2]", "[4,9,5]\n[9,4,9,8,4]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().intersection", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:37", "tests_total": 12...
cpp
{ "raw_signature": "vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {", "container": "Solution", "callable": "intersection", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" } ], "return_type": "ve...
350
intersection-of-two-arrays-ii
Easy
Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2] Output: [2,2] Example 2: Input: nums1 = [4,9,5], nums2 = [9,...
{ "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,2,1]\n[2,2]", "[4,9,5]\n[9,4,9,8,4]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().intersect", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:40", "tests_total": 137, ...
cpp
{ "raw_signature": "vector<int> intersect(vector<int>& nums1, vector<int>& nums2) {", "container": "Solution", "callable": "intersect", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" } ], "return_type": "vector<i...
354
russian-doll-envelopes
Hard
You are given a 2D array of integers envelopes where envelopes[i] = [w_i, h_i] represents the width and the height of an envelope. One envelope can fit into another if and only if both the width and height of one envelope are greater than the other envelope's width and height. Return the maximum number of envelopes y...
{ "language": "python", "source": "def check(candidate):\n assert candidate(envelopes = [[10, 16], [2, 3], [6, 8], [7, 19]]) == 3\n assert candidate(envelopes = [[1, 3], [3, 5], [6, 7], [8, 4], [9, 5]]) == 3\n assert candidate(envelopes = [[5, 4], [6, 4], [6, 7], [2, 3]]) == 3\n assert candidate(envelop...
[ "[[5,4],[6,4],[6,7],[2,3]]", "[[1,1],[1,1],[1,1]]" ]
[]
{ "canonical_parameter_names": [ "envelopes" ], "leetcode_dataset_entry_point": "Solution().maxEnvelopes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:44", "tests_total": 96, "test...
cpp
{ "raw_signature": "int maxEnvelopes(vector<vector<int>>& envelopes) {", "container": "Solution", "callable": "maxEnvelopes", "parameters": [ { "name": "envelopes", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "...
363
max-sum-of-rectangle-no-larger-than-k
Hard
Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k. It is guaranteed that there will be a rectangle with a sum no larger than k. Example 1: Input: matrix = [[1,0,1],[0,-2,3]], k = 2 Output: 2 Explanation: Because the sum of the blue re...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],k = 2) == 2\n assert candidate(matrix = [[5, 12, 4], [3, 9, 1], [11, 1, 3]],k = 17) == 17\n assert candidate(matrix = [[1, 0, 1], [0, -2, 3]],k = 2) == 2\n assert candidate(matrix = [[1...
[ "[[1,0,1],[0,-2,3]]\n2", "[[2,2,-1]]\n3" ]
[]
{ "canonical_parameter_names": [ "matrix", "k" ], "leetcode_dataset_entry_point": "Solution().maxSumSubmatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:46:58", "tests_total": 20...
cpp
{ "raw_signature": "int maxSumSubmatrix(vector<vector<int>>& matrix, int k) {", "container": "Solution", "callable": "maxSumSubmatrix", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" }, { "name": "k", "type": "int" } ], "return_type": "int", "sig...
365
water-and-jug-problem
Medium
You are given two jugs with capacities x liters and y liters. You have an infinite water supply. Return whether the total amount of water in both jugs may reach target using the following operations: - Fill either jug completely with water. - Completely empty either jug. - Pour water from one jug into another until th...
{ "language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 7,target = 1) == True\n assert candidate(x = 7,y = 3,target = 1) == True\n assert candidate(x = 8,y = 5,target = 9) == True\n assert candidate(x = 2,y = 6,target = 5) == False\n assert candidate(x = 10,y = 10,target...
[ "3\n5\n4" ]
[]
{ "canonical_parameter_names": [ "x", "y", "target" ], "leetcode_dataset_entry_point": "Solution().canMeasureWater", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:00", "tests_t...
cpp
{ "raw_signature": "bool canMeasureWater(int x, int y, int target) {", "container": "Solution", "callable": "canMeasureWater", "parameters": [ { "name": "x", "type": "int" }, { "name": "y", "type": "int" }, { "name": "target", "type": "int" } ], "r...
367
valid-perfect-square
Easy
Given a positive integer num, return true if num is a perfect square or false otherwise. A perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself. You must not use any built-in library function, such as sqrt. Example 1: Input: num = 16 Output: tr...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 14) == False\n assert candidate(num = 9) == True\n assert candidate(num = 1000000000) == False\n assert candidate(num = 49) == True\n assert candidate(num = 50) == False\n assert candidate(num = 25) == True\n asse...
[ "16", "14" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().isPerfectSquare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:05", "tests_total": 50, "tests_d...
cpp
{ "raw_signature": "bool isPerfectSquare(int num) {", "container": "Solution", "callable": "isPerfectSquare", "parameters": [ { "name": "num", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
368
largest-divisible-subset
Medium
Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies: - answer[i] % answer[j] == 0, or - answer[j] % answer[i] == 0 If there are multiple solutions, return any of them. Example 1: Input: nums = [1,2,3] Outpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == [9, 3, 1]\n assert candidate(nums = [100, 200, 400, 800, 1600, 3200]) == [3200, 1600, 800, 400, 200, 100]\n assert candidate(nums = [1, 5, 10, 20, 25, 50]) == [20, 10, 5, 1]\n assert candid...
[ "[1,2,3]", "[1,2,4,8]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().largestDivisibleSubset", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:07", "tests_total": 109, ...
cpp
{ "raw_signature": "vector<int> largestDivisibleSubset(vector<int>& nums) {", "container": "Solution", "callable": "largestDivisibleSubset", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_...
371
sum-of-two-integers
Medium
Given two integers a and b, return the sum of the two integers without using the operators + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = 2, b = 3 Output: 5 Constraints: - -1000 <= a, b <= 1000
{ "language": "python", "source": "def check(candidate):\n assert candidate(a = 1000,b = -1000) == 0\n assert candidate(a = -2,b = -3) == -5\n assert candidate(a = 0,b = 5) == 5\n assert candidate(a = 500,b = 500) == 1000\n assert candidate(a = -5,b = -5) == -10\n assert candidate(a = 1,b = 2) == ...
[ "1\n2", "2\n3" ]
[]
{ "canonical_parameter_names": [ "a", "b" ], "leetcode_dataset_entry_point": "Solution().getSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:14", "tests_total": 80, "tests_dro...
cpp
{ "raw_signature": "int getSum(int a, int b) {", "container": "Solution", "callable": "getSum", "parameters": [ { "name": "a", "type": "int" }, { "name": "b", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "lee...
373
find-k-pairs-with-smallest-sums
Medium
You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k. Define a pair (u, v) which consists of one element from the first array and one element from the second array. Return the k pairs (u_1, v_1), (u_2, v_2), ..., (u_k, v_k) with the smallest sums. Example 1: Input: nums1 ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 8, 8, 10],nums2 = [1, 7, 11, 11],k = 10) == [[5, 1], [8, 1], [8, 1], [10, 1], [5, 7], [8, 7], [8, 7], [5, 11], [5, 11], [10, 7]]\n assert candidate(nums1 = [1, 1, 2],nums2 = [1, 2, 3],k = 4) == [[1, 1], [1, 1], [1, 2], [1,...
[ "[1,7,11]\n[2,4,6]\n3", "[1,1,2]\n[1,2,3]\n2" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2", "k" ], "leetcode_dataset_entry_point": "Solution().kSmallestPairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:17", "tests...
cpp
{ "raw_signature": "vector<vector<int>> kSmallestPairs(vector<int>& nums1, vector<int>& nums2, int k) {", "container": "Solution", "callable": "kSmallestPairs", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" }, {...
375
guess-number-higher-or-lower-ii
Medium
We are playing the Guessing Game. The game will work as follows: 1. I pick a number between 1 and n. 2. You guess a number. 3. If you guess the right number, you win the game. 4. If you guess the wrong number, then I will tell you whether the number I picked is higher or lower, and you will continue guessing. 5. Every...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 100) == 400\n assert candidate(n = 15) == 30\n assert candidate(n = 200) == 952\n assert candidate(n = 2) == 1\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 16\n assert candidate(n = 5) == 6\n asse...
[ "10", "1", "2" ]
[ "The best strategy to play the game is to minimize the maximum loss you could possibly face. Another strategy is to minimize the expected loss. Here, we are interested in the first scenario.", "Take a small example (n = 3). What do you end up paying in the worst case?", "Check out this article if you're still s...
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().getMoneyAmount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:19", "tests_total": 28, "tests_drop...
cpp
{ "raw_signature": "int getMoneyAmount(int n) {", "container": "Solution", "callable": "getMoneyAmount", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
376
wiggle-subsequence
Medium
A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are trivially wiggle sequences. - For exampl...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3]) == 2\n assert candidate(nums = [80, 80, 80, 80, 80, 80]) == 1\n assert candidate(nums = [3, 3, 3, 2, 5, 25, 50, 41, 60, 70, 55, 65, 80, 90, 99]) == 7\n assert candidate(nums = [1, 1, 1, 1]) == 1\n assert ...
[ "[1,7,4,9,2,5]", "[1,17,5,10,13,15,10,5,16,8]", "[1,2,3,4,5,6,7,8,9]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().wiggleMaxLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:22", "tests_total": 134, "tests...
cpp
{ "raw_signature": "int wiggleMaxLength(vector<int>& nums) {", "container": "Solution", "callable": "wiggleMaxLength", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippet...
377
combination-sum-iv
Medium
Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The test cases are generated so that the answer can fit in a 32-bit integer. Example 1: Input: nums = [1,2,3], target = 4 Output: 7 Explanation: The possible combination ways are: (...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],target = 100) == 274\n assert candidate(nums = [1, 2, 3],target = 4) == 7\n assert candidate(nums = [5, 50, 75],target = 95) == 16\n assert candidate(nums = [5, 1, 3],target = 8) == 19\n assert candidate(n...
[ "[1,2,3]\n4", "[9]\n3" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().combinationSum4", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:24", "tests_total":...
cpp
{ "raw_signature": "int combinationSum4(vector<int>& nums, int target) {", "container": "Solution", "callable": "combinationSum4", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "int", "signature_sou...
378
kth-smallest-element-in-a-sorted-matrix
Medium
Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the k^th smallest element in the matrix. Note that it is the k^th smallest element in the sorted order, not the k^th distinct element. You must find a solution with a memory complexity better than O(n^2). Example 1: Input:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 2], [1, 3]],k = 1) == 1\n assert candidate(matrix = [[5, 9, 11], [9, 11, 13], [12, 13, 15]],k = 5) == 11\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 4) == 4\n assert candidate(matrix = [[1, 3,...
[ "[[1,5,9],[10,11,13],[12,13,15]]\n8", "[[-5]]\n1" ]
[]
{ "canonical_parameter_names": [ "matrix", "k" ], "leetcode_dataset_entry_point": "Solution().kthSmallest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:27", "tests_total": 88, ...
cpp
{ "raw_signature": "int kthSmallest(vector<vector<int>>& matrix, int k) {", "container": "Solution", "callable": "kthSmallest", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" }, { "name": "k", "type": "int" } ], "return_type": "int", "signature_s...
383
ransom-note
Easy
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote. Example 1: Input: ransomNote = "a", magazine = "b" Output: false Example 2: Input: ransomNote = "aa", magazine...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ransomNote = \"abc\",magazine = \"def\") == False\n assert candidate(ransomNote = \"hello\",magazine = \"hll\") == False\n assert candidate(ransomNote = \"mississippi\",magazine = \"mspsisgp\") == False\n assert candidate(ransom...
[ "\"a\"\n\"b\"", "\"aa\"\n\"ab\"", "\"aa\"\n\"aab\"" ]
[]
{ "canonical_parameter_names": [ "ransomNote", "magazine" ], "leetcode_dataset_entry_point": "Solution().canConstruct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:29", "tests_to...
cpp
{ "raw_signature": "bool canConstruct(string ransomNote, string magazine) {", "container": "Solution", "callable": "canConstruct", "parameters": [ { "name": "ransomNote", "type": "string" }, { "name": "magazine", "type": "string" } ], "return_type": "bool", "signatu...
386
lexicographical-numbers
Medium
Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order. You must write an algorithm that runs in O(n) time and uses O(1) extra space. Example 1: Input: n = 13 Output: [1,10,11,12,13,2,3,4,5,6,7,8,9] Example 2: Input: n = 2 Output: [1,2] Constraints: - 1 <= n <= 5 * 10^4
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 4321) == [1, 10, 100, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 101, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 102, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 103, 1030, 1031, 1032...
[ "13", "2" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().lexicalOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:31", "tests_total": 37, "tests_droppe...
cpp
{ "raw_signature": "vector<int> lexicalOrder(int n) {", "container": "Solution", "callable": "lexicalOrder", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
387
first-unique-character-in-a-string
Easy
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" Output: 0 Explanation: The character 'l' at index 0 is the first character that does not occur at any other index. Example 2: Input: s = "loveleetcode" Output: 2 Ex...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbbccccddeeeeeffffffgggggghhhhhhiiiiiiiijjjjjjjjjkkkkkkkkkkklllllllllllllmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnooooooooollllllllllllllllmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnp\") == 165\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz...
[ "\"leetcode\"", "\"loveleetcode\"", "\"aabb\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().firstUniqChar", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:33", "tests_total": 91, "tests_dropp...
cpp
{ "raw_signature": "int firstUniqChar(string s) {", "container": "Solution", "callable": "firstUniqChar", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
389
find-the-difference
Easy
You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the letter that was added to t. Example 1: Input: s = "abcd", t = "abcde" Output: "e" Explanation: 'e' is the letter that was added. Example 2: Input: s = "", t = "y" Out...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",t = \"abcde\") == \"e\"\n assert candidate(s = \"aeiou\",t = \"aeiouf\") == \"f\"\n assert candidate(s = \"abcdxyz\",t = \"abcdzyxw\") == \"w\"\n assert candidate(s = \"a\",t = \"ab\") == \"b\"\n assert candidate...
[ "\"abcd\"\n\"abcde\"", "\"\"\n\"y\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().findTheDifference", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:38", "tests_total": 96, ...
cpp
{ "raw_signature": "char findTheDifference(string s, string t) {", "container": "Solution", "callable": "findTheDifference", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "char", "signature_source": "leetcode/...
390
elimination-game
Medium
You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order. Apply the following algorithm on arr: - Starting from left to right, remove the first number and every other number afterward until you reach the end of the list. - Repeat the previous step again, but this time from right to...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 11) == 8\n assert candidate(n = 100) == 54\n assert candidate(n = 9) == 6\n assert candidate(n = 1000000) == 481110\n assert candidate(n = 2) == 2\n assert candidate(n = 20) == 6\n assert candidate(n = 1) == 1\n ...
[ "9", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().lastRemaining", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:41", "tests_total": 78, "tests_dropp...
cpp
{ "raw_signature": "int lastRemaining(int n) {", "container": "Solution", "callable": "lastRemaining", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
391
perfect-rectangle
Hard
Given an array rectangles where rectangles[i] = [x_i, y_i, a_i, b_i] represents an axis-aligned rectangle. The bottom-left point of the rectangle is (x_i, y_i) and the top-right point of it is (a_i, b_i). Return true if all the rectangles together form an exact cover of a rectangular region. Example 1: Input: rectan...
{ "language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[0, 0, 2, 2], [0, 2, 2, 4], [2, 0, 4, 2], [2, 2, 4, 4]]) == True\n assert candidate(rectangles = [[0, 0, 1, 1], [0, 1, 3, 2], [1, 0, 2, 2]]) == False\n assert candidate(rectangles = [[1, 1, 3, 3], [3, 1, 4, 2], [3, 2,...
[ "[[1,1,3,3],[3,1,4,2],[3,2,4,4],[1,3,2,4],[2,3,3,4]]", "[[1,1,2,3],[1,3,2,4],[3,1,4,2],[3,2,4,4]]", "[[1,1,3,3],[3,1,4,2],[1,3,2,4],[2,2,4,4]]" ]
[]
{ "canonical_parameter_names": [ "rectangles" ], "leetcode_dataset_entry_point": "Solution().isRectangleCover", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:43", "tests_total": 98, ...
cpp
{ "raw_signature": "bool isRectangleCover(vector<vector<int>>& rectangles) {", "container": "Solution", "callable": "isRectangleCover", "parameters": [ { "name": "rectangles", "type": "vector<vector<int>>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "typ...
392
is-subsequence
Easy
Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abdc\") == True\n assert candidate(s = \"xyz\",t = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"aec\",t = \"abcde\") == False\n assert candidate(s = \"\",t = \"ahbgdc\") == True\n assert ...
[ "\"abc\"\n\"ahbgdc\"", "\"axc\"\n\"ahbgdc\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().isSubsequence", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:45", "tests_total": 69, "te...
cpp
{ "raw_signature": "bool isSubsequence(string s, string t) {", "container": "Solution", "callable": "isSubsequence", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnip...
393
utf-8-validation
Medium
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e. it translates to a sequence of valid UTF-8 encoded characters). A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: 1. For a 1-byte character, the first bit is a 0, followed by its Uni...
{ "language": "python", "source": "def check(candidate):\n assert candidate(data = [237, 130, 130, 130]) == False\n assert candidate(data = [237, 128, 128, 130, 128, 128]) == False\n assert candidate(data = [238, 130, 130]) == True\n assert candidate(data = [31, 130, 130, 130]) == False\n assert cand...
[ "[197,130,1]", "[235,140,4]" ]
[ "Read the data integer by integer. When you read it, process the least significant 8 bits of it.", "Assume the next encoding is 1-byte data. If it is not 1-byte data, read the next integer and assume it is 2-bytes data.", "Similarly, if it is not 2-bytes data, try 3-bytes then 4-bytes. If you read four integers...
{ "canonical_parameter_names": [ "data" ], "leetcode_dataset_entry_point": "Solution().validUtf8", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:48", "tests_total": 135, "tests_dropp...
cpp
{ "raw_signature": "bool validUtf8(vector<int>& data) {", "container": "Solution", "callable": "validUtf8", "parameters": [ { "name": "data", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
394
decode-string
Medium
Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; there are no extra white spaces,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"2[ab3[cd]]\") == \"abcdcdcdabcdcdcd\"\n assert candidate(s = \"2[ab3[c]]\") == \"abcccabccc\"\n assert candidate(s = \"1[a1[b1[c]]]\") == \"abc\"\n assert candidate(s = \"2[3[a]]\") == \"aaaaaa\"\n assert candidate(s = ...
[ "\"3[a]2[bc]\"", "\"3[a2[c]]\"", "\"2[abc]3[cd]ef\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().decodeString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:50", "tests_total": 133, "tests_dropp...
cpp
{ "raw_signature": "string decodeString(string s) {", "container": "Solution", "callable": "decodeString", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
395
longest-substring-with-at-least-k-repeating-characters
Medium
Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k. if no such substring exists, return 0. Example 1: Input: s = "aaabb", k = 3 Output: 3 Explanation: The longest substring is "aaa", as 'a' is re...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcabc\",k = 3) == 9\n assert candidate(s = \"abcdefg\",k = 1) == 7\n assert candidate(s = \"bbaaacccddddeee\",k = 4) == 4\n assert candidate(s = \"aabcabb\",k = 2) == 2\n assert candidate(s = \"aaa\",k = 4) == 0\n ...
[ "\"aaabb\"\n3", "\"ababbc\"\n2" ]
[]
{ "canonical_parameter_names": [ "s", "k" ], "leetcode_dataset_entry_point": "Solution().longestSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:52", "tests_total": 109, ...
cpp
{ "raw_signature": "int longestSubstring(string s, int k) {", "container": "Solution", "callable": "longestSubstring", "parameters": [ { "name": "s", "type": "string" }, { "name": "k", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippe...