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
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, "...
typescript
{ "raw_signature": "function topKFrequent(nums: number[], k: number): number[] {", "container": null, "callable": "topKFrequent", "parameters": [ { "name": "nums", "type": "number[]" }, { "name": "k", "type": "number" } ], "return_type": "number[]", "signature_sourc...
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...
typescript
{ "raw_signature": "function intersection(nums1: number[], nums2: number[]): number[] {", "container": null, "callable": "intersection", "parameters": [ { "name": "nums1", "type": "number[]" }, { "name": "nums2", "type": "number[]" } ], "return_type": "number[]", "s...
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, ...
typescript
{ "raw_signature": "function intersect(nums1: number[], nums2: number[]): number[] {", "container": null, "callable": "intersect", "parameters": [ { "name": "nums1", "type": "number[]" }, { "name": "nums2", "type": "number[]" } ], "return_type": "number[]", "signatu...
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...
typescript
{ "raw_signature": "function maxEnvelopes(envelopes: number[][]): number {", "container": null, "callable": "maxEnvelopes", "parameters": [ { "name": "envelopes", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/...
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...
typescript
{ "raw_signature": "function maxSumSubmatrix(matrix: number[][], k: number): number {", "container": null, "callable": "maxSumSubmatrix", "parameters": [ { "name": "matrix", "type": "number[][]" }, { "name": "k", "type": "number" } ], "return_type": "number", "signa...
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...
typescript
{ "raw_signature": "function canMeasureWater(x: number, y: number, target: number): boolean {", "container": null, "callable": "canMeasureWater", "parameters": [ { "name": "x", "type": "number" }, { "name": "y", "type": "number" }, { "name": "target", "typ...
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...
typescript
{ "raw_signature": "function isPerfectSquare(num: number): boolean {", "container": null, "callable": "isPerfectSquare", "parameters": [ { "name": "num", "type": "number" } ], "return_type": "boolean", "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, ...
typescript
{ "raw_signature": "function largestDivisibleSubset(nums: number[]): number[] {", "container": null, "callable": "largestDivisibleSubset", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": ...
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...
typescript
{ "raw_signature": "function getSum(a: number, b: number): number {", "container": null, "callable": "getSum", "parameters": [ { "name": "a", "type": "number" }, { "name": "b", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets...
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...
typescript
{ "raw_signature": "function kSmallestPairs(nums1: number[], nums2: number[], k: number): number[][] {", "container": null, "callable": "kSmallestPairs", "parameters": [ { "name": "nums1", "type": "number[]" }, { "name": "nums2", "type": "number[]" }, { "name": ...
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...
typescript
{ "raw_signature": "function getMoneyAmount(n: number): number {", "container": null, "callable": "getMoneyAmount", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "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...
typescript
{ "raw_signature": "function wiggleMaxLength(nums: number[]): number {", "container": null, "callable": "wiggleMaxLength", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnip...
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":...
typescript
{ "raw_signature": "function combinationSum4(nums: number[], target: number): number {", "container": null, "callable": "combinationSum4", "parameters": [ { "name": "nums", "type": "number[]" }, { "name": "target", "type": "number" } ], "return_type": "number", "sig...
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, ...
typescript
{ "raw_signature": "function kthSmallest(matrix: number[][], k: number): number {", "container": null, "callable": "kthSmallest", "parameters": [ { "name": "matrix", "type": "number[][]" }, { "name": "k", "type": "number" } ], "return_type": "number", "signature_sou...
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...
typescript
{ "raw_signature": "function canConstruct(ransomNote: string, magazine: string): boolean {", "container": null, "callable": "canConstruct", "parameters": [ { "name": "ransomNote", "type": "string" }, { "name": "magazine", "type": "string" } ], "return_type": "boolean"...
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...
typescript
{ "raw_signature": "function lexicalOrder(n: number): number[] {", "container": null, "callable": "lexicalOrder", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number[]", "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...
typescript
{ "raw_signature": "function firstUniqChar(s: string): number {", "container": null, "callable": "firstUniqChar", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "number", "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, ...
typescript
{ "raw_signature": "function findTheDifference(s: string, t: string): string {", "container": null, "callable": "findTheDifference", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "string", "signature_source": ...
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...
typescript
{ "raw_signature": "function lastRemaining(n: number): number {", "container": null, "callable": "lastRemaining", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "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, ...
typescript
{ "raw_signature": "function isRectangleCover(rectangles: number[][]): boolean {", "container": null, "callable": "isRectangleCover", "parameters": [ { "name": "rectangles", "type": "number[][]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source"...
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...
typescript
{ "raw_signature": "function isSubsequence(s: string, t: string): boolean {", "container": null, "callable": "isSubsequence", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "boolean", "signature_source": "leetc...
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...
typescript
{ "raw_signature": "function validUtf8(data: number[]): boolean {", "container": null, "callable": "validUtf8", "parameters": [ { "name": "data", "type": "number[]" } ], "return_type": "boolean", "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...
typescript
{ "raw_signature": "function decodeString(s: string): string {", "container": null, "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, ...
typescript
{ "raw_signature": "function longestSubstring(s: string, k: number): number {", "container": null, "callable": "longestSubstring", "parameters": [ { "name": "s", "type": "string" }, { "name": "k", "type": "number" } ], "return_type": "number", "signature_source": "l...
396
rotate-function
Medium
You are given an integer array nums of length n. Assume arr_k to be an array obtained by rotating nums by k positions clock-wise. We define the rotation function F on nums as follow: - F(k) = 0 * arr_k[0] + 1 * arr_k[1] + ... + (n - 1) * arr_k[n - 1]. Return the maximum value of F(0), F(1), ..., F(n-1). The test ca...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1]) == 6\n assert candidate(nums = [1, 0, 0, 0, 1]) == 7\n assert candidate(nums = [10, -10, 20, -20]) == 50\n assert candidate(nums = [1, 2...
[ "[4,3,2,6]", "[100]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().maxRotateFunction", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:54", "tests_total": 89, "test...
typescript
{ "raw_signature": "function maxRotateFunction(nums: number[]): number {", "container": null, "callable": "maxRotateFunction", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/code...
397
integer-replacement
Medium
Given a positive integer n, you can apply one of the following operations: 1. If n is even, replace n with n / 2. 2. If n is odd, replace n with either n + 1 or n - 1. Return the minimum number of operations needed for n to become 1. Example 1: Input: n = 8 Output: 3 Explanation: 8 -> 4 -> 2 -> 1 Example 2: Input...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 15) == 5\n assert candidate(n = 4) == 2\n assert candidate(n = 2147483647) == 32\n assert candidate(n = 1) == 0\n assert candidate(n = 1000000000) == 38\n assert candidate(n = 7) == 4\...
[ "8", "7", "4" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().integerReplacement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:57", "tests_total": 37, "tests_...
typescript
{ "raw_signature": "function integerReplacement(n: number): number {", "container": null, "callable": "integerReplacement", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets...
399
evaluate-division
Medium
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [A_i, B_i] and values[i] represent the equation A_i / B_i = values[i]. Each A_i or B_i is a string that represents a single variable. You are also given some queries, where queries[j] = [C_j, D_j] represents th...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "[[\"a\",\"b\"],[\"b\",\"c\"]]\n[2.0,3.0]\n[[\"a\",\"c\"],[\"b\",\"a\"],[\"a\",\"e\"],[\"a\",\"a\"],[\"x\",\"x\"]]", "[[\"a\",\"b\"],[\"b\",\"c\"],[\"bc\",\"cd\"]]\n[1.5,2.5,5.0]\n[[\"a\",\"c\"],[\"c\",\"b\"],[\"bc\",\"cd\"],[\"cd\",\"bc\"]]", "[[\"a\",\"b\"]]\n[0.5]\n[[\"a\",\"b\"],[\"b\",\"a\"],[\"a\",\"c\"],...
[ "Do you recognize this as a graph problem?" ]
{ "canonical_parameter_names": [ "equations", "values", "queries" ], "leetcode_dataset_entry_point": "Solution().calcEquation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:47:59",...
typescript
{ "raw_signature": "function calcEquation(equations: string[][], values: number[], queries: string[][]): number[] {", "container": null, "callable": "calcEquation", "parameters": [ { "name": "equations", "type": "string[][]" }, { "name": "values", "type": "number[]" }, ...
400
nth-digit
Medium
Given an integer n, return the n^th digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. Example 1: Input: n = 3 Output: 3 Example 2: Input: n = 11 Output: 0 Explanation: The 11^th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10. Const...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 11) == 0\n assert candidate(n = 231) == 3\n assert candidate(n = 15) == 2\n assert candidate(n = 2147483647) == 2\n assert candidate(n = 1000000) == 1\n assert candidate(n = 123456789)...
[ "3", "11" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().findNthDigit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:01", "tests_total": 50, "tests_droppe...
typescript
{ "raw_signature": "function findNthDigit(n: number): number {", "container": null, "callable": "findNthDigit", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
401
binary-watch
Easy
A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right. - For example, the below binary watch reads "4:51". Given an integer turnedOn which represents the number of LED...
{ "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", "9" ]
[ "Simplify by seeking for solutions that involve comparing set bit counts.", "Consider precomputing all possible times for comparison." ]
{ "canonical_parameter_names": [ "turnedOn" ], "leetcode_dataset_entry_point": "Solution().readBinaryWatch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:03", "tests_total": 12, "te...
typescript
{ "raw_signature": "function readBinaryWatch(turnedOn: number): string[] {", "container": null, "callable": "readBinaryWatch", "parameters": [ { "name": "turnedOn", "type": "number" } ], "return_type": "string[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/...
402
remove-k-digits
Medium
Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num. Example 1: Input: num = "1432219", k = 3 Output: "1219" Explanation: Remove the three digits 4, 3, and 2 to form the new number 1219 which is the smallest. Example 2: In...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = \"100\",k = 1) == \"0\"\n assert candidate(num = \"999\",k = 2) == \"9\"\n assert candidate(num = \"1234567890\",k = 9) == \"0\"\n assert candidate(num = \"111111\",k = 2) == \"1111\"\n assert candidate(num = \"98765432...
[ "\"1432219\"\n3", "\"10200\"\n1", "\"10\"\n2" ]
[]
{ "canonical_parameter_names": [ "num", "k" ], "leetcode_dataset_entry_point": "Solution().removeKdigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:06", "tests_total": 111, ...
typescript
{ "raw_signature": "function removeKdigits(num: string, k: number): string {", "container": null, "callable": "removeKdigits", "parameters": [ { "name": "num", "type": "string" }, { "name": "k", "type": "number" } ], "return_type": "string", "signature_source": "lee...
403
frog-jump
Hard
A frog is crossing a river. The river is divided into some number of units, and at each unit, there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water. Given a list of stones positions (in units) in sorted ascending order, determine if the frog can cross the river by landin...
{ "language": "python", "source": "def check(candidate):\n assert candidate(stones = [0, 1, 3, 8, 14, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == False\n assert candidate(stones = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n ...
[ "[0,1,3,5,6,8,12,17]", "[0,1,2,3,4,8,9,11]" ]
[]
{ "canonical_parameter_names": [ "stones" ], "leetcode_dataset_entry_point": "Solution().canCross", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:08", "tests_total": 82, "tests_dropp...
typescript
{ "raw_signature": "function canCross(stones: number[]): boolean {", "container": null, "callable": "canCross", "parameters": [ { "name": "stones", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
405
convert-a-number-to-hexadecimal
Easy
Given a 32-bit integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself. Note: You are not al...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 31) == \"1f\"\n assert candidate(num = 10) == \"a\"\n assert candidate(num = 16777215) == \"ffffff\"\n assert candidate(num = -16777215) == \"ff000001\"\n assert candidate(num = -1) == \"ffffffff\"\n assert candidate...
[ "26", "-1" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().toHex", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:12", "tests_total": 60, "tests_dropped": 8...
typescript
{ "raw_signature": "function toHex(num: number): string {", "container": null, "callable": "toHex", "parameters": [ { "name": "num", "type": "number" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
406
queue-reconstruction-by-height
Medium
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [h_i, k_i] represents the i^th person of height h_i with exactly k_i other people in front who have a height greater than or equal to h_i. Reconstruct and return the queue that is r...
{ "language": "python", "source": "def check(candidate):\n assert candidate(people = [[9, 0], [7, 0], [5, 0], [6, 1], [3, 2], [2, 2], [1, 4], [8, 1]]) == [[5, 0], [7, 0], [2, 2], [3, 2], [1, 4], [6, 1], [9, 0], [8, 1]]\n assert candidate(people = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0]]) == [[5, 0], [...
[ "[[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]", "[[6,0],[5,0],[4,0],[3,2],[2,2],[1,4]]" ]
[ "What can you say about the position of the shortest person? If the position of the shortest person is i, how many people would be in front of the shortest person?", "Once you fix the position of the shortest person, what can you say about the position of the second shortest person?" ]
{ "canonical_parameter_names": [ "people" ], "leetcode_dataset_entry_point": "Solution().reconstructQueue", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:15", "tests_total": 101, "te...
typescript
{ "raw_signature": "function reconstructQueue(people: number[][]): number[][] {", "container": null, "callable": "reconstructQueue", "parameters": [ { "name": "people", "type": "number[][]" } ], "return_type": "number[][]", "signature_source": "leetcode/codeSnippets", "type_source": ...
407
trapping-rain-water-ii
Hard
Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining. Example 1: Input: heightMap = [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] Output: 4 Explanation: After the rain, water is trapped between the blocks. We have t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(heightMap = [[5, 5, 5, 5, 5], [5, 1, 2, 1, 5], [5, 2, 3, 2, 5], [5, 1, 2, 1, 5], [5, 5, 5, 5, 5]]) == 30\n assert candidate(heightMap = [[1, 2], [2, 1]]) == 0\n assert candidate(heightMap = [[1, 2, 3], [0, 1, 0], [1, 2, 1]]) == 0\n...
[ "[[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]", "[[3,3,3,3,3],[3,2,2,2,3],[3,2,1,2,3],[3,2,2,2,3],[3,3,3,3,3]]" ]
[]
{ "canonical_parameter_names": [ "heightMap" ], "leetcode_dataset_entry_point": "Solution().trapRainWater", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:17", "tests_total": 78, "tes...
typescript
{ "raw_signature": "function trapRainWater(heightMap: number[][]): number {", "container": null, "callable": "trapRainWater", "parameters": [ { "name": "heightMap", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
409
longest-palindrome
Easy
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, "Aa" is not considered a palindrome. Example 1: Input: s = "abccccdd" Output: 7 Explanation: One longest palindrome that can be...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbccc\") == 7\n assert candidate(s = \"abccccdd\") == 7\n assert candidate(s = \"zyyzzzzz\") == 8\n assert candidate(s = \"abcdedcba\") == 9\n assert candidate(s = \"aabbbb\") == 6\n assert candidate(s = \"aaaaa\")...
[ "\"abccccdd\"", "\"a\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:21", "tests_total": 68, "tests_d...
typescript
{ "raw_signature": "function longestPalindrome(s: string): number {", "container": null, "callable": "longestPalindrome", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" ...
410
split-array-largest-sum
Hard
Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split. A subarray is a contiguous part of the array. Example 1: Input: nums = [7,2,5,10,8], k = 2 Output: 18 Explanation: There are four...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 2, 5, 10, 8],k = 2) == 18\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [10, 10, 10, 10],k = 2) == 20\n assert candidate(nums = [10, 5, 13, 4, 8, 4, 5, 11, 14, 9, 15],k = 6) == 23\n ...
[ "[7,2,5,10,8]\n2", "[1,2,3,4,5]\n2" ]
[]
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().splitArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:24", "tests_total": 83, "te...
typescript
{ "raw_signature": "function splitArray(nums: number[], k: number): number {", "container": null, "callable": "splitArray", "parameters": [ { "name": "nums", "type": "number[]" }, { "name": "k", "type": "number" } ], "return_type": "number", "signature_source": "lee...
412
fizz-buzz
Easy
Given an integer n, return a string array answer (1-indexed) where: - answer[i] == "FizzBuzz" if i is divisible by 3 and 5. - answer[i] == "Fizz" if i is divisible by 3. - answer[i] == "Buzz" if i is divisible by 5. - answer[i] == i (as a string) if none of the above conditions are true. Example 1: Input: n = 3 Outp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == ['1', '2', 'Fizz']\n assert candidate(n = 100) == ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz', 'Buzz', '11', 'Fizz', '13', '14', 'FizzBuzz', '16', '17', 'Fizz', '19', 'Buzz', 'Fizz', '22', '23', 'Fizz', 'Buzz', ...
[ "3", "5", "15" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().fizzBuzz", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:28", "tests_total": 44, "tests_dropped": ...
typescript
{ "raw_signature": "function fizzBuzz(n: number): string[] {", "container": null, "callable": "fizzBuzz", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "string[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
413
arithmetic-slices
Medium
An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. - For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences. Given an integer array nums, return the number of arithmetic subarrays of nums. A s...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums = [1, 2, 4, 5, 6, 7]) == 3\n assert candidate(nums = [3, -1, -5, -9]) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candida...
[ "[1,2,3,4]", "[1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().numberOfArithmeticSlices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:31", "tests_total": 171,...
typescript
{ "raw_signature": "function numberOfArithmeticSlices(nums: number[]): number {", "container": null, "callable": "numberOfArithmeticSlices", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": ...
414
third-maximum-number
Easy
You are given an integer array nums. Return the third distinct maximum number in this array. If the third maximum does not exist, return the maximum number. Example 1: Input: nums = [3,2,1] Output: 1 Explanation: The first distinct maximum is 3. The second distinct maximum is 2. The third distinct maximum is 1. Exa...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, -2147483648]) == -2147483648\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7,...
[ "[3,2,1]", "[1,2]", "[2,2,3,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().thirdMax", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:33", "tests_total": 127, "tests_droppe...
typescript
{ "raw_signature": "function thirdMax(nums: number[]): number {", "container": null, "callable": "thirdMax", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
415
add-strings
Easy
Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string. You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly. Example 1: Input: num1 = "11", ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num1 = \"500\",num2 = \"500\") == \"1000\"\n assert candidate(num1 = \"11\",num2 = \"123\") == \"134\"\n assert candidate(num1 = \"1000\",num2 = \"2000\") == \"3000\"\n assert candidate(num1 = \"10000\",num2 = \"20000\") == \"30...
[ "\"11\"\n\"123\"", "\"456\"\n\"77\"", "\"0\"\n\"0\"" ]
[]
{ "canonical_parameter_names": [ "num1", "num2" ], "leetcode_dataset_entry_point": "Solution().addStrings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:35", "tests_total": 92, ...
typescript
{ "raw_signature": "function addStrings(num1: string, num2: string): string {", "container": null, "callable": "addStrings", "parameters": [ { "name": "num1", "type": "string" }, { "name": "num2", "type": "string" } ], "return_type": "string", "signature_source": "l...
416
partition-equal-subset-sum
Medium
Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false otherwise. Example 1: Input: nums = [1,5,11,5] Output: true Explanation: The array can be partitioned as [1, 5, 5] and [11]. Example 2: Input: nums = [1,2,3,5]...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5]) == False\n assert candidate(nums = [1, 5, 11, 5]) == True\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4]) == True\n assert candidate(nums = [2, 2, 3, 3]) =...
[ "[1,5,11,5]", "[1,2,3,5]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().canPartition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:38", "tests_total": 86, "tests_dro...
typescript
{ "raw_signature": "function canPartition(nums: number[]): boolean {", "container": null, "callable": "canPartition", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets...
417
pacific-atlantic-water-flow
Medium
There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. The island is partitioned into a grid of square cells. You are given an m x n integer matrix height...
{ "language": "python", "source": "def check(candidate):\n assert candidate(heights = [[1, 2, 3, 4, 5], [2, 2, 2, 2, 2], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]]) == [(0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 0), (3, 1), (3, 2), (4, 0), ...
[ "[[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]]", "[[1]]" ]
[]
{ "canonical_parameter_names": [ "heights" ], "leetcode_dataset_entry_point": "Solution().pacificAtlantic", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:40", "tests_total": 62, "tes...
typescript
{ "raw_signature": "function pacificAtlantic(heights: number[][]): number[][] {", "container": null, "callable": "pacificAtlantic", "parameters": [ { "name": "heights", "type": "number[][]" } ], "return_type": "number[][]", "signature_source": "leetcode/codeSnippets", "type_source": ...
419
battleships-in-a-board
Medium
You are given an m x n matrix board where each cell is part of a battleship 'X' or empty '.', return the number of the battleships on board. Battleships can only be placed horizontally or vertically on board. In other words, they can only be made of the shape 1 x k (1 row, k columns) or k x 1 (k rows, 1 column), where...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [['X', '.', '.', 'X'], ['.', '.', '.', 'X'], ['.', '.', '.', 'X']]) == 2\n assert candidate(board = [['X', 'X', 'X'], ['.', '.', '.'], ['X', 'X', 'X']]) == 2\n assert candidate(board = [['.']]) == 0\n assert candidate(bo...
[ "[[\"X\",\".\",\".\",\"X\"],[\".\",\".\",\".\",\"X\"],[\".\",\".\",\".\",\"X\"]]", "[[\".\"]]" ]
[]
{ "canonical_parameter_names": [ "board" ], "leetcode_dataset_entry_point": "Solution().countBattleships", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:44", "tests_total": 101, "tes...
typescript
{ "raw_signature": "function countBattleships(board: string[][]): number {", "container": null, "callable": "countBattleships", "parameters": [ { "name": "board", "type": "string[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/...
420
strong-password-checker
Hard
A password is considered strong if the below conditions are all met: - It has at least 6 characters and at most 20 characters. - It contains at least one lowercase letter, at least one uppercase letter, and at least one digit. - It does not contain three repeating characters in a row (i.e., "Baaabb0" is weak, but "Baa...
{ "language": "python", "source": "def check(candidate):\n assert candidate(password = \"AAAbbb\") == 2\n assert candidate(password = \"aA1\") == 3\n assert candidate(password = \"Aa1234567890\") == 0\n assert candidate(password = \"Aaaaaa1A\") == 1\n assert candidate(password = \"Passwo0rd!!\") == 0...
[ "\"a\"", "\"aA1\"", "\"1337C0d3\"" ]
[]
{ "canonical_parameter_names": [ "password" ], "leetcode_dataset_entry_point": "Solution().strongPasswordChecker", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:47", "tests_total": 174...
typescript
{ "raw_signature": "function strongPasswordChecker(password: string): number {", "container": null, "callable": "strongPasswordChecker", "parameters": [ { "name": "password", "type": "string" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "l...
421
maximum-xor-of-two-numbers-in-an-array
Medium
Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. Example 1: Input: nums = [3,10,5,25,2,8] Output: 28 Explanation: The maximum result is 5 XOR 25 = 28. Example 2: Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70] Output: 127 Constraints: - 1 <= nums.length <= ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 10, 5, 25, 2, 8]) == 28\n assert candidate(nums = [14, 70, 53, 83, 49, 91, 36, 80, 92, 51, 66, 70]) == 127\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(nums = [1000000000, 2147483647...
[ "[3,10,5,25,2,8]", "[14,70,53,83,49,91,36,80,92,51,66,70]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findMaximumXOR", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:49", "tests_total": 102, "tests_...
typescript
{ "raw_signature": "function findMaximumXOR(nums: number[]): number {", "container": null, "callable": "findMaximumXOR", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippe...
423
reconstruct-original-digits-from-english
Medium
Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order. Example 1: Input: s = "owoztneoer" Output: "012" Example 2: Input: s = "fviefuro" Output: "45" Constraints: - 1 <= s.length <= 10^5 - s[i] is one of the characters ["e","g","f","i","h","o","n","...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"sevensixfivefourthree\") == \"34567\"\n assert candidate(s = \"fivefivethree\") == \"355\"\n assert candidate(s = \"oneonetwothreefourfivesixseveneightnine\") == \"1123456789\"\n assert candidate(s = \"fivefivesixsix\") ==...
[ "\"owoztneoer\"", "\"fviefuro\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().originalDigits", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:54", "tests_total": 185, "tests_dro...
typescript
{ "raw_signature": "function originalDigits(s: string): string {", "container": null, "callable": "originalDigits", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
424
longest-repeating-character-replacement
Medium
You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times. Return the length of the longest substring containing the same letter you can get after performing the above operations. Example...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"ABABABAB\",k = 3) == 7\n assert candidate(s = \"AAAAAAAAAAAAABBBAABBCCDDEE\",k = 5) == 20\n assert candidate(s = \"AABBCCDD\",k = 2) == 4\n assert candidate(s = \"A\",k = 1) == 1\n assert candidate(s = \"AABAABBBCCCC\",...
[ "\"ABAB\"\n2", "\"AABABBA\"\n1" ]
[]
{ "canonical_parameter_names": [ "s", "k" ], "leetcode_dataset_entry_point": "Solution().characterReplacement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:48:56", "tests_total": 10...
typescript
{ "raw_signature": "function characterReplacement(s: string, k: number): number {", "container": null, "callable": "characterReplacement", "parameters": [ { "name": "s", "type": "string" }, { "name": "k", "type": "number" } ], "return_type": "number", "signature_sou...
433
minimum-genetic-mutation
Medium
A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'. Suppose we need to investigate a mutation from a gene string startGene to a gene string endGene where one mutation is defined as one single character changed in the gene string. - For example, "AACCGGTT" --> "AAC...
{ "language": "python", "source": "def check(candidate):\n assert candidate(startGene = \"AACCGGTT\",endGene = \"AAACGGTA\",bank = ['AACCGGTA', 'AACCGCTA', 'AAACGGTA']) == 2\n assert candidate(startGene = \"AACCGGTT\",endGene = \"AACCGGTA\",bank = ['AACCGGTA']) == 1\n assert candidate(startGene = \"AACCGGT...
[ "\"AACCGGTT\"\n\"AACCGGTA\"\n[\"AACCGGTA\"]", "\"AACCGGTT\"\n\"AAACGGTA\"\n[\"AACCGGTA\",\"AACCGCTA\",\"AAACGGTA\"]" ]
[]
{ "canonical_parameter_names": [ "startGene", "endGene", "bank" ], "leetcode_dataset_entry_point": "Solution().minMutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:01", ...
typescript
{ "raw_signature": "function minMutation(startGene: string, endGene: string, bank: string[]): number {", "container": null, "callable": "minMutation", "parameters": [ { "name": "startGene", "type": "string" }, { "name": "endGene", "type": "string" }, { "name": "...
435
non-overlapping-intervals
Medium
Given an array of intervals intervals where intervals[i] = [start_i, end_i], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note that intervals which only touch at a point are non-overlapping. For example, [1, 2] and [2, 3] are non-overlapping. Example 1: ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [1, 3]]) == 1\n assert candidate(intervals = [[-2, -1], [1, 2], [-1, 1], [2, 3]]) == 0\n assert candidate(intervals = [[1, 5], [2, 3], [4, 6], [7, 8]]) == 1\n assert candidate(intervals = [[1...
[ "[[1,2],[2,3],[3,4],[1,3]]", "[[1,2],[1,2],[1,2]]", "[[1,2],[2,3]]" ]
[]
{ "canonical_parameter_names": [ "intervals" ], "leetcode_dataset_entry_point": "Solution().eraseOverlapIntervals", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:05", "tests_total": 10...
typescript
{ "raw_signature": "function eraseOverlapIntervals(intervals: number[][]): number {", "container": null, "callable": "eraseOverlapIntervals", "parameters": [ { "name": "intervals", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_s...
436
find-right-interval
Medium
You are given an array of intervals, where intervals[i] = [start_i, end_i] and each start_i is unique. The right interval for an interval i is an interval j such that start_j >= end_i and start_j is minimized. Note that i may equal j. Return an array of right interval indices for each interval i. If no right interval...
{ "language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[-1, 1], [0, 2], [1, 3], [2, 4], [3, 5]]) == [2, 3, 4, -1, -1]\n assert candidate(intervals = [[5, 10], [2, 3], [1, 5], [8, 12]]) == [-1, 0, 0, -1]\n assert candidate(intervals = [[10, 20], [20, 30], [5, 15], [30, 40]]...
[ "[[1,2]]", "[[3,4],[2,3],[1,2]]", "[[1,4],[2,3],[3,4]]" ]
[]
{ "canonical_parameter_names": [ "intervals" ], "leetcode_dataset_entry_point": "Solution().findRightInterval", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:08", "tests_total": 113, ...
typescript
{ "raw_signature": "function findRightInterval(intervals: number[][]): number[] {", "container": null, "callable": "findRightInterval", "parameters": [ { "name": "intervals", "type": "number[][]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_sourc...
438
find-all-anagrams-in-a-string
Medium
Given two strings s and p, return an array of all the start indices of p's anagrams in s. You may return the answer in any order. Example 1: Input: s = "cbaebabacd", p = "abc" Output: [0,6] Explanation: The substring with start index = 0 is "cba", which is an anagram of "abc". The substring with start index = 6 is "b...
{ "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 ...
[ "\"cbaebabacd\"\n\"abc\"", "\"abab\"\n\"ab\"" ]
[]
{ "canonical_parameter_names": [ "s", "p" ], "leetcode_dataset_entry_point": "Solution().findAnagrams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:12", "tests_total": 102, "te...
typescript
{ "raw_signature": "function findAnagrams(s: string, p: string): number[] {", "container": null, "callable": "findAnagrams", "parameters": [ { "name": "s", "type": "string" }, { "name": "p", "type": "string" } ], "return_type": "number[]", "signature_source": "leetc...
440
k-th-smallest-in-lexicographical-order
Hard
Given two integers n and k, return the k^th lexicographically smallest integer in the range [1, n]. Example 1: Input: n = 13, k = 2 Output: 10 Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10. Example 2: Input: n = 1, k = 1 Output: 1 Constra...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 13,k = 2) == 10\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 100000,k = 50000) == 54998\n assert candidate(n = 10,k = 10) == 9\n assert candidate(n = 1000000,k = 100000) == 189998\n assert candidate(n = ...
[ "13\n2", "1\n1" ]
[]
{ "canonical_parameter_names": [ "n", "k" ], "leetcode_dataset_entry_point": "Solution().findKthNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:17", "tests_total": 94, "te...
typescript
{ "raw_signature": "function findKthNumber(n: number, k: number): number {", "container": null, "callable": "findKthNumber", "parameters": [ { "name": "n", "type": "number" }, { "name": "k", "type": "number" } ], "return_type": "number", "signature_source": "leetcod...
441
arranging-coins
Easy
You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the i^th row has exactly i coins. The last row of the staircase may be incomplete. Given the integer n, return the number of complete rows of the staircase you will build. Example 1: Input: n = 5 Output: 2 Exp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 100) == 13\n assert candidate(n = 30) == 7\n assert candidate(n = 15) == 5\n assert candidate(n = 22) == 6\n assert candidate(n = 21) == 6\n assert candidate(n = 2147483647) == 65535\n...
[ "5", "8" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().arrangeCoins", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:19", "tests_total": 54, "tests_droppe...
typescript
{ "raw_signature": "function arrangeCoins(n: number): number {", "container": null, "callable": "arrangeCoins", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
442
find-all-duplicates-in-an-array
Medium
Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears at most twice, return an array of all the integers that appears twice. You must write an algorithm that runs in O(n) time and uses only constant auxiliary space, excluding the space needed to store t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2]) == [1]\n assert candidate(nums = [5, 3, 2, 3, 5, 1]) == [3, 5]\n assert candidate(nums = [1]) == []\n assert candidate(nums = [5, 3, 1, 2, 4, 3, 5]) == [3, 5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4,...
[ "[4,3,2,7,8,2,3,1]", "[1,1,2]", "[1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findDuplicates", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:21", "tests_total": 61, "tests_d...
typescript
{ "raw_signature": "function findDuplicates(nums: number[]): number[] {", "container": null, "callable": "findDuplicates", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSn...
446
arithmetic-slices-ii-subsequence
Hard
Given an integer array nums, return the number of all the arithmetic subsequences of nums. A sequence of numbers is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. - For example, [1, 3, 5, 7, 9], [7, 7, 7, 7], and [3, -1, -5, -9] are ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 29\n assert candidate(nums = [1, 2, 3, 8, 9]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9]) == 7\n assert candidate(nums = [1, 2, 3, 4,...
[ "[2,4,6,8,10]", "[7,7,7,7,7]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().numberOfArithmeticSlices", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:31", "tests_total": 164,...
typescript
{ "raw_signature": "function numberOfArithmeticSlices(nums: number[]): number {", "container": null, "callable": "numberOfArithmeticSlices", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": ...
447
number-of-boomerangs
Medium
You are given n points in the plane that are all distinct, where points[i] = [x_i, y_i]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Return the number of boomerangs. Example 1: Input: points = [[0,0],[1,0],[2,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]) == 8\n assert candidate(points = [[1, 0], [0, 0], [0, 1]]) == 2\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(points = [[0, 0], [1, 0], [...
[ "[[0,0],[1,0],[2,0]]", "[[1,1],[2,2],[3,3]]", "[[1,1]]" ]
[]
{ "canonical_parameter_names": [ "points" ], "leetcode_dataset_entry_point": "Solution().numberOfBoomerangs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:33", "tests_total": 105, "...
typescript
{ "raw_signature": "function numberOfBoomerangs(points: number[][]): number {", "container": null, "callable": "numberOfBoomerangs", "parameters": [ { "name": "points", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "lee...
448
find-all-numbers-disappeared-in-an-array
Easy
Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. Example 1: Input: nums = [4,3,2,7,8,2,3,1] Output: [5,6] Example 2: Input: nums = [1,1] Output: [2] Constraints: - n == nums.length - 1 <= n <= 10^5 - 1 <= nu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == []\n assert candidate(nums = [10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == []\n assert candidate(nums = [1, 1]) == [2]\n assert candidate(nums = [4, 3, 2, 7, 8, 2, 3, 1]) == [5, 6]\n assert candidate(nums = [...
[ "[4,3,2,7,8,2,3,1]", "[1,1]" ]
[ "This is a really easy problem if you decide to use additional memory. For those trying to write an initial solution using additional memory, think counters!", "However, the trick really is to not use any additional space than what is already available to use. Sometimes, multiple passes over the input array help ...
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findDisappearedNumbers", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:35", "tests_total": 68, ...
typescript
{ "raw_signature": "function findDisappearedNumbers(nums: number[]): number[] {", "container": null, "callable": "findDisappearedNumbers", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": ...
451
sort-characters-by-frequency
Medium
Given a string s, sort it in decreasing order based on the frequency of the characters. The frequency of a character is the number of times it appears in the string. Return the sorted string. If there are multiple answers, return any of them. Example 1: Input: s = "tree" Output: "eert" Explanation: 'e' appears twice...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aA\") == \"aA\"\n assert candidate(s = \"2a554442f544asf\") == \"4444455522aaffs\"\n assert candidate(s = \"2a554442f544asfasss\") == \"44444ssssaaa55522ff\"\n assert candidate(s = \"zzzzZZZZ\") == \"zzzzZZZZ\"\n assert...
[ "\"tree\"", "\"cccaaa\"", "\"Aabb\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().frequencySort", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:40", "tests_total": 54, "tests_dropp...
typescript
{ "raw_signature": "function frequencySort(s: string): string {", "container": null, "callable": "frequencySort", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
452
minimum-number-of-arrows-to-burst-balloons
Medium
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points[i] = [x_start, x_end] denotes a balloon whose horizontal diameter stretches between x_start and x_end. You do not know the exact y-coordinates of the balloons. A...
{ "language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(points = [[10, 16], [2, 8], [1, 6], [7, 12]]) == 2\n assert candidate(points = [[1, 100], [2, 99], [3, 98]]) == 1\n assert candidate(points = [[3, 9], [7, 12], [...
[ "[[10,16],[2,8],[1,6],[7,12]]", "[[1,2],[3,4],[5,6],[7,8]]", "[[1,2],[2,3],[3,4],[4,5]]" ]
[]
{ "canonical_parameter_names": [ "points" ], "leetcode_dataset_entry_point": "Solution().findMinArrowShots", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:42", "tests_total": 110, "t...
typescript
{ "raw_signature": "function findMinArrowShots(points: number[][]): number {", "container": null, "callable": "findMinArrowShots", "parameters": [ { "name": "points", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetc...
453
minimum-moves-to-equal-array-elements
Medium
Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment n - 1 elements of the array by 1. Example 1: Input: nums = [1,2,3] Output: 3 Explanation: Only three moves are needed (remember each move increments two elements): [1,2,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, -1000000000]) == 2000000000\n assert candidate(nums = [1, 2, 100]) == 100\n assert candidate(nums = [10, 15, 20]) == 15\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, ...
[ "[1,2,3]", "[1,1,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:44", "tests_total": 77, "tests_dropped...
typescript
{ "raw_signature": "function minMoves(nums: number[]): number {", "container": null, "callable": "minMoves", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
454
4sum-ii
Medium
Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that: - 0 <= i, j, k, l < n - nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0 Example 1: Input: nums1 = [1,2], nums2 = [-2,-1], nums3 = [-1,2], nums4 = [0,2] Output: 2 Explanation: The two tuples ar...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3],nums3 = [1, -1, 0],nums4 = [0, 2, -2]) == 13\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3],nums3 = [1, 2, 3],nums4 = [-1, -2, -3]) == 19\n assert candidate(nums1 = [-1, -2, -3],num...
[ "[1,2]\n[-2,-1]\n[-1,2]\n[0,2]", "[0]\n[0]\n[0]\n[0]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2", "nums3", "nums4" ], "leetcode_dataset_entry_point": "Solution().fourSumCount", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:4...
typescript
{ "raw_signature": "function fourSumCount(nums1: number[], nums2: number[], nums3: number[], nums4: number[]): number {", "container": null, "callable": "fourSumCount", "parameters": [ { "name": "nums1", "type": "number[]" }, { "name": "nums2", "type": "number[]" }, {...
455
assign-cookies
Easy
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and each cookie j has a size s[j]. If s[j] >= g[i], we can assign the cookie...
{ "language": "python", "source": "def check(candidate):\n assert candidate(g = [1, 2, 3, 4, 5],s = [5, 4, 3, 2, 1]) == 5\n assert candidate(g = [1, 3, 5],s = [2, 4, 6]) == 3\n assert candidate(g = [3, 3, 3, 3],s = [1, 1, 1, 1]) == 0\n assert candidate(g = [1, 1, 1, 1],s = [1, 1, 1, 1]) == 4\n assert...
[ "[1,2,3]\n[1,1]", "[1,2]\n[1,2,3]" ]
[]
{ "canonical_parameter_names": [ "g", "s" ], "leetcode_dataset_entry_point": "Solution().findContentChildren", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:49", "tests_total": 129...
typescript
{ "raw_signature": "function findContentChildren(g: number[], s: number[]): number {", "container": null, "callable": "findContentChildren", "parameters": [ { "name": "g", "type": "number[]" }, { "name": "s", "type": "number[]" } ], "return_type": "number", "signatu...
456
132-pattern
Medium
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false. Example 1: Input: nums = [1,2,3,4] Output: false Explanation: There is no 132 p...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 3, 2, 0]) == True\n assert candidate(nums = [1, 3, 2, 4, 5]) == True\n assert candidate(nums = [3, 5, 0, 2, 3]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums ...
[ "[1,2,3,4]", "[3,1,4,2]", "[-1,3,2,0]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().find132pattern", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:51", "tests_total": 143, "tests_...
typescript
{ "raw_signature": "function find132pattern(nums: number[]): boolean {", "container": null, "callable": "find132pattern", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnip...
457
circular-array-loop
Medium
You are playing a game involving a circular array of non-zero integers nums. Each nums[i] denotes the number of indices forward/backward you must move if you are located at index i: - If nums[i] is positive, move nums[i] steps forward, and - If nums[i] is negative, move abs(nums[i]) steps backward. Since the array is...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-5, 1, 1, 4, 2]) == True\n assert candidate(nums = [-1, 2, -1, 2, -1]) == False\n assert candidate(nums = [-1, -2, -3, -4, -5, 6]) == False\n assert candidate(nums = [-2, -3, -4, -5, -6]) == False\n assert candidate(n...
[ "[2,-1,1,2,2]", "[-1,-2,-3,-4,-5,6]", "[1,-1,5,1,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().circularArrayLoop", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:53", "tests_total": 116, "tes...
typescript
{ "raw_signature": "function circularArrayLoop(nums: number[]): boolean {", "container": null, "callable": "circularArrayLoop", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/co...
458
poor-pigs
Hard
There are buckets buckets of liquid, where exactly one of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or not. Unfortunately, you only have minutesToTest minutes to determine which bucket is poisonous. You can feed the pigs ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(buckets = 4,minutesToDie = 15,minutesToTest = 15) == 2\n assert candidate(buckets = 1,minutesToDie = 1,minutesToTest = 1) == 0\n assert candidate(buckets = 1000,minutesToDie = 1,minutesToTest = 100) == 2\n assert candidate(bucke...
[ "4\n15\n15", "4\n15\n30" ]
[ "What if you only have one shot? Eg. 4 buckets, 15 mins to die, and 15 mins to test.", "How many states can we generate with x pigs and T tests?", "Find minimum x such that (T+1)^x >= N" ]
{ "canonical_parameter_names": [ "buckets", "minutesToDie", "minutesToTest" ], "leetcode_dataset_entry_point": "Solution().poorPigs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:4...
typescript
{ "raw_signature": "function poorPigs(buckets: number, minutesToDie: number, minutesToTest: number): number {", "container": null, "callable": "poorPigs", "parameters": [ { "name": "buckets", "type": "number" }, { "name": "minutesToDie", "type": "number" }, { "n...
459
repeated-substring-pattern
Easy
Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. Example 1: Input: s = "abab" Output: true Explanation: It is the substring "ab" twice. Example 2: Input: s = "aba" Output: false Example 3: Input: s = "abcabcabcabc" Output: true E...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abac\") == False\n assert candidate(s = \"abcdef\") == False\n assert candidate(s = \"abababab\") == True\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
[ "\"abab\"", "\"aba\"", "\"abcabcabcabc\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().repeatedSubstringPattern", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:49:58", "tests_total": 87, "...
typescript
{ "raw_signature": "function repeatedSubstringPattern(s: string): boolean {", "container": null, "callable": "repeatedSubstringPattern", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
461
hamming-distance
Easy
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, return the Hamming distance between them. Example 1: Input: x = 1, y = 4 Output: 2 Explanation: 1 (0 0 0 1) 4 (0 1 0 0) ↑ ↑ The above arrows point to positions ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 1) == 1\n assert candidate(x = 7,y = 15) == 1\n assert candidate(x = 1073741823,y = 2147483647) == 1\n assert candidate(x = 1023,y = 512) == 9\n assert candidate(x = 2147483647,y = 0) == 31\n assert candidate(x =...
[ "1\n4", "3\n1" ]
[]
{ "canonical_parameter_names": [ "x", "y" ], "leetcode_dataset_entry_point": "Solution().hammingDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:00", "tests_total": 88, "...
typescript
{ "raw_signature": "function hammingDistance(x: number, y: number): number {", "container": null, "callable": "hammingDistance", "parameters": [ { "name": "x", "type": "number" }, { "name": "y", "type": "number" } ], "return_type": "number", "signature_source": "lee...
462
minimum-moves-to-equal-array-elements-ii
Medium
Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or decrement an element of the array by 1. Test cases are designed so that the answer will fit in a 32-bit integer. Example 1: Input: nums = [1,2,3] Output: 2 Explanati...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7,...
[ "[1,2,3]", "[1,10,2,9]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().minMoves2", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:03", "tests_total": 79, "tests_droppe...
typescript
{ "raw_signature": "function minMoves2(nums: number[]): number {", "container": null, "callable": "minMoves2", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
463
island-perimeter
Easy
You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells). The island ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 1, 0, 0, 0], [0, 1, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1]]) == 4\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, ...
[ "[[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]", "[[1]]", "[[1,0]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().islandPerimeter", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:05", "tests_total": 72, "tests_...
typescript
{ "raw_signature": "function islandPerimeter(grid: number[][]): number {", "container": null, "callable": "islandPerimeter", "parameters": [ { "name": "grid", "type": "number[][]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/code...
464
can-i-win
Medium
In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10. The player who first causes the running total to reach or exceed 100 wins. What if we change the game so that players cannot re-use integers? For example, two players might take turns drawing from a common pool of numbers f...
{ "language": "python", "source": "def check(candidate):\n assert candidate(maxChoosableInteger = 15,desiredTotal = 50) == True\n assert candidate(maxChoosableInteger = 10,desiredTotal = 0) == True\n assert candidate(maxChoosableInteger = 10,desiredTotal = 15) == True\n assert candidate(maxChoosableInte...
[ "10\n11", "10\n0", "10\n1" ]
[]
{ "canonical_parameter_names": [ "maxChoosableInteger", "desiredTotal" ], "leetcode_dataset_entry_point": "Solution().canIWin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:07", "...
typescript
{ "raw_signature": "function canIWin(maxChoosableInteger: number, desiredTotal: number): boolean {", "container": null, "callable": "canIWin", "parameters": [ { "name": "maxChoosableInteger", "type": "number" }, { "name": "desiredTotal", "type": "number" } ], "return_...
466
count-the-repetitions
Hard
We define str = [s, n] as the string str which consists of the string s concatenated n times. - For example, str == ["abc", 3] =="abcabcabc". We define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. - For example, s1 = "abc" can be obtained from s2 = "...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"acb\",n1 = 1,s2 = \"acb\",n2 = 1) == 1\n assert candidate(s1 = \"aaa\",n1 = 3,s2 = \"a\",n2 = 1) == 9\n assert candidate(s1 = \"aabaacaabaab\",n1 = 8,s2 = \"aab\",n2 = 1) == 24\n assert candidate(s1 = \"acb\",n1 = 4,s2 = ...
[ "\"acb\"\n4\n\"ab\"\n2", "\"acb\"\n1\n\"acb\"\n1" ]
[]
{ "canonical_parameter_names": [ "s1", "n1", "s2", "n2" ], "leetcode_dataset_entry_point": "Solution().getMaxRepetitions", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:12", ...
typescript
{ "raw_signature": "function getMaxRepetitions(s1: string, n1: number, s2: string, n2: number): number {", "container": null, "callable": "getMaxRepetitions", "parameters": [ { "name": "s1", "type": "string" }, { "name": "n1", "type": "number" }, { "name": "s2",...
467
unique-substrings-in-wraparound-string
Medium
We define the string base to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so base will look like this: - "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Given a string s, return the number of unique non-empty substrings of s are present in base. Example 1: Input: s = "a" Ou...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"qpqprstuvwxyzqpqprstuvwxyzqpqprstuvwxyz\") == 48\n assert candidate(s = \"abczabczabcz\") == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 351\n assert candidate(s = \"azza\") == 3\n assert candidate(s = ...
[ "\"a\"", "\"cac\"", "\"zab\"" ]
[ "One possible solution might be to consider allocating an array size of 26 for each character in the alphabet. (Credits to @r2ysxu)" ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().findSubstringInWraproundString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:14", "tests_total": 6...
typescript
{ "raw_signature": "function findSubstringInWraproundString(s: string): number {", "container": null, "callable": "findSubstringInWraproundString", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source"...
468
validate-ip-address
Medium
Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type. A valid IPv4 address is an IP in the form "x_1.x_2.x_3.x_4" where 0 <= x_i <= 255 and x_i cannot contain leading zeros. For example, "192.168.1.1" and "192.168.1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(queryIP = \"192.168.1.1.1\") == \"Neither\"\n assert candidate(queryIP = \"2001:DB8:85A3:0:0:8A2E:370:7334\") == \"IPv6\"\n assert candidate(queryIP = \"2001:0db8:85a3:0000:0000:8A2E:0370:7334\") == \"IPv6\"\n assert candidate(q...
[ "\"172.16.254.1\"", "\"2001:0db8:85a3:0:0:8A2E:0370:7334\"", "\"256.256.256.256\"" ]
[]
{ "canonical_parameter_names": [ "queryIP" ], "leetcode_dataset_entry_point": "Solution().validIPAddress", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:17", "tests_total": 243, "tes...
typescript
{ "raw_signature": "function validIPAddress(queryIP: string): string {", "container": null, "callable": "validIPAddress", "parameters": [ { "name": "queryIP", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnip...
472
concatenated-words
Hard
Given an array of strings words (without duplicates), return all the concatenated words in the given list of words. A concatenated word is defined as a string that is comprised entirely of at least two shorter words (not necessarily distinct) in the given array. Example 1: Input: words = ["cat","cats","catsdogcats",...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['hello', 'world', 'helloworld', 'worldhello']) == ['helloworld', 'worldhello']\n assert candidate(words = ['apple', 'banana', 'appbanana', 'banapple', 'app', 'ban']) == ['banapple', 'appbanana']\n assert candidate(words = ...
[ "[\"cat\",\"cats\",\"catsdogcats\",\"dog\",\"dogcatsdog\",\"hippopotamuses\",\"rat\",\"ratcatdogcat\"]", "[\"cat\",\"dog\",\"catdog\"]" ]
[]
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().findAllConcatenatedWordsInADict", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:24", "tests_tota...
typescript
{ "raw_signature": "function findAllConcatenatedWordsInADict(words: string[]): string[] {", "container": null, "callable": "findAllConcatenatedWordsInADict", "parameters": [ { "name": "words", "type": "string[]" } ], "return_type": "string[]", "signature_source": "leetcode/codeSnippets...
473
matchsticks-to-square
Medium
You are given an integer array matchsticks where matchsticks[i] is the length of the i^th matchstick. You want to use all the matchsticks to make one square. You should not break any stick, but you can link them up, and each matchstick must be used exactly one time. Return true if you can make this square and false ot...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matchsticks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(matchsticks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(matchsticks = [10, 10, 10, 10]) == True\n assert candidate(m...
[ "[1,1,2,2,2]", "[3,3,3,3,4]" ]
[ "Treat the matchsticks as an array. Can we split the array into 4 equal parts?", "Every matchstick can belong to either of the 4 sides. We don't know which one. Maybe try out all options!", "For every matchstick, we have to try out each of the 4 options i.e. which side it can belong to. We can make use of recur...
{ "canonical_parameter_names": [ "matchsticks" ], "leetcode_dataset_entry_point": "Solution().makesquare", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:26", "tests_total": 85, "test...
typescript
{ "raw_signature": "function makesquare(matchsticks: number[]): boolean {", "container": null, "callable": "makesquare", "parameters": [ { "name": "matchsticks", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/co...
474
ones-and-zeroes
Medium
You are given an array of binary strings strs and two integers m and n. Return the size of the largest subset of strs such that there are at most m 0's and n 1's in the subset. A set x is a subset of a set y if all elements of x are also elements of y. Example 1: Input: strs = ["10","0001","111001","1","0"], m = 5,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(strs = ['0', '0', '1', '1'],m = 2,n = 2) == 4\n assert candidate(strs = ['111', '000', '101010'],m = 3,n = 3) == 2\n assert candidate(strs = ['10', '0', '1'],m = 1,n = 1) == 2\n assert candidate(strs = ['111', '000', '1010', '01...
[ "[\"10\",\"0001\",\"111001\",\"1\",\"0\"]\n5\n3", "[\"10\",\"0\",\"1\"]\n1\n1" ]
[]
{ "canonical_parameter_names": [ "strs", "m", "n" ], "leetcode_dataset_entry_point": "Solution().findMaxForm", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:28", "tests_total":...
typescript
{ "raw_signature": "function findMaxForm(strs: string[], m: number, n: number): number {", "container": null, "callable": "findMaxForm", "parameters": [ { "name": "strs", "type": "string[]" }, { "name": "m", "type": "number" }, { "name": "n", "type": "numb...
475
heaters
Medium
Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every house can be warmed, as long as the house is within the heater's warm radius range. Given the positions of houses and heaters on a horizontal line, return the minimum radius stand...
{ "language": "python", "source": "def check(candidate):\n assert candidate(houses = [1, 5],heaters = [2]) == 3\n assert candidate(houses = [1],heaters = [1]) == 0\n assert candidate(houses = [10, 20, 30, 40, 50],heaters = [15, 45]) == 15\n assert candidate(houses = [10, 20, 30, 40, 50],heaters = [5, 15...
[ "[1,2,3]\n[2]", "[1,2,3,4]\n[1,4]", "[1,5]\n[2]" ]
[]
{ "canonical_parameter_names": [ "houses", "heaters" ], "leetcode_dataset_entry_point": "Solution().findRadius", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:30", "tests_total": 1...
typescript
{ "raw_signature": "function findRadius(houses: number[], heaters: number[]): number {", "container": null, "callable": "findRadius", "parameters": [ { "name": "houses", "type": "number[]" }, { "name": "heaters", "type": "number[]" } ], "return_type": "number", "sig...
476
number-complement
Easy
The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation. - For example, The integer 5 is "101" in binary and its complement is "010" which is the integer 2. Given an integer num, return its complement. Example 1: Input: num = 5 Output:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 31) == 0\n assert candidate(num = 10) == 5\n assert candidate(num = 32) == 31\n assert candidate(num = 5) == 2\n assert candidate(num = 1023) == 0\n assert candidate(num = 1) == 0\n assert candidate(num = 100) == ...
[ "5", "1" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().findComplement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:33", "tests_total": 44, "tests_dr...
typescript
{ "raw_signature": "function findComplement(num: number): number {", "container": null, "callable": "findComplement", "parameters": [ { "name": "num", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
477
total-hamming-distance
Medium
The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums. Example 1: Input: nums = [4,14,2] Output: 6 Explanation: In binary representation, the 4 ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 48\n assert candidate(nums = [4, 14, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 112\n assert candidate(nums = [31, 14, 7, 3, 1]) == 24\n assert candidate(n...
[ "[4,14,2]", "[4,14,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().totalHammingDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:35", "tests_total": 98, "t...
typescript
{ "raw_signature": "function totalHammingDistance(nums: number[]): number {", "container": null, "callable": "totalHammingDistance", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
480
sliding-window-median
Hard
The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle values. - For examples, if arr = [2,3,4], the median is 3. - For examples, if arr = [1,2,3,4], the median is (2 + 3) / 2 = 2.5. You are given an integer arr...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"Decimal answers are accepted within 1e-5 (absolute or relative), as on LeetCode.\"\"\"\n import math\n if isinstance(result, list) and isinstance(expected, list):\n return len(result) == len(expected) and all(answers_mat...
[ "[1,3,-1,-3,5,3,6,7]\n3", "[1,2,3,4,2,3,1,4,2]\n3" ]
[ "The simplest of solutions comes from the basic idea of finding the median given a set of numbers. We know that by definition, a median is the center element (or an average of the two center elements). Given an unsorted list of numbers, how do we find the median element? If you know the answer to this question, can...
{ "canonical_parameter_names": [ "nums", "k" ], "leetcode_dataset_entry_point": "Solution().medianSlidingWindow", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:40", "tests_total": ...
typescript
{ "raw_signature": "function medianSlidingWindow(nums: number[], k: number): number[] {", "container": null, "callable": "medianSlidingWindow", "parameters": [ { "name": "nums", "type": "number[]" }, { "name": "k", "type": "number" } ], "return_type": "number[]", "s...
481
magical-string
Medium
A magical string s consists of only '1' and '2' and obeys the following rule: - Concatenating the sequence of lengths of its consecutive groups of identical characters '1' and '2' generates the string s itself. The first few elements of s is s = "1221121221221121122……". If we group the consecutive 1's and 2's in s, i...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 100000) == 49972\n assert candidate(n = 100) == 49\n assert candidate(n = 15) == 7\n assert candidate(n = 10000) == 4996\n assert candidate(n = 6) == 3\n assert candidate(n = 20) == 10\n assert candidate(n = 1) == 1...
[ "6", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().magicalString", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:42", "tests_total": 41, "tests_dropp...
typescript
{ "raw_signature": "function magicalString(n: number): number {", "container": null, "callable": "magicalString", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
482
license-key-formatting
Easy
You are given a license key represented as a string s that consists of only alphanumeric characters and dashes. The string is separated into n + 1 groups by n dashes. You are also given an integer k. We want to reformat the string s such that each group contains exactly k characters, except for the first group, which ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"AB-CD-EF-GH-IJ\",k = 2) == \"AB-CD-EF-GH-IJ\"\n assert candidate(s = \"abcdefg-hijkl-mnopqr-stuv-wxyz\",k = 5) == \"A-BCDEF-GHIJK-LMNOP-QRSTU-VWXYZ\"\n assert candidate(s = \"1234567890\",k = 3) == \"1-234-567-890\"\n asse...
[ "\"5F3Z-2e-9-w\"\n4", "\"2-5g-3-J\"\n2" ]
[]
{ "canonical_parameter_names": [ "s", "k" ], "leetcode_dataset_entry_point": "Solution().licenseKeyFormatting", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:44", "tests_total": 10...
typescript
{ "raw_signature": "function licenseKeyFormatting(s: string, k: number): string {", "container": null, "callable": "licenseKeyFormatting", "parameters": [ { "name": "s", "type": "string" }, { "name": "k", "type": "number" } ], "return_type": "string", "signature_sou...
483
smallest-good-base
Hard
Given an integer n represented as a string, return the smallest good base of n. We call k >= 2 a good base of n, if all digits of n base k are 1's. Example 1: Input: n = "13" Output: "3" Explanation: 13 base 3 is 111. Example 2: Input: n = "4681" Output: "8" Explanation: 4681 base 8 is 11111. Example 3: Input: n...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = \"4681\") == \"8\"\n assert candidate(n = \"9\") == \"8\"\n assert candidate(n = \"104729\") == \"104728\"\n assert candidate(n = \"15\") == \"2\"\n assert candidate(n = \"218\") == \"217\"\n assert candidate(n = \"13\...
[ "\"13\"", "\"4681\"", "\"1000000000000000000\"" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().smallestGoodBase", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:46", "tests_total": 104, "tests_d...
typescript
{ "raw_signature": "function smallestGoodBase(n: string): string {", "container": null, "callable": "smallestGoodBase", "parameters": [ { "name": "n", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
485
max-consecutive-ones
Easy
Given a binary array nums, return the maximum number of consecutive 1's in the array. Example 1: Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. Example 2: Input: nums = [1,0,1,1,0,1] Output: 2 Constrain...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(nums = [1, 0, 1, 1, 0, 1]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 0...
[ "[1,1,0,1,1,1]", "[1,0,1,1,0,1]" ]
[ "You need to think about two things as far as any window is concerned. One is the starting point for the window. How do you detect that a new window of 1s has started? The next part is detecting the ending point for this window. How do you detect the ending point for an existing window? If you figure these two thin...
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findMaxConsecutiveOnes", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:51", "tests_total": 97, ...
typescript
{ "raw_signature": "function findMaxConsecutiveOnes(nums: number[]): number {", "container": null, "callable": "findMaxConsecutiveOnes", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "lee...
486
predict-the-winner
Medium
You are given an integer array nums. Two players are playing a game with this array: Player 1 and Player 2. Player 1 and Player 2 take turns, with Player 1 starting first. Both players start the game with a score of 0. At each turn, the current player takes the number at either end of the array (i.e., nums[0] or num...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 5, 2]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert can...
[ "[1,5,2]", "[1,5,233,7]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().predictTheWinner", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:50:53", "tests_total": 109, "test...
typescript
{ "raw_signature": "function predictTheWinner(nums: number[]): boolean {", "container": null, "callable": "predictTheWinner", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/code...
491
non-decreasing-subsequences
Medium
Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order. Example 1: Input: nums = [4,6,7,7] Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]] Example 2: Input: nums = [4,4,3,2,1...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[4,6,7,7]", "[4,4,3,2,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findSubsequences", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:03", "tests_total": 103, "test...
typescript
{ "raw_signature": "function findSubsequences(nums: number[]): number[][] {", "container": null, "callable": "findSubsequences", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number[][]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
492
construct-the-rectangle
Easy
A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: 1. The area of the rectangular web page you designed must equal to the given target area. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(area = 81) == [9, 9]\n assert candidate(area = 122122) == [427, 286]\n assert candidate(area = 37) == [37, 1]\n assert candidate(area = 10000000) == [3200, 3125]\n assert candidate(area = 1) == [1, 1]\n assert candidate(ar...
[ "4", "37", "122122" ]
[ "The W is always less than or equal to the square root of the area, so we start searching at sqrt(area) till we find the result." ]
{ "canonical_parameter_names": [ "area" ], "leetcode_dataset_entry_point": "Solution().constructRectangle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:05", "tests_total": 74, "tes...
typescript
{ "raw_signature": "function constructRectangle(area: number): number[] {", "container": null, "callable": "constructRectangle", "parameters": [ { "name": "area", "type": "number" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/co...
493
reverse-pairs
Hard
Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where: - 0 <= i < j < nums.length and - nums[i] > 2 * nums[j]. Example 1: Input: nums = [1,3,2,3,1] Output: 2 Explanation: The reverse pairs are: (1, 4) --> nums[1] = 3, nums[4] = 1, 3 > 2 * 1 (3, 4) --> nu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9]) == 6\n assert candidate(nums = [2147483647, -2147483648, 0, 1, -1]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 5, 3, 4, 2]) == 1\n a...
[ "[1,3,2,3,1]", "[2,4,3,5,1]" ]
[ "Use the merge-sort technique.", "Divide the array into two parts and sort them.", "For each integer in the first part, count the number of integers that satisfy the condition from the second part. Use the pointer to help you in the counting process." ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().reversePairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:08", "tests_total": 126, "tests_dr...
typescript
{ "raw_signature": "function reversePairs(nums: number[]): number {", "container": null, "callable": "reversePairs", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" ...
494
target-sum
Medium
You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers. - For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them to buil...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],target = 60) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],target = 3) == 3\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 32\n assert candidate(nums = [1000],target = 1000) == 1\n assert candid...
[ "[1,1,1,1,1]\n3", "[1]\n1" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().findTargetSumWays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:10", "tests_total...
typescript
{ "raw_signature": "function findTargetSumWays(nums: number[], target: number): number {", "container": null, "callable": "findTargetSumWays", "parameters": [ { "name": "nums", "type": "number[]" }, { "name": "target", "type": "number" } ], "return_type": "number", ...
495
teemo-attacking
Easy
Our hero Teemo is attacking an enemy Ashe with poison attacks! When Teemo attacks Ashe, Ashe gets poisoned for a exactly duration seconds. More formally, an attack at second t will mean Ashe is poisoned during the inclusive time interval [t, t + duration - 1]. If Teemo attacks again before the poison effect ends, the t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(timeSeries = [0, 1, 2, 3, 4, 5],duration = 1) == 6\n assert candidate(timeSeries = [1, 5, 9],duration = 4) == 12\n assert candidate(timeSeries = [1],duration = 5) == 5\n assert candidate(timeSeries = [10, 14, 15],duration = 5) =...
[ "[1,4]\n2", "[1,2]\n2" ]
[]
{ "canonical_parameter_names": [ "timeSeries", "duration" ], "leetcode_dataset_entry_point": "Solution().findPoisonedDuration", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:12", "...
typescript
{ "raw_signature": "function findPoisonedDuration(timeSeries: number[], duration: number): number {", "container": null, "callable": "findPoisonedDuration", "parameters": [ { "name": "timeSeries", "type": "number[]" }, { "name": "duration", "type": "number" } ], "retu...
496
next-greater-element-i
Easy
The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two distinct 0-indexed integer arrays nums1 and nums2, where nums1 is a subset of nums2. For each 0 <= i < nums1.length, find the index j such that nums1[i] == nums2[j] and de...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [2, 3, 5, 6],nums2 = [5, 6, 2, 3, 8, 9]) == [3, 8, 6, 8]\n assert candidate(nums1 = [1, 2],nums2 = [2, 1]) == [-1, -1]\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 3, 2, 1]) == [-1, -1, -1, -1]\n assert candidate(...
[ "[4,1,2]\n[1,3,4,2]", "[2,4]\n[1,2,3,4]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().nextGreaterElement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:15", "tests_tota...
typescript
{ "raw_signature": "function nextGreaterElement(nums1: number[], nums2: number[]): number[] {", "container": null, "callable": "nextGreaterElement", "parameters": [ { "name": "nums1", "type": "number[]" }, { "name": "nums2", "type": "number[]" } ], "return_type": "num...
498
diagonal-traverse
Medium
Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] Example 2: Input: mat = [[1,2],[3,4]] Output: [1,2,3,4] Constraints: - m == mat.length - n == mat[i].length - 1 <= m, n <= 10^4 - 1 <= m * ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 2], [3, 4]]) == [1, 2, 3, 4]\n assert candidate(mat = [[1]]) == [1]\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == [1, 2, 5, 9, 6, 3, 4, 7, 10, 11, 8, 12]\n assert candidate(mat = [[1, 2, 3...
[ "[[1,2,3],[4,5,6],[7,8,9]]", "[[1,2],[3,4]]" ]
[]
{ "canonical_parameter_names": [ "mat" ], "leetcode_dataset_entry_point": "Solution().findDiagonalOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:17", "tests_total": 62, "tests...
typescript
{ "raw_signature": "function findDiagonalOrder(mat: number[][]): number[] {", "container": null, "callable": "findDiagonalOrder", "parameters": [ { "name": "mat", "type": "number[][]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
500
keyboard-row
Easy
Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below. Note that the strings are case-insensitive, both lowercased and uppercased of the same letter are treated as if they are at the same row. In the American keyboar...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['Hello', 'Alaska', 'Dad', 'Peace']) == ['Alaska', 'Dad']\n assert candidate(words = ['qwerty', 'ASDFGH', 'zxcvbN']) == ['qwerty', 'ASDFGH', 'zxcvbN']\n assert candidate(words = ['QwErTy', 'aSdF', 'zXcV']) == ['QwErTy', 'aS...
[ "[\"Hello\",\"Alaska\",\"Dad\",\"Peace\"]", "[\"omk\"]", "[\"adsdf\",\"sfd\"]" ]
[]
{ "canonical_parameter_names": [ "words" ], "leetcode_dataset_entry_point": "Solution().findWords", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:22", "tests_total": 81, "tests_dropp...
typescript
{ "raw_signature": "function findWords(words: string[]): string[] {", "container": null, "callable": "findWords", "parameters": [ { "name": "words", "type": "string[]" } ], "return_type": "string[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" ...
502
ipo
Hard
Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can only finish at most k distinct projects before the IPO. Help LeetCode design the best way ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(k = 1,w = 10,profits = [5, 6],capital = [4, 0]) == 16\n assert candidate(k = 5,w = 10,profits = [5, 4, 3, 2, 1],capital = [1, 2, 3, 4, 5]) == 25\n assert candidate(k = 2,w = 3,profits = [8, 10, 6],capital = [2, 5, 0]) == 21\n as...
[ "2\n0\n[1,2,3]\n[0,1,1]", "3\n0\n[1,2,3]\n[0,1,2]" ]
[]
{ "canonical_parameter_names": [ "k", "w", "profits", "capital" ], "leetcode_dataset_entry_point": "Solution().findMaximizedCapital", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T...
typescript
{ "raw_signature": "function findMaximizedCapital(k: number, w: number, profits: number[], capital: number[]): number {", "container": null, "callable": "findMaximizedCapital", "parameters": [ { "name": "k", "type": "number" }, { "name": "w", "type": "number" }, { ...
503
next-greater-element-ii
Medium
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums. The next greater number of a number x is the first greater number to its traversing-order next in the array, which means you could search circularly to find its ne...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == [-1, 5, 5, 5, 5]\n assert candidate(nums = [1]) == [-1]\n assert candidate(nums = [3, 10, 4, 3, 2, 1, 5]) == [10, -1, 5, 5, 5, 5, 10]\n assert candidate(nums = [10, 5, 7, 3, 6, 2]) == [-1, 7, 10, 6, 10...
[ "[1,2,1]", "[1,2,3,4,3]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().nextGreaterElements", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:29", "tests_total": 122, "t...
typescript
{ "raw_signature": "function nextGreaterElements(nums: number[]): number[] {", "container": null, "callable": "nextGreaterElements", "parameters": [ { "name": "nums", "type": "number[]" } ], "return_type": "number[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetc...
504
base-7
Easy
Given an integer num, return a string of its base 7 representation. Example 1: Input: num = 100 Output: "202" Example 2: Input: num = -7 Output: "-10" Constraints: - -10^7 <= num <= 10^7
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = -1000000) == \"-11333311\"\n assert candidate(num = 49) == \"100\"\n assert candidate(num = 165) == \"324\"\n assert candidate(num = -10000000) == \"-150666343\"\n assert candidate(num = 0) == \"0\"\n assert candidat...
[ "100", "-7" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().convertToBase7", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:31", "tests_total": 47, "tests_dr...
typescript
{ "raw_signature": "function convertToBase7(num: number): string {", "container": null, "callable": "convertToBase7", "parameters": [ { "name": "num", "type": "number" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
506
relative-ranks
Easy
You are given an integer array score of size n, where score[i] is the score of the i^th athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on their scores, where the 1^st place athlete has the highest score, the 2^nd place athlete has the 2^nd highest score, and so on. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(score = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == ['Gold Medal', 'Silver Medal', 'Bronze Medal', '4', '5', '6', '7', '8', '9', '10']\n assert candidate(score = [5, 4, 3, 2, 1]) == ['Gold Medal', 'Silver Medal', 'Bronze Medal', '4'...
[ "[5,4,3,2,1]", "[10,3,8,9,4]" ]
[]
{ "canonical_parameter_names": [ "score" ], "leetcode_dataset_entry_point": "Solution().findRelativeRanks", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:36", "tests_total": 89, "tes...
typescript
{ "raw_signature": "function findRelativeRanks(score: number[]): string[] {", "container": null, "callable": "findRelativeRanks", "parameters": [ { "name": "score", "type": "number[]" } ], "return_type": "string[]", "signature_source": "leetcode/codeSnippets", "type_source": "leetcod...
507
perfect-number
Easy
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly. Given an integer n, return true if n is a perfect number, otherwise return false. Example 1: Input: num = 28 Output: true Explanatio...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 8128) == True\n assert candidate(num = 10) == False\n assert candidate(num = 100000000) == False\n assert candidate(num = 28) == True\n assert candidate(num = 12) == False\n assert candidate(num = 7) == False\n as...
[ "28", "7" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().checkPerfectNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:38", "tests_total": 49, "test...
typescript
{ "raw_signature": "function checkPerfectNumber(num: number): boolean {", "container": null, "callable": "checkPerfectNumber", "parameters": [ { "name": "num", "type": "number" } ], "return_type": "boolean", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSn...
509
fibonacci-number
Easy
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n > 1. Given n, calculate F(n). Example 1: Input: n = 2 Output: 1 Explanation: F...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 2\n assert candidate(n = 30) == 832040\n assert candidate(n = 4) == 3\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 6765\n assert candidate(n = 1) == 1\n assert...
[ "2", "3", "4" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().fib", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:43", "tests_total": 17, "tests_dropped": 0, ...
typescript
{ "raw_signature": "function fib(n: number): number {", "container": null, "callable": "fib", "parameters": [ { "name": "n", "type": "number" } ], "return_type": "number", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
514
freedom-trail
Hard
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to spell a specific keyword to open the door. Given a string ring that represents the code engraved on the outer ring and another string key that represents the keyword that ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ring = \"caotmcaataijjxi\",key = \"oatjiioijjjxxxcx\") == 42\n assert candidate(ring = \"godding\",key = \"gd\") == 4\n assert candidate(ring = \"pqwcx\",key = \"cpqwx\") == 13\n assert candidate(ring = \"edcba\",key = \"abc\") ...
[ "\"godding\"\n\"gd\"", "\"godding\"\n\"godding\"" ]
[]
{ "canonical_parameter_names": [ "ring", "key" ], "leetcode_dataset_entry_point": "Solution().findRotateSteps", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:51:48", "tests_total": 70...
typescript
{ "raw_signature": "function findRotateSteps(ring: string, key: string): number {", "container": null, "callable": "findRotateSteps", "parameters": [ { "name": "ring", "type": "string" }, { "name": "key", "type": "string" } ], "return_type": "number", "signature_sou...