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 |
|---|---|---|---|---|---|---|---|---|---|
553 | optimal-division | Medium | You are given an integer array nums. The adjacent integers in nums will perform the float division.
- For example, for nums = [2,3,4], we will evaluate the expression "2/3/4".
However, you can add any number of parenthesis at any position to change the priority of operations. You want to add these parentheses such th... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 20, 30]) == \"10/(20/30)\"\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"2/(2/2/2/2/2/2/2/2/2)\"\n assert candidate(nums = [3, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == \"3/(100/100/100/100/100/1... | [
"[1000,100,10,2]",
"[2,3,4]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().optimalDivision",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:06",
"tests_total": 114,
"tests... | go | {
"raw_signature": "func optimalDivision(nums []int) string {",
"container": null,
"callable": "optimalDivision",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
554 | brick-wall | Medium | There is a rectangular brick wall in front of you with n rows of bricks. The i^th row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.
Draw a vertical line from the top to the bottom and cross the least bricks. If your line... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(wall = [[2], [2, 2], [2, 2, 2]]) == 1\n assert candidate(wall = [[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2]]) == 0\n assert candidate(wall = [[7], [8, 5, 7], [9, 1, 7, 5], [9, 3], [1, 5, 4], [2, 8, 2, 2], [1, 9, 1, 1, 1], [3, 5, 1, 2... | [
"[[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]",
"[[1],[1],[1]]"
] | [] | {
"canonical_parameter_names": [
"wall"
],
"leetcode_dataset_entry_point": "Solution().leastBricks",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:08",
"tests_total": 63,
"tests_drop... | go | {
"raw_signature": "func leastBricks(wall [][]int) int {",
"container": null,
"callable": "leastBricks",
"parameters": [
{
"name": "wall",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
556 | next-greater-element-iii | Medium | Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1.
Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer,... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 987654321) == -1\n assert candidate(n = 230241) == 230412\n assert candidate(n = 2147483476) == 2147483647\n assert candidate(n = 12) == 21\n assert candidate(n = 21) == -1\n assert candidate(n = 1234) == 1243\n ass... | [
"12",
"21"
] | [] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().nextGreaterElement",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:12",
"tests_total": 80,
"tests_... | go | {
"raw_signature": "func nextGreaterElement(n int) int {",
"container": null,
"callable": "nextGreaterElement",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
557 | reverse-words-in-a-string-iii | Easy | Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: s = "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
Example 2:
Input: s = "Mr Ding"
Output: "rM gniD"
Constraints:
- 1 <= s.length <= 5 *... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"Reverse each word\") == \"esreveR hcae drow\"\n assert candidate(s = \"Python Programming\") == \"nohtyP gnimmargorP\"\n assert candidate(s = \"Python is fun\") == \"nohtyP si nuf\"\n assert candidate(s = \"reverse each wo... | [
"\"Let's take LeetCode contest\"",
"\"Mr Ding\""
] | [] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().reverseWords",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:15",
"tests_total": 91,
"tests_droppe... | go | {
"raw_signature": "func reverseWords(s string) string {",
"container": null,
"callable": "reverseWords",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
560 | subarray-sum-equals-k | Medium | Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
A subarray is a contiguous non-empty sequence of elements within an array.
Example 1:
Input: nums = [1,1,1], k = 2
Output: 2
Example 2:
Input: nums = [1,2,3], k = 3
Output: 2
Constraints:
- 1 <= nums.len... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2],k = 4) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 55\n assert candidate(nums = [1, 2, 1, 2, 1],k = 3) == 4... | [
"[1,1,1]\n2",
"[1,2,3]\n3"
] | [
"Will Brute force work here? Try to optimize it.",
"Can we optimize it by using some extra space?",
"What about storing sum frequencies in a hash table? Will it be useful?",
"sum(i,j)=sum(0,j)-sum(0,i), where sum(i,j) represents the sum of all the elements from index i to j-1. Can we use this property to opti... | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().subarraySum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:17",
"tests_total": 102,
"... | go | {
"raw_signature": "func subarraySum(nums []int, k int) int {",
"container": null,
"callable": "subarraySum",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
... |
561 | array-partition | Easy | Given an integer array nums of 2n integers, group these integers into n pairs (a_1, b_1), (a_2, b_2), ..., (a_n, b_n) such that the sum of min(a_i, b_i) for all i is maximized. Return the maximized sum.
Example 1:
Input: nums = [1,4,3,2]
Output: 4
Explanation: All possible pairings (ignoring the ordering of elements)... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 28\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(nums = [-10000, -9999, -9998, -9997, -9996, -9995, -9994, -9993]) == -39988\n assert candidate(nums = [1, 2, ... | [
"[1,4,3,2]",
"[6,2,6,5,1,2]"
] | [
"Obviously, brute force won't help here. Think of something else, take some example like 1,2,3,4.",
"How will you make pairs to get the result? There must be some pattern.",
"Did you observe that- Minimum element gets add into the result in sacrifice of maximum element.",
"Still won't able to find pairs? Sort... | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().arrayPairSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:19",
"tests_total": 112,
"tests_dr... | go | {
"raw_signature": "func arrayPairSum(nums []int) int {",
"container": null,
"callable": "arrayPairSum",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
564 | find-the-closest-palindrome | Hard | Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one.
The closest is defined as the absolute difference minimized between two integers.
Example 1:
Input: n = "123"
Output: "121"
Example 2:
Input: n = "1"
Output... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = \"10\") == \"9\"\n assert candidate(n = \"1001\") == \"999\"\n assert candidate(n = \"1234\") == \"1221\"\n assert candidate(n = \"123321\") == \"122221\"\n assert candidate(n = \"999999999\") == \"1000000001\"\n asser... | [
"\"123\"",
"\"1\""
] | [
"Will brute force work for this problem? Think of something else.",
"Take some examples like 1234, 999,1000, etc and check their closest palindromes. How many different cases are possible?",
"Do we have to consider only left half or right half of the string or both?",
"Try to find the closest palindrome of th... | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().nearestPalindromic",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:26",
"tests_total": 114,
"tests... | go | {
"raw_signature": "func nearestPalindromic(n string) string {",
"container": null,
"callable": "nearestPalindromic",
"parameters": [
{
"name": "n",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
565 | array-nesting | Medium | You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].
You should build a set s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... } subjected to the following rule:
- The first element in s[k] starts with the selection of the element nums[k] of index =... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 0, 3, 4, 2]) == 3\n assert candidate(nums = [5, 1, 4, 2, 0, 6, 3]) == 6\n assert candidate(nums = [3, 2, 1, 0]) == 2\n assert candidate(nums = [1, 2, 0, 3]) == 3\n assert candidate(nums = [0, 2, 1]) == 2\n asser... | [
"[5,4,0,3,1,6,2]",
"[0,1,2]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().arrayNesting",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:29",
"tests_total": 97,
"tests_dro... | go | {
"raw_signature": "func arrayNesting(nums []int) int {",
"container": null,
"callable": "arrayNesting",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
566 | reshape-the-matrix | Easy | In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data.
You are given an m x n matrix mat and two integers r and c representing the number of rows and the number of columns of the wanted reshaped matrix.
The reshaped m... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],r = 1,c = 6) == [[1, 2, 3, 4, 5, 6]]\n assert candidate(mat = [[1, 2], [3, 4]],r = 1,c = 4) == [[1, 2, 3, 4]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],r = 3,c = 2) == [[1, 2], [3, 4], [5, 6]]\n ... | [
"[[1,2],[3,4]]\n1\n4",
"[[1,2],[3,4]]\n2\n4"
] | [
"Do you know how 2d matrix is stored in 1d memory? Try to map 2-dimensions into one.",
"M[i][j]=M[n*i+j] , where n is the number of cols. This is the one way of converting 2-d indices into one 1-d index. Now, how will you convert 1-d index into 2-d indices?",
"Try to use division and modulus to convert 1-d inde... | {
"canonical_parameter_names": [
"mat",
"r",
"c"
],
"leetcode_dataset_entry_point": "Solution().matrixReshape",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:31",
"tests_total"... | go | {
"raw_signature": "func matrixReshape(mat [][]int, r int, c int) [][]int {",
"container": null,
"callable": "matrixReshape",
"parameters": [
{
"name": "mat",
"type": "[][]int"
},
{
"name": "r",
"type": "int"
},
{
"name": "c",
"type": "int"
}
],
"r... |
567 | permutation-in-string | Medium | Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.
In other words, return true if one of s1's permutations is the substring of s2.
Example 1:
Input: s1 = "ab", s2 = "eidbaooo"
Output: true
Explanation: s2 contains one permutation of s1 ("ba").
Example 2:
Input: s1 = "a... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"abc\",s2 = \"bbbccca\") == False\n assert candidate(s1 = \"adc\",s2 = \"dcda\") == True\n assert candidate(s1 = \"abc\",s2 = \"bbbccba\") == True\n assert candidate(s1 = \"abcde\",s2 = \"adecb\") == True\n assert candi... | [
"\"ab\"\n\"eidbaooo\"",
"\"ab\"\n\"eidboaoo\""
] | [
"Obviously, brute force will result in TLE. Think of something else.",
"How will you check whether one string is a permutation of another string?",
"One way is to sort the string and then compare. But, Is there a better way?",
"If one string is a permutation of another string then they must have one common me... | {
"canonical_parameter_names": [
"s1",
"s2"
],
"leetcode_dataset_entry_point": "Solution().checkInclusion",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:33",
"tests_total": 95,
... | go | {
"raw_signature": "func checkInclusion(s1 string, s2 string) bool {",
"container": null,
"callable": "checkInclusion",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/cod... |
575 | distribute-candies | Easy | Alice has n candies, where the i^th candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor.
The doctor advised Alice to only eat n / 2 of the candies she has (n is always even). Alice likes her candies very much, and she wants to eat the maximum number of different types ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(candyType = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2]) == 3\n assert candidate(candyType = [1, 1, 2, 3]) == 2\n assert candidate(candyType = [1, 1, 1, 2, 2, 2]) == 2\n assert candidate(candyType = [0, 0, 0, 0, 0, 0]) == 1\n assert candi... | [
"[1,1,2,2,3,3]",
"[1,1,2,3]",
"[6,6,6,6]"
] | [
"To maximize the number of kinds of candies, we should try to distribute candies such that Alice will gain all kinds.",
"What is the upper limit of the number of kinds of candies Alice will gain? Remember candies are to distributed equally.",
"Which data structure is the most suitable for finding the number of ... | {
"canonical_parameter_names": [
"candyType"
],
"leetcode_dataset_entry_point": "Solution().distributeCandies",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:42",
"tests_total": 106,
... | go | {
"raw_signature": "func distributeCandies(candyType []int) int {",
"container": null,
"callable": "distributeCandies",
"parameters": [
{
"name": "candyType",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets... |
576 | out-of-boundary-paths | Medium | There is an m x n grid with a ball. The ball is initially at the position [startRow, startColumn]. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply at most maxMove moves to the ball.
Given the five integers m, n, maxMove... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 3,n = 3,maxMove = 1,startRow = 1,startColumn = 1) == 0\n assert candidate(m = 5,n = 5,maxMove = 50,startRow = 0,startColumn = 0) == 101070018\n assert candidate(m = 2,n = 2,maxMove = 2,startRow = 0,startColumn = 0) == 6\n as... | [
"2\n2\n2\n0\n0",
"1\n3\n3\n0\n1"
] | [
"Is traversing every path feasible? There are many possible paths for a small matrix. Try to optimize it.",
"Can we use some space to store the number of paths and update them after every move?",
"One obvious thing: the ball will go out of the boundary only by crossing it. Also, there is only one possible way t... | {
"canonical_parameter_names": [
"m",
"n",
"maxMove",
"startRow",
"startColumn"
],
"leetcode_dataset_entry_point": "Solution().findPaths",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "20... | go | {
"raw_signature": "func findPaths(m int, n int, maxMove int, startRow int, startColumn int) int {",
"container": null,
"callable": "findPaths",
"parameters": [
{
"name": "m",
"type": "int"
},
{
"name": "n",
"type": "int"
},
{
"name": "maxMove",
"type": "i... |
581 | shortest-unsorted-continuous-subarray | Medium | Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.
Return the shortest such subarray and output its length.
Example 1:
Input: nums = [2,6,4,8,10,9,15]
Output: 5
Explanatio... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 2\n assert candidate(nums = [1, 2, 3, 5, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(... | [
"[2,6,4,8,10,9,15]",
"[1,2,3,4]",
"[1]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findUnsortedSubarray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:47",
"tests_total": 158,
"... | go | {
"raw_signature": "func findUnsortedSubarray(nums []int) int {",
"container": null,
"callable": "findUnsortedSubarray",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
583 | delete-operation-for-two-strings | Medium | Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.
In one step, you can delete exactly one character in either string.
Example 1:
Input: word1 = "sea", word2 = "eat"
Output: 2
Explanation: You need one step to make "sea" to "ea" and another step to make "... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(word1 = \"abc\",word2 = \"def\") == 6\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == 10\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 50\n assert candidate(word1... | [
"\"sea\"\n\"eat\"",
"\"leetcode\"\n\"etco\""
] | [] | {
"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:53:52",
"tests_total": 104... | go | {
"raw_signature": "func minDistance(word1 string, word2 string) int {",
"container": null,
"callable": "minDistance",
"parameters": [
{
"name": "word1",
"type": "string"
},
{
"name": "word2",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode... |
587 | erect-the-fence | Hard | You are given an array trees where trees[i] = [x_i, y_i] represents the location of a tree in the garden.
Fence the entire garden using the minimum length of rope, as it is expensive. The garden is well-fenced only if all the trees are enclosed.
Return the coordinates of trees that are exactly located on the fence pe... | {
"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,2],[2,0],[2,4],[3,3],[4,2]]",
"[[1,2],[2,2],[4,2]]"
] | [] | {
"canonical_parameter_names": [
"trees"
],
"leetcode_dataset_entry_point": "Solution().outerTrees",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:54",
"tests_total": 113,
"tests_dro... | go | {
"raw_signature": "func outerTrees(trees [][]int) [][]int {",
"container": null,
"callable": "outerTrees",
"parameters": [
{
"name": "trees",
"type": "[][]int"
}
],
"return_type": "[][]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
591 | tag-validator | Hard | Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.
A code snippet is valid if all the following rules hold:
1. The code must be wrapped in a valid closed tag. Otherwise, the code is invalid.
2. A closed tag (not necessarily valid) has exactly the fo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(code = \"<A>abc</A>\") == True\n assert candidate(code = \"<A><![CDATA[wahaha]]]></A>\") == True\n assert candidate(code = \"<A><B><![CDATA[CDATA]]></B></A>\") == True\n assert candidate(code = \"<A><B></C></B></A>\") == False\n... | [
"\"<DIV>This is the first line <![CDATA[<div>]]></DIV>\"",
"\"<DIV>>> ![cdata[]] <![CDATA[<div>]>]]>]]>>]</DIV>\"",
"\"<A> <B> </A> </B>\""
] | [] | {
"canonical_parameter_names": [
"code"
],
"leetcode_dataset_entry_point": "Solution().isValid",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:56",
"tests_total": 231,
"tests_dropped... | go | {
"raw_signature": "func isValid(code string) bool {",
"container": null,
"callable": "isValid",
"parameters": [
{
"name": "code",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
592 | fraction-addition-and-subtraction | Medium | Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format.
The final result should be an irreducible fraction. If your final result is an integer, change it to the format of a fraction that has a denominator 1. So in this case, 2 should be... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(expression = \"9/10-1/5\") == \"7/10\"\n assert candidate(expression = \"5/6-1/3\") == \"1/2\"\n assert candidate(expression = \"-1/10-2/10-3/10-4/10\") == \"-1/1\"\n assert candidate(expression = \"3/4+1/4-1/2\") == \"1/2\"\n ... | [
"\"-1/2+1/2\"",
"\"-1/2+1/2+1/3\"",
"\"1/3-1/2\""
] | [] | {
"canonical_parameter_names": [
"expression"
],
"leetcode_dataset_entry_point": "Solution().fractionAddition",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:53:58",
"tests_total": 126,
... | go | {
"raw_signature": "func fractionAddition(expression string) string {",
"container": null,
"callable": "fractionAddition",
"parameters": [
{
"name": "expression",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
593 | valid-square | Medium | Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.
The coordinate of a point p_i is represented as [x_i, y_i]. The input is not given in any order.
A valid square has four equal sides with positive length and four equal angles (90-degree angles).
Ex... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(p1 = [-1, -1],p2 = [-1, 1],p3 = [1, 1],p4 = [1, -1]) == True\n assert candidate(p1 = [1, 2],p2 = [3, 4],p3 = [5, 6],p4 = [7, 8]) == False\n assert candidate(p1 = [2, 2],p2 = [3, 3],p3 = [4, 4],p4 = [5, 5]) == False\n assert cand... | [
"[0,0]\n[1,1]\n[1,0]\n[0,1]",
"[0,0]\n[1,1]\n[1,0]\n[0,12]",
"[1,0]\n[-1,0]\n[0,1]\n[0,-1]"
] | [] | {
"canonical_parameter_names": [
"p1",
"p2",
"p3",
"p4"
],
"leetcode_dataset_entry_point": "Solution().validSquare",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:01",
"tes... | go | {
"raw_signature": "func validSquare(p1 []int, p2 []int, p3 []int, p4 []int) bool {",
"container": null,
"callable": "validSquare",
"parameters": [
{
"name": "p1",
"type": "[]int"
},
{
"name": "p2",
"type": "[]int"
},
{
"name": "p3",
"type": "[]int"
},... |
594 | longest-harmonious-subsequence | Easy | We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1.
Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences.
Example 1:
Input: nums = [1,3,2,2,5,2,3,7]
Output: 5
Explanation:
The l... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 6]) == 4\n assert candidate(nums = [-1, 0, -1, 0, -1, 0, -1]) == 7\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 9\n assert candidate... | [
"[1,3,2,2,5,2,3,7]",
"[1,2,3,4]",
"[1,1,1,1]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findLHS",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:03",
"tests_total": 116,
"tests_dropped... | go | {
"raw_signature": "func findLHS(nums []int) int {",
"container": null,
"callable": "findLHS",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
598 | range-addition-ii | Easy | You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [a_i, b_i] means M[x][y] should be incremented by one for all 0 <= x < a_i and 0 <= y < b_i.
Count and return the number of maximum integers in the matrix after performing all the operations.
Example 1:
Input: m =... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 5,n = 4,ops = [[2, 2]]) == 4\n assert candidate(m = 1,n = 1,ops = []) == 1\n assert candidate(m = 2,n = 2,ops = [[2, 2], [1, 1], [2, 2]]) == 1\n assert candidate(m = 1,n = 1,ops = [[1, 1]]) == 1\n assert candidate(m = 4,n... | [
"3\n3\n[[2,2],[3,3]]",
"3\n3\n[[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3],[2,2],[3,3],[3,3],[3,3]]",
"3\n3\n[]"
] | [] | {
"canonical_parameter_names": [
"m",
"n",
"ops"
],
"leetcode_dataset_entry_point": "Solution().maxCount",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:05",
"tests_total": 112... | go | {
"raw_signature": "func maxCount(m int, n int, ops [][]int) int {",
"container": null,
"callable": "maxCount",
"parameters": [
{
"name": "m",
"type": "int"
},
{
"name": "n",
"type": "int"
},
{
"name": "ops",
"type": "[][]int"
}
],
"return_type": "... |
599 | minimum-index-sum-of-two-lists | Easy | Given two arrays of strings list1 and list2, find the common strings with the least index sum.
A common string is a string that appeared in both list1 and list2.
A common string with the least index sum is a common string such that if it appeared at list1[i] and list2[j] then i + j should be the minimum value among a... | {
"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 ... | [
"[\"Shogun\",\"Tapioca Express\",\"Burger King\",\"KFC\"]\n[\"Piatti\",\"The Grill at Torrey Pines\",\"Hungry Hunter Steakhouse\",\"Shogun\"]",
"[\"Shogun\",\"Tapioca Express\",\"Burger King\",\"KFC\"]\n[\"KFC\",\"Shogun\",\"Burger King\"]",
"[\"happy\",\"sad\",\"good\"]\n[\"sad\",\"happy\",\"good\"]"
] | [] | {
"canonical_parameter_names": [
"list1",
"list2"
],
"leetcode_dataset_entry_point": "Solution().findRestaurant",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:08",
"tests_total": ... | go | {
"raw_signature": "func findRestaurant(list1 []string, list2 []string) []string {",
"container": null,
"callable": "findRestaurant",
"parameters": [
{
"name": "list1",
"type": "[]string"
},
{
"name": "list2",
"type": "[]string"
}
],
"return_type": "[]string",
"sign... |
600 | non-negative-integers-without-consecutive-ones | Hard | Given a positive integer n, return the number of the integers in the range [0, n] whose binary representations do not contain consecutive ones.
Example 1:
Input: n = 5
Output: 5
Explanation:
Here are the non-negative integers <= 5 with their corresponding binary representations:
0 : 0
1 : 1
2 : 10
3 : 11
4 : 100
5 : ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 100) == 34\n assert candidate(n = 15) == 8\n assert candidate(n = 1000000) == 17711\n assert candidate(n = 32) == 14\n assert candidate(n = 2) == 3\n assert candidate(n = 1) == 2\n assert candidate(n = 1000000000) =... | [
"5",
"1",
"2"
] | [] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().findIntegers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:10",
"tests_total": 26,
"tests_droppe... | go | {
"raw_signature": "func findIntegers(n int) int {",
"container": null,
"callable": "findIntegers",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
605 | can-place-flowers | Easy | You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.
Given an integer array flowerbed containing 0's and 1's, where 0 means empty and 1 means not empty, and an integer n, return true if n new flowers can be planted in the flowerbed wi... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(flowerbed = [1, 0, 0, 0, 0, 1],n = 2) == False\n assert candidate(flowerbed = [1, 0, 1, 0, 1],n = 0) == True\n assert candidate(flowerbed = [1, 0, 0, 0, 1],n = 1) == True\n assert candidate(flowerbed = [1, 0, 0, 0, 1],n = 2) == ... | [
"[1,0,0,0,1]\n1",
"[1,0,0,0,1]\n2"
] | [] | {
"canonical_parameter_names": [
"flowerbed",
"n"
],
"leetcode_dataset_entry_point": "Solution().canPlaceFlowers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:12",
"tests_total":... | go | {
"raw_signature": "func canPlaceFlowers(flowerbed []int, n int) bool {",
"container": null,
"callable": "canPlaceFlowers",
"parameters": [
{
"name": "flowerbed",
"type": "[]int"
},
{
"name": "n",
"type": "int"
}
],
"return_type": "bool",
"signature_source": "leetco... |
609 | find-duplicate-file-in-system | Medium | Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms of their paths. You may return the answer in any order.
A group of duplicate files consists of at least two files that have the same content.... | {
"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... | [
"[\"root/a 1.txt(abcd) 2.txt(efgh)\",\"root/c 3.txt(abcd)\",\"root/c/d 4.txt(efgh)\",\"root 4.txt(efgh)\"]",
"[\"root/a 1.txt(abcd) 2.txt(efgh)\",\"root/c 3.txt(abcd)\",\"root/c/d 4.txt(efgh)\"]"
] | [] | {
"canonical_parameter_names": [
"paths"
],
"leetcode_dataset_entry_point": "Solution().findDuplicate",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:17",
"tests_total": 83,
"tests_d... | go | {
"raw_signature": "func findDuplicate(paths []string) [][]string {",
"container": null,
"callable": "findDuplicate",
"parameters": [
{
"name": "paths",
"type": "[]string"
}
],
"return_type": "[][]string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
611 | valid-triangle-number | Medium | Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Example 1:
Input: nums = [2,2,3,4]
Output: 3
Explanation: Valid combinations are:
2,3,4 (using the first 2)
2,3,4 (using the second 2)
2,2,3
Example 2:
Input: nums ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 22\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [4, 2, 3, 4]) == 4\n assert candidate(nums = [0, 1, 0, 1]) ==... | [
"[2,2,3,4]",
"[4,2,3,4]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().triangleNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:19",
"tests_total": 115,
"tests_... | go | {
"raw_signature": "func triangleNumber(nums []int) int {",
"container": null,
"callable": "triangleNumber",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
621 | task-scheduler | Medium | You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n. Each CPU interval can be idle or allow the completion of one task. Tasks can be completed in any order, but there's a constraint: there has to be a gap of at least n intervals between two tasks with the same label.
Return the ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(tasks = ['A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'D', 'D', 'D'],n = 3) == 13\n assert candidate(tasks = ['A', 'B', 'C', 'D'],n = 0) == 4\n assert candidate(tasks = ['A', 'B', 'C', 'D', 'E', 'F', 'G'],n = 2) == 7\n assert ca... | [
"[\"A\",\"A\",\"A\",\"B\",\"B\",\"B\"]\n2",
"[\"A\",\"C\",\"A\",\"B\",\"D\",\"B\"]\n1",
"[\"A\",\"A\",\"A\", \"B\",\"B\",\"B\"]\n3"
] | [
"There are many different solutions for this problem, including a greedy algorithm.",
"For every cycle, find the most frequent letter that can be placed in this cycle. After placing, decrease the frequency of that letter by one.",
"Use Priority Queue."
] | {
"canonical_parameter_names": [
"tasks",
"n"
],
"leetcode_dataset_entry_point": "Solution().leastInterval",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:26",
"tests_total": 86,
... | go | {
"raw_signature": "func leastInterval(tasks []byte, n int) int {",
"container": null,
"callable": "leastInterval",
"parameters": [
{
"name": "tasks",
"type": "[]byte"
},
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnipp... |
624 | maximum-distance-in-arrays | Medium | You are given m arrays, where each array is sorted in ascending order.
You can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a - b|.
Return the maximum distance.
Example 1:
Input:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arrays = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 7\n assert candidate(arrays = [[1, 2, 3], [4, 5], [1, 2, 3]]) == 4\n assert candidate(arrays = [[1, 3, 5], [2, 4, 6], [0, 7, 9]]) == 8\n assert candidate(arrays = [[-10000, 10000], [... | [
"[[1,2,3],[4,5],[1,2,3]]",
"[[1],[1]]"
] | [] | {
"canonical_parameter_names": [
"arrays"
],
"leetcode_dataset_entry_point": "Solution().maxDistance",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:31",
"tests_total": 100,
"tests_d... | go | {
"raw_signature": "func maxDistance(arrays [][]int) int {",
"container": null,
"callable": "maxDistance",
"parameters": [
{
"name": "arrays",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
628 | maximum-product-of-three-numbers | Easy | You are given an integer array nums.
Find three numbers whose product is maximum and return the maximum product.
Example 1:
Input: nums = [1,2,3]
Output: 6
Explanation:
The only three numbers are 1, 2, and 3, so the maximum product is 1 * 2 * 3 = 6.
Example 2:
Input: nums = [1,2,3,4]
Output: 24
Explanation:
The la... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-10, -10, 5, 2]) == 500\n assert candidate(nums = [1, 2, 3, 4]) == 24\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 99]) == 99\n assert candidate(nums = [0, 2, 3, 5]) == 30\n assert candidate(nums = [0, 2, 3, -1, 5]) =... | [
"[1,2,3]",
"[1,2,3,4]",
"[-1,-2,-3]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().maximumProduct",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:35",
"tests_total": 111,
"tests_... | go | {
"raw_signature": "func maximumProduct(nums []int) int {",
"container": null,
"callable": "maximumProduct",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
629 | k-inverse-pairs-array | Hard | For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j].
Given two integers n and k, return the number of different arrays consisting of numbers from 1 to n such that there are exactly k inverse pairs. Since the answer can be huge, return it modulo 1... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1000,k = 500) == 955735232\n assert candidate(n = 100,k = 0) == 1\n assert candidate(n = 20,k = 50) == 788876615\n assert candidate(n = 1000,k = 0) == 1\n assert candidate(n = 10,k = 10) == 21670\n assert candidate(n =... | [
"3\n0",
"3\n1"
] | [] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().kInversePairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:38",
"tests_total": 80,
"te... | go | {
"raw_signature": "func kInversePairs(n int, k int) int {",
"container": null,
"callable": "kInversePairs",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_... |
630 | course-schedule-iii | Hard | There are n different online courses numbered from 1 to n. You are given an array courses where courses[i] = [duration_i, lastDay_i] indicate that the i^th course should be taken continuously for duration_i days and must be finished before or on lastDay_i.
You will start on the 1^st day and you cannot take two or more... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(courses = [[7, 17], [3, 12], [10, 20], [9, 10], [11, 15], [11, 16], [8, 13], [11, 17], [4, 11], [2, 12]]) == 4\n assert candidate(courses = [[100, 200], [200, 1300], [1000, 1250], [300, 3100]]) == 4\n assert candidate(courses = [[1... | [
"[[100,200],[200,1300],[1000,1250],[2000,3200]]",
"[[1,2]]",
"[[3,2],[4,3]]"
] | [
"During iteration, say I want to add the current course, currentTotalTime being total time of all courses taken till now, but adding the current course might exceed my deadline or it doesn’t. 1. If it doesn’t, then I have added one new course. Increment the currentTotalTime with duration of current course.",
"2. ... | {
"canonical_parameter_names": [
"courses"
],
"leetcode_dataset_entry_point": "Solution().scheduleCourse",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:40",
"tests_total": 130,
"tes... | go | {
"raw_signature": "func scheduleCourse(courses [][]int) int {",
"container": null,
"callable": "scheduleCourse",
"parameters": [
{
"name": "courses",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
632 | smallest-range-covering-elements-from-k-lists | Hard | You have k lists of sorted integers in non-decreasing order. Find the smallest range that includes at least one number from each of the k lists.
We define the range [a, b] is smaller than range [c, d] if b - a < d - c or a < c if b - a == d - c.
Example 1:
Input: nums = [[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]
Out... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [[-10, -5, -3, -1], [0, 2, 4, 6], [5, 10, 15, 20]]) == [-1, 5]\n assert candidate(nums = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]) == [1, 1]\n assert candidate(nums = [[1, 5, 9], [2, 6, 10], [3, 7, 11]]) == [1, 3]\n assert candi... | [
"[[4,10,15,24,26],[0,9,12,20],[5,18,22,30]]",
"[[1,2,3],[1,2,3],[1,2,3]]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().smallestRange",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:42",
"tests_total": 97,
"tests_dr... | go | {
"raw_signature": "func smallestRange(nums [][]int) []int {",
"container": null,
"callable": "smallestRange",
"parameters": [
{
"name": "nums",
"type": "[][]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
633 | sum-of-square-numbers | Medium | Given a non-negative integer c, decide whether there're two integers a and b such that a^2 + b^2 = c.
Example 1:
Input: c = 5
Output: true
Explanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: c = 3
Output: false
Constraints:
- 0 <= c <= 2^31 - 1
| {
"language": "python",
"source": "def check(candidate):\n assert candidate(c = 0) == True\n assert candidate(c = 1000000001) == False\n assert candidate(c = 25) == True\n assert candidate(c = 2) == True\n assert candidate(c = 3) == False\n assert candidate(c = 5) == True\n assert candidate(c =... | [
"5",
"3"
] | [] | {
"canonical_parameter_names": [
"c"
],
"leetcode_dataset_entry_point": "Solution().judgeSquareSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:45",
"tests_total": 52,
"tests_drop... | go | {
"raw_signature": "func judgeSquareSum(c int) bool {",
"container": null,
"callable": "judgeSquareSum",
"parameters": [
{
"name": "c",
"type": "int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
636 | exclusive-time-of-functions | Medium | On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n - 1.
Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its ID is popped off the stack. The function whose ID is at t... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,logs = ['0:start:0', '0:end:1']) == [2]\n assert candidate(n = 4,logs = ['0:start:0', '1:start:1', '2:start:2', '2:end:3', '1:end:4', '0:end:5', '3:start:6', '3:end:7']) == [2, 2, 2, 2]\n assert candidate(n = 4,logs = ['0:sta... | [
"2\n[\"0:start:0\",\"1:start:2\",\"1:end:5\",\"0:end:6\"]",
"1\n[\"0:start:0\",\"0:start:2\",\"0:end:5\",\"0:start:6\",\"0:end:6\",\"0:end:7\"]",
"2\n[\"0:start:0\",\"0:start:2\",\"0:end:5\",\"1:start:6\",\"1:end:6\",\"0:end:7\"]"
] | [] | {
"canonical_parameter_names": [
"n",
"logs"
],
"leetcode_dataset_entry_point": "Solution().exclusiveTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:49",
"tests_total": 69,
... | go | {
"raw_signature": "func exclusiveTime(n int, logs []string) []int {",
"container": null,
"callable": "exclusiveTime",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "logs",
"type": "[]string"
}
],
"return_type": "[]int",
"signature_source": "leetcode/cod... |
638 | shopping-offers | Medium | In LeetCode Store, there are n items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds of items with a sale price.
You are given an integer array price where price[i] is the price of the i^th item, and an integer array needs where needs[... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(price = [10, 10, 10],special = [[3, 1, 0, 10], [1, 2, 1, 15]],needs = [2, 2, 1]) == 25\n assert candidate(price = [4, 10, 1, 1, 1],special = [[1, 1, 1, 1, 1, 7]],needs = [4, 10, 1, 1, 1]) == 109\n assert candidate(price = [10, 10, ... | [
"[2,5]\n[[3,0,5],[1,2,10]]\n[3,2]",
"[2,3,4]\n[[1,1,0,4],[2,2,1,9]]\n[1,2,1]"
] | [] | {
"canonical_parameter_names": [
"price",
"special",
"needs"
],
"leetcode_dataset_entry_point": "Solution().shoppingOffers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:54",
... | go | {
"raw_signature": "func shoppingOffers(price []int, special [][]int, needs []int) int {",
"container": null,
"callable": "shoppingOffers",
"parameters": [
{
"name": "price",
"type": "[]int"
},
{
"name": "special",
"type": "[][]int"
},
{
"name": "needs",
"... |
639 | decode-ways-ii | Hard | A message containing letters from A-Z can be encoded into numbers using the following mapping:
'A' -> "1"
'B' -> "2"
...
'Z' -> "26"
To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"*1*2*3*4*5*6*7*8*9*\") == 554657727\n assert candidate(s = \"26\") == 2\n assert candidate(s = \"2*\") == 15\n assert candidate(s = \"11106\") == 2\n assert candidate(s = \"210\") == 1\n assert candidate(s = \"******... | [
"\"*\"",
"\"1*\"",
"\"2*\""
] | [] | {
"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:54:56",
"tests_total": 157,
"tests_dropp... | go | {
"raw_signature": "func numDecodings(s string) int {",
"container": null,
"callable": "numDecodings",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
640 | solve-the-equation | Medium | Solve a given equation and return the value of 'x' in the form of a string "x=#value". The equation contains only '+', '-' operation, the variable 'x' and its coefficient. You should return "No solution" if there is no solution for the equation, or "Infinite solutions" if there are infinite solutions for the equation.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(equation = \"-x=x\") == \"x=0\"\n assert candidate(equation = \"0x=0\") == \"Infinite solutions\"\n assert candidate(equation = \"x+3x=4x\") == \"Infinite solutions\"\n assert candidate(equation = \"2x+3=3x+1\") == \"x=2\"\n ... | [
"\"x+5-3+x=6+x-2\"",
"\"x=x\"",
"\"2x=x\""
] | [] | {
"canonical_parameter_names": [
"equation"
],
"leetcode_dataset_entry_point": "Solution().solveEquation",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:54:58",
"tests_total": 253,
"tes... | go | {
"raw_signature": "func solveEquation(equation string) string {",
"container": null,
"callable": "solveEquation",
"parameters": [
{
"name": "equation",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
643 | maximum-average-subarray-i | Easy | You are given an integer array nums consisting of n elements, and an integer k.
Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answer with a calculation error less than 10^-5 will be accepted.
Example 1:
Input: nums = [1,12,-5,-6,50,3], k = 4
Outpu... | {
"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,12,-5,-6,50,3]\n4",
"[5]\n1"
] | [] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().findMaxAverage",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:01",
"tests_total": 95,
... | go | {
"raw_signature": "func findMaxAverage(nums []int, k int) float64 {",
"container": null,
"callable": "findMaxAverage",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "float64",
"signature_source": "leetcode/cod... |
645 | set-mismatch | Easy | You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which results in repetition of one number and loss of another number.
You are given an integer array nums representing the data sta... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [3, 1, 2, 5, 3]) == [3, 4]\n assert candidate(nums = [10, 2, 8, 2, 5, 3, 9, 1, 4, 7]) == [2, 6]\n assert candidate(nums = [9, 1, 8, 5, 6, 7, 9, 2, 4]) == [9, 3]\n assert candidate(nums = [1, 2, 4, 6, 6]) == [6, 2]\n as... | [
"[1,2,2,4]",
"[1,1]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findErrorNums",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:05",
"tests_total": 89,
"tests_dr... | go | {
"raw_signature": "func findErrorNums(nums []int) []int {",
"container": null,
"callable": "findErrorNums",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
646 | maximum-length-of-pair-chain | Medium | You are given an array of n pairs pairs where pairs[i] = [left_i, right_i] and left_i < right_i.
A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion.
Return the length longest chain which can be formed.
You do not need to use up all the given intervals. You can sele... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(pairs = [[1, 20], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == 5\n assert candidate(pairs = [[-10, -5], [-3, -1], [0, 2], [5, 6]]) == 4\n assert candidate(pairs = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 5\n assert candida... | [
"[[1,2],[2,3],[3,4]]",
"[[1,2],[7,8],[4,5]]"
] | [] | {
"canonical_parameter_names": [
"pairs"
],
"leetcode_dataset_entry_point": "Solution().findLongestChain",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:08",
"tests_total": 106,
"tes... | go | {
"raw_signature": "func findLongestChain(pairs [][]int) int {",
"container": null,
"callable": "findLongestChain",
"parameters": [
{
"name": "pairs",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
647 | palindromic-substrings | Medium | Given a string s, return the number of palindromic substrings in it.
A string is a palindrome when it reads the same backward as forward.
A substring is a contiguous sequence of characters within the string.
Example 1:
Input: s = "abc"
Output: 3
Explanation: Three palindromic strings: "a", "b", "c".
Example 2:
In... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abba\") == 6\n assert candidate(s = \"aaaaa\") == 15\n assert candidate(s = \"babad\") == 7\n assert candidate(s = \"noon\") == 6\n assert candidate(s = \"banana\") == 10\n assert candidate(s = \"aabbbaa\") == 14\n ... | [
"\"abc\"",
"\"aaa\""
] | [
"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().countSubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:10",
"tests_total": 140,
"tests_dr... | go | {
"raw_signature": "func countSubstrings(s string) int {",
"container": null,
"callable": "countSubstrings",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
648 | replace-words | Medium | In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For example, when the root "help" is followed by the word "ful", we can form a derivative "helpful".
Given a dictionary consisting of many roots and a sentence consisting o... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(dictionary = ['a', 'aa', 'aaa'],sentence = \"aaaa aaa aa a\") == \"a a a a\"\n assert candidate(dictionary = ['base', 'bat', 'ba'],sentence = \"baseball batman bat\") == \"ba ba ba\"\n assert candidate(dictionary = ['dog', 'cat'],s... | [
"[\"cat\",\"bat\",\"rat\"]\n\"the cattle was rattled by the battery\"",
"[\"a\",\"b\",\"c\"]\n\"aadsfasf absbs bbab cadsfafs\""
] | [] | {
"canonical_parameter_names": [
"dictionary",
"sentence"
],
"leetcode_dataset_entry_point": "Solution().replaceWords",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:12",
"tests_to... | go | {
"raw_signature": "func replaceWords(dictionary []string, sentence string) string {",
"container": null,
"callable": "replaceWords",
"parameters": [
{
"name": "dictionary",
"type": "[]string"
},
{
"name": "sentence",
"type": "string"
}
],
"return_type": "string",
"... |
649 | dota2-senate | Medium | In the world of Dota2, there are two parties: the Radiant and the Dire.
The Dota2 senate consists of senators coming from two parties. Now the Senate wants to decide on a change in the Dota2 game. The voting for this change is a round-based procedure. In each round, each senator can exercise one of the two rights:
- ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(senate = \"RDDRDR\") == \"Dire\"\n assert candidate(senate = \"RDD\") == \"Dire\"\n assert candidate(senate = \"DRDR\") == \"Dire\"\n assert candidate(senate = \"RDDRRD\") == \"Radiant\"\n assert candidate(senate = \"RDRDRDRD... | [
"\"RD\"",
"\"RDD\""
] | [] | {
"canonical_parameter_names": [
"senate"
],
"leetcode_dataset_entry_point": "Solution().predictPartyVictory",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:14",
"tests_total": 177,
... | go | {
"raw_signature": "func predictPartyVictory(senate string) string {",
"container": null,
"callable": "predictPartyVictory",
"parameters": [
{
"name": "senate",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSn... |
650 | 2-keys-keyboard | Medium | There is only one character 'A' on the screen of a notepad. You can perform one of two operations on this notepad for each step:
- Copy All: You can copy all the characters present on the screen (a partial copy is not allowed).
- Paste: You can paste the characters which are copied last time.
Given an integer n, retu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == 3\n assert candidate(n = 12) == 7\n assert candidate(n = 100) == 14\n assert candidate(n = 10) == 7\n assert candidate(n = 1000) == 21\n assert candidate(n = 5) == 5\n assert candidate(n = 4) == 4\n assert ... | [
"3",
"1"
] | [
"How many characters may be there in the clipboard at the last step if n = 3? n = 7? n = 10? n = 24?"
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().minSteps",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:17",
"tests_total": 65,
"tests_dropped": ... | go | {
"raw_signature": "func minSteps(n int) int {",
"container": null,
"callable": "minSteps",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
657 | robot-return-to-origin | Easy | There is a robot starting at the position (0, 0), the origin, on a 2D plane. Given a sequence of its moves, judge if this robot ends up at (0, 0) after it completes its moves.
You are given a string moves that represents the move sequence of the robot where moves[i] represents its i^th move. Valid moves are 'R' (right... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(moves = \"LULLDDRRUURRDDLL\") == False\n assert candidate(moves = \"UUUUUUUUUUDDDDDDDDDDLLLLRRRR\") == True\n assert candidate(moves = \"UDLR\") == True\n assert candidate(moves = \"UUDDRRLL\") == True\n assert candidate(move... | [
"\"UD\"",
"\"LL\""
] | [] | {
"canonical_parameter_names": [
"moves"
],
"leetcode_dataset_entry_point": "Solution().judgeCircle",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:30",
"tests_total": 112,
"tests_dr... | go | {
"raw_signature": "func judgeCircle(moves string) bool {",
"container": null,
"callable": "judgeCircle",
"parameters": [
{
"name": "moves",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
658 | find-k-closest-elements | Medium | Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.
An integer a is closer to x than an integer b if:
- |a - x| < |b - x|, or
- |a - x| == |b - x| and a < b
Example 1:
Input: arr = [1,2,3,4,5], k = 4, x = 3
Out... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(arr = [1, 3, 5, 7, 9],k = 4,x = 6) == [3, 5, 7, 9]\n assert candidate(arr = [1, 3, 5, 7, 9],k = 2,x = 6) == [5, 7]\n assert candidate(arr = [1, 3, 5, 7, 9],k = 1,x = 6) == [5]\n assert candidate(arr = [1, 3, 5, 7, 9],k = 5,x = 6... | [
"[1,2,3,4,5]\n4\n3",
"[1,1,2,3,4,5]\n4\n-1"
] | [] | {
"canonical_parameter_names": [
"arr",
"k",
"x"
],
"leetcode_dataset_entry_point": "Solution().findClosestElements",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:33",
"tests_... | go | {
"raw_signature": "func findClosestElements(arr []int, k int, x int) []int {",
"container": null,
"callable": "findClosestElements",
"parameters": [
{
"name": "arr",
"type": "[]int"
},
{
"name": "k",
"type": "int"
},
{
"name": "x",
"type": "int"
}
]... |
659 | split-array-into-consecutive-subsequences | Medium | You are given an integer array nums that is sorted in non-decreasing order.
Determine if it is possible to split nums into one or more subsequences such that both of the following conditions are true:
- Each subsequence is a consecutive increasing sequence (i.e. each integer is exactly one more than the previous inte... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5]) == False\n assert candidate(nums = ... | [
"[1,2,3,3,4,5]",
"[1,2,3,3,4,4,5,5]",
"[1,2,3,4,4,5]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().isPossible",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:35",
"tests_total": 123,
"tests_drop... | go | {
"raw_signature": "func isPossible(nums []int) bool {",
"container": null,
"callable": "isPossible",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
661 | image-smoother | Easy | An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If one or more of the surrounding cells of a cell is not present, we do not consider it in the... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(img = [[100, 200, 100], [200, 50, 200], [100, 200, 100]]) == [[137, 141, 137], [141, 138, 141], [137, 141, 137]]\n assert candidate(img = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [[30, 35, 40], [45, 50, 55], [60, 65, 70]]\n a... | [
"[[1,1,1],[1,0,1],[1,1,1]]",
"[[100,200,100],[200,50,200],[100,200,100]]"
] | [] | {
"canonical_parameter_names": [
"img"
],
"leetcode_dataset_entry_point": "Solution().imageSmoother",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:39",
"tests_total": 81,
"tests_dro... | go | {
"raw_signature": "func imageSmoother(img [][]int) [][]int {",
"container": null,
"callable": "imageSmoother",
"parameters": [
{
"name": "img",
"type": "[][]int"
}
],
"return_type": "[][]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
664 | strange-printer | Hard | There is a strange printer with the following two special properties:
- The printer can only print a sequence of the same character each time.
- At each turn, the printer can print new characters starting from and ending at any place and will cover the original existing characters.
Given a string s, return the minimu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"pppppppp\") == 1\n assert candidate(s = \"abcba\") == 3\n assert candidate(s = \"aabbaa\") == 2\n assert candidate(s = \"zzzzy\") == 2\n assert candidate(s = \"abababab\") == 5\n assert candidate(s = \"ppqpqr\") == 4... | [
"\"aaabbb\"",
"\"aba\""
] | [] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().strangePrinter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:46",
"tests_total": 102,
"tests_dro... | go | {
"raw_signature": "func strangePrinter(s string) int {",
"container": null,
"callable": "strangePrinter",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
665 | non-decreasing-array | Medium | Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.
We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2).
Example 1:
Input: nums = [4,2,3]
Output: true
Explanation: You could m... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 5, 4, 6]) == True\n assert candidate(nums = [10, 5, 7]) == True\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 5, 4]) == True\n assert candidate(nums = [1, 1, 1]) == True\... | [
"[4,2,3]",
"[4,2,1]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().checkPossibility",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:49",
"tests_total": 165,
"test... | go | {
"raw_signature": "func checkPossibility(nums []int) bool {",
"container": null,
"callable": "checkPossibility",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
667 | beautiful-arrangement-ii | Medium | Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement:
- Suppose this list is answer = [a_1, a_2, a_3, ... , a_n], then the list [|a_1 - a_2|, |a_2 - a_3|, |a_3 - a_4|, ... , |a_{n-1} - a_n|] has exactly k distinct intege... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3,k = 1) == [1, 2, 3]\n assert candidate(n = 7,k = 4) == [1, 7, 2, 6, 5, 4, 3]\n assert candidate(n = 10,k = 5) == [1, 10, 2, 9, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 5,k = 2) == [1, 5, 4, 3, 2]\n assert candidate(n = ... | [
"3\n1",
"3\n2"
] | [] | {
"canonical_parameter_names": [
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().constructArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:53",
"tests_total": 71,
"t... | go | {
"raw_signature": "func constructArray(n int, k int) []int {",
"container": null,
"callable": "constructArray",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
... |
668 | kth-smallest-number-in-multiplication-table | Hard | Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed).
Given three integers m, n, and k, return the k^th smallest element in the m x n multiplication table.
Example 1:
Input: m = 3, n = 3, k = 5
Output: 3
Explanation: T... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(m = 3,n = 3,k = 5) == 3\n assert candidate(m = 10,n = 10,k = 25) == 10\n assert candidate(m = 5,n = 5,k = 1) == 1\n assert candidate(m = 4,n = 4,k = 10) == 6\n assert candidate(m = 4,n = 4,k = 8) == 4\n assert candidate(m ... | [
"3\n3\n5",
"2\n3\n6"
] | [] | {
"canonical_parameter_names": [
"m",
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().findKthNumber",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:55:55",
"tests_total": ... | go | {
"raw_signature": "func findKthNumber(m int, n int, k int) int {",
"container": null,
"callable": "findKthNumber",
"parameters": [
{
"name": "m",
"type": "int"
},
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "in... |
670 | maximum-swap | Medium | You are given an integer num. You can swap two digits at most once to get the maximum valued number.
Return the maximum valued number you can get.
Example 1:
Input: num = 2736
Output: 7236
Explanation: Swap the number 2 and the number 7.
Example 2:
Input: num = 9973
Output: 9973
Explanation: No swap.
Constraints:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(num = 9) == 9\n assert candidate(num = 12) == 21\n assert candidate(num = 21) == 21\n assert candidate(num = 0) == 0\n assert candidate(num = 98368) == 98863\n assert candidate(num = 11111) == 11111\n assert candidate(n... | [
"2736",
"9973"
] | [] | {
"canonical_parameter_names": [
"num"
],
"leetcode_dataset_entry_point": "Solution().maximumSwap",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:00",
"tests_total": 119,
"tests_drop... | go | {
"raw_signature": "func maximumSwap(num int) int {",
"container": null,
"callable": "maximumSwap",
"parameters": [
{
"name": "num",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
672 | bulb-switcher-ii | Medium | There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall. Each of the four buttons has a different functionality where:
- Button 1: Flips the status of all the bulbs.
- Button 2: Flips the status of all the bulbs with even labels (i.e., 2, 4, ...).
- Button 3: Fli... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 1,presses = 1) == 2\n assert candidate(n = 5,presses = 3) == 8\n assert candidate(n = 1000,presses = 1000) == 8\n assert candidate(n = 4,presses = 2) == 7\n assert candidate(n = 2,presses = 1) == 3\n assert candidate(n... | [
"1\n1",
"2\n1",
"3\n1"
] | [] | {
"canonical_parameter_names": [
"n",
"presses"
],
"leetcode_dataset_entry_point": "Solution().flipLights",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:04",
"tests_total": 90,
... | go | {
"raw_signature": "func flipLights(n int, presses int) int {",
"container": null,
"callable": "flipLights",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "presses",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
... |
673 | number-of-longest-increasing-subsequence | Medium | Given an integer array nums, return the number of longest increasing subsequences.
Notice that the sequence has to be strictly increasing.
Example 1:
Input: nums = [1,3,5,4,7]
Output: 2
Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7].
Example 2:
Input: nums = [2,2,2,2,2]
Outp... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 2, 4, 3, 5, 4, 7, 2]) == 3\n assert candidate(nums = [1, 2]) == 1\n asser... | [
"[1,3,5,4,7]",
"[2,2,2,2,2]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findNumberOfLIS",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:07",
"tests_total": 109,
"tests... | go | {
"raw_signature": "func findNumberOfLIS(nums []int) int {",
"container": null,
"callable": "findNumberOfLIS",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
674 | longest-continuous-increasing-subsequence | Easy | Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e. subarray). The subsequence must be strictly increasing.
A continuous increasing subsequence is defined by two indices l and r (l < r) such that it is [nums[l], nums[l + 1], ..., nums[r - 1], nums[r]] and ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 4, 5, 6, 7, 8, 12]) == 6\n assert candidate(nums = [0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101,... | [
"[1,3,5,4,7]",
"[2,2,2,2,2]"
] | [] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findLengthOfLCIS",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:09",
"tests_total": 134,
"test... | go | {
"raw_signature": "func findLengthOfLCIS(nums []int) int {",
"container": null,
"callable": "findLengthOfLCIS",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
675 | cut-off-trees-for-golf-event | Hard | You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix:
- 0 means the cell cannot be walked through.
- 1 represents an empty cell that can be walked through.
- A number greater than 1 represents a tree in a cell that can be walked through, and ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(forest = [[1, 2, 3, 4], [0, 0, 0, 0], [5, 6, 7, 8], [9, 10, 11, 12]]) == -1\n assert candidate(forest = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(forest = [[1, 2, 3], [0, 0, 4], [7, 6, 5]]) == 6\n asser... | [
"[[1,2,3],[0,0,4],[7,6,5]]",
"[[1,2,3],[0,0,0],[7,6,5]]",
"[[2,3,4],[0,0,5],[8,7,6]]"
] | [] | {
"canonical_parameter_names": [
"forest"
],
"leetcode_dataset_entry_point": "Solution().cutOffTree",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:11",
"tests_total": 99,
"tests_dro... | go | {
"raw_signature": "func cutOffTree(forest [][]int) int {",
"container": null,
"callable": "cutOffTree",
"parameters": [
{
"name": "forest",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
678 | valid-parenthesis-string | Medium | Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.
The following rules define a valid string:
- Any left parenthesis '(' must have a corresponding right parenthesis ')'.
- Any right parenthesis ')' must have a corresponding left parenthesis '('.
- Left parenthesis... | {
"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 = \"****\") == True\n assert candidate(s = \"(()****)\") == True\n assert candidate(s ... | [
"\"()\"",
"\"(*)\"",
"\"(*))\"",
"\"(\""
] | [
"Use backtracking to explore all possible combinations of treating '*' as either '(', ')', or an empty string. If any combination leads to a valid string, return true.",
"DP[i][j] represents whether the substring s[i:j] is valid.",
"Keep track of the count of open parentheses encountered so far. If you encounte... | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().checkValidString",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:13",
"tests_total": 181,
"tests_d... | go | {
"raw_signature": "func checkValidString(s string) bool {",
"container": null,
"callable": "checkValidString",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
679 | 24-game | Hard | You are given an integer array cards of length 4. You have four cards, each containing a number in the range [1, 9]. You should arrange the numbers on these cards in a mathematical expression using the operators ['+', '-', '*', '/'] and the parentheses '(' and ')' to get the value 24.
You are restricted with the follo... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cards = [9, 9, 9, 9]) == False\n assert candidate(cards = [2, 8, 1, 4]) == True\n assert candidate(cards = [4, 4, 7, 7]) == True\n assert candidate(cards = [1, 3, 4, 6]) == True\n assert candidate(cards = [9, 5, 5, 1]) == Tru... | [
"[4,1,8,7]",
"[1,2,1,2]"
] | [] | {
"canonical_parameter_names": [
"cards"
],
"leetcode_dataset_entry_point": "Solution().judgePoint24",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:15",
"tests_total": 109,
"tests_d... | go | {
"raw_signature": "func judgePoint24(cards []int) bool {",
"container": null,
"callable": "judgePoint24",
"parameters": [
{
"name": "cards",
"type": "[]int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
680 | valid-palindrome-ii | Easy | Given a string s, return true if the s can be palindrome after deleting at most one character from it.
Example 1:
Input: s = "aba"
Output: true
Example 2:
Input: s = "abca"
Output: true
Explanation: You could delete the character 'c'.
Example 3:
Input: s = "abc"
Output: false
Constraints:
- 1 <= s.length <= 10^... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"raceecar\") == True\n assert candidate(s = \"abcba\") == True\n assert candidate(s = \"deeee\") == True\n assert candidate(s = \"ab\") == True\n assert candidate(s = \"abc\") == False\n assert candidate(s = \"racecar... | [
"\"aba\"",
"\"abca\"",
"\"abc\""
] | [] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().validPalindrome",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:17",
"tests_total": 108,
"tests_dr... | go | {
"raw_signature": "func validPalindrome(s string) bool {",
"container": null,
"callable": "validPalindrome",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
682 | baseball-game | Easy | You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record.
You are given a list of strings operations, where operations[i] is the i^th operation you must apply to the record and is one of the following:
- An integer x.
- Record a new score of x.
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(operations = ['3', 'D', '+', '2', 'C', '+', '+', 'C', 'C', 'C']) == 9\n assert candidate(operations = ['10', '20', '30', 'D', '+']) == 210\n assert candidate(operations = ['3', '6', '+', 'D', 'C', '3', 'D', '+', '-2', 'D', '9', '+'... | [
"[\"5\",\"2\",\"C\",\"D\",\"+\"]",
"[\"5\",\"-2\",\"4\",\"C\",\"D\",\"9\",\"+\",\"+\"]",
"[\"1\",\"C\"]"
] | [] | {
"canonical_parameter_names": [
"operations"
],
"leetcode_dataset_entry_point": "Solution().calPoints",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:22",
"tests_total": 76,
"tests_... | go | {
"raw_signature": "func calPoints(operations []string) int {",
"container": null,
"callable": "calPoints",
"parameters": [
{
"name": "operations",
"type": "[]string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
684 | redundant-connection | Medium | In this problem, a tree is an undirected graph that is connected and has no cycles.
You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edge added. The added edge has two different vertices chosen from 1 to n, and was not an edge that already existed. The graph is represe... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[3, 4], [1, 2], [2, 4], [3, 5], [2, 5]]) == [2, 5]\n assert candidate(edges = [[1, 2], [2, 3], [1, 3]]) == [1, 3]\n assert candidate(edges = [[1, 4], [3, 4], [1, 3], [1, 2], [4, 5]]) == [1, 3]\n assert candidate(edges =... | [
"[[1,2],[1,3],[2,3]]",
"[[1,2],[2,3],[3,4],[1,4],[1,5]]"
] | [] | {
"canonical_parameter_names": [
"edges"
],
"leetcode_dataset_entry_point": "Solution().findRedundantConnection",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:26",
"tests_total": 76,
... | go | {
"raw_signature": "func findRedundantConnection(edges [][]int) []int {",
"container": null,
"callable": "findRedundantConnection",
"parameters": [
{
"name": "edges",
"type": "[][]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/... |
685 | redundant-connection-ii | Hard | In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents.
The given input is a directed graph that started as a rooted tree with n node... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(edges = [[3, 1], [4, 1], [5, 2], [3, 2], [3, 5]]) == [3, 1]\n assert candidate(edges = [[1, 2], [2, 3], [3, 1]]) == [3, 1]\n assert candidate(edges = [[3, 1], [4, 1], [5, 2], [3, 5], [4, 2]]) == [4, 1]\n assert candidate(edges =... | [
"[[1,2],[1,3],[2,3]]",
"[[1,2],[2,3],[3,4],[4,1],[1,5]]"
] | [] | {
"canonical_parameter_names": [
"edges"
],
"leetcode_dataset_entry_point": "Solution().findRedundantDirectedConnection",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:29",
"tests_tota... | go | {
"raw_signature": "func findRedundantDirectedConnection(edges [][]int) []int {",
"container": null,
"callable": "findRedundantDirectedConnection",
"parameters": [
{
"name": "edges",
"type": "[][]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_sou... |
686 | repeated-string-match | Medium | Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible for b to be a substring of a after repeating it, return -1.
Notice: string "abc" repeated 0 times is "", repeated 1 time is "abc" and repeated 2 times is "abcabc".
Exampl... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(a = \"abab\",b = \"abababab\") == 2\n assert candidate(a = \"ab\",b = \"aba\") == 2\n assert candidate(a = \"abc\",b = \"def\") == -1\n assert candidate(a = \"abc\",b = \"abcabc\") == 2\n assert candidate(a = \"aaaaaaaaaaaaaa... | [
"\"abcd\"\n\"cdabcdab\"",
"\"a\"\n\"aa\""
] | [] | {
"canonical_parameter_names": [
"a",
"b"
],
"leetcode_dataset_entry_point": "Solution().repeatedStringMatch",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:31",
"tests_total": 144... | go | {
"raw_signature": "func repeatedStringMatch(a string, b string) int {",
"container": null,
"callable": "repeatedStringMatch",
"parameters": [
{
"name": "a",
"type": "string"
},
{
"name": "b",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode... |
688 | knight-probability-in-chessboard | Medium | On an n x n chessboard, a knight starts at the cell (row, column) and attempts to make exactly k moves. The rows and columns are 0-indexed, so the top-left cell is (0, 0), and the bottom-right cell is (n - 1, n - 1).
A chess knight has eight possible moves it can make, as illustrated below. Each move is two cells in a... | {
"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... | [
"3\n2\n0\n0",
"1\n0\n0\n0"
] | [] | {
"canonical_parameter_names": [
"n",
"k",
"row",
"column"
],
"leetcode_dataset_entry_point": "Solution().knightProbability",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:35... | go | {
"raw_signature": "func knightProbability(n int, k int, row int, column int) float64 {",
"container": null,
"callable": "knightProbability",
"parameters": [
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
},
{
"name": "row",
"type": "int"
... |
689 | maximum-sum-of-3-non-overlapping-subarrays | Hard | Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them.
Return the result as a list of indices representing the starting position of each interval (0-indexed). If there are multiple answers, return the lexicographically smallest one.
Example 1:
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 2) == [0, 2, 4]\n assert candidate(nums = [1, 2, 1, 2, 6, 7, 5, 1, 9, 7, 4, 6],k = 3) == [3, 6, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ... | [
"[1,2,1,2,6,7,5,1]\n2",
"[1,2,1,2,1,2,1,2,1]\n2"
] | [] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().maxSumOfThreeSubarrays",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:37",
"tests_total... | go | {
"raw_signature": "func maxSumOfThreeSubarrays(nums []int, k int) []int {",
"container": null,
"callable": "maxSumOfThreeSubarrays",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "[]int",
"signature_source": "... |
691 | stickers-to-spell-word | Hard | We are given n different types of stickers. Each sticker has a lowercase English word on it.
You would like to spell out the given string target by cutting individual letters from your collection of stickers and rearranging them. You can use each sticker more than once if you want, and you have infinite quantities of ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(stickers = ['aaa', 'bbb'],target = \"aabbbccc\") == -1\n assert candidate(stickers = ['a', 'b', 'c'],target = \"abc\") == 3\n assert candidate(stickers = ['abc', 'abc'],target = \"abcabc\") == 2\n assert candidate(stickers = ['a... | [
"[\"with\",\"example\",\"science\"]\n\"thehat\"",
"[\"notice\",\"possible\"]\n\"basicbasic\""
] | [
"We want to perform an exhaustive search, but we need to speed it up based on the input data being random. For all stickers, we can ignore any letters that are not in the target word. When our candidate answer won't be smaller than an answer we have already found, we can stop searching this path. When a sticker dom... | {
"canonical_parameter_names": [
"stickers",
"target"
],
"leetcode_dataset_entry_point": "Solution().minStickers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:39",
"tests_total":... | go | {
"raw_signature": "func minStickers(stickers []string, target string) int {",
"container": null,
"callable": "minStickers",
"parameters": [
{
"name": "stickers",
"type": "[]string"
},
{
"name": "target",
"type": "string"
}
],
"return_type": "int",
"signature_source... |
692 | top-k-frequent-words | Medium | Given an array of strings words and an integer k, return the k most frequent strings.
Return the answer sorted by the frequency from highest to lowest. Sort the words with the same frequency by their lexicographical order.
Example 1:
Input: words = ["i","love","leetcode","i","love","coding"], k = 2
Output: ["i","lov... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['a', 'aa', 'aaa'],k = 1) == ['a']\n assert candidate(words = ['a', 'aa', 'aaa'],k = 2) == ['a', 'aa']\n assert candidate(words = ['i', 'love', 'leetcode', 'i', 'love', 'coding'],k = 2) == ['i', 'love']\n assert candidat... | [
"[\"i\",\"love\",\"leetcode\",\"i\",\"love\",\"coding\"]\n2",
"[\"the\",\"day\",\"is\",\"sunny\",\"the\",\"the\",\"the\",\"sunny\",\"is\",\"is\"]\n4"
] | [] | {
"canonical_parameter_names": [
"words",
"k"
],
"leetcode_dataset_entry_point": "Solution().topKFrequent",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:42",
"tests_total": 92,
... | go | {
"raw_signature": "func topKFrequent(words []string, k int) []string {",
"container": null,
"callable": "topKFrequent",
"parameters": [
{
"name": "words",
"type": "[]string"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "[]string",
"signature_source": "leetco... |
693 | binary-number-with-alternating-bits | Easy | Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
Example 1:
Input: n = 5
Output: true
Explanation: The binary representation of 5 is: 101
Example 2:
Input: n = 7
Output: false
Explanation: The binary representation of 7 is: 111.
Exampl... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 3) == False\n assert candidate(n = 11) == False\n assert candidate(n = 15) == False\n assert candidate(n = 2) == True\n assert candidate(n = 1) == True\n assert candidate(n = 7) == False\n assert candidate(n = 10) =... | [
"5",
"7",
"11"
] | [] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().hasAlternatingBits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:44",
"tests_total": 72,
"tests_... | go | {
"raw_signature": "func hasAlternatingBits(n int) bool {",
"container": null,
"callable": "hasAlternatingBits",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
695 | max-area-of-island | Medium | You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
The area of an island is the number of cells with a value 1 in the island.
Return the maximum area of an isl... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0,... | [
"[[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]]",
"[[0,0,0,0,0,0,0,0]]"
] | [] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().maxAreaOfIsland",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:48",
"tests_total": 59,
"tests_... | go | {
"raw_signature": "func maxAreaOfIsland(grid [][]int) int {",
"container": null,
"callable": "maxAreaOfIsland",
"parameters": [
{
"name": "grid",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
696 | count-binary-substrings | Easy | Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.
Substrings that occur multiple times are counted the number of times they occur.
Example 1:
Input: s = "00110011"
Output: 6
Expla... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"000111000111\") == 9\n assert candidate(s = \"01\") == 1\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"00110011\") == 6\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"10101\") =... | [
"\"00110011\"",
"\"10101\""
] | [
"How many valid binary substrings exist in \"000111\", and how many in \"11100\"? What about \"00011100\"?"
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countBinarySubstrings",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:50",
"tests_total": 158,
"te... | go | {
"raw_signature": "func countBinarySubstrings(s string) int {",
"container": null,
"callable": "countBinarySubstrings",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
697 | degree-of-an-array | Easy | Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.
Your task is to find the smallest possible length of a (contiguous) subarray of nums, that has the same degree as nums.
Example 1:
Input: nums = [1,2,2,3,1]
Output: 2
Explan... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 2, 2, 3, 1]) == 2\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 2\n assert candidate... | [
"[1,2,2,3,1]",
"[1,2,2,3,1,4,2]"
] | [
"Say 5 is the only element that occurs the most number of times - for example, nums = [1, 5, 2, 3, 5, 4, 5, 6]. What is the answer?"
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().findShortestSubArray",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:53",
"tests_total": 93,
"t... | go | {
"raw_signature": "func findShortestSubArray(nums []int) int {",
"container": null,
"callable": "findShortestSubArray",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
698 | partition-to-k-equal-sum-subsets | Medium | Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.
Example 1:
Input: nums = [4,3,2,3,5,2,1], k = 4
Output: true
Explanation: It is possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.
Example 2... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 3, 4, 5],k = 4) == False\n assert candidate(nums = [4, 4, 6, 2, 3, 8, 10, 2, 10, 7],k = 4) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(nums = [1, 2, 3, 4],k = ... | [
"[4,3,2,3,5,2,1]\n4",
"[1,2,3,4]\n3"
] | [
"We can figure out what target each subset must sum to. Then, let's recursively search, where at each call to our function, we choose which of k subsets the next value will join."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().canPartitionKSubsets",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:56",
"tests_total":... | go | {
"raw_signature": "func canPartitionKSubsets(nums []int, k int) bool {",
"container": null,
"callable": "canPartitionKSubsets",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "bool",
"signature_source": "leetco... |
699 | falling-squares | Hard | There are several squares being dropped onto the X-axis of a 2D plane.
You are given a 2D integer array positions where positions[i] = [left_i, sideLength_i] represents the i^th square with a side length of sideLength_i that is dropped with its left edge aligned with X-coordinate left_i.
Each square is dropped one at... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(positions = [[4, 1], [2, 2], [1, 3], [3, 4]]) == [1, 2, 5, 9]\n assert candidate(positions = [[1, 5], [2, 2], [7, 3]]) == [5, 7, 7]\n assert candidate(positions = [[1, 3], [3, 2], [5, 1]]) == [3, 5, 5]\n assert candidate(positio... | [
"[[1,2],[2,3],[6,1]]",
"[[100,100],[200,100]]"
] | [
"If positions = [[10, 20], [20, 30]], this is the same as [[1, 2], [2, 3]]. Currently, the values of positions are very large. Can you generalize this approach so as to make the values in positions manageable?"
] | {
"canonical_parameter_names": [
"positions"
],
"leetcode_dataset_entry_point": "Solution().fallingSquares",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:56:58",
"tests_total": 105,
"t... | go | {
"raw_signature": "func fallingSquares(positions [][]int) []int {",
"container": null,
"callable": "fallingSquares",
"parameters": [
{
"name": "positions",
"type": "[][]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippe... |
704 | binary-search | Easy | Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.
You must write an algorithm with O(log n) runtime complexity.
Example 1:
Input: nums = [-1,0,3,5,9,12], target = 9
Outpu... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [-10, 0, 10, 20, 30],target = -5) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],target = 6) == -1\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],target = 0) == -1\n assert candidate(nums = [1, 2, 3,... | [
"[-1,0,3,5,9,12]\n9",
"[-1,0,3,5,9,12]\n2"
] | [] | {
"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:57:04",
"tests_total": 115,
"... | go | {
"raw_signature": "func search(nums []int, target int) int {",
"container": null,
"callable": "search",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "target",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
... |
712 | minimum-ascii-delete-sum-for-two-strings | Medium | Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.
Example 1:
Input: s1 = "sea", s2 = "eat"
Output: 231
Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
Deleting "t" from "eat" adds 116 to the sum.
At the end, both strings are eq... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s1 = \"delete\",s2 = \"leet\") == 403\n assert candidate(s1 = \"aaa\",s2 = \"aa\") == 97\n assert candidate(s1 = \"abc\",s2 = \"abcde\") == 201\n assert candidate(s1 = \"abc\",s2 = \"def\") == 597\n assert candidate(s1 = \"pq... | [
"\"sea\"\n\"eat\"",
"\"delete\"\n\"leet\""
] | [
"Let dp(i, j) be the answer for inputs s1[i:] and s2[j:]."
] | {
"canonical_parameter_names": [
"s1",
"s2"
],
"leetcode_dataset_entry_point": "Solution().minimumDeleteSum",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:11",
"tests_total": 115,... | go | {
"raw_signature": "func minimumDeleteSum(s1 string, s2 string) int {",
"container": null,
"callable": "minimumDeleteSum",
"parameters": [
{
"name": "s1",
"type": "string"
},
{
"name": "s2",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/c... |
713 | subarray-product-less-than-k | Medium | You are given an array of integers nums and an integer k.
Return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.
Example 1:
Input: nums = [10,5,2,6], k = 100
Output: 8
Explanation: The 8 subarrays that have product less than 100 are:
[10], [5], [2], [... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [10, 2, 5, 6, 1],k = 100) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 100) == 21\n assert candidate(nums = [6, 5, 1, 2, 3],k = 10... | [
"[686, 28, 455, 675, 605, 29, 942, 48, 502, 889, 854, 206, 231, 796, 272, 565, 887, 969, 558, 13, 22, 455, 145, 804, 15]\n515854",
"[542, 433, 935, 193, 280, 849, 122, 107, 688, 913, 31, 311, 814, 507, 596, 109, 340, 981, 662, 145, 955, 692, 659, 46, 276, 734, 177, 727, 329, 320, 93, 78, 451, 129, 226, 491, 595, ... | [
"For each j, let opt(j) be the smallest i so that nums[i] * nums[i+1] * ... * nums[j] is less than k. opt is an increasing function."
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().numSubarrayProductLessThanK",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:13",
"tests_... | go | {
"raw_signature": "func numSubarrayProductLessThanK(nums []int, k int) int {",
"container": null,
"callable": "numSubarrayProductLessThanK",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_sour... |
714 | best-time-to-buy-and-sell-stock-with-transaction-fee | Medium | You are given an array prices where prices[i] is the price of a given stock on the i^th day, and an integer fee representing a transaction fee.
Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.
Note:
- You may not... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(prices = [10, 20, 30, 40, 50],fee = 5) == 35\n assert candidate(prices = [1, 3, 2, 8, 4, 9],fee = 2) == 8\n assert candidate(prices = [1, 2, 3, 4, 5],fee = 1) == 3\n assert candidate(prices = [50, 40, 30, 20, 10],fee = 5) == 0\n... | [
"[1,3,2,8,4,9]\n2",
"[1,3,7,5,10,3]\n3"
] | [
"Consider the first K stock prices. At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases."
] | {
"canonical_parameter_names": [
"prices",
"fee"
],
"leetcode_dataset_entry_point": "Solution().maxProfit",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:15",
"tests_total": 107,
... | go | {
"raw_signature": "func maxProfit(prices []int, fee int) int {",
"container": null,
"callable": "maxProfit",
"parameters": [
{
"name": "prices",
"type": "[]int"
},
{
"name": "fee",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets"... |
717 | 1-bit-and-2-bit-characters | Easy | We have two special characters:
- The first character can be represented by one bit 0.
- The second character can be represented by two bits (10 or 11).
Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
Example 1:
Input: bits = [1,0,0]
Output: true
Explanatio... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(bits = [1, 1, 1, 0]) == False\n assert candidate(bits = [0, 0, 0, 0]) == True\n assert candidate(bits = [1, 0, 1, 1, 0]) == True\n assert candidate(bits = [0]) == True\n assert candidate(bits = [1, 1, 1, 1, 0]) == True\n a... | [
"[1,0,0]",
"[1,1,1,0]"
] | [
"Keep track of where the next character starts. At the end, you want to know if you started on the last bit."
] | {
"canonical_parameter_names": [
"bits"
],
"leetcode_dataset_entry_point": "Solution().isOneBitCharacter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:18",
"tests_total": 95,
"test... | go | {
"raw_signature": "func isOneBitCharacter(bits []int) bool {",
"container": null,
"callable": "isOneBitCharacter",
"parameters": [
{
"name": "bits",
"type": "[]int"
}
],
"return_type": "bool",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
718 | maximum-length-of-repeated-subarray | Medium | Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.
Example 1:
Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7]
Output: 3
Explanation: The repeated subarray with maximum length is [3,2,1].
Example 2:
Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0]
Output: 5
... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3, 2, 1],nums2 = [3, 2, 1, 4, 7]) == 3\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 1\n assert candidate(nums1 = [1, 0, 0, 0, 1],nums2 = [1, 0, 0, 0, 1]) == 5\n assert candidate(nums1 = [1],nums2 = [... | [
"[1,2,3,2,1]\n[3,2,1,4,7]",
"[0,0,0,0,0]\n[0,0,0,0,0]"
] | [
"Use dynamic programming. dp[i][j] will be the longest common prefix of A[i:] and B[j:].",
"The answer is max(dp[i][j]) over all i, j."
] | {
"canonical_parameter_names": [
"nums1",
"nums2"
],
"leetcode_dataset_entry_point": "Solution().findLength",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:20",
"tests_total": 110,... | go | {
"raw_signature": "func findLength(nums1 []int, nums2 []int) int {",
"container": null,
"callable": "findLength",
"parameters": [
{
"name": "nums1",
"type": "[]int"
},
{
"name": "nums2",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeS... |
719 | find-k-th-smallest-pair-distance | Hard | The distance of a pair of integers a and b is defined as the absolute difference between a and b.
Given an integer array nums and an integer k, return the k^th smallest distance among all the pairs nums[i] and nums[j] where 0 <= i < j < nums.length.
Example 1:
Input: nums = [1,3,1], k = 1
Output: 0
Explanation: Here... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 4\n assert candidate(nums = [9, 10, 7, 10, 6, 1, 5, 4, 9, 8],k = 18) == 2\n assert candidate(nums = [62, 24, 6, 4, 40],k = 2) == 16\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 1\n ass... | [
"[1,3,1]\n1",
"[1,1,1]\n2",
"[1,6,1]\n3"
] | [
"Binary search for the answer. How can you check how many pairs have distance <= X?"
] | {
"canonical_parameter_names": [
"nums",
"k"
],
"leetcode_dataset_entry_point": "Solution().smallestDistancePair",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:22",
"tests_total":... | go | {
"raw_signature": "func smallestDistancePair(nums []int, k int) int {",
"container": null,
"callable": "smallestDistancePair",
"parameters": [
{
"name": "nums",
"type": "[]int"
},
{
"name": "k",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode... |
720 | longest-word-in-dictionary | Medium | Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words.
If there is more than one possible answer, return the longest word with the smallest lexicographical order. If there is no answer, return the empty str... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == \"abcdefgh\"\n assert candidate(words = ['a', 'b', 'c']) == \"a\"\n assert candidate(words = ['w', 'wo', 'wor', 'worl', 'world']) == \"world\"\n as... | [
"[\"w\",\"wo\",\"wor\",\"worl\",\"world\"]",
"[\"a\",\"banana\",\"app\",\"appl\",\"ap\",\"apply\",\"apple\"]"
] | [
"For every word in the input list, we can check whether all prefixes of that word are in the input list by using a Set."
] | {
"canonical_parameter_names": [
"words"
],
"leetcode_dataset_entry_point": "Solution().longestWord",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:24",
"tests_total": 116,
"tests_dr... | go | {
"raw_signature": "func longestWord(words []string) string {",
"container": null,
"callable": "longestWord",
"parameters": [
{
"name": "words",
"type": "[]string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
721 | accounts-merge | Medium | Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.
Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some comm... | {
"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 ... | [
"[[\"John\",\"johnsmith@mail.com\",\"john_newyork@mail.com\"],[\"John\",\"johnsmith@mail.com\",\"john00@mail.com\"],[\"Mary\",\"mary@mail.com\"],[\"John\",\"johnnybravo@mail.com\"]]",
"[[\"Gabe\",\"Gabe0@m.co\",\"Gabe3@m.co\",\"Gabe1@m.co\"],[\"Kevin\",\"Kevin3@m.co\",\"Kevin5@m.co\",\"Kevin0@m.co\"],[\"Ethan\",\... | [
"For every pair of emails in the same account, draw an edge between those emails. The problem is about enumerating the connected components of this graph."
] | {
"canonical_parameter_names": [
"accounts"
],
"leetcode_dataset_entry_point": "Solution().accountsMerge",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:26",
"tests_total": 85,
"test... | go | {
"raw_signature": "func accountsMerge(accounts [][]string) [][]string {",
"container": null,
"callable": "accountsMerge",
"parameters": [
{
"name": "accounts",
"type": "[][]string"
}
],
"return_type": "[][]string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcod... |
722 | remove-comments | Medium | Given a C++ program, remove comments from it. The program source is an array of strings source where source[i] is the i^th line of the source code. This represents the result of splitting the original source code string by the newline character '\n'.
In C++, there are two types of comments, line comments, and block co... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(source = ['/* This is a comment // with a line comment inside the block comment */', 'int x = 10;', 'cout << \"Hello World\";', '}']) == ['int x = 10;', 'cout << \"Hello World\";', '}']\n assert candidate(source = ['int main() {', ' ... | [
"[\"/*Test program */\", \"int main()\", \"{ \", \" // variable declaration \", \"int a, b, c;\", \"/* This is a test\", \" multiline \", \" comment for \", \" testing */\", \"a = b + c;\", \"}\"]",
"[\"a/*comment\", \"line\", \"more_comment*/b\"]"
] | [
"Carefully parse each line according to the following rules: * If we start a block comment and we aren't in a block, then we will skip over the next two characters and change our state to be in a block. * If we end a block comment and we are in a block, then we will skip over the next two characters and change our ... | {
"canonical_parameter_names": [
"source"
],
"leetcode_dataset_entry_point": "Solution().removeComments",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:28",
"tests_total": 102,
"test... | go | {
"raw_signature": "func removeComments(source []string) []string {",
"container": null,
"callable": "removeComments",
"parameters": [
{
"name": "source",
"type": "[]string"
}
],
"return_type": "[]string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
724 | find-pivot-index | Easy | Given an array of integers nums, calculate the pivot index of this array.
The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right.
If the index is on the left edge of the array, then the left sum is 0 because ... | {
"language": "python",
"source": "def check(candidate):\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, 10]) == -1\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums ... | [
"[1,7,3,6,5,6]",
"[1,2,3]",
"[2,1,-1]"
] | [
"Create an array sumLeft where sumLeft[i] is the sum of all the numbers to the left of index i.",
"Create an array sumRight where sumRight[i] is the sum of all the numbers to the right of index i.",
"For each index i, check if sumLeft[i] equals sumRight[i]. If so, return i. If no such i is found, return -1."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().pivotIndex",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:33",
"tests_total": 95,
"tests_dropp... | go | {
"raw_signature": "func pivotIndex(nums []int) int {",
"container": null,
"callable": "pivotIndex",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
726 | number-of-atoms | Hard | Given a string formula representing a chemical formula, return the count of each atom.
The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.
One or more digits representing that element's count may follow if the count is greater than 1. If the count ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(formula = \"(NH4)3PO4\") == \"H12N3O4P\"\n assert candidate(formula = \"(NH4)2SO4\") == \"H8N2O4S\"\n assert candidate(formula = \"Be32(Al2(SiO3)4)3\") == \"Al6Be32O36Si12\"\n assert candidate(formula = \"Mg(OH)2\") == \"H2MgO2\... | [
"\"H2O\"",
"\"Mg(OH)2\"",
"\"K4(ON(SO3)2)2\""
] | [
"To parse formula[i:], when we see a `'('`, we will parse recursively whatever is inside the brackets (up to the correct closing ending bracket) and add it to our count, multiplying by the following multiplicity if there is one. Otherwise, we should see an uppercase character: we will parse the rest of the letters ... | {
"canonical_parameter_names": [
"formula"
],
"leetcode_dataset_entry_point": "Solution().countOfAtoms",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:35",
"tests_total": 173,
"tests... | go | {
"raw_signature": "func countOfAtoms(formula string) string {",
"container": null,
"callable": "countOfAtoms",
"parameters": [
{
"name": "formula",
"type": "string"
}
],
"return_type": "string",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
728 | self-dividing-numbers | Easy | A self-dividing number is a number that is divisible by every digit it contains.
- For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
A self-dividing number is not allowed to contain the digit zero.
Given two integers left and right, return a list of all the self-dividin... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(left = 120,right = 130) == [122, 124, 126, 128]\n assert candidate(left = 47,right = 85) == [48, 55, 66, 77]\n assert candidate(left = 1,right = 100) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88... | [
"1\n22",
"47\n85"
] | [
"For each number in the range, check whether it is self dividing by converting that number to a character array (or string in Python), then checking that each digit is nonzero and divides the original number."
] | {
"canonical_parameter_names": [
"left",
"right"
],
"leetcode_dataset_entry_point": "Solution().selfDividingNumbers",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:39",
"tests_tota... | go | {
"raw_signature": "func selfDividingNumbers(left int, right int) []int {",
"container": null,
"callable": "selfDividingNumbers",
"parameters": [
{
"name": "left",
"type": "int"
},
{
"name": "right",
"type": "int"
}
],
"return_type": "[]int",
"signature_source": "le... |
730 | count-different-palindromic-subsequences | Hard | Given a string s, return the number of different non-empty palindromic subsequences in s. Since the answer may be very large, return it modulo 10^9 + 7.
A subsequence of a string is obtained by deleting zero or more characters from the string.
A sequence is palindromic if it is equal to the sequence reversed.
Two se... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(s = \"abba\") == 6\n assert candidate(s = \"abccba\") == 14\n assert candidate(s = \"abcba\") == 10\n assert candidate(s = \"abac\") == 5\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd... | [
"\"bccb\"",
"\"abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba\""
] | [
"Let dp(i, j) be the answer for the string T = S[i:j+1] including the empty sequence. The answer is the number of unique characters in T, plus palindromes of the form \"a_a\", \"b_b\", \"c_c\", and \"d_d\", where \"_\" represents zero or more characters."
] | {
"canonical_parameter_names": [
"s"
],
"leetcode_dataset_entry_point": "Solution().countPalindromicSubsequences",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:42",
"tests_total": 79,... | go | {
"raw_signature": "func countPalindromicSubsequences(s string) int {",
"container": null,
"callable": "countPalindromicSubsequences",
"parameters": [
{
"name": "s",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/code... |
733 | flood-fill | Easy | You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. Your task is to perform a flood fill on the image starting from the pixel image[sr][sc].
To perform a flood fill:
1. Begin with the sta... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(image = [[0, 0, 0], [0, 0, 0]],sr = 0,sc = 0,color = 0) == [[0, 0, 0], [0, 0, 0]]\n assert candidate(image = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],sr = 0,sc = 0,color = 3) == [[3, 3, 3], [3, 3, 3], [3, 3, 3]]\n assert candidate(image =... | [
"[[1,1,1],[1,1,0],[1,0,1]]\n1\n1\n2",
"[[0,0,0],[0,0,0]]\n0\n0\n0"
] | [
"Write a recursive function that paints the pixel if it's the correct color, then recurses on neighboring pixels."
] | {
"canonical_parameter_names": [
"image",
"sr",
"sc",
"color"
],
"leetcode_dataset_entry_point": "Solution().floodFill",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:44",
... | go | {
"raw_signature": "func floodFill(image [][]int, sr int, sc int, color int) [][]int {",
"container": null,
"callable": "floodFill",
"parameters": [
{
"name": "image",
"type": "[][]int"
},
{
"name": "sr",
"type": "int"
},
{
"name": "sc",
"type": "int"
... |
735 | asteroid-collision | Medium | We are given an array asteroids of integers representing asteroids in a row. The indices of the asteroid in the array represent their relative position in space.
For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each astero... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(asteroids = [1, -1, 2, -2, 3, -3]) == []\n assert candidate(asteroids = [8, -8]) == []\n assert candidate(asteroids = [-2, -2, 1, 1]) == [-2, -2, 1, 1]\n assert candidate(asteroids = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == [1, 2... | [
"[5,10,-5]",
"[8,-8]",
"[10,2,-5]",
"[3,5,-6,2,-1,4]"
] | [
"Say a row of asteroids is stable. What happens when a new asteroid is added on the right?"
] | {
"canonical_parameter_names": [
"asteroids"
],
"leetcode_dataset_entry_point": "Solution().asteroidCollision",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:48",
"tests_total": 123,
... | go | {
"raw_signature": "func asteroidCollision(asteroids []int) []int {",
"container": null,
"callable": "asteroidCollision",
"parameters": [
{
"name": "asteroids",
"type": "[]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnip... |
736 | parse-lisp-expression | Hard | You are given a string expression representing a Lisp-like expression to return the integer value of.
The syntax for these expressions is given as follows.
- An expression is either an integer, let expression, add expression, mult expression, or an assigned variable. Expressions always evaluate to a single integer.
-... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(expression = \"(let x 2 (mult x (let x 3 y 4 (add x y))))\") == 14\n assert candidate(expression = \"(let x 7 (let y 2 (let z 3 (mult x (add y z)))))\") == 35\n assert candidate(expression = \"(mult (let x 2 (mult 3 x)) (let x 2 (a... | [
"\"(let x 2 (mult x (let x 3 y 4 (add x y))))\"",
"\"(let x 3 x 2 x)\"",
"\"(let x 1 y 2 x (add x y) (add x y))\""
] | [
"* If the expression starts with a digit or '-', it's an integer: return it. * If the expression starts with a letter, it's a variable. Recall it by checking the current scope in reverse order. * Otherwise, group the tokens (variables or expressions) within this expression by counting the \"balance\" `bal` of the o... | {
"canonical_parameter_names": [
"expression"
],
"leetcode_dataset_entry_point": "Solution().evaluate",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:50",
"tests_total": 111,
"tests_... | go | {
"raw_signature": "func evaluate(expression string) int {",
"container": null,
"callable": "evaluate",
"parameters": [
{
"name": "expression",
"type": "string"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
738 | monotone-increasing-digits | Medium | An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.
Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits.
Example 1:
Input: n = 10
Output: 9
Example 2:
Input: n = 1234
Output: 1234
Example 3:
Input:... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(n = 999999999) == 999999999\n assert candidate(n = 111) == 111\n assert candidate(n = 100) == 99\n assert candidate(n = 1000) == 999\n assert candidate(n = 222) == 222\n assert candidate(n = 333) == 333\n assert candida... | [
"10",
"1234",
"332"
] | [
"Build the answer digit by digit, adding the largest possible one that would make the number still less than or equal to N."
] | {
"canonical_parameter_names": [
"n"
],
"leetcode_dataset_entry_point": "Solution().monotoneIncreasingDigits",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:55",
"tests_total": 111,
... | go | {
"raw_signature": "func monotoneIncreasingDigits(n int) int {",
"container": null,
"callable": "monotoneIncreasingDigits",
"parameters": [
{
"name": "n",
"type": "int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
739 | daily-temperatures | Medium | Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the i^th day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.
Example 1:
Input: temperatures... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(temperatures = [80, 79, 78, 77, 76, 75, 74, 73]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(temperatures = [73, 74, 75, 71, 69, 72, 76, 73]) == [1, 1, 4, 2, 1, 1, 0, 0]\n assert candidate(temperatures = [40, 39, 38, 37, 36, 35,... | [
"[73,74,75,71,69,72,76,73]",
"[30,40,50,60]",
"[30,60,90]"
] | [
"If the temperature is say, 70 today, then in the future a warmer temperature must be either 71, 72, 73, ..., 99, or 100. We could remember when all of them occur next."
] | {
"canonical_parameter_names": [
"temperatures"
],
"leetcode_dataset_entry_point": "Solution().dailyTemperatures",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:57",
"tests_total": 107... | go | {
"raw_signature": "func dailyTemperatures(temperatures []int) []int {",
"container": null,
"callable": "dailyTemperatures",
"parameters": [
{
"name": "temperatures",
"type": "[]int"
}
],
"return_type": "[]int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/co... |
740 | delete-and-earn | Medium | You are given an integer array nums. You want to maximize the number of points you get by performing the following operation any number of times:
- Pick any nums[i] and delete it to earn nums[i] points. Afterwards, you must delete every element equal to nums[i] - 1 and every element equal to nums[i] + 1.
Return the m... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [2, 3, 5, 8, 13, 21]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 60\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums = [2, 2, ... | [
"[3,4,2]",
"[2,2,3,3,3,4]"
] | [
"If you take a number, you might as well take them all. Keep track of what the value is of the subset of the input with maximum M when you either take or don't take M."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().deleteAndEarn",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:57:59",
"tests_total": 115,
"tests_d... | go | {
"raw_signature": "func deleteAndEarn(nums []int) int {",
"container": null,
"callable": "deleteAndEarn",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
741 | cherry-pickup | Hard | You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.
- 0 means the cell is empty, so you can pass through,
- 1 means the cell contains a cherry that you can pick up and pass through, or
- -1 means the cell contains a thorn that blocks your way.
Return the maximum ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(grid = [[0, 1, -1], [1, 0, -1], [1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 1]]) == 12\n ... | [
"[[0,1,-1],[1,0,-1],[1,1,1]]",
"[[1,1,-1],[1,-1,1],[-1,1,1]]"
] | [] | {
"canonical_parameter_names": [
"grid"
],
"leetcode_dataset_entry_point": "Solution().cherryPickup",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:02",
"tests_total": 77,
"tests_dro... | go | {
"raw_signature": "func cherryPickup(grid [][]int) int {",
"container": null,
"callable": "cherryPickup",
"parameters": [
{
"name": "grid",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
743 | network-delay-time | Medium | You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (u_i, v_i, w_i), where u_i is the source node, v_i is the target node, and w_i is the time it takes for a signal to travel from source to target.
We will send a signal from a given nod... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(times = [[1, 2, 10], [2, 3, 10], [1, 3, 1]],n = 3,k = 1) == 10\n assert candidate(times = [[1, 2, 1]],n = 2,k = 1) == 1\n assert candidate(times = [[1, 2, 1], [2, 3, 2], [1, 3, 4]],n = 3,k = 1) == 3\n assert candidate(times = [[... | [
"[[2,1,1],[2,3,1],[3,4,1]]\n4\n2",
"[[1,2,1]]\n2\n1",
"[[1,2,1]]\n2\n2"
] | [
"We visit each node at some time, and if that time is better than the fastest time we've reached this node, we travel along outgoing edges in sorted order. Alternatively, we could use Dijkstra's algorithm."
] | {
"canonical_parameter_names": [
"times",
"n",
"k"
],
"leetcode_dataset_entry_point": "Solution().networkDelayTime",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:06",
"tests_t... | go | {
"raw_signature": "func networkDelayTime(times [][]int, n int, k int) int {",
"container": null,
"callable": "networkDelayTime",
"parameters": [
{
"name": "times",
"type": "[][]int"
},
{
"name": "n",
"type": "int"
},
{
"name": "k",
"type": "int"
}
]... |
744 | find-smallest-letter-greater-than-target | Easy | You are given an array of characters letters that is sorted in non-decreasing order, and a character target. There are at least two different characters in letters.
Return the smallest character in letters that is lexicographically greater than target. If such a character does not exist, return the first character in ... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],target = \"d\") == \"e\"\n assert candidate(letters = ['c', 'f', 'j'],target = \"c\") == \"f\"\n assert candidate(letters = ['x', 'x', 'y', 'y'],target = \"z\") == \"x\"\... | [
"[\"c\",\"f\",\"j\"]\n\"a\"",
"[\"c\",\"f\",\"j\"]\n\"c\"",
"[\"x\",\"x\",\"y\",\"y\"]\n\"z\""
] | [
"Try to find whether each of 26 next letters are in the given string array."
] | {
"canonical_parameter_names": [
"letters",
"target"
],
"leetcode_dataset_entry_point": "Solution().nextGreatestLetter",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:08",
"tests_t... | go | {
"raw_signature": "func nextGreatestLetter(letters []byte, target byte) byte {",
"container": null,
"callable": "nextGreatestLetter",
"parameters": [
{
"name": "letters",
"type": "[]byte"
},
{
"name": "target",
"type": "byte"
}
],
"return_type": "byte",
"signature_... |
746 | min-cost-climbing-stairs | Easy | You are given an integer array cost where cost[i] is the cost of i^th step on a staircase.
Once you pay the cost, you can either climb one or two steps.
You can either start from the step with index 0, or the step with index 1.
Return the minimum cost to reach the top of the staircase, which is the position just pas... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(cost = [999, 999, 999, 999]) == 1998\n assert candidate(cost = [1, 2, 3, 4, 5]) == 6\n assert candidate(cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]) == 6\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n asse... | [
"[10,15,20]",
"[1,100,1,1,1,100,1,1,100,1]"
] | [
"Build an array dp where dp[i] is the minimum cost to climb to the top starting from the ith staircase.",
"Assuming we have n staircase labeled from 0 to n - 1 and assuming the top is n, then dp[n] = 0, marking that if you are at the top, the cost is 0.",
"Now, looping from n - 1 to 0, the dp[i] = cost[i] + min... | {
"canonical_parameter_names": [
"cost"
],
"leetcode_dataset_entry_point": "Solution().minCostClimbingStairs",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:11",
"tests_total": 102,
... | go | {
"raw_signature": "func minCostClimbingStairs(cost []int) int {",
"container": null,
"callable": "minCostClimbingStairs",
"parameters": [
{
"name": "cost",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
... |
747 | largest-number-at-least-twice-of-others | Easy | You are given an integer array nums where the largest integer is unique.
Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.
Example 1:
Input: nums = [3,6,1,0]
Output: 1
Explanation... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 6]) == 3\n assert candidate(nums = [3, 6, 1, 0]) == 1\n assert candidate(nums = [7, 1, 3, 2]) == 0\n assert candidate(nums = [10, 1, 2, 3]) == 0\n assert candidate(nums = [100, 1, 2, 3]) == 0\n assert cand... | [
"[3,6,1,0]",
"[1,2,3,4]"
] | [
"Scan through the array to find the unique largest element `m`, keeping track of it's index `maxIndex`. Scan through the array again. If we find some `x != m` with `m < 2*x`, we should return `-1`. Otherwise, we should return `maxIndex`."
] | {
"canonical_parameter_names": [
"nums"
],
"leetcode_dataset_entry_point": "Solution().dominantIndex",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:13",
"tests_total": 142,
"tests_d... | go | {
"raw_signature": "func dominantIndex(nums []int) int {",
"container": null,
"callable": "dominantIndex",
"parameters": [
{
"name": "nums",
"type": "[]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
748 | shortest-completing-word | Easy | Given a string licensePlate and an array of strings words, find the shortest completing word in words.
A completing word is a word that contains all the letters in licensePlate. Ignore numbers and spaces in licensePlate, and treat letters as case insensitive. If a letter appears more than once in licensePlate, then it... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(licensePlate = \"GrC8950\",words = ['grace', 'please']) == \"grace\"\n assert candidate(licensePlate = \"Ah71752\",words = ['enough', 'these', 'playground', 'point', 'president']) == None\n assert candidate(licensePlate = \"xyz\",w... | [
"\"1s3 PSt\"\n[\"step\",\"steps\",\"stripe\",\"stepple\"]",
"\"1s3 456\"\n[\"looks\",\"pest\",\"stew\",\"show\"]"
] | [
"Count only the letters (possibly converted to lowercase) of each word. If a word is shorter and the count of each letter is at least the count of that letter in the licensePlate, it is the best answer we've seen yet."
] | {
"canonical_parameter_names": [
"licensePlate",
"words"
],
"leetcode_dataset_entry_point": "Solution().shortestCompletingWord",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:15",
... | go | {
"raw_signature": "func shortestCompletingWord(licensePlate string, words []string) string {",
"container": null,
"callable": "shortestCompletingWord",
"parameters": [
{
"name": "licensePlate",
"type": "string"
},
{
"name": "words",
"type": "[]string"
}
],
"return_ty... |
749 | contain-virus | Hard | A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.
The world is modeled as an m x n binary grid isInfected, where isInfected[i][j] == 0 represents uninfected cells, and isInfected[i][j] == 1 represents cells contaminated with the virus. A wall (and only one wall) can be... | {
"language": "python",
"source": "def check(candidate):\n assert candidate(isInfected = [[0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 10\n assert candidate(isInfected = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0,... | [
"[[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]]",
"[[1,1,1],[1,0,1],[1,1,1]]",
"[[1,1,1,0,0,0,0,0,0],[1,0,1,0,1,1,1,1,1],[1,1,1,0,0,0,0,0,0]]"
] | [
"The implementation is long - we want to perfrom the following steps: * Find all viral regions (connected components), additionally for each region keeping track of the frontier (neighboring uncontaminated cells), and the perimeter of the region. * Disinfect the most viral region, adding it's perimeter to the answe... | {
"canonical_parameter_names": [
"isInfected"
],
"leetcode_dataset_entry_point": "Solution().containVirus",
"problem_source": "newfacade/LeetCodeDataset",
"description_source": "leetcode.com",
"interface_source": "leetcode/codeSnippets",
"fetched_at": "2026-09-30T19:58:17",
"tests_total": 58,
"tes... | go | {
"raw_signature": "func containVirus(isInfected [][]int) int {",
"container": null,
"callable": "containVirus",
"parameters": [
{
"name": "isInfected",
"type": "[][]int"
}
],
"return_type": "int",
"signature_source": "leetcode/codeSnippets",
"type_source": "leetcode/codeSnippets"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.