question_id
int64
1
3.24k
task_id
stringlengths
3
77
difficulty
stringclasses
3 values
problem_description
stringlengths
193
3.69k
canonical_tests
dict
public_tests
listlengths
1
5
hints
listlengths
0
8
metadata
dict
language
stringclasses
9 values
interface
dict
1
two-sum
Easy
You are given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], ...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[2,7,11,15]\n9", "[3,2,4]\n6", "[3,3]\n6" ]
[ "A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions just for completeness. It is from these brute force solutions that you can come up with optimizations.", "So, if we fix one of the numbers, say x, we have to...
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().twoSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:26", "tests_total": 80, "t...
cpp
{ "raw_signature": "vector<int> twoSum(vector<int>& nums, int target) {", "container": "Solution", "callable": "twoSum", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "vector<int>", "signature_sourc...
3
longest-substring-without-repeating-characters
Medium
Given a string s, find the length of the longest substring without duplicate characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Note that "bca" and "cab" are also correct answers. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcbb\") == 3\n assert candidate(s = \"bbbbb\") == 1\n assert candidate(s = \"pwwkew\") == 3\n assert candidate(s = \"abcdabcabcabcd\") == 4\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 7\n assert c...
[ "\"abcabcbb\"", "\"bbbbb\"", "\"pwwkew\"" ]
[ "There are less than 100 unique characters. We can check all substrings with length at most 100 for example. This is a good enough approximation." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().lengthOfLongestSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:36", "tests_total": 69, "...
cpp
{ "raw_signature": "int lengthOfLongestSubstring(string s) {", "container": "Solution", "callable": "lengthOfLongestSubstring", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippet...
4
median-of-two-sorted-arrays
Hard
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 = [1,2]...
{ "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]\n[2]", "[1,2]\n[3,4]" ]
[]
{ "canonical_parameter_names": [ "nums1", "nums2" ], "leetcode_dataset_entry_point": "Solution().findMedianSortedArrays", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:38", "tests_...
cpp
{ "raw_signature": "double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {", "container": "Solution", "callable": "findMedianSortedArrays", "parameters": [ { "name": "nums1", "type": "vector<int>&" }, { "name": "nums2", "type": "vector<int>&" } ], "re...
5
longest-palindromic-substring
Medium
Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: - 1 <= s.length <= 1000 - s consist of only digits and English letters.
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abba\") == \"abba\"\n assert candidate(s = \"aaaa\") == \"aaaa\"\n assert candidate(s = \"abacdfgdcaba\") == \"aba\"\n assert candidate(s = \"ac\") == \"a\"\n assert candidate(s = \"babad\") == \"aba\"\n assert candi...
[ "\"babad\"", "\"cbbd\"" ]
[ "How can we reuse a previously computed palindrome to compute a larger palindrome?", "If “aba” is a palindrome, is “xabax” a palindrome? Similarly is “xabay” a palindrome?", "Complexity based hint: If we use brute-force and check whether for every start and end position a substring is a palindrome we have O(n^2...
{ "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:35:41", "tests_total": 124, "tests_...
cpp
{ "raw_signature": "string longestPalindrome(string s) {", "container": "Solution", "callable": "longestPalindrome", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
6
zigzag-conversion
Medium
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversi...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"PAYPALISHIRING\",numRows = 4) == \"PINALSIGYAHRPI\"\n assert candidate(s = \"ABCDEFGHI\",numRows = 3) == \"AEIBDFHCG\"\n assert candidate(s = \"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z\",numRows = 5) == \"AEIMQUY,,...
[ "\"PAYPALISHIRING\"\n3", "\"PAYPALISHIRING\"\n4", "\"A\"\n1" ]
[]
{ "canonical_parameter_names": [ "s", "numRows" ], "leetcode_dataset_entry_point": "Solution().convert", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:43", "tests_total": 104, "t...
cpp
{ "raw_signature": "string convert(string s, int numRows) {", "container": "Solution", "callable": "convert", "parameters": [ { "name": "s", "type": "string" }, { "name": "numRows", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippe...
7
reverse-integer
Medium
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-2^31, 2^31 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input: x = 123 Output: 321 Example 2...
{ "language": "python", "source": "def check(candidate):\n assert candidate(x = -2147483412) == -2143847412\n assert candidate(x = 2147483647) == 0\n assert candidate(x = 120) == 21\n assert candidate(x = -123) == -321\n assert candidate(x = 1534236469) == 0\n assert candidate(x = 0) == 0\n ass...
[ "123", "-123", "120" ]
[]
{ "canonical_parameter_names": [ "x" ], "leetcode_dataset_entry_point": "Solution().reverse", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:45", "tests_total": 61, "tests_dropped": 1...
cpp
{ "raw_signature": "int reverse(int x) {", "container": "Solution", "callable": "reverse", "parameters": [ { "name": "x", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
8
string-to-integer-atoi
Medium
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer. The algorithm for myAtoi(string s) is as follows: 1. Whitespace: Ignore any leading whitespace (" "). 2. Signedness: Determine the sign by checking if the next character is '-' or '+', assuming positivity if neither present. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"2147483647\") == 2147483647\n assert candidate(s = \"42 with words\") == 42\n assert candidate(s = \"20000000000000000000000000000000000000000\") == 2147483647\n assert candidate(s = \"-2147483649\") == -2147483648\n as...
[ "\"42\"", "\" -042\"", "\"1337c0d3\"", "\"0-1\"", "\"words and 987\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().myAtoi", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:47", "tests_total": 185, "tests_dropped": 1...
cpp
{ "raw_signature": "int myAtoi(string s) {", "container": "Solution", "callable": "myAtoi", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
9
palindrome-number
Easy
Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. The...
{ "language": "python", "source": "def check(candidate):\n assert candidate(x = 1221) == True\n assert candidate(x = 10) == False\n assert candidate(x = 123421) == False\n assert candidate(x = 1) == True\n assert candidate(x = -121) == False\n assert candidate(x = 123456) == False\n assert cand...
[ "121", "-121", "10" ]
[ "Beware of overflow when you reverse the integer." ]
{ "canonical_parameter_names": [ "x" ], "leetcode_dataset_entry_point": "Solution().isPalindrome", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:49", "tests_total": 61, "tests_droppe...
cpp
{ "raw_signature": "bool isPalindrome(int x) {", "container": "Solution", "callable": "isPalindrome", "parameters": [ { "name": "x", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
10
regular-expression-matching
Hard
Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: - '.' Matches any single character. - '*' Matches zero or more of the preceding element. Return a boolean indicating whether the matching covers the entire input string (not partial). Example 1: Input:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"aa\",p = \"a*\") == True\n assert candidate(s = \"aab\",p = \"c*a*b\") == True\n assert candidate(s = \"ab\",p = \".*\") == True\n assert candidate(s = \"aa\",p = \"a\") == False\n assert candidate(s = \"mississippi\",p...
[ "\"aa\"\n\"a\"", "\"aa\"\n\"a*\"", "\"ab\"\n\".*\"" ]
[]
{ "canonical_parameter_names": [ "s", "p" ], "leetcode_dataset_entry_point": "Solution().isMatch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:52", "tests_total": 151, "tests_d...
cpp
{ "raw_signature": "bool isMatch(string s, string p) {", "container": "Solution", "callable": "isMatch", "parameters": [ { "name": "s", "type": "string" }, { "name": "p", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "ty...
11
container-with-most-water
Medium
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the i^th line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container...
{ "language": "python", "source": "def check(candidate):\n assert candidate(height = [1, 1]) == 1\n assert candidate(height = [4, 3, 2, 1, 4]) == 16\n assert candidate(height = [8, 10, 14, 0, 13, 10, 9, 9, 8, 9]) == 72\n assert candidate(height = [1, 8, 6, 2, 5, 4, 8, 3, 7]) == 49\n assert candidate(...
[ "[1,8,6,2,5,4,8,3,7]", "[1,1]" ]
[ "If you simulate the problem, it will be O(n^2) which is not efficient.", "Try to use two-pointers. Set one pointer to the left and one to the right of the array. Always move the pointer that points to the lower line.", "How can you calculate the amount of water at each step?" ]
{ "canonical_parameter_names": [ "height" ], "leetcode_dataset_entry_point": "Solution().maxArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:54", "tests_total": 116, "tests_dropp...
cpp
{ "raw_signature": "int maxArea(vector<int>& height) {", "container": "Solution", "callable": "maxArea", "parameters": [ { "name": "height", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
12
integer-to-roman
Medium
Seven different symbols represent Roman numerals with the following values: Symbol | Value I | 1 V | 5 X | 10 L | 50 C | 100 D | 500 M | 1000 Roman numerals are formed by appending the conversions of decimal place values from highest to lowest. Converting a decimal place value into a Roman numeral has the following r...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num = 44) == \"XLIV\"\n assert candidate(num = 9) == \"IX\"\n assert candidate(num = 4) == \"IV\"\n assert candidate(num = 2023) == \"MMXXIII\"\n assert candidate(num = 589) == \"DLXXXIX\"\n assert candidate(num = 444) == ...
[ "3749", "58", "1994" ]
[]
{ "canonical_parameter_names": [ "num" ], "leetcode_dataset_entry_point": "Solution().intToRoman", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:56", "tests_total": 77, "tests_droppe...
cpp
{ "raw_signature": "string intToRoman(int num) {", "container": "Solution", "callable": "intToRoman", "parameters": [ { "name": "num", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
13
roman-to-integer
Easy
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written a...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"XCIX\") == 99\n assert candidate(s = \"MMCMXCIX\") == 2999\n assert candidate(s = \"MMMCMXCIX\") == 3999\n assert candidate(s = \"DCXXI\") == 621\n assert candidate(s = \"XC\") == 90\n assert candidate(s = \"VIII\") ...
[ "\"III\"", "\"LVIII\"", "\"MCMXCIV\"" ]
[ "Problem is simpler to solve by working the string from back to front and using a map." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().romanToInt", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:35:58", "tests_total": 94, "tests_dropped"...
cpp
{ "raw_signature": "int romanToInt(string s) {", "container": "Solution", "callable": "romanToInt", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
14
longest-common-prefix
Easy
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among t...
{ "language": "python", "source": "def check(candidate):\n assert candidate(strs = ['hello', 'helium', 'helper']) == \"hel\"\n assert candidate(strs = ['a']) == \"a\"\n assert candidate(strs = ['', '', '', '']) == \"\"\n assert candidate(strs = ['apple', 'app', 'apricot']) == \"ap\"\n assert candidat...
[ "[\"flower\",\"flow\",\"flight\"]", "[\"dog\",\"racecar\",\"car\"]" ]
[]
{ "canonical_parameter_names": [ "strs" ], "leetcode_dataset_entry_point": "Solution().longestCommonPrefix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:00", "tests_total": 148, "t...
cpp
{ "raw_signature": "string longestCommonPrefix(vector<string>& strs) {", "container": "Solution", "callable": "longestCommonPrefix", "parameters": [ { "name": "strs", "type": "vector<string>&" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "...
15
3sum
Medium
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example 1: Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation: nums[0] + ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-2, 0, 0, 2, 2]) == [[-2, 0, 2]]\n assert candidate(nums = [0, 0, 0]) == [[0, 0, 0]]\n assert candidate(nums = [-1, 0, 1, 2, -1, -4]) == [[-1, -1, 2], [-1, 0, 1]]\n assert candidate(nums = [-2, 0, 1, 1, 2]) == [[-2, 0, 2...
[ "[-1,0,1,2,-1,-4]", "[0,1,1]", "[0,0,0]" ]
[ "So, we essentially need to find three numbers x, y, and z such that they add up to the given value. If we fix one of the numbers say x, we are left with the two-sum problem at hand!", "For the two-sum problem, if we fix one of the numbers, say x, we have to scan the entire array to find the next number y, which ...
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().threeSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:03", "tests_total": 104, "tests_droppe...
cpp
{ "raw_signature": "vector<vector<int>> threeSum(vector<int>& nums) {", "container": "Solution", "callable": "threeSum", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source": "le...
16
3sum-closest
Medium
You are given an integer array nums of length n and an integer target. Find three integers at distinct indices in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Outpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128],target = 82) == 82\n assert candidate(nums = [1, 1, 1, 0],target = -100) == 2\n assert candidate(nums = [-10, -2, -5, -1],target = -12) == -13\n assert candidate(nums = [-5, -4, -3, -2, -1],t...
[ "[-1,2,1,-4]\n1", "[0,0,0]\n1" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().threeSumClosest", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:05", "tests_total":...
cpp
{ "raw_signature": "int threeSumClosest(vector<int>& nums, int target) {", "container": "Solution", "callable": "threeSumClosest", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "int", "signature_sou...
17
letter-combinations-of-a-phone-number
Medium
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Example 1: Input: digits = "23" Ou...
{ "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 ...
[ "\"23\"", "\"2\"" ]
[]
{ "canonical_parameter_names": [ "digits" ], "leetcode_dataset_entry_point": "Solution().letterCombinations", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:07", "tests_total": 79, "t...
cpp
{ "raw_signature": "vector<string> letterCombinations(string digits) {", "container": "Solution", "callable": "letterCombinations", "parameters": [ { "name": "digits", "type": "string" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source": "...
18
4sum
Medium
Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: - 0 <= a, b, c, d < n - a, b, c, and d are distinct. - nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order. Example 1: Input: nums = [1,0,-1,0,-2,2], ta...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[1,0,-1,0,-2,2]\n0", "[2,2,2,2,2]\n8" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().fourSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:09", "tests_total": 90, "...
cpp
{ "raw_signature": "vector<vector<int>> fourSum(vector<int>& nums, int target) {", "container": "Solution", "callable": "fourSum", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "vector<vector<int>>", ...
20
valid-parentheses
Easy
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order. 3. Every close bracket has a corresponding open brac...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"((((((()))))))\") == True\n assert candidate(s = \"{[()]}\") == True\n assert candidate(s = \"[[[[[[{{{{}}}}]]]]]]\") == True\n assert candidate(s = \"({[(])})\") == False\n assert candidate(s = \"([)]\") == False\n ...
[ "\"()\"", "\"()[]{}\"", "\"(]\"", "\"([])\"", "\"([)]\"" ]
[ "Use a stack of characters.", "When you encounter an opening bracket, push it to the top of the stack.", "When you encounter a closing bracket, check if the top of the stack was the opening for it. If yes, pop it from the stack. Otherwise, return false." ]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().isValid", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:13", "tests_total": 148, "tests_dropped": ...
cpp
{ "raw_signature": "bool isValid(string s) {", "container": "Solution", "callable": "isValid", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
28
find-the-index-of-the-first-occurrence-in-a-string
Easy
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "sadbutsad", needle = "sad" Output: 0 Explanation: "sad" occurs at index 0 and 6. The first occurrence is at index 0, so we return 0. Example 2:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(haystack = \"ababcabcabababd\",needle = \"ababd\") == 10\n assert candidate(haystack = \"abcde\",needle = \"f\") == -1\n assert candidate(haystack = \"mississippi\",needle = \"issi\") == 1\n assert candidate(haystack = \"sadbuts...
[ "\"sadbutsad\"\n\"sad\"", "\"leetcode\"\n\"leeto\"" ]
[]
{ "canonical_parameter_names": [ "haystack", "needle" ], "leetcode_dataset_entry_point": "Solution().strStr", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:31", "tests_total": 144,...
cpp
{ "raw_signature": "int strStr(string haystack, string needle) {", "container": "Solution", "callable": "strStr", "parameters": [ { "name": "haystack", "type": "string" }, { "name": "needle", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/...
29
divide-two-integers
Medium
Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. The integer division should truncate toward zero, which means losing its fractional part. For example, 8.345 would be truncated to 8, and -2.7335 would be truncated to -2. Return the quotient after d...
{ "language": "python", "source": "def check(candidate):\n assert candidate(dividend = 10,divisor = 3) == 3\n assert candidate(dividend = -2147483648,divisor = 2) == -1073741824\n assert candidate(dividend = -2147483648,divisor = -1) == 2147483647\n assert candidate(dividend = -1,divisor = -1) == 1\n ...
[ "10\n3", "7\n-3" ]
[]
{ "canonical_parameter_names": [ "dividend", "divisor" ], "leetcode_dataset_entry_point": "Solution().divide", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:33", "tests_total": 135...
cpp
{ "raw_signature": "int divide(int dividend, int divisor) {", "container": "Solution", "callable": "divide", "parameters": [ { "name": "dividend", "type": "int" }, { "name": "divisor", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippe...
30
substring-with-concatenation-of-all-words
Hard
You are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactly contains all the strings of any permutation of words concatenated. - For example, if words = ["ab","cd","ef"], then "abcdef", "abefcd", "cdabef", "cdefab", "efabcd", ...
{ "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 ...
[ "\"barfoothefoobarman\"\n[\"foo\",\"bar\"]", "\"wordgoodgoodgoodbestword\"\n[\"word\",\"good\",\"best\",\"word\"]", "\"barfoofoobarthefoobarman\"\n[\"bar\",\"foo\",\"the\"]" ]
[]
{ "canonical_parameter_names": [ "s", "words" ], "leetcode_dataset_entry_point": "Solution().findSubstring", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:36", "tests_total": 94, ...
cpp
{ "raw_signature": "vector<int> findSubstring(string s, vector<string>& words) {", "container": "Solution", "callable": "findSubstring", "parameters": [ { "name": "s", "type": "string" }, { "name": "words", "type": "vector<string>&" } ], "return_type": "vector<int>", ...
32
longest-valid-parentheses
Hard
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring. Example 1: Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()". Example 2: Input: s = ")()())" Output: 4 Explanation: The longest valid parenthes...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()())\") == 6\n assert candidate(s = \"())\") == 2\n assert candidate(s = \"())(()\") == 2\n assert candidate(s = \"((((((()))))))\") == 14\n assert candidate(s = \"((())()())()\") == 12\n assert candidate(s = \")()...
[ "\"(()\"", "\")()())\"", "\"\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().longestValidParentheses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:40", "tests_total": 133, "...
cpp
{ "raw_signature": "int longestValidParentheses(string s) {", "container": "Solution", "callable": "longestValidParentheses", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"...
33
search-in-rotated-sorted-array
Medium
There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly left rotated at an unknown index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For ex...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3],target = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 9\n assert candidate(nums = [5, 1, 3],target = 1) == 1\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2],target = 3) == -1\n ...
[ "[4,5,6,7,0,1,2]\n0", "[4,5,6,7,0,1,2]\n3", "[1]\n0" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().search", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:42", "tests_total": 131, "...
cpp
{ "raw_signature": "int search(vector<int>& nums, int target) {", "container": "Solution", "callable": "search", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/co...
34
find-first-and-last-position-of-element-in-sorted-array
Medium
Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Exampl...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],target = 1) == [0, 6]\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 4, 4, 4, 4],target = 2) == [0, 3]\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5) == [4, 4]\n assert candidate(nums = [5, 7, 7...
[ "[5,7,7,8,8,10]\n8", "[5,7,7,8,8,10]\n6", "[]\n0" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().searchRange", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:44", "tests_total": 137...
cpp
{ "raw_signature": "vector<int> searchRange(vector<int>& nums, int target) {", "container": "Solution", "callable": "searchRange", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "vector<int>", "signa...
35
search-insert-position
Easy
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 Example 2: Input: nu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-10, 0, 5, 10],target = 0) == 1\n assert candidate(nums = [1, 2, 4, 6, 7, 9],target = 3) == 2\n assert candidate(nums = [1, 3, 5],target = 4) == 2\n assert candidate(nums = [1, 3, 5, 6],target = 2) == 1\n assert candi...
[ "[1,3,5,6]\n5", "[1,3,5,6]\n2", "[1,3,5,6]\n7" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().searchInsert", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:47", "tests_total": 11...
cpp
{ "raw_signature": "int searchInsert(vector<int>& nums, int target) {", "container": "Solution", "callable": "searchInsert", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "int", "signature_source": ...
36
valid-sudoku
Medium
Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: 1. Each row must contain the digits 1-9 without repetition. 2. Each column must contain the digits 1-9 without repetition. 3. Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [['8', '3', '.', '.', '7', '.', '.', '.', '.'], ['6', '.', '.', '1', '9', '5', '.', '.', '.'], ['.', '9', '8', '.', '.', '.', '.', '6', '.'], ['8', '.', '.', '.', '6', '.', '.', '.', '3'], ['4', '.', '.', '8', '.', '3', '.', '.',...
[ "[[\"5\",\"3\",\".\",\".\",\"7\",\".\",\".\",\".\",\".\"],[\"6\",\".\",\".\",\"1\",\"9\",\"5\",\".\",\".\",\".\"],[\".\",\"9\",\"8\",\".\",\".\",\".\",\".\",\"6\",\".\"],[\"8\",\".\",\".\",\".\",\"6\",\".\",\".\",\".\",\"3\"],[\"4\",\".\",\".\",\"8\",\".\",\"3\",\".\",\".\",\"1\"],[\"7\",\".\",\".\",\".\",\"2\",\"....
[]
{ "canonical_parameter_names": [ "board" ], "leetcode_dataset_entry_point": "Solution().isValidSudoku", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:49", "tests_total": 19, "tests_d...
cpp
{ "raw_signature": "bool isValidSudoku(vector<vector<char>>& board) {", "container": "Solution", "callable": "isValidSudoku", "parameters": [ { "name": "board", "type": "vector<vector<char>>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "le...
38
count-and-say
Medium
The count-and-say sequence is a sequence of digit strings defined by the recursive formula: - countAndSay(1) = "1" - countAndSay(n) is the run-length encoding of countAndSay(n - 1). Run-length encoding (RLE) is a string compression method that works by replacing each maximal group of consecutive identical characters ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == \"1113213211\"\n assert candidate(n = 3) == \"21\"\n assert candidate(n = 30) == \"311311222113111231133211121312211231131112311211133112111312211213211312111322211231131122111213122112311311222112111331121113112221121113...
[ "1", "4" ]
[ "Create a helper function that maps an integer to pairs of its digits and their frequencies. For example, if you call this function with \"223314444411\", then it maps it to an array of pairs [[2,2], [3,2], [1,1], [4,5], [1, 2]].", "Create another helper function that takes the array of pairs and creates a new in...
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().countAndSay", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:53", "tests_total": 28, "tests_dropped...
cpp
{ "raw_signature": "string countAndSay(int n) {", "container": "Solution", "callable": "countAndSay", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
39
combination-sum
Medium
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are uniqu...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[2,3,6,7]\n7", "[2,3,5]\n8", "[2]\n1" ]
[]
{ "canonical_parameter_names": [ "candidates", "target" ], "leetcode_dataset_entry_point": "Solution().combinationSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:55", "tests_to...
cpp
{ "raw_signature": "vector<vector<int>> combinationSum(vector<int>& candidates, int target) {", "container": "Solution", "callable": "combinationSum", "parameters": [ { "name": "candidates", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type...
40
combination-sum-ii
Medium
Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used once in the combination. Note: The solution set must not contain duplicate combinations. Example 1: Inpu...
{ "language": "python", "source": "def check(candidate):\n assert candidate(candidates = [1, 1, 1, 1, 1],target = 3) == [[1, 1, 1]]\n assert candidate(candidates = [2, 5, 2, 1, 2],target = 5) == [[1, 2, 2], [5]]\n assert candidate(candidates = [4, 4, 2, 1, 4, 2, 2, 1, 3],target = 6) == [[1, 1, 2, 2], [1, 1...
[ "[10,1,2,7,6,1,5]\n8", "[2,5,2,1,2]\n5" ]
[]
{ "canonical_parameter_names": [ "candidates", "target" ], "leetcode_dataset_entry_point": "Solution().combinationSum2", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:36:58", "tests_t...
cpp
{ "raw_signature": "vector<vector<int>> combinationSum2(vector<int>& candidates, int target) {", "container": "Solution", "callable": "combinationSum2", "parameters": [ { "name": "candidates", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_ty...
41
first-missing-positive
Hard
Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space. Example 1: Input: nums = [1,2,0] Output: 3 Explanation: The numbers in the range [1,2] are all in the array. Example 2: Input...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000, -1000000, 500000]) == 1\n assert candidate(nums = [1000000, -1000000, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 2, 2]) == 3\n assert candidate(nums = [2147483647, ...
[ "[1,2,0]", "[3,4,-1,1]", "[7,8,9,11,12]" ]
[ "Think about how you would solve the problem in non-constant space. Can you apply that logic to the existing space?", "We don't care about duplicates or non-positive integers", "Remember that O(2n) = O(n)" ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().firstMissingPositive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:00", "tests_total": 126, "...
cpp
{ "raw_signature": "int firstMissingPositive(vector<int>& nums) {", "container": "Solution", "callable": "firstMissingPositive", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/c...
42
trapping-rain-water
Hard
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this...
{ "language": "python", "source": "def check(candidate):\n assert candidate(height = [3, 1, 2, 1, 4, 3, 2, 1, 5]) == 11\n assert candidate(height = [3, 0, 1, 3, 0, 1, 3]) == 10\n assert candidate(height = [5, 4, 3, 2, 1]) == 0\n assert candidate(height = [1]) == 0\n assert candidate(height = [2, 0, 2...
[ "[0,1,0,2,1,0,1,3,2,1,2,1]", "[4,2,0,3,2,5]" ]
[]
{ "canonical_parameter_names": [ "height" ], "leetcode_dataset_entry_point": "Solution().trap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:02", "tests_total": 128, "tests_dropped"...
cpp
{ "raw_signature": "int trap(vector<int>& height) {", "container": "Solution", "callable": "trap", "parameters": [ { "name": "height", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
43
multiply-strings
Medium
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2: Input: num1 = "1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(num1 = \"999999999999999999\",num2 = \"888888888888888888\") == \"888888888888888887111111111111111112\"\n assert candidate(num1 = \"0\",num2 = \"12345\") == \"0\"\n assert candidate(num1 = \"2\",num2 = \"3\") == \"6\"\n assert ...
[ "\"2\"\n\"3\"", "\"123\"\n\"456\"" ]
[]
{ "canonical_parameter_names": [ "num1", "num2" ], "leetcode_dataset_entry_point": "Solution().multiply", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:04", "tests_total": 71, "t...
cpp
{ "raw_signature": "string multiply(string num1, string num2) {", "container": "Solution", "callable": "multiply", "parameters": [ { "name": "num1", "type": "string" }, { "name": "num2", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/co...
44
wildcard-matching
Hard
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: - '?' Matches any single character. - '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). Example 1: Input: s = "aa...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcde\",p = \"ab*e\") == True\n assert candidate(s = \"abcde\",p = \"*\") == True\n assert candidate(s = \"mississippi\",p = \"m??*ss*?i*pi\") == False\n assert candidate(s = \"aa\",p = \"a\") == False\n assert candidat...
[ "\"aa\"\n\"a\"", "\"aa\"\n\"*\"", "\"cb\"\n\"?a\"" ]
[]
{ "canonical_parameter_names": [ "s", "p" ], "leetcode_dataset_entry_point": "Solution().isMatch", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:06", "tests_total": 209, "tests_d...
cpp
{ "raw_signature": "bool isMatch(string s, string p) {", "container": "Solution", "callable": "isMatch", "parameters": [ { "name": "s", "type": "string" }, { "name": "p", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "ty...
45
jump-game-ii
Medium
You are given a 0-indexed array of integers nums of length n. You are initially positioned at index 0. Each element nums[i] represents the maximum length of a forward jump from index i. In other words, if you are at index i, you can jump to any index (i + j) where: - 0 <= j <= nums[i] and - i + j < n Return the mini...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 4, 4, 6, 9, 4, 4, 7, 4, 4, 8, 2, 6, 8, 1, 5, 9, 6, 5, 2, 7, 9, 7, 9, 6, 9, 4, 1, 6, 8, 8, 4, 4, 2, 0, 7, 1, 3, 8, 0, 1, 2, 1, 2, 4, 3, 2, 0, 7, 1, 2, 7, 0, 6, 8, 0, 6, 5, 9, 9, 7, 4, 6, 6, 5, 8, 9, 3, 4, 3, 7, 0, 4, 9, 0, 9...
[ "[2,3,1,1,4]", "[2,3,0,1,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().jump", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:09", "tests_total": 44, "tests_dropped": 0...
cpp
{ "raw_signature": "int jump(vector<int>& nums) {", "container": "Solution", "callable": "jump", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
46
permutations
Medium
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2: Input: nums = [0,1] Output: [[0,1],[1,0]] Example 3: Input: nums = [1] Output: [[1]] Constr...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[1,2,3]", "[0,1]", "[1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().permute", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:11", "tests_total": 60, "tests_dropped"...
cpp
{ "raw_signature": "vector<vector<int>> permute(vector<int>& nums) {", "container": "Solution", "callable": "permute", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
47
permutations-ii
Medium
Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. Example 1: Input: nums = [1,1,2] Output: [[1,1,2], [1,2,1], [2,1,1]] Example 2: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Constraints: - 1 <= nums.lengt...
{ "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,2]", "[1,2,3]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().permuteUnique", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:13", "tests_total": 73, "tests_dr...
cpp
{ "raw_signature": "vector<vector<int>> permuteUnique(vector<int>& nums) {", "container": "Solution", "callable": "permuteUnique", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_so...
49
group-anagrams
Medium
Given an array of strings strs, group the anagrams together. You can return the answer in any order. Example 1: Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["bat"],["nat","tan"],["ate","eat","tea"]] Explanation: - There is no string in strs that can be rearranged to form "bat". - The strings "nat" an...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The groups, and the items inside each group, may come in any order.\"\"\"\n def canonical(groups):\n return sorted((sorted(g, key=repr) if isinstance(g, list) else g for g in groups), key=repr)\n if isinstance(result, li...
[ "[\"eat\",\"tea\",\"tan\",\"ate\",\"nat\",\"bat\"]", "[\"\"]", "[\"a\"]" ]
[]
{ "canonical_parameter_names": [ "strs" ], "leetcode_dataset_entry_point": "Solution().groupAnagrams", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:18", "tests_total": 69, "tests_dr...
cpp
{ "raw_signature": "vector<vector<string>> groupAnagrams(vector<string>& strs) {", "container": "Solution", "callable": "groupAnagrams", "parameters": [ { "name": "strs", "type": "vector<string>&" } ], "return_type": "vector<vector<string>>", "signature_source": "leetcode/codeSnippets"...
50
powx-n
Medium
Implement pow(x, n), which calculates x raised to the power n (i.e., x^n). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2^-2 = 1/2^2 = 1/4 = 0.25 Constraints: - -100.0 < x < 100.0 ...
{ "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...
[ "2.00000\n10", "2.10000\n3", "2.00000\n-2" ]
[]
{ "canonical_parameter_names": [ "x", "n" ], "leetcode_dataset_entry_point": "Solution().myPow", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:20", "tests_total": 83, "tests_drop...
cpp
{ "raw_signature": "double myPow(double x, int n) {", "container": "Solution", "callable": "myPow", "parameters": [ { "name": "x", "type": "double" }, { "name": "n", "type": "int" } ], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_sou...
53
maximum-subarray
Medium
Given an integer array nums, find the subarray with the largest sum, and return its sum. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. Example 2: Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum 1. Example 3: Inp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4, 7]) == 12\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [100, -1, 50, -1, 100]) == ...
[ "[-2,1,-3,4,-1,2,1,-5,4]", "[1]", "[5,4,-1,7,8]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().maxSubArray", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:26", "tests_total": 98, "tests_drop...
cpp
{ "raw_signature": "int maxSubArray(vector<int>& nums) {", "container": "Solution", "callable": "maxSubArray", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
54
spiral-matrix
Medium
Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] Output: [1,2,3,4,8,12,11,10,9,5,6,7] Constraints: - m == matrix.length - n == matrix[i].length - ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [1, 2, 3, 4, 5]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(matrix = [[7], [9], [3]]) == [7, 9, 3]\n assert candidat...
[ "[[1,2,3],[4,5,6],[7,8,9]]", "[[1,2,3,4],[5,6,7,8],[9,10,11,12]]" ]
[ "Well for some problems, the best way really is to come up with some algorithms for simulation. Basically, you need to simulate what the problem asks us to do.", "We go boundary by boundary and move inwards. That is the essential operation. First row, last column, last row, first column, and then we move inwards ...
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().spiralOrder", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:29", "tests_total": 53, "tests_dr...
cpp
{ "raw_signature": "vector<int> spiralOrder(vector<vector<int>>& matrix) {", "container": "Solution", "callable": "spiralOrder", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_so...
55
jump-game
Medium
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. Example 1: Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 5, 0, 0]) == True\n assert candidate(nums = [1, 1, 1, 1, 1]) == True\n assert candidate(nums = [0]) == True\n assert candidate(nums = [5, 0, 0, 0, 0...
[ "[2,3,1,1,4]", "[3,2,1,0,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().canJump", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:31", "tests_total": 66, "tests_dropped"...
cpp
{ "raw_signature": "bool canJump(vector<int>& nums) {", "container": "Solution", "callable": "canJump", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
56
merge-intervals
Medium
Given an array of intervals where intervals[i] = [start_i, end_i], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,...
{ "language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [[1, 5]]\n assert candidate(intervals = [[1, 2], [3, 5], [6, 7], [8, 10], [12, 16], [4, 9]]) == [[1, 2], [3, 10], [12, 16]]\n assert candidate(intervals = [[1, 3], [2, 6], [8, 10], [...
[ "[[1,3],[2,6],[8,10],[15,18]]", "[[1,4],[4,5]]", "[[4,7],[1,4]]" ]
[]
{ "canonical_parameter_names": [ "intervals" ], "leetcode_dataset_entry_point": "Solution().merge", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:33", "tests_total": 91, "tests_dropp...
cpp
{ "raw_signature": "vector<vector<int>> merge(vector<vector<int>>& intervals) {", "container": "Solution", "callable": "merge", "parameters": [ { "name": "intervals", "type": "vector<vector<int>>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", ...
57
insert-interval
Medium
You are given an array of non-overlapping intervals intervals where intervals[i] = [start_i, end_i] represent the start and the end of the i^th interval and intervals is sorted in ascending order by start_i. You are also given an interval newInterval = [start, end] that represents the start and end of another interval....
{ "language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 5]],newInterval = [2, 3]) == [[1, 5]]\n assert candidate(intervals = [[1, 5]],newInterval = [0, 3]) == [[0, 5]]\n assert candidate(intervals = [[1, 2], [3, 10], [12, 16]],newInterval = [10, 11]) == [[1, 2], [3, 11]...
[ "[[1,3],[6,9]]\n[2,5]", "[[1,2],[3,5],[6,7],[8,10],[12,16]]\n[4,8]" ]
[ "Intervals Array is sorted. Can you use Binary Search to find the correct position to insert the new Interval.?", "Can you try merging the overlapping intervals while inserting the new interval?", "This can be done by comparing the end of the last interval with the start of the new interval and vice versa." ]
{ "canonical_parameter_names": [ "intervals", "newInterval" ], "leetcode_dataset_entry_point": "Solution().insert", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:35", "tests_total"...
cpp
{ "raw_signature": "vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {", "container": "Solution", "callable": "insert", "parameters": [ { "name": "intervals", "type": "vector<vector<int>>&" }, { "name": "newInterval", "type": "vector<int>&"...
59
spiral-matrix-ii
Medium
Given a positive integer n, generate an n x n matrix filled with elements from 1 to n^2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Output: [[1]] Constraints: - 1 <= n <= 20
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [[1, 2, 3], [8, 9, 4], [7, 6, 5]]\n assert candidate(n = 15) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 16], [55, 104, 105, 106, 107, 108, 109, 110, 111,...
[ "3", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().generateMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:40", "tests_total": 20, "tests_drop...
cpp
{ "raw_signature": "vector<vector<int>> generateMatrix(int n) {", "container": "Solution", "callable": "generateMatrix", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
60
permutation-sequence
Hard
The set [1, 2, 3, ..., n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following sequence for n = 3: 1. "123" 2. "132" 3. "213" 4. "231" 5. "312" 6. "321" Given n and k, return the k^th permutation sequence. Example 1: Input: n = 3, k = 3 Output: ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == \"123\"\n assert candidate(n = 8,k = 40320) == \"87654321\"\n assert candidate(n = 4,k = 9) == \"2314\"\n assert candidate(n = 9,k = 362880) == \"987654321\"\n assert candidate(n = 5,k = 10) == \"13452\"\n ...
[ "3\n3", "4\n9", "3\n1" ]
[]
{ "canonical_parameter_names": [ "n", "k" ], "leetcode_dataset_entry_point": "Solution().getPermutation", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:42", "tests_total": 58, "t...
cpp
{ "raw_signature": "string getPermutation(int n, int k) {", "container": "Solution", "callable": "getPermutation", "parameters": [ { "name": "n", "type": "int" }, { "name": "k", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets",...
62
unique-paths
Medium
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return the number of possible un...
{ "language": "python", "source": "def check(candidate):\n assert candidate(m = 1,n = 100) == 1\n assert candidate(m = 3,n = 7) == 28\n assert candidate(m = 5,n = 5) == 70\n assert candidate(m = 10,n = 10) == 48620\n assert candidate(m = 5,n = 3) == 15\n assert candidate(m = 1,n = 1) == 1\n ass...
[ "3\n7", "3\n2" ]
[]
{ "canonical_parameter_names": [ "m", "n" ], "leetcode_dataset_entry_point": "Solution().uniquePaths", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:47", "tests_total": 55, "test...
cpp
{ "raw_signature": "int uniquePaths(int m, int n) {", "container": "Solution", "callable": "uniquePaths", "parameters": [ { "name": "m", "type": "int" }, { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_sou...
63
unique-paths-ii
Medium
You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respectiv...
{ "language": "python", "source": "def check(candidate):\n assert candidate(obstacleGrid = [[1, 0], [0, 0]]) == 0\n assert candidate(obstacleGrid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 17\n assert candidate(obstacleGrid = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0], [0, 1,...
[ "[[0,0,0],[0,1,0],[0,0,0]]", "[[0,1],[0,0]]" ]
[ "Use dynamic programming since, from each cell, you can move to the right or down.", "assume dp[i][j] is the number of unique paths to reach (i, j). dp[i][j] = dp[i][j -1] + dp[i - 1][j]. Be careful when you encounter an obstacle. set its value in dp to 0." ]
{ "canonical_parameter_names": [ "obstacleGrid" ], "leetcode_dataset_entry_point": "Solution().uniquePathsWithObstacles", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:49", "tests_tota...
cpp
{ "raw_signature": "int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {", "container": "Solution", "callable": "uniquePathsWithObstacles", "parameters": [ { "name": "obstacleGrid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/cod...
64
minimum-path-sum
Medium
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time. Example 1: Input: grid = [[1,3,1],[1,5,1],[4,2,1]] Output: 7 Explanation: Because the path 1 → 3 → ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == 12\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 60\n assert candidate(grid = [[10, 15, 20], [25, 30, 35], [40, 45, 50]]) == 130\n ...
[ "[[1,3,1],[1,5,1],[4,2,1]]", "[[1,2,3],[4,5,6]]" ]
[]
{ "canonical_parameter_names": [ "grid" ], "leetcode_dataset_entry_point": "Solution().minPathSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:51", "tests_total": 77, "tests_dropp...
cpp
{ "raw_signature": "int minPathSum(vector<vector<int>>& grid) {", "container": "Solution", "callable": "minPathSum", "parameters": [ { "name": "grid", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
65
valid-number
Hard
Given a string s, return whether s is a valid number. For example, all the following are valid numbers: "2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789", while the following are not valid numbers: "abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53". Formall...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"0089\") == True\n assert candidate(s = \"-123.456e789\") == True\n assert candidate(s = \"95a54e53\") == False\n assert candidate(s = \"e3\") == False\n assert candidate(s = \"4.\") == True\n assert candidate(s = \"2...
[ "\"0\"", "\"e\"", "\".\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().isNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:54", "tests_total": 306, "tests_dropped":...
cpp
{ "raw_signature": "bool isNumber(string s) {", "container": "Solution", "callable": "isNumber", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
66
plus-one
Easy
You are given a large integer represented as an integer array digits, where each digits[i] is the i^th digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the re...
{ "language": "python", "source": "def check(candidate):\n assert candidate(digits = [5, 8, 9, 9, 9]) == [5, 9, 0, 0, 0]\n assert candidate(digits = [2, 0, 0, 0, 0]) == [2, 0, 0, 0, 1]\n assert candidate(digits = [1, 0, 0, 0]) == [1, 0, 0, 1]\n assert candidate(digits = [1, 9, 9, 9, 9, 9, 9, 9, 9, 9]) =...
[ "[1,2,3]", "[4,3,2,1]", "[9]" ]
[]
{ "canonical_parameter_names": [ "digits" ], "leetcode_dataset_entry_point": "Solution().plusOne", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:56", "tests_total": 77, "tests_droppe...
cpp
{ "raw_signature": "vector<int> plusOne(vector<int>& digits) {", "container": "Solution", "callable": "plusOne", "parameters": [ { "name": "digits", "type": "vector<int>&" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSni...
67
add-binary
Easy
Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010", b = "1011" Output: "10101" Constraints: - 1 <= a.length, b.length <= 10^4 - a and b consist only of '0' or '1' characters. - Each string does not contain leading z...
{ "language": "python", "source": "def check(candidate):\n assert candidate(a = \"11\",b = \"1\") == \"100\"\n assert candidate(a = \"1101001\",b = \"1000111\") == \"10110000\"\n assert candidate(a = \"1101\",b = \"1001\") == \"10110\"\n assert candidate(a = \"1000000000000000000000000000000\",b = \"1\"...
[ "\"11\"\n\"1\"", "\"1010\"\n\"1011\"" ]
[]
{ "canonical_parameter_names": [ "a", "b" ], "leetcode_dataset_entry_point": "Solution().addBinary", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:37:58", "tests_total": 86, "tests_...
cpp
{ "raw_signature": "string addBinary(string a, string b) {", "container": "Solution", "callable": "addBinary", "parameters": [ { "name": "a", "type": "string" }, { "name": "b", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets...
68
text-justification
Hard
Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(words = ['Try', 'your', 'best', 'to', 'be', 'like', 'them', 'at', 'best', 'you', 'can', 'be', 'like', 'them.'],maxWidth = 20) == ['Try your best to be', 'like them at best', 'you can be like', 'them. ']\n assert...
[ "[\"This\", \"is\", \"an\", \"example\", \"of\", \"text\", \"justification.\"]\n16", "[\"What\",\"must\",\"be\",\"acknowledgment\",\"shall\",\"be\"]\n16", "[\"Science\",\"is\",\"what\",\"we\",\"understand\",\"well\",\"enough\",\"to\",\"explain\",\"to\",\"a\",\"computer.\",\"Art\",\"is\",\"everything\",\"else\",...
[]
{ "canonical_parameter_names": [ "words", "maxWidth" ], "leetcode_dataset_entry_point": "Solution().fullJustify", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:00", "tests_total": ...
cpp
{ "raw_signature": "vector<string> fullJustify(vector<string>& words, int maxWidth) {", "container": "Solution", "callable": "fullJustify", "parameters": [ { "name": "words", "type": "vector<string>&" }, { "name": "maxWidth", "type": "int" } ], "return_type": "vector<...
69
sqrtx
Easy
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. You must not use any built-in exponent function or operator. - For example, do not use pow(x, 0.5) in c++ or x ** 0.5 in python. Example 1: Input: x = 4 Output: 2 Exp...
{ "language": "python", "source": "def check(candidate):\n assert candidate(x = 2147483647) == 46340\n assert candidate(x = 26) == 5\n assert candidate(x = 4) == 2\n assert candidate(x = 1) == 1\n assert candidate(x = 25) == 5\n assert candidate(x = 0) == 0\n assert candidate(x = 101) == 10\n ...
[ "4", "8" ]
[ "Try exploring all integers. (Credits: @annujoshi)", "Use the sorted property of integers to reduced the search space. (Credits: @annujoshi)" ]
{ "canonical_parameter_names": [ "x" ], "leetcode_dataset_entry_point": "Solution().mySqrt", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:02", "tests_total": 67, "tests_dropped": 11...
cpp
{ "raw_signature": "int mySqrt(int x) {", "container": "Solution", "callable": "mySqrt", "parameters": [ { "name": "x", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
70
climbing-stairs
Easy
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Ex...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 45) == 1836311903\n assert candidate(n = 4) == 5\n assert candidate(n = 20) == 10946\n assert candidate(n = 2) == 2\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 89\n ...
[ "2", "3" ]
[ "To reach nth step, what could have been your previous steps? (Think about the step sizes)" ]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().climbStairs", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:05", "tests_total": 16, "tests_dropped...
cpp
{ "raw_signature": "int climbStairs(int n) {", "container": "Solution", "callable": "climbStairs", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
71
simplify-path
Medium
You are given an absolute path for a Unix-style file system, which always begins with a slash '/'. Your task is to transform this absolute path into its simplified canonical path. The rules of a Unix-style file system are as follows: - A single period '.' represents the current directory. - A double period '..' repre...
{ "language": "python", "source": "def check(candidate):\n assert candidate(path = \"/.../a/../b/c/../d/./\") == \"/.../b/d\"\n assert candidate(path = \"/a/../../b/../c///.//\") == \"/c\"\n assert candidate(path = \"/a/b/c/d/e/f/g/../../..\") == \"/a/b/c/d\"\n assert candidate(path = \"/a/b/c/d/e/../.....
[ "\"/home/\"", "\"/home//foo/\"", "\"/home/user/Documents/../Pictures\"", "\"/../\"", "\"/.../a/../b/c/../d/./\"" ]
[]
{ "canonical_parameter_names": [ "path" ], "leetcode_dataset_entry_point": "Solution().simplifyPath", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:07", "tests_total": 198, "tests_dr...
cpp
{ "raw_signature": "string simplifyPath(string path) {", "container": "Solution", "callable": "simplifyPath", "parameters": [ { "name": "path", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
72
edit-distance
Medium
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: - Insert a character - Delete a character - Replace a character Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse ->...
{ "language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"park\",word2 = \"spake\") == 3\n assert candidate(word1 = \"algorithm\",word2 = \"altruistic\") == 6\n assert candidate(word1 = \"abc\",word2 = \"\") == 3\n assert candidate(word1 = \"horse\",word2 = \"ros\") == 3\n ...
[ "\"horse\"\n\"ros\"", "\"intention\"\n\"execution\"" ]
[]
{ "canonical_parameter_names": [ "word1", "word2" ], "leetcode_dataset_entry_point": "Solution().minDistance", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:09", "tests_total": 132...
cpp
{ "raw_signature": "int minDistance(string word1, string word2) {", "container": "Solution", "callable": "minDistance", "parameters": [ { "name": "word1", "type": "string" }, { "name": "word2", "type": "string" } ], "return_type": "int", "signature_source": "leetcod...
74
search-a-2d-matrix
Medium
You are given an m x n integer matrix matrix with the following two properties: - Each row is sorted in non-decreasing order. - The first integer of each row is greater than the last integer of the previous row. Given an integer target, return true if target is in matrix or false otherwise. You must write a solution...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[1, 3, 5, 7], [10, 11, 16, 20]],target = 10) == True\n assert candidate(matrix = [[-10, -5, -3], [0, 3, 10], [15, 20, 25]],target = 3) == True\n assert candidate(matrix = [[-10, -5, -3, -1], [0, 2, 3, 5], [7, 8, 11, 13], ...
[ "[[1,3,5,7],[10,11,16,20],[23,30,34,60]]\n3", "[[1,3,5,7],[10,11,16,20],[23,30,34,60]]\n13" ]
[]
{ "canonical_parameter_names": [ "matrix", "target" ], "leetcode_dataset_entry_point": "Solution().searchMatrix", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:13", "tests_total": ...
cpp
{ "raw_signature": "bool searchMatrix(vector<vector<int>>& matrix, int target) {", "container": "Solution", "callable": "searchMatrix", "parameters": [ { "name": "matrix", "type": "vector<vector<int>>&" }, { "name": "target", "type": "int" } ], "return_type": "bool", ...
76
minimum-window-substring
Hard
Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "". The testcases will be generated such that the answer is unique. Example 1: In...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"acbbaca\",t = \"aba\") == \"baca\"\n assert candidate(s = \"aabbcc\",t = \"abc\") == \"abbc\"\n assert candidate(s = \"aaaaaaa\",t = \"aa\") == \"aa\"\n assert candidate(s = \"a\",t = \"aa\") == \"\"\n assert candidate(...
[ "\"ADOBECODEBANC\"\n\"ABC\"", "\"a\"\n\"a\"", "\"a\"\n\"aa\"" ]
[ "Use two pointers to create a window of letters in s, which would have all the characters from t.", "Expand the right pointer until all the characters of t are covered.", "Once all the characters are covered, move the left pointer and ensure that all the characters are still covered to minimize the subarray siz...
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().minWindow", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:18", "tests_total": 80, "tests_...
cpp
{ "raw_signature": "string minWindow(string s, string t) {", "container": "Solution", "callable": "minWindow", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets...
77
combinations
Medium
Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. You may return the answer in any order. Example 1: Input: n = 4, k = 2 Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] Explanation: There are 4 choose 2 = 6 total combinations. Note that combinations are unordered, ...
{ "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\n2", "1\n1" ]
[]
{ "canonical_parameter_names": [ "n", "k" ], "leetcode_dataset_entry_point": "Solution().combine", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:20", "tests_total": 36, "tests_dr...
cpp
{ "raw_signature": "vector<vector<int>> combine(int n, int k) {", "container": "Solution", "callable": "combine", "parameters": [ { "name": "n", "type": "int" }, { "name": "k", "type": "int" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/co...
78
subsets
Medium
Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]] Cons...
{ "language": "python", "source": "def answers_match(result, expected):\n \"\"\"The answer may list its items in any order (only the top-level order is free).\"\"\"\n if isinstance(result, list) and isinstance(expected, list):\n return sorted(result, key=repr) == sorted(expected, key=repr)\n return ...
[ "[1,2,3]", "[0]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().subsets", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:22", "tests_total": 91, "tests_dropped"...
cpp
{ "raw_signature": "vector<vector<int>> subsets(vector<int>& nums) {", "container": "Solution", "callable": "subsets", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
79
word-search
Medium
Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. Example 1: Input: board = [...
{ "language": "python", "source": "def check(candidate):\n assert candidate(board = [['A', 'B'], ['C', 'D']],word = \"BD\") == True\n assert candidate(board = [['A', 'B'], ['C', 'D']],word = \"AC\") == True\n assert candidate(board = [['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E']],word =...
[ "[[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]]\n\"ABCCED\"", "[[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]]\n\"SEE\"", "[[\"A\",\"B\",\"C\",\"E\"],[\"S\",\"F\",\"C\",\"S\"],[\"A\",\"D\",\"E\",\"E\"]]\n\"ABCB\"" ]
[]
{ "canonical_parameter_names": [ "board", "word" ], "leetcode_dataset_entry_point": "Solution().exist", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:24", "tests_total": 17, "tes...
cpp
{ "raw_signature": "bool exist(vector<vector<char>>& board, string word) {", "container": "Solution", "callable": "exist", "parameters": [ { "name": "board", "type": "vector<vector<char>>&" }, { "name": "word", "type": "string" } ], "return_type": "bool", "signature...
81
search-in-rotated-sorted-array-ii
Medium
There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values). Before being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-index...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2],target = 6) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1],target = 2) == True\n assert candidate(nums = [4, 5, 6, 6, 7, 0, 1, 2, 4, 4],target = 4) == True\n...
[ "[2,5,6,0,0,1,2]\n0", "[2,5,6,0,0,1,2]\n3" ]
[]
{ "canonical_parameter_names": [ "nums", "target" ], "leetcode_dataset_entry_point": "Solution().search", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:29", "tests_total": 77, "t...
cpp
{ "raw_signature": "bool search(vector<int>& nums, int target) {", "container": "Solution", "callable": "search", "parameters": [ { "name": "nums", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "bool", "signature_source": "leetcode/...
84
largest-rectangle-in-histogram
Hard
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. Example 1: Input: heights = [2,1,5,6,2,3] Output: 10 Explanation: The above is a histogram where width of each bar is 1. The largest rectangle is show...
{ "language": "python", "source": "def check(candidate):\n assert candidate(heights = [1]) == 1\n assert candidate(heights = [1, 0, 1, 0, 1]) == 1\n assert candidate(heights = [10000, 10000, 10000, 10000, 10000]) == 50000\n assert candidate(heights = [0]) == 0\n assert candidate(heights = [1, 2, 3, 4...
[ "[2,1,5,6,2,3]", "[2,4]" ]
[]
{ "canonical_parameter_names": [ "heights" ], "leetcode_dataset_entry_point": "Solution().largestRectangleArea", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:35", "tests_total": 96, ...
cpp
{ "raw_signature": "int largestRectangleArea(vector<int>& heights) {", "container": "Solution", "callable": "largestRectangleArea", "parameters": [ { "name": "heights", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leet...
85
maximal-rectangle
Hard
Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] Output: 6 Explanation: The maximal rectangle is shown in the above picture...
{ "language": "python", "source": "def check(candidate):\n assert candidate(matrix = [['1']]) == 1\n assert candidate(matrix = [['0', '1', '0', '1'], ['1', '0', '1', '0'], ['0', '1', '0', '1']]) == 1\n assert candidate(matrix = [['1', '1'], ['1', '1']]) == 4\n assert candidate(matrix = [['0']]) == 0\n ...
[ "[[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"1\",\"1\"],[\"1\",\"1\",\"1\",\"1\",\"1\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]]", "[[\"0\"]]", "[[\"1\"]]" ]
[]
{ "canonical_parameter_names": [ "matrix" ], "leetcode_dataset_entry_point": "Solution().maximalRectangle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:38", "tests_total": 66, "tes...
cpp
{ "raw_signature": "int maximalRectangle(vector<vector<char>>& matrix) {", "container": "Solution", "callable": "maximalRectangle", "parameters": [ { "name": "matrix", "type": "vector<vector<char>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source...
87
scramble-string
Hard
We can scramble a string s to get a string t using the following algorithm: 1. If the length of the string is 1, stop. 2. If the length of the string is > 1, do the following: - Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y. - Rando...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"abcdefghij\",s2 = \"ihgfedcbaj\") == True\n assert candidate(s1 = \"noon\",s2 = \"onon\") == True\n assert candidate(s1 = \"abc\",s2 = \"cab\") == True\n assert candidate(s1 = \"abcdefghijklmnop\",s2 = \"ponmlkjihgfedcba\...
[ "\"great\"\n\"rgeat\"", "\"abcde\"\n\"caebd\"", "\"a\"\n\"a\"" ]
[]
{ "canonical_parameter_names": [ "s1", "s2" ], "leetcode_dataset_entry_point": "Solution().isScramble", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:42", "tests_total": 109, "te...
cpp
{ "raw_signature": "bool isScramble(string s1, string s2) {", "container": "Solution", "callable": "isScramble", "parameters": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" } ], "return_type": "bool", "signature_source": "leetcode/codeSnippe...
89
gray-code
Medium
An n-bit gray code sequence is a sequence of 2^n integers where: - Every integer is in the inclusive range [0, 2^n - 1], - The first integer is 0, - An integer appears no more than once in the sequence, - The binary representation of every pair of adjacent integers differs by exactly one bit, and - The binary represen...
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [0, 1, 3, 2, 6, 7, 5, 4]\n assert candidate(n = 4) == [0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8]\n assert candidate(n = 2) == [0, 1, 3, 2]\n assert candidate(n = 1) == [0, 1]\n assert candidate(n = 10) =...
[ "2", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().grayCode", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:47", "tests_total": 12, "tests_dropped": ...
cpp
{ "raw_signature": "vector<int> grayCode(int n) {", "container": "Solution", "callable": "grayCode", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
90
subsets-ii
Medium
Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] Example 2: Input: nums = [0] Output: [[],[0]] Const...
{ "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]", "[0]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().subsetsWithDup", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:49", "tests_total": 103, "tests_...
cpp
{ "raw_signature": "vector<vector<int>> subsetsWithDup(vector<int>& nums) {", "container": "Solution", "callable": "subsetsWithDup", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_...
91
decode-ways
Medium
You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping: "1" -> 'A' "2" -> 'B' ... "25" -> 'Y' "26" -> 'Z' However, while decoding the message, you realize that there are many different ways you can decode the message because some codes are contained in o...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(s = \"1111001111001111001111001111001111001111001111001111...
[ "\"12\"", "\"226\"", "\"06\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().numDecodings", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:51", "tests_total": 176, "tests_dropp...
cpp
{ "raw_signature": "int numDecodings(string s) {", "container": "Solution", "callable": "numDecodings", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
93
restore-ip-addresses
Medium
A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. - For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. Given a stri...
{ "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 ...
[ "\"25525511135\"", "\"0000\"", "\"101023\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().restoreIpAddresses", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:38:56", "tests_total": 143, "tests...
cpp
{ "raw_signature": "vector<string> restoreIpAddresses(string s) {", "container": "Solution", "callable": "restoreIpAddresses", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<string>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/c...
96
unique-binary-search-trees
Medium
Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. Example 1: Input: n = 3 Output: 5 Example 2: Input: n = 1 Output: 1 Constraints: - 1 <= n <= 19
{ "language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 5\n assert candidate(n = 4) == 14\n assert candidate(n = 19) == 1767263190\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 16796\n assert candidate(n = 5) == 42\n assert candidate(n = 8) == 1430\n...
[ "3", "1" ]
[]
{ "canonical_parameter_names": [ "n" ], "leetcode_dataset_entry_point": "Solution().numTrees", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:00", "tests_total": 14, "tests_dropped": ...
cpp
{ "raw_signature": "int numTrees(int n) {", "container": "Solution", "callable": "numTrees", "parameters": [ { "name": "n", "type": "int" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
97
interleaving-string
Medium
Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration where s and t are divided into n and m substrings respectively, such that: - s = s_1 + s_2 + ... + s_n - t = t_1 + t_2 + ... + t_m - |n - m| <= 1 - The interleaving is s_1...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"abc\",s2 = \"abc\",s3 = \"aabbcc\") == True\n assert candidate(s1 = \"\",s2 = \"a\",s3 = \"a\") == True\n assert candidate(s1 = \"\",s2 = \"b\",s3 = \"b\") == True\n assert candidate(s1 = \"a\",s2 = \"\",s3 = \"a\") == Tr...
[ "\"aabcc\"\n\"dbbca\"\n\"aadbbcbcac\"", "\"aabcc\"\n\"dbbca\"\n\"aadbbbaccc\"", "\"\"\n\"\"\n\"\"" ]
[]
{ "canonical_parameter_names": [ "s1", "s2", "s3" ], "leetcode_dataset_entry_point": "Solution().isInterleave", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:03", "tests_total"...
cpp
{ "raw_signature": "bool isInterleave(string s1, string s2, string s3) {", "container": "Solution", "callable": "isInterleave", "parameters": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" }, { "name": "s3", "type": "string" } ...
115
distinct-subsequences
Hard
Given two strings s and t, return the number of distinct subsequences of s which equals t. The test cases are generated so that the answer fits on a 32-bit signed integer. Example 1: Input: s = "rabbbit", t = "rabbit" Output: 3 Explanation: As shown below, there are 3 ways you can generate "rabbit" from s. rabbbit r...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abcd\") == 0\n assert candidate(s = \"abcd\",t = \"abcd\") == 1\n assert candidate(s = \"rabbbit\",t = \"rabbit\") == 3\n assert candidate(s = \"aaa\",t = \"a\") == 3\n assert candidate(s = \"mississippi\",t...
[ "\"rabbbit\"\n\"rabbit\"", "\"babgbag\"\n\"bag\"" ]
[]
{ "canonical_parameter_names": [ "s", "t" ], "leetcode_dataset_entry_point": "Solution().numDistinct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:43", "tests_total": 101, "tes...
cpp
{ "raw_signature": "int numDistinct(string s, string t) {", "container": "Solution", "callable": "numDistinct", "parameters": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets",...
118
pascals-triangle
Easy
Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] Example 2: Input: numRows = 1 Output: [[1]] Constraints: - 1 <= numR...
{ "language": "python", "source": "def check(candidate):\n assert candidate(numRows = 10) == [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]]\n assert ...
[ "5", "1" ]
[]
{ "canonical_parameter_names": [ "numRows" ], "leetcode_dataset_entry_point": "Solution().generate", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:46", "tests_total": 16, "tests_drop...
cpp
{ "raw_signature": "vector<vector<int>> generate(int numRows) {", "container": "Solution", "callable": "generate", "parameters": [ { "name": "numRows", "type": "int" } ], "return_type": "vector<vector<int>>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
119
pascals-triangle-ii
Easy
Given an integer rowIndex, return the rowIndex^th (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Input: rowIndex = 3 Output: [1,3,3,1] Example 2: Input: rowIndex = 0 Output: [1] Example 3: Input: rowIndex = 1 Output...
{ "language": "python", "source": "def check(candidate):\n assert candidate(rowIndex = 0) == [1]\n assert candidate(rowIndex = 10) == [1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1]\n assert candidate(rowIndex = 15) == [1, 15, 105, 455, 1365, 3003, 5005, 6435, 6435, 5005, 3003, 1365, 455, 105, 15, 1]\n ...
[ "3", "0", "1" ]
[]
{ "canonical_parameter_names": [ "rowIndex" ], "leetcode_dataset_entry_point": "Solution().getRow", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:48", "tests_total": 20, "tests_dropp...
cpp
{ "raw_signature": "vector<int> getRow(int rowIndex) {", "container": "Solution", "callable": "getRow", "parameters": [ { "name": "rowIndex", "type": "int" } ], "return_type": "vector<int>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
120
triangle
Medium
Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either index i or index i + 1 on the next row. Example 1: Input: triangle = [[2],[3,4],[6,5,7],[4,1,8,3]...
{ "language": "python", "source": "def check(candidate):\n assert candidate(triangle = [[-10]]) == -10\n assert candidate(triangle = [[-1], [2, 3], [1, -1, -3], [-2, 1, -1, -2]]) == -3\n assert candidate(triangle = [[0], [1, 2], [3, 4, 5], [6, 7, 8, 9]]) == 10\n assert candidate(triangle = [[-1], [2, -2...
[ "[[2],[3,4],[6,5,7],[4,1,8,3]]", "[[-10]]" ]
[]
{ "canonical_parameter_names": [ "triangle" ], "leetcode_dataset_entry_point": "Solution().minimumTotal", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:50", "tests_total": 92, "tests...
cpp
{ "raw_signature": "int minimumTotal(vector<vector<int>>& triangle) {", "container": "Solution", "callable": "minimumTotal", "parameters": [ { "name": "triangle", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "le...
121
best-time-to-buy-and-sell-stock
Easy
You are given an array prices where prices[i] is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(prices = [10, 9, 8, 2]) == 0\n assert candidate(prices = [1]) == 0\n assert candidate(prices = [2, 1, 2, 1, 0, 1, 2]) == 2\n assert candidate(prices = [2, 1]) == 0\n assert candidate(prices = [7, 6, 4, 3, 1]) == 0\n assert...
[ "[7,1,5,3,6,4]", "[7,6,4,3,1]" ]
[]
{ "canonical_parameter_names": [ "prices" ], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:52", "tests_total": 99, "tests_drop...
cpp
{ "raw_signature": "int maxProfit(vector<int>& prices) {", "container": "Solution", "callable": "maxProfit", "parameters": [ { "name": "prices", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
122
best-time-to-buy-and-sell-stock-ii
Medium
You are given an integer array prices where prices[i] is the price of a given stock on the i^th day. On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can sell and buy the stock multiple times on the same day, ensuring you never hold mo...
{ "language": "python", "source": "def check(candidate):\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(prices = [1, 2, 2, 3, 4, 4, 5]) == 4\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1]) == 3\n assert c...
[ "[7,1,5,3,6,4]", "[1,2,3,4,5]", "[7,6,4,3,1]" ]
[]
{ "canonical_parameter_names": [ "prices" ], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:55", "tests_total": 125, "tests_dro...
cpp
{ "raw_signature": "int maxProfit(vector<int>& prices) {", "container": "Solution", "callable": "maxProfit", "parameters": [ { "name": "prices", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
123
best-time-to-buy-and-sell-stock-iii
Hard
You are given an array prices where prices[i] is the price of a given stock on the i^th day. Find the maximum profit you can achieve. You may complete at most two transactions. Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again). Example 1: Input: pr...
{ "language": "python", "source": "def check(candidate):\n assert candidate(prices = [1, 5, 1, 5, 1, 5, 1, 5]) == 8\n assert candidate(prices = [2, 1, 4, 5, 2, 9, 7]) == 11\n assert candidate(prices = [10, 22, 5, 75, 65, 80]) == 87\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n a...
[ "[3,3,5,0,0,3,1,4]", "[1,2,3,4,5]", "[7,6,4,3,1]" ]
[]
{ "canonical_parameter_names": [ "prices" ], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:39:57", "tests_total": 117, "tests_dro...
cpp
{ "raw_signature": "int maxProfit(vector<int>& prices) {", "container": "Solution", "callable": "maxProfit", "parameters": [ { "name": "prices", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
127
word-ladder
Hard
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s_1 -> s_2 -> ... -> s_k such that: - Every adjacent pair of words differs by a single letter. - Every s_i for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList. -...
{ "language": "python", "source": "def check(candidate):\n assert candidate(beginWord = \"leet\",endWord = \"code\",wordList = ['lest', 'leet', 'lose', 'code', 'lode', 'robe', 'home', 'dote', 'cake']) == 0\n assert candidate(beginWord = \"talk\",endWord = \"tell\",wordList = ['talk', 'tell', 'tall', 'toll', '...
[ "\"hit\"\n\"cog\"\n[\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]", "\"hit\"\n\"cog\"\n[\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]" ]
[]
{ "canonical_parameter_names": [ "beginWord", "endWord", "wordList" ], "leetcode_dataset_entry_point": "Solution().ladderLength", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:04...
cpp
{ "raw_signature": "int ladderLength(string beginWord, string endWord, vector<string>& wordList) {", "container": "Solution", "callable": "ladderLength", "parameters": [ { "name": "beginWord", "type": "string" }, { "name": "endWord", "type": "string" }, { "name"...
128
longest-consecutive-sequence
Medium
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Example 1: Input: nums = [100,4,200,1,3,2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. Exampl...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -2, -3, -4]) == 4\n assert candidate(nums = [10, 5, 12, 3, 9, 7, 8, 11]) == 6\n assert candidate(nums = [1, 9, 3, 10, 4, 20, 2]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candi...
[ "[100,4,200,1,3,2]", "[0,3,7,2,5,8,4,6,0,1]", "[1,0,1,2]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().longestConsecutive", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:06", "tests_total": 138, "te...
cpp
{ "raw_signature": "int longestConsecutive(vector<int>& nums) {", "container": "Solution", "callable": "longestConsecutive", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeS...
131
palindrome-partitioning
Medium
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example 1: Input: s = "aab" Output: [["a","a","b"],["aa","b"]] Example 2: Input: s = "a" Output: [["a"]] Constraints: - 1 <= s.length <= 16 - s contains only lowercase Englis...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"madam\") == [['m', 'a', 'd', 'a', 'm'], ['m', 'ada', 'm'], ['madam']]\n assert candidate(s = \"deified\") == [['d', 'e', 'i', 'f', 'i', 'e', 'd'], ['d', 'e', 'ifi', 'e', 'd'], ['d', 'eifie', 'd'], ['deified']]\n assert candid...
[ "\"aab\"", "\"a\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().partition", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:12", "tests_total": 128, "tests_dropped"...
cpp
{ "raw_signature": "vector<vector<string>> partition(string s) {", "container": "Solution", "callable": "partition", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "vector<vector<string>>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
132
palindrome-partitioning-ii
Hard
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. Example 1: Input: s = "aab" Output: 1 Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut. Example 2: Input: s = "a" Output: 0 ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"abcdcba\") == 0\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"ab\") == 1\n ass...
[ "\"aab\"", "\"a\"", "\"ab\"" ]
[]
{ "canonical_parameter_names": [ "s" ], "leetcode_dataset_entry_point": "Solution().minCut", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:15", "tests_total": 158, "tests_dropped": 0...
cpp
{ "raw_signature": "int minCut(string s) {", "container": "Solution", "callable": "minCut", "parameters": [ { "name": "s", "type": "string" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
134
gas-station
Medium
There are n gas stations along a circular route, where the amount of gas at the i^th station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the i^th station to its next (i + 1)^th station. You begin the journey with an empty tank at one of the gas stations. Given two i...
{ "language": "python", "source": "def check(candidate):\n assert candidate(gas = [1, 2, 3, 4, 5],cost = [3, 4, 5, 1, 2]) == 3\n assert candidate(gas = [1, 1, 1, 1],cost = [1, 1, 1, 1]) == 3\n assert candidate(gas = [1, 1, 1, 1, 1],cost = [1, 1, 1, 1, 1]) == 4\n assert candidate(gas = [5, 1, 2, 3, 4],co...
[ "[1,2,3,4,5]\n[3,4,5,1,2]", "[2,3,4]\n[3,4,3]" ]
[]
{ "canonical_parameter_names": [ "gas", "cost" ], "leetcode_dataset_entry_point": "Solution().canCompleteCircuit", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:17", "tests_total":...
cpp
{ "raw_signature": "int canCompleteCircuit(vector<int>& gas, vector<int>& cost) {", "container": "Solution", "callable": "canCompleteCircuit", "parameters": [ { "name": "gas", "type": "vector<int>&" }, { "name": "cost", "type": "vector<int>&" } ], "return_type": "int"...
135
candy
Hard
There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: - Each child must have at least one candy. - Children with a higher rating get more candies than their neighbors. Retur...
{ "language": "python", "source": "def check(candidate):\n assert candidate(ratings = [50, 40, 30, 20, 10]) == 15\n assert candidate(ratings = [1]) == 1\n assert candidate(ratings = [1, 3, 4, 5, 2]) == 11\n assert candidate(ratings = [1, 1, 1, 1]) == 4\n assert candidate(ratings = [1, 2, 3, 2, 1, 2, ...
[ "[1,0,2]", "[1,2,2]" ]
[]
{ "canonical_parameter_names": [ "ratings" ], "leetcode_dataset_entry_point": "Solution().candy", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:19", "tests_total": 112, "tests_droppe...
cpp
{ "raw_signature": "int candy(vector<int>& ratings) {", "container": "Solution", "callable": "candy", "parameters": [ { "name": "ratings", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
136
single-number
Easy
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input:...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -1, -2, 2]) == -2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10, 1, 10, 2, 2]) == 1\n assert candidate(nums = [3, 3, 7, 7, 10]) == 10\n assert candidate(nums = [10, 10, 20, 20, 30]) == 30\n ...
[ "[2,2,1]", "[4,1,2,1,2]", "[1]" ]
[ "Think about the XOR (^) operator's property." ]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().singleNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:21", "tests_total": 108, "tests_dr...
cpp
{ "raw_signature": "int singleNumber(vector<int>& nums) {", "container": "Solution", "callable": "singleNumber", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
137
single-number-ii
Medium
Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,3,2] Output: 3 Example 2: Input: num...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 7]) == 7\n assert candidate(nums = [-1, -1, -1, 100]) == 100\n assert candidate(nums = [-2, -2, -2, 1]) == 1\n assert candidate(nums = [1000000, 1000000, 1000000, 2000000]) == 2000000\...
[ "[2,2,3,2]", "[0,1,0,1,0,1,99]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().singleNumber", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:24", "tests_total": 98, "tests_dro...
cpp
{ "raw_signature": "int singleNumber(vector<int>& nums) {", "container": "Solution", "callable": "singleNumber", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
139
word-break
Medium
Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: tr...
{ "language": "python", "source": "def check(candidate):\n assert candidate(s = \"cars\",wordDict = ['car', 'ca', 'rs']) == True\n assert candidate(s = \"goals\",wordDict = ['go', 'goal', 'goals']) == True\n assert candidate(s = \"pineapplepenapple\",wordDict = ['apple', 'pen', 'applepen', 'pine', 'pineapp...
[ "\"leetcode\"\n[\"leet\",\"code\"]", "\"applepenapple\"\n[\"apple\",\"pen\"]", "\"catsandog\"\n[\"cats\",\"dog\",\"sand\",\"and\",\"cat\"]" ]
[]
{ "canonical_parameter_names": [ "s", "wordDict" ], "leetcode_dataset_entry_point": "Solution().wordBreak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:26", "tests_total": 87, ...
cpp
{ "raw_signature": "bool wordBreak(string s, vector<string>& wordDict) {", "container": "Solution", "callable": "wordBreak", "parameters": [ { "name": "s", "type": "string" }, { "name": "wordDict", "type": "vector<string>&" } ], "return_type": "bool", "signature_sou...
140
word-break-ii
Hard
Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example 1: Input: s = "catsanddog", w...
{ "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 ...
[ "\"catsanddog\"\n[\"cat\",\"cats\",\"and\",\"sand\",\"dog\"]", "\"pineapplepenapple\"\n[\"apple\",\"pen\",\"applepen\",\"pine\",\"pineapple\"]", "\"catsandog\"\n[\"cats\",\"dog\",\"sand\",\"and\",\"cat\"]" ]
[]
{ "canonical_parameter_names": [ "s", "wordDict" ], "leetcode_dataset_entry_point": "Solution().wordBreak", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:28", "tests_total": 59, ...
cpp
{ "raw_signature": "vector<string> wordBreak(string s, vector<string>& wordDict) {", "container": "Solution", "callable": "wordBreak", "parameters": [ { "name": "s", "type": "string" }, { "name": "wordDict", "type": "vector<string>&" } ], "return_type": "vector<string...
149
max-points-on-a-line
Hard
Given an array of points where points[i] = [x_i, y_i] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. Example 1: Input: points = [[1,1],[2,2],[3,3]] Output: 3 Example 2: Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] Output: 4 Constraints: - 1 <=...
{ "language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n assert candidate(points = [[0, 0], [1, 1], [0, 1], [1, 0]]) == 2\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 6\n assert candi...
[ "[[1,1],[2,2],[3,3]]", "[[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]]" ]
[]
{ "canonical_parameter_names": [ "points" ], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:44", "tests_total": 108, "tests_dro...
cpp
{ "raw_signature": "int maxPoints(vector<vector<int>>& points) {", "container": "Solution", "callable": "maxPoints", "parameters": [ { "name": "points", "type": "vector<vector<int>>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/cod...
150
evaluate-reverse-polish-notation
Medium
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. Evaluate the expression. Return an integer that represents the value of the expression. Note that: - The valid operators are '+', '-', '*', and '/'. - Each operand may be an integer or another expression. ...
{ "language": "python", "source": "def check(candidate):\n assert candidate(tokens = ['4', '13', '5', '/', '+']) == 6\n assert candidate(tokens = ['2', '1', '+', '3', '*']) == 9\n assert candidate(tokens = ['10', '6', '9', '3', '+', '-11', '*', '/', '*', '17', '+', '5', '+']) == 22\n assert candidate(to...
[ "[\"2\",\"1\",\"+\",\"3\",\"*\"]", "[\"4\",\"13\",\"5\",\"/\",\"+\"]", "[\"10\",\"6\",\"9\",\"3\",\"+\",\"-11\",\"*\",\"/\",\"*\",\"17\",\"+\",\"5\",\"+\"]" ]
[]
{ "canonical_parameter_names": [ "tokens" ], "leetcode_dataset_entry_point": "Solution().evalRPN", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:46", "tests_total": 97, "tests_droppe...
cpp
{ "raw_signature": "int evalRPN(vector<string>& tokens) {", "container": "Solution", "callable": "evalRPN", "parameters": [ { "name": "tokens", "type": "vector<string>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
152
maximum-product-subarray
Medium
Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. Note that the product of an array with a single element is the value of that element. Example 1: Input: nums = [2,3,-2,4] Output: 6 Explana...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, -5, -2, -4, 3]) == 24\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-2, 3, -4]) == 24\n assert candidate(nums = [3, -1, 4]) == 4\n assert candidate(nums = [-1, -2, -3, 0]) == 6\n assert candidat...
[ "[2,3,-2,4]", "[-2,0,-1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:50", "tests_total": 91, "tests_dropp...
cpp
{ "raw_signature": "int maxProduct(vector<int>& nums) {", "container": "Solution", "callable": "maxProduct", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
153
find-minimum-in-rotated-sorted-array
Medium
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: - [4,5,6,7,0,1,2] if it was rotated 4 times. - [0,1,2,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2]) == 0\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1, 0]) == 1\n assert candidate(nums = [1, 3, 2]) == 1\n assert candidate(nums = [10, 15, 1, 3, 8]) == 1...
[ "[3,4,5,1,2]", "[4,5,6,7,0,1,2]", "[11,13,15,17]" ]
[ "Array was originally in ascending order. Now that the array is rotated, there would be a point in the array where there is a small deflection from the increasing sequence. eg. The array would be something like [4, 5, 6, 7, 0, 1, 2].", "You can divide the search space into two and see which direction to go. Can y...
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findMin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:52", "tests_total": 95, "tests_dropped"...
cpp
{ "raw_signature": "int findMin(vector<int>& nums) {", "container": "Solution", "callable": "findMin", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
154
find-minimum-in-rotated-sorted-array-ii
Hard
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: - [4,5,6,7,0,1,4] if it was rotated 4 times. - [0,1,4,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(nums = [1, 3, 5]) == 1\n assert candidate(nums = [2, 2, 2, 0, 1]) == 0\n assert candidate(nums = [5, 1, 2, 3, 4]) == 1\n assert candidate(nums = [3, 4, 5, 1, 2]) ...
[ "[1,3,5]", "[2,2,2,0,1]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findMin", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:40:55", "tests_total": 120, "tests_dropped...
cpp
{ "raw_signature": "int findMin(vector<int>& nums) {", "container": "Solution", "callable": "findMin", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
162
find-peak-element
Medium
A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always cons...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 1]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [2, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5...
[ "[1,2,3,1]", "[1,2,1,3,5,6,4]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().findPeakElement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:06", "tests_total": 92, "tests_...
cpp
{ "raw_signature": "int findPeakElement(vector<int>& nums) {", "container": "Solution", "callable": "findPeakElement", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippet...
164
maximum-gap
Medium
Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. You must write an algorithm that runs in linear time and uses linear extra space. Example 1: Input: nums = [3,6,9,1] Output: 3 Explanation: The sorted...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 999999999\n assert candidate(nums = [8, 10, 58, 59, 9, 29, 90, 1, 7, 2, 45]) == 31\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, ...
[ "[3,6,9,1]", "[10]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().maximumGap", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:11", "tests_total": 127, "tests_drop...
cpp
{ "raw_signature": "int maximumGap(vector<int>& nums) {", "container": "Solution", "callable": "maximumGap", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets" }
165
compare-version-numbers
Medium
Given two version strings, version1 and version2, compare them. A version string consists of revisions separated by dots '.'. The value of the revision is its integer conversion ignoring leading zeros. To compare version strings, compare their revision values in left-to-right order. If one of the version strings has f...
{ "language": "python", "source": "def check(candidate):\n assert candidate(version1 = \"0\",version2 = \"0.0.0\") == 0\n assert candidate(version1 = \"1.1.1.1\",version2 = \"1.1.1.1\") == 0\n assert candidate(version1 = \"1.2.3.4\",version2 = \"1.2.3\") == 1\n assert candidate(version1 = \"1.1.1.1\",ve...
[ "\"1.2\"\n\"1.10\"", "\"1.01\"\n\"1.001\"", "\"1.0\"\n\"1.0.0.0\"" ]
[ "You can use two pointers for each version string to traverse them together while comparing the corresponding segments.", "Utilize the substring method to extract each version segment delimited by '.'. Ensure you're extracting the segments correctly by adjusting the start and end indices accordingly." ]
{ "canonical_parameter_names": [ "version1", "version2" ], "leetcode_dataset_entry_point": "Solution().compareVersion", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:13", "tests_to...
cpp
{ "raw_signature": "int compareVersion(string version1, string version2) {", "container": "Solution", "callable": "compareVersion", "parameters": [ { "name": "version1", "type": "string" }, { "name": "version2", "type": "string" } ], "return_type": "int", "signature...
166
fraction-to-recurring-decimal
Medium
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses If multiple answers are possible, return any of them. It is guaranteed that the length of the answer string is less than 10...
{ "language": "python", "source": "def check(candidate):\n assert candidate(numerator = 7,denominator = -3) == \"-2.(3)\"\n assert candidate(numerator = 1,denominator = 6) == \"0.1(6)\"\n assert candidate(numerator = 4,denominator = 333) == \"0.(012)\"\n assert candidate(numerator = 22,denominator = 7) ...
[ "1\n2", "2\n1", "4\n333" ]
[ "No scary math, just apply elementary math knowledge. Still remember how to perform a long division?", "Try a long division on 4/9, the repeating part is obvious. Now try 4/333. Do you see a pattern?", "Notice that once the remainder starts repeating, so does the divided result.", "Be wary of edge cases! List...
{ "canonical_parameter_names": [ "numerator", "denominator" ], "leetcode_dataset_entry_point": "Solution().fractionToDecimal", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:15", "t...
cpp
{ "raw_signature": "string fractionToDecimal(int numerator, int denominator) {", "container": "Solution", "callable": "fractionToDecimal", "parameters": [ { "name": "numerator", "type": "int" }, { "name": "denominator", "type": "int" } ], "return_type": "string", "s...
167
two-sum-ii-input-array-is-sorted
Medium
You are given a 1-indexed array of integers numbers that is already sorted in non-decreasing order. Find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index_1] and numbers[index_2] where 1 <= index_1 < index_2 <= numbers.length. Return the indices of the two numbers i...
{ "language": "python", "source": "def check(candidate):\n assert candidate(numbers = [-3, -2, -1, 0, 0, 1, 2, 3],target = 0) == [1, 8]\n assert candidate(numbers = [-10, -5, 0, 5, 10],target = 0) == [1, 5]\n assert candidate(numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 17) == [8, 9]\n assert candidat...
[ "[2,7,11,15]\n9", "[2,3,4]\n6", "[-1,0]\n-1" ]
[]
{ "canonical_parameter_names": [ "numbers", "target" ], "leetcode_dataset_entry_point": "Solution().twoSum", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:17", "tests_total": 89, ...
cpp
{ "raw_signature": "vector<int> twoSum(vector<int>& numbers, int target) {", "container": "Solution", "callable": "twoSum", "parameters": [ { "name": "numbers", "type": "vector<int>&" }, { "name": "target", "type": "int" } ], "return_type": "vector<int>", "signature...
168
excel-sheet-column-title
Easy
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: Input: columnNumber = 1 Output: "A" Example 2: Input: columnNumber = 28 Output: "AB" Example 3: Input: columnNumber = 701 Output: "...
{ "language": "python", "source": "def check(candidate):\n assert candidate(columnNumber = 1) == \"A\"\n assert candidate(columnNumber = 28) == \"AB\"\n assert candidate(columnNumber = 1045) == \"ANE\"\n assert candidate(columnNumber = 2147483647) == \"FXSHRXW\"\n assert candidate(columnNumber = 4569...
[ "1", "28", "701" ]
[]
{ "canonical_parameter_names": [ "columnNumber" ], "leetcode_dataset_entry_point": "Solution().convertToTitle", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:20", "tests_total": 38, ...
cpp
{ "raw_signature": "string convertToTitle(int columnNumber) {", "container": "Solution", "callable": "convertToTitle", "parameters": [ { "name": "columnNumber", "type": "int" } ], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnipp...
169
majority-element
Easy
Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: nums = [3,2,3] Output: 3 Example 2: Input: nums = [2,2,1,1,1,2,2] Output: 2 Constraints: - n...
{ "language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3]) == 1\n assert candidate(nums = [2, 2, 1, 1, 1, 2, 2]) == 2\n assert candidate(nums = [-1, 100, -1, -1, -1, -1, 1, 1, 1, 1]) == -1\n assert ca...
[ "[3,2,3]", "[2,2,1,1,1,2,2]" ]
[]
{ "canonical_parameter_names": [ "nums" ], "leetcode_dataset_entry_point": "Solution().majorityElement", "problem_source": "newfacade/LeetCodeDataset", "description_source": "leetcode.com", "interface_source": "leetcode/codeSnippets", "fetched_at": "2026-09-30T19:41:22", "tests_total": 45, "tests_...
cpp
{ "raw_signature": "int majorityElement(vector<int>& nums) {", "container": "Solution", "callable": "majorityElement", "parameters": [ { "name": "nums", "type": "vector<int>&" } ], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippet...