questionFrontendId
int64
1
3.51k
questionTitle
stringlengths
3
79
TitleSlug
stringlengths
3
79
content
stringlengths
431
25.4k
difficulty
stringclasses
3 values
totalAccepted
stringlengths
2
6
totalSubmission
stringlengths
2
6
totalAcceptedRaw
int64
124
16.8M
totalSubmissionRaw
int64
285
30.3M
acRate
stringlengths
4
5
similarQuestions
stringlengths
2
714
mysqlSchemas
stringclasses
295 values
category
stringclasses
6 values
codeDefinition
stringlengths
122
24.9k
sampleTestCase
stringlengths
1
4.33k
metaData
stringlengths
37
3.13k
envInfo
stringclasses
26 values
topicTags
stringlengths
2
153
201
Bitwise AND of Numbers Range
bitwise-and-of-numbers-range
<p>Given two integers <code>left</code> and <code>right</code> that represent the range <code>[left, right]</code>, return <em>the bitwise AND of all numbers in this range, inclusive</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> left = 5, right = 7 <strong>Ou...
Medium
447.7K
941.6K
447,701
941,605
47.5%
['longest-nice-subarray']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rangeBitwiseAnd(int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rangeBitwiseAnd(int left, int right) {\n \n }\n}"}, {"value": "python", "text": ...
5 7
{ "name": "rangeBitwiseAnd", "params": [ { "name": "left", "type": "integer" }, { "name": "right", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Bit Manipulation']
202
Happy Number
happy-number
<p>Write an algorithm to determine if a number <code>n</code> is happy.</p> <p>A <strong>happy number</strong> is a number defined by the following process:</p> <ul> <li>Starting with any positive integer, replace the number by the sum of the squares of its digits.</li> <li>Repeat the process until the number equal...
Easy
1.8M
3.1M
1,817,270
3,147,351
57.7%
['linked-list-cycle', 'add-digits', 'ugly-number', 'sum-of-digits-of-string-after-convert', 'minimum-addition-to-make-integer-beautiful', 'smallest-value-after-replacing-with-sum-of-prime-factors', 'count-the-digits-that-divide-a-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isHappy(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isHappy(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solutio...
19
{ "name": "isHappy", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Math', 'Two Pointers']
203
Remove Linked List Elements
remove-linked-list-elements
<p>Given the <code>head</code> of a linked list and an integer <code>val</code>, remove all the nodes of the linked list that has <code>Node.val == val</code>, and return <em>the new head</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/202...
Easy
1.3M
2.6M
1,332,533
2,591,943
51.4%
['remove-element', 'delete-node-in-a-linked-list', 'delete-the-middle-node-of-a-linked-list', 'delete-nodes-from-linked-list-present-in-array', 'convert-doubly-linked-list-to-array-i', 'convert-doubly-linked-list-to-array-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[1,2,6,3,4,5,6] 6
{ "name": "removeElements", "params": [ { "name": "head", "type": "ListNode", "dealloc": false }, { "name": "val", "type": "integer" } ], "return": { "type": "ListNode", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Recursion']
204
Count Primes
count-primes
<p>Given an integer <code>n</code>, return <em>the number of prime numbers that are strictly less than</em> <code>n</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 10 <strong>Output:</strong> 4 <strong>Explanation:</strong> There are 4 prime numbers less ...
Medium
1M
3M
1,029,728
2,980,525
34.5%
['ugly-number', 'ugly-number-ii', 'perfect-squares', 'number-of-common-factors', 'prime-pairs-with-target-sum', 'find-the-count-of-numbers-which-are-not-special']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countPrimes(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countPrimes(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solu...
10
{ "name": "countPrimes", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Enumeration', 'Number Theory']
205
Isomorphic Strings
isomorphic-strings
<p>Given two strings <code>s</code> and <code>t</code>, <em>determine if they are isomorphic</em>.</p> <p>Two strings <code>s</code> and <code>t</code> are isomorphic if the characters in <code>s</code> can be replaced to get <code>t</code>.</p> <p>All occurrences of a character must be replaced with another characte...
Easy
1.7M
3.7M
1,724,079
3,702,369
46.6%
['word-pattern', 'find-and-replace-pattern']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isIsomorphic(string s, string t) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isIsomorphic(String s, String t) {\n \n }\n}"}, {"value": "python", "text": "Py...
"egg" "add"
{ "name": "isIsomorphic", "params": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String']
206
Reverse Linked List
reverse-linked-list
<p>Given the <code>head</code> of a singly linked list, reverse the list, and return <em>the reversed list</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev1ex1.jpg" style="width: 542px; height: 222px;" /> <pre> <strong>Input:...
Easy
5.1M
6.5M
5,121,275
6,494,790
78.9%
['reverse-linked-list-ii', 'binary-tree-upside-down', 'palindrome-linked-list', 'reverse-nodes-in-even-length-groups', 'maximum-twin-sum-of-a-linked-list', 'remove-nodes-from-linked-list', 'insert-greatest-common-divisors-in-linked-list']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[1,2,3,4,5]
{ "name": "reverseList", "params": [ { "name": "head", "type": "ListNode", "dealloc": false } ], "return": { "type": "ListNode", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Recursion']
207
Course Schedule
course-schedule
<p>There are a total of <code>numCourses</code> courses you have to take, labeled from <code>0</code> to <code>numCourses - 1</code>. You are given an array <code>prerequisites</code> where <code>prerequisites[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that you <strong>must</strong> take course <code>b<sub>i<...
Medium
2M
4.1M
2,011,891
4,129,624
48.7%
['course-schedule-ii', 'graph-valid-tree', 'minimum-height-trees', 'course-schedule-iii', 'build-a-matrix-with-conditions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canFinish(int numCourses, vector<vector<int>>& prerequisites) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canFinish(int numCourses, int[][] prerequisites) {\n ...
2 [[1,0]]
{ "name": "canFinish", "params": [ { "name": "numCourses", "type": "integer" }, { "name": "prerequisites", "type": "integer[][]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Topological Sort']
208
Implement Trie (Prefix Tree)
implement-trie-prefix-tree
<p>A <a href="https://en.wikipedia.org/wiki/Trie" target="_blank"><strong>trie</strong></a> (pronounced as &quot;try&quot;) or <strong>prefix tree</strong> is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocom...
Medium
1.3M
1.9M
1,282,410
1,894,735
67.7%
['design-add-and-search-words-data-structure', 'design-search-autocomplete-system', 'replace-words', 'implement-magic-dictionary', 'encrypt-and-decrypt-strings', 'implement-trie-ii-prefix-tree', 'count-prefix-and-suffix-pairs-ii', 'count-prefix-and-suffix-pairs-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Trie {\npublic:\n Trie() {\n \n }\n \n void insert(string word) {\n \n }\n \n bool search(string word) {\n \n }\n \n bool startsWith(string prefix) {\n \n }\n};\n\n/**\n * Your Trie object will be instant...
["Trie","insert","search","search","startsWith","insert","search"] [[],["apple"],["apple"],["app"],["app"],["app"],["app"]]
{ "classname": "Trie", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "string", "name": "word" } ], "name": "insert", "return": { "type": "void" } }, { "params": [ { "type": "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Design', 'Trie']
209
Minimum Size Subarray Sum
minimum-size-subarray-sum
<p>Given an array of positive integers <code>nums</code> and a positive integer <code>target</code>, return <em>the <strong>minimal length</strong> of a </em><span data-keyword="subarray-nonempty"><em>subarray</em></span><em> whose sum is greater than or equal to</em> <code>target</code>. If there is no such subarray, ...
Medium
1.4M
2.9M
1,403,145
2,865,434
49.0%
['minimum-window-substring', 'maximum-size-subarray-sum-equals-k', 'maximum-length-of-repeated-subarray', 'minimum-operations-to-reduce-x-to-zero', 'k-radius-subarray-averages', 'maximum-product-after-k-increments', 'shortest-subarray-with-or-at-least-k-i', 'minimum-positive-sum-subarray']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minSubArrayLen(int target, vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minSubArrayLen(int target, int[] nums) {\n \n }\n}"}, {"value": "python...
7 [2,3,1,2,4,3]
{ "name": "minSubArrayLen", "params": [ { "name": "target", "type": "integer" }, { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Sliding Window', 'Prefix Sum']
210
Course Schedule II
course-schedule-ii
<p>There are a total of <code>numCourses</code> courses you have to take, labeled from <code>0</code> to <code>numCourses - 1</code>. You are given an array <code>prerequisites</code> where <code>prerequisites[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that you <strong>must</strong> take course <code>b<sub>i<...
Medium
1.3M
2.5M
1,325,057
2,504,060
52.9%
['course-schedule', 'alien-dictionary', 'minimum-height-trees', 'sequence-reconstruction', 'course-schedule-iii', 'parallel-courses', 'find-all-possible-recipes-from-given-supplies', 'build-a-matrix-with-conditions', 'sort-array-by-moving-items-to-empty-space']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] findOrder(int numCourses, int[][] prerequisites) {\n ...
2 [[1,0]]
{ "name": "findOrder", "params": [ { "name": "numCourses", "type": "integer" }, { "name": "prerequisites", "type": "integer[][]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Topological Sort']
211
Design Add and Search Words Data Structure
design-add-and-search-words-data-structure
<p>Design a data structure that supports adding new words and finding if a string matches any previously added string.</p> <p>Implement the <code>WordDictionary</code> class:</p> <ul> <li><code>WordDictionary()</code>&nbsp;Initializes the object.</li> <li><code>void addWord(word)</code> Adds <code>word</code> to th...
Medium
754.4K
1.6M
754,419
1,609,382
46.9%
['implement-trie-prefix-tree', 'prefix-and-suffix-search', 'match-substring-after-replacement', 'sum-of-prefix-scores-of-strings', 'count-prefix-and-suffix-pairs-ii', 'count-prefix-and-suffix-pairs-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class WordDictionary {\npublic:\n WordDictionary() {\n \n }\n \n void addWord(string word) {\n \n }\n \n bool search(string word) {\n \n }\n};\n\n/**\n * Your WordDictionary object will be instantiated and called as such:\n * ...
["WordDictionary","addWord","addWord","addWord","search","search","search","search"] [[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]]
{ "classname": "WordDictionary", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "string", "name": "word" } ], "name": "addWord", "return": { "type": "void" } }, { "params": [ { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Depth-First Search', 'Design', 'Trie']
212
Word Search II
word-search-ii
<p>Given an <code>m x n</code> <code>board</code>&nbsp;of characters and a list of strings <code>words</code>, return <em>all words on the board</em>.</p> <p>Each word must be constructed from letters of sequentially adjacent cells, where <strong>adjacent cells</strong> are horizontally or vertically neighboring. The ...
Hard
771.7K
2.1M
771,724
2,079,016
37.1%
['word-search', 'unique-paths-iii', 'encrypt-and-decrypt-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> findWords(vector<vector<char>>& board, vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> findWords(char[][] board, String[] words) {\n...
[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]] ["oath","pea","eat","rain"]
{ "name": "findWords", "params": [ { "name": "board", "type": "character[][]" }, { "name": "words", "type": "string[]" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Backtracking', 'Trie', 'Matrix']
213
House Robber II
house-robber-ii
<p>You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are <strong>arranged in a circle.</strong> That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have a security system connected, and&nbsp;...
Medium
965.1K
2.2M
965,118
2,229,724
43.3%
['house-robber', 'paint-house', 'paint-fence', 'house-robber-iii', 'non-negative-integers-without-consecutive-ones', 'coin-path']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rob(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rob(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Sol...
[2,3,2]
{ "name": "rob", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
214
Shortest Palindrome
shortest-palindrome
<p>You are given a string <code>s</code>. You can convert <code>s</code> to a <span data-keyword="palindrome-string">palindrome</span> by adding characters in front of it.</p> <p>Return <em>the shortest palindrome you can find by performing this transformation</em>.</p> <p>&nbsp;</p> <p><strong class="example">Exampl...
Hard
303.1K
749.4K
303,059
749,398
40.4%
['longest-palindromic-substring', 'find-the-index-of-the-first-occurrence-in-a-string', 'palindrome-pairs', 'maximum-deletions-on-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string shortestPalindrome(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String shortestPalindrome(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"aacecaaa"
{ "name": "shortestPalindrome", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Rolling Hash', 'String Matching', 'Hash Function']
215
Kth Largest Element in an Array
kth-largest-element-in-an-array
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the</em> <code>k<sup>th</sup></code> <em>largest element in the array</em>.</p> <p>Note that it is the <code>k<sup>th</sup></code> largest element in the sorted order, not the <code>k<sup>th</sup></code> distinct element.</p> <p>Can...
Medium
2.9M
4.3M
2,914,073
4,301,757
67.7%
['wiggle-sort-ii', 'top-k-frequent-elements', 'third-maximum-number', 'kth-largest-element-in-a-stream', 'k-closest-points-to-origin', 'find-the-kth-largest-integer-in-the-array', 'find-subsequence-of-length-k-with-the-largest-sum', 'k-highest-ranked-items-within-a-price-range']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findKthLargest(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findKthLargest(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text":...
[3,2,1,5,6,4] 2
{ "name": "findKthLargest", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Divide and Conquer', 'Sorting', 'Heap (Priority Queue)', 'Quickselect']
216
Combination Sum III
combination-sum-iii
<p>Find all valid combinations of <code>k</code> numbers that sum up to <code>n</code> such that the following conditions are true:</p> <ul> <li>Only numbers <code>1</code> through <code>9</code> are used.</li> <li>Each number is used <strong>at most once</strong>.</li> </ul> <p>Return <em>a list of all possible va...
Medium
642.2K
897.5K
642,165
897,547
71.5%
['combination-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> combinationSum3(int k, int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<List<Integer>> combinationSum3(int k, int n) {\n \n }\n}"}, {"value": ...
3 7
{ "name": "combinationSum3", "params": [ { "name": "k", "type": "integer" }, { "name": "n", "type": "integer" } ], "return": { "type": "list<list<integer>>", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Backtracking']
217
Contains Duplicate
contains-duplicate
<p>Given an integer array <code>nums</code>, return <code>true</code> if any value appears <strong>at least twice</strong> in the array, and return <code>false</code> if every element is distinct.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</stron...
Easy
5M
7.9M
4,988,359
7,923,433
63.0%
['contains-duplicate-ii', 'contains-duplicate-iii', 'make-array-zero-by-subtracting-equal-amounts', 'find-valid-pair-of-adjacent-digits-in-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool containsDuplicate(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean containsDuplicate(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "P...
[1,2,3,1]
{ "name": "containsDuplicate", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Sorting']
218
The Skyline Problem
the-skyline-problem
<p>A city&#39;s <strong>skyline</strong> is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the buildings, return <em>the <strong>skyline</strong> formed by these buildings collectively</em>.</p> <p>The geometric informati...
Hard
316.4K
723.2K
316,415
723,194
43.8%
['falling-squares', 'shifting-letters-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> getSkyline(vector<vector<int>>& buildings) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<List<Integer>> getSkyline(int[][] buildings) {\n \n }\n}"...
[[2,9,10],[3,7,15],[5,12,12],[15,20,10],[19,24,8]]
{ "name": "getSkyline", "params": [ { "name": "buildings", "type": "integer[][]" } ], "return": { "type": "list<list<integer>>", "colsize": 2, "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Divide and Conquer', 'Binary Indexed Tree', 'Segment Tree', 'Line Sweep', 'Heap (Priority Queue)', 'Ordered Set']
219
Contains Duplicate II
contains-duplicate-ii
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <code>true</code> <em>if there are two <strong>distinct indices</strong> </em><code>i</code><em> and </em><code>j</code><em> in the array such that </em><code>nums[i] == nums[j]</code><em> and </em><code>abs(i - j) &lt;= k</code>.</p> <p...
Easy
1.3M
2.7M
1,298,038
2,677,001
48.5%
['contains-duplicate', 'contains-duplicate-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool containsNearbyDuplicate(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean containsNearbyDuplicate(int[] nums, int k) {\n \n }\n}"}, {"va...
[1,2,3,1] 3
{ "name": "containsNearbyDuplicate", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Sliding Window']
220
Contains Duplicate III
contains-duplicate-iii
<p>You are given an integer array <code>nums</code> and two integers <code>indexDiff</code> and <code>valueDiff</code>.</p> <p>Find a pair of indices <code>(i, j)</code> such that:</p> <ul> <li><code>i != j</code>,</li> <li><code>abs(i - j) &lt;= indexDiff</code>.</li> <li><code>abs(nums[i] - nums[j]) &lt;= valueD...
Hard
278.1K
1.2M
278,068
1,183,887
23.5%
['contains-duplicate', 'contains-duplicate-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool containsNearbyAlmostDuplicate(vector<int>& nums, int indexDiff, int valueDiff) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean containsNearbyAlmostDuplicate(int[] nums, i...
[1,2,3,1] 3 0
{ "name": "containsNearbyAlmostDuplicate", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "indexDiff", "type": "integer" }, { "name": "valueDiff", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sliding Window', 'Sorting', 'Bucket Sort', 'Ordered Set']
221
Maximal Square
maximal-square
<p>Given an <code>m x n</code> binary <code>matrix</code> filled with <code>0</code>&#39;s and <code>1</code>&#39;s, <em>find the largest square containing only</em> <code>1</code>&#39;s <em>and return its area</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.l...
Medium
797.4K
1.6M
797,389
1,647,010
48.4%
['maximal-rectangle', 'largest-plus-sign', 'count-artifacts-that-can-be-extracted', 'stamping-the-grid', 'maximize-area-of-square-hole-in-grid']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximalSquare(vector<vector<char>>& matrix) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximalSquare(char[][] matrix) {\n \n }\n}"}, {"value": "python", "text":...
[["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]]
{ "name": "maximalSquare", "params": [ { "name": "matrix", "type": "character[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Matrix']
222
Count Complete Tree Nodes
count-complete-tree-nodes
<p>Given the <code>root</code> of a <strong>complete</strong> binary tree, return the number of the nodes in the tree.</p> <p>According to <strong><a href="http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees" target="_blank">Wikipedia</a></strong>, every level, except possibly the last, is completely filled...
Easy
930K
1.3M
930,037
1,341,970
69.3%
['closest-binary-search-tree-value']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,2,3,4,5,6]
{ "name": "countNodes", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Binary Search', 'Bit Manipulation', 'Tree', 'Binary Tree']
223
Rectangle Area
rectangle-area
<p>Given the coordinates of two <strong>rectilinear</strong> rectangles in a 2D plane, return <em>the total area covered by the two rectangles</em>.</p> <p>The first rectangle is defined by its <strong>bottom-left</strong> corner <code>(ax1, ay1)</code> and its <strong>top-right</strong> corner <code>(ax2, ay2)</code>...
Medium
245.7K
521.3K
245,684
521,315
47.1%
['rectangle-overlap', 'find-the-number-of-ways-to-place-people-ii', 'find-the-number-of-ways-to-place-people-i', 'find-the-largest-area-of-square-inside-two-rectangles']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int computeArea(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int computeArea(int ax1, int ay1, int ax2, int ...
-3 0 3 4 0 -1 9 2
{ "name": "computeArea", "params": [ { "name": "ax1", "type": "integer" }, { "name": "ay1", "type": "integer" }, { "name": "ax2", "type": "integer" }, { "name": "ay2", "type": "integer" }, { "name": "bx1", "type": "integ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Geometry']
224
Basic Calculator
basic-calculator
<p>Given a string <code>s</code> representing a valid expression, implement a basic calculator to evaluate it, and return <em>the result of the evaluation</em>.</p> <p><strong>Note:</strong> You are <strong>not</strong> allowed to use any built-in function which evaluates strings as mathematical expressions, such as <...
Hard
577.6K
1.3M
577,626
1,279,145
45.2%
['evaluate-reverse-polish-notation', 'basic-calculator-ii', 'different-ways-to-add-parentheses', 'expression-add-operators', 'basic-calculator-iii', 'the-score-of-students-solving-math-expression', 'minimize-result-by-adding-parentheses-to-expression']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int calculate(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int calculate(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class So...
"1 + 1"
{ "name": "calculate", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Stack', 'Recursion']
225
Implement Stack using Queues
implement-stack-using-queues
<p>Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (<code>push</code>, <code>top</code>, <code>pop</code>, and <code>empty</code>).</p> <p>Implement the <code>MyStack</code> class:</p> <ul> <li><code>void push(int x)</code> Pu...
Easy
870.5K
1.3M
870,526
1,302,772
66.8%
['implement-queue-using-stacks']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyStack {\npublic:\n MyStack() {\n \n }\n \n void push(int x) {\n \n }\n \n int pop() {\n \n }\n \n int top() {\n \n }\n \n bool empty() {\n \n }\n};\n\n/**\n * Your MyStack object will be...
["MyStack","push","push","top","pop","empty"] [[],[1],[2],[],[],[]]
{ "classname": "MyStack", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "x" } ], "name": "push", "return": { "type": "void" } }, { "params": [], "return": { "t...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Stack', 'Design', 'Queue']
226
Invert Binary Tree
invert-binary-tree
<p>Given the <code>root</code> of a binary tree, invert the tree, and return <em>its root</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/03/14/invert1-tree.jpg" style="width: 500px; height: 165px;" /> <pre> <strong>Input:</strong> ro...
Easy
2.5M
3.2M
2,537,164
3,221,660
78.8%
['reverse-odd-levels-of-binary-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[4,2,7,1,3,6,9]
{ "name": "invertTree", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree']
227
Basic Calculator II
basic-calculator-ii
<p>Given a string <code>s</code> which represents an expression, <em>evaluate this expression and return its value</em>.&nbsp;</p> <p>The integer division should truncate toward zero.</p> <p>You may assume that the given expression is always valid. All intermediate results will be in the range of <code>[-2<sup>31</su...
Medium
805.7K
1.8M
805,727
1,772,409
45.5%
['basic-calculator', 'expression-add-operators', 'basic-calculator-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int calculate(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int calculate(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class So...
"3+2*2"
{ "name": "calculate", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Stack']
228
Summary Ranges
summary-ranges
<p>You are given a <strong>sorted unique</strong> integer array <code>nums</code>.</p> <p>A <strong>range</strong> <code>[a,b]</code> is the set of all integers from <code>a</code> to <code>b</code> (inclusive).</p> <p>Return <em>the <strong>smallest sorted</strong> list of ranges that <strong>cover all the numbers i...
Easy
762.2K
1.4M
762,241
1,444,824
52.8%
['missing-ranges', 'data-stream-as-disjoint-intervals', 'find-maximal-uncovered-ranges']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> summaryRanges(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> summaryRanges(int[] nums) {\n \n }\n}"}, {"value": "python", "te...
[0,1,2,4,5,7]
{ "name": "summaryRanges", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array']
229
Majority Element II
majority-element-ii
<p>Given an integer array of size <code>n</code>, find all elements that appear more than <code>&lfloor; n/3 &rfloor;</code> times.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> nums = [3,2,3] <strong>Output:</strong> [3] </pre> <p><strong class="example">Example ...
Medium
924.4K
1.7M
924,367
1,714,262
53.9%
['majority-element', 'check-if-a-number-is-majority-element-in-a-sorted-array', 'most-frequent-even-element']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> majorityElement(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> majorityElement(int[] nums) {\n \n }\n}"}, {"value": "python", "...
[3,2,3]
{ "name": "majorityElement", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "list<integer>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Sorting', 'Counting']
230
Kth Smallest Element in a BST
kth-smallest-element-in-a-bst
<p>Given the <code>root</code> of a binary search tree, and an integer <code>k</code>, return <em>the</em> <code>k<sup>th</sup></code> <em>smallest value (<strong>1-indexed</strong>) of all the values of the nodes in the tree</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="h...
Medium
1.8M
2.4M
1,810,547
2,416,048
74.9%
['binary-tree-inorder-traversal', 'second-minimum-node-in-a-binary-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[3,1,4,null,2] 1
{ "name": "kthSmallest", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
231
Power of Two
power-of-two
<p>Given an integer <code>n</code>, return <em><code>true</code> if it is a power of two. Otherwise, return <code>false</code></em>.</p> <p>An integer <code>n</code> is a power of two, if there exists an integer <code>x</code> such that <code>n == 2<sup>x</sup></code>.</p> <p>&nbsp;</p> <p><strong class="example">Exa...
Easy
1.6M
3.4M
1,637,579
3,393,753
48.3%
['number-of-1-bits', 'power-of-three', 'power-of-four']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isPowerOfTwo(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isPowerOfTwo(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "cla...
1
{ "name": "isPowerOfTwo", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Bit Manipulation', 'Recursion']
232
Implement Queue using Stacks
implement-queue-using-stacks
<p>Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (<code>push</code>, <code>peek</code>, <code>pop</code>, and <code>empty</code>).</p> <p>Implement the <code>MyQueue</code> class:</p> <ul> <li><code>void push(int x)</code> ...
Easy
1.2M
1.7M
1,156,652
1,703,188
67.9%
['implement-stack-using-queues']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyQueue {\npublic:\n MyQueue() {\n \n }\n \n void push(int x) {\n \n }\n \n int pop() {\n \n }\n \n int peek() {\n \n }\n \n bool empty() {\n \n }\n};\n\n/**\n * Your MyQueue object will b...
["MyQueue","push","push","peek","pop","empty"] [[],[1],[2],[],[],[]]
{ "classname": "MyQueue", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "x" } ], "return": { "type": "void" }, "name": "push" }, { "params": [], "return": { "t...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Stack', 'Design', 'Queue']
233
Number of Digit One
number-of-digit-one
<p>Given an integer <code>n</code>, count <em>the total number of digit </em><code>1</code><em> appearing in all non-negative integers less than or equal to</em> <code>n</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 13 <strong>Output:</strong> 6 </pre> ...
Hard
112.1K
313.8K
112,108
313,849
35.7%
['factorial-trailing-zeroes', 'digit-count-in-range']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countDigitOne(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countDigitOne(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
13
{ "name": "countDigitOne", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Recursion']
234
Palindrome Linked List
palindrome-linked-list
<p>Given the <code>head</code> of a singly linked list, return <code>true</code><em> if it is a </em><span data-keyword="palindrome-sequence"><em>palindrome</em></span><em> or </em><code>false</code><em> otherwise</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://asset...
Easy
2.3M
4.2M
2,344,888
4,232,457
55.4%
['palindrome-number', 'valid-palindrome', 'reverse-linked-list', 'maximum-twin-sum-of-a-linked-list']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[1,2,2,1]
{ "name": "isPalindrome", "params": [ { "name": "head", "type": "ListNode" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Two Pointers', 'Stack', 'Recursion']
235
Lowest Common Ancestor of a Binary Search Tree
lowest-common-ancestor-of-a-binary-search-tree
<p>Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/Lowest_common_ancestor" target="_blank">definition of LCA on Wikipedia</a>: &ldquo;The lowest common ancestor is defined between two nodes <code>...
Medium
1.8M
2.7M
1,841,391
2,718,008
67.7%
['lowest-common-ancestor-of-a-binary-tree', 'smallest-common-region', 'lowest-common-ancestor-of-a-binary-tree-ii', 'lowest-common-ancestor-of-a-binary-tree-iii', 'lowest-common-ancestor-of-a-binary-tree-iv']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\n\nclass Solution {\npublic:\n TreeNode* lowestCommonAncestor(Tr...
[6,2,8,0,4,7,9,null,null,3,5] 2 8
{ "name": "lowestCommonAncestor", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "p", "type": "integer" }, { "name": "q", "type": "integer" } ], "return": { "type": "TreeNode" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
236
Lowest Common Ancestor of a Binary Tree
lowest-common-ancestor-of-a-binary-tree
<p>Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/Lowest_common_ancestor" target="_blank">definition of LCA on Wikipedia</a>: &ldquo;The lowest common ancestor is defined between two nodes <code>p</code> and <cod...
Medium
2.1M
3.1M
2,078,066
3,145,123
66.1%
['lowest-common-ancestor-of-a-binary-search-tree', 'smallest-common-region', 'find-players-with-zero-or-one-losses', 'lowest-common-ancestor-of-a-binary-tree-ii', 'lowest-common-ancestor-of-a-binary-tree-iii', 'lowest-common-ancestor-of-a-binary-tree-iv', 'step-by-step-directions-from-a-binary-tree-node-to-another', 'c...
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n TreeNode* lowestCommonAncestor(Tree...
[3,5,1,6,2,0,8,null,null,7,4] 5 1
{ "name": "lowestCommonAncestor", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "p", "type": "integer" }, { "name": "q", "type": "integer" } ], "return": { "type": "TreeNode" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
237
Delete Node in a Linked List
delete-node-in-a-linked-list
<p>There is a singly-linked list <code>head</code> and we want to delete a node <code>node</code> in it.</p> <p>You are given the node to be deleted <code>node</code>. You will <strong>not be given access</strong> to the first node of <code>head</code>.</p> <p>All the values of the linked list are <strong>unique</str...
Medium
1.7M
2M
1,673,264
2,042,308
81.9%
['remove-linked-list-elements', 'remove-nodes-from-linked-list', 'delete-nodes-from-linked-list-present-in-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode(int x) : val(x), next(NULL) {}\n * };\n */\nclass Solution {\npublic:\n void deleteNode(ListNode* node) {\n \n }\n};"}, {"value": "java...
[4,5,1,9] 5
{ "name": "deleteNode", "params": [ { "name": "head", "type": "ListNode" }, { "name": "node", "type": "integer" } ], "return": { "type": "void" }, "output": { "paramindex": 0 }, "manual": true, "languages": [ "cpp", "java", "python", "c",...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List']
238
Product of Array Except Self
product-of-array-except-self
<p>Given an integer array <code>nums</code>, return <em>an array</em> <code>answer</code> <em>such that</em> <code>answer[i]</code> <em>is equal to the product of all the elements of</em> <code>nums</code> <em>except</em> <code>nums[i]</code>.</p> <p>The product of any prefix or suffix of <code>nums</code> is <strong>...
Medium
3.5M
5.2M
3,515,335
5,207,190
67.5%
['trapping-rain-water', 'maximum-product-subarray', 'paint-house-ii', 'minimum-difference-in-sums-after-removal-of-elements', 'construct-product-matrix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> productExceptSelf(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] productExceptSelf(int[] nums) {\n \n }\n}"}, {"value": "python", "text...
[1,2,3,4]
{ "name": "productExceptSelf", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Prefix Sum']
239
Sliding Window Maximum
sliding-window-maximum
<p>You are given an array of integers&nbsp;<code>nums</code>, there is a sliding window of size <code>k</code> which is moving from the very left of the array to the very right. You can only see the <code>k</code> numbers in the window. Each time the sliding window moves right by one position.</p> <p>Return <em>the ma...
Hard
1.3M
2.7M
1,274,843
2,691,288
47.4%
['minimum-window-substring', 'min-stack', 'longest-substring-with-at-most-two-distinct-characters', 'paint-house-ii', 'jump-game-vi', 'maximum-number-of-robots-within-budget', 'maximum-tastiness-of-candy-basket', 'maximal-score-after-applying-k-operations']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> maxSlidingWindow(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] maxSlidingWindow(int[] nums, int k) {\n \n }\n}"}, {"value": "py...
[1,3,-1,-3,5,3,6,7] 3
{ "name": "maxSlidingWindow", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Queue', 'Sliding Window', 'Heap (Priority Queue)', 'Monotonic Queue']
240
Search a 2D Matrix II
search-a-2d-matrix-ii
<p>Write an efficient algorithm that searches for a value <code>target</code> in an <code>m x n</code> integer matrix <code>matrix</code>. This matrix has the following properties:</p> <ul> <li>Integers in each row are sorted in ascending from left to right.</li> <li>Integers in each column are sorted in ascending f...
Medium
1.1M
2M
1,109,305
2,028,716
54.7%
['search-a-2d-matrix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool searchMatrix(vector<vector<int>>& matrix, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean searchMatrix(int[][] matrix, int target) {\n \n }\n}"}, {"...
[[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]] 5
{ "name": "searchMatrix", "params": [ { "name": "matrix", "type": "integer[][]" }, { "name": "target", "type": "integer" } ], "return": { "type": "boolean" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Divide and Conquer', 'Matrix']
241
Different Ways to Add Parentheses
different-ways-to-add-parentheses
<p>Given a string <code>expression</code> of numbers and operators, return <em>all possible results from computing all the different possible ways to group numbers and operators</em>. You may return the answer in <strong>any order</strong>.</p> <p>The test cases are generated such that the output values fit in a 32-bi...
Medium
343K
475.1K
342,951
475,070
72.2%
['unique-binary-search-trees-ii', 'basic-calculator', 'expression-add-operators', 'the-score-of-students-solving-math-expression', 'minimize-result-by-adding-parentheses-to-expression']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> diffWaysToCompute(string expression) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> diffWaysToCompute(String expression) {\n \n }\n}"}, {"value": ...
"2-1-1"
{ "name": "diffWaysToCompute", "params": [ { "name": "expression", "type": "string" } ], "return": { "type": "list<integer>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Dynamic Programming', 'Recursion', 'Memoization']
242
Valid Anagram
valid-anagram
<p>Given two strings <code>s</code> and <code>t</code>, return <code>true</code> if <code>t</code> is an <span data-keyword="anagram">anagram</span> of <code>s</code>, and <code>false</code> otherwise.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</...
Easy
4.6M
6.9M
4,609,349
6,948,818
66.3%
['group-anagrams', 'palindrome-permutation', 'find-all-anagrams-in-a-string', 'find-resultant-array-after-removing-anagrams']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isAnagram(string s, string t) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isAnagram(String s, String t) {\n \n }\n}"}, {"value": "python", "text": "Python",...
"anagram" "nagaram"
{ "name": "isAnagram", "params": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Sorting']
243
Shortest Word Distance
shortest-word-distance
null
Easy
230.3K
349.6K
230,284
349,629
65.9%
['shortest-word-distance-ii', 'shortest-word-distance-iii', 'find-all-k-distant-indices-in-an-array']
[]
Algorithms
null
["practice", "makes", "perfect", "coding", "makes"] "coding" "practice"
{ "name": "shortestDistance", "params": [ { "name": "wordsDict", "type": "string[]" }, { "name": "word1", "type": "string" }, { "name": "word2", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String']
244
Shortest Word Distance II
shortest-word-distance-ii
null
Medium
165.6K
267.2K
165,610
267,166
62.0%
['merge-two-sorted-lists', 'shortest-word-distance', 'shortest-word-distance-iii']
[]
Algorithms
null
["WordDistance","shortest","shortest"] [[["practice","makes","perfect","coding","makes"]],["coding","practice"],["makes","coding"]]
{ "classname": "WordDistance", "maxbytesperline": 300000, "constructor": { "params": [ { "type": "string[]", "name": "wordsDict" }, { "type": "integer", "name": "wordsSize", "lang": "c", "value": "size_1" } ] }, "methods": [ {...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Two Pointers', 'String', 'Design']
245
Shortest Word Distance III
shortest-word-distance-iii
null
Medium
87.5K
148.5K
87,531
148,455
59.0%
['shortest-word-distance', 'shortest-word-distance-ii']
[]
Algorithms
null
["practice", "makes", "perfect", "coding", "makes"] "makes" "coding"
{ "name": "shortestWordDistance", "params": [ { "name": "wordsDict", "type": "string[]" }, { "name": "word1", "type": "string" }, { "name": "word2", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String']
246
Strobogrammatic Number
strobogrammatic-number
null
Easy
192.2K
403.8K
192,218
403,835
47.6%
['strobogrammatic-number-ii', 'strobogrammatic-number-iii', 'confusing-number']
[]
Algorithms
null
"69"
{ "name": "isStrobogrammatic", "params": [ { "name": "num", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Two Pointers', 'String']
247
Strobogrammatic Number II
strobogrammatic-number-ii
null
Medium
152.5K
287.5K
152,514
287,525
53.0%
['strobogrammatic-number', 'strobogrammatic-number-iii', 'sum-of-k-mirror-numbers']
[]
Algorithms
null
2
{ "name": "findStrobogrammatic", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Recursion']
248
Strobogrammatic Number III
strobogrammatic-number-iii
null
Hard
37.5K
88.6K
37,540
88,554
42.4%
['strobogrammatic-number', 'strobogrammatic-number-ii']
[]
Algorithms
null
"50" "100"
{ "name": "strobogrammaticInRange", "params": [ { "name": "low", "type": "string" }, { "name": "high", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Recursion']
249
Group Shifted Strings
group-shifted-strings
null
Medium
287.5K
428.3K
287,540
428,293
67.1%
['group-anagrams', 'find-maximum-number-of-string-pairs']
[]
Algorithms
null
["abc","bcd","acef","xyz","az","ba","a","z"]
{ "name": "groupStrings", "params": [ { "name": "strings", "type": "string[]", "dealloc": false } ], "return": { "type": "list<list<string>>", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String']
250
Count Univalue Subtrees
count-univalue-subtrees
null
Medium
162.9K
285.5K
162,906
285,483
57.1%
['subtree-of-another-tree', 'longest-univalue-path']
[]
Algorithms
null
[5,1,5,5,5,null,5]
{ "name": "countUnivalSubtrees", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
251
Flatten 2D Vector
flatten-2d-vector
null
Medium
137K
273.7K
136,998
273,729
50.0%
['binary-search-tree-iterator', 'zigzag-iterator', 'peeking-iterator', 'flatten-nested-list-iterator']
[]
Algorithms
null
["Vector2D","next","next","next","hasNext","hasNext","next","hasNext"] [[[[1,2],[3],[4]]],[],[],[],[],[],[],[]]
{ "classname": "Vector2D", "maxbytesperline": 200000, "constructor": { "params": [ { "type": "integer[][]", "name": "vec" } ] }, "methods": [ { "name": "next", "params": [], "return": { "type": "integer" } }, { "name": "hasN...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Design', 'Iterator']
252
Meeting Rooms
meeting-rooms
null
Easy
458.5K
779.2K
458,462
779,166
58.8%
['merge-intervals', 'meeting-rooms-ii', 'meeting-rooms-iii', 'points-that-intersect-with-cars']
[]
Algorithms
null
[[0,30],[5,10],[15,20]]
{ "name": "canAttendMeetings", "params": [ { "name": "intervals", "type": "integer[][]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting']
253
Meeting Rooms II
meeting-rooms-ii
null
Medium
1M
2M
1,028,616
1,977,843
52.0%
['merge-intervals', 'meeting-rooms', 'minimum-number-of-arrows-to-burst-balloons', 'car-pooling', 'number-of-flowers-in-full-bloom', 'meeting-rooms-iii', 'total-cost-to-hire-k-workers', 'points-that-intersect-with-cars']
[]
Algorithms
null
[[0,30],[5,10],[15,20]]
{ "name": "minMeetingRooms", "params": [ { "name": "intervals", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'Prefix Sum']
254
Factor Combinations
factor-combinations
null
Medium
135.8K
270.7K
135,794
270,661
50.2%
['combination-sum']
[]
Algorithms
null
1
{ "name": "getFactors", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "list<list<integer>>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Backtracking']
255
Verify Preorder Sequence in Binary Search Tree
verify-preorder-sequence-in-binary-search-tree
null
Medium
86.8K
171.1K
86,806
171,079
50.7%
['binary-tree-preorder-traversal']
[]
Algorithms
null
[5,2,1,3,6]
{ "name": "verifyPreorder", "params": [ { "name": "preorder", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Stack', 'Tree', 'Binary Search Tree', 'Recursion', 'Monotonic Stack', 'Binary Tree']
256
Paint House
paint-house
null
Medium
228.4K
359.4K
228,400
359,362
63.6%
['house-robber', 'house-robber-ii', 'paint-house-ii', 'paint-fence', 'minimum-path-cost-in-a-grid']
[]
Algorithms
null
[[17,2,17],[16,16,5],[14,3,19]]
{ "name": "minCost", "params": [ { "name": "costs", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
257
Binary Tree Paths
binary-tree-paths
<p>Given the <code>root</code> of a binary tree, return <em>all root-to-leaf paths in <strong>any order</strong></em>.</p> <p>A <strong>leaf</strong> is a node with no children.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/03/12/paths-t...
Easy
846.7K
1.3M
846,695
1,282,229
66.0%
['path-sum-ii', 'smallest-string-starting-from-leaf', 'step-by-step-directions-from-a-binary-tree-node-to-another']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,2,3,null,5]
{ "name": "binaryTreePaths", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "list<string>", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Backtracking', 'Tree', 'Depth-First Search', 'Binary Tree']
258
Add Digits
add-digits
<p>Given an integer <code>num</code>, repeatedly add all its digits until the result has only one digit, and return it.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 38 <strong>Output:</strong> 2 <strong>Explanation:</strong> The process is 38 --&gt; 3 + 8 --...
Easy
954.2K
1.4M
954,159
1,409,267
67.7%
['happy-number', 'sum-of-digits-in-the-minimum-number', 'sum-of-digits-of-string-after-convert', 'minimum-sum-of-four-digit-number-after-splitting-digits', 'calculate-digit-sum-of-a-string', 'difference-between-element-sum-and-digit-sum-of-an-array', 'alternating-digit-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int addDigits(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int addDigits(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solu...
38
{ "name": "addDigits", "params": [ { "name": "num", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Simulation', 'Number Theory']
259
3Sum Smaller
3sum-smaller
null
Medium
162.6K
319.1K
162,580
319,065
51.0%
['3sum', '3sum-closest', 'valid-triangle-number', 'two-sum-less-than-k', 'maximize-greatness-of-an-array', 'find-polygon-with-the-largest-perimeter']
[]
Algorithms
null
[-2,0,1,3] 2
{ "name": "threeSumSmaller", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "target", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting']
260
Single Number III
single-number-iii
<p>Given an integer array <code>nums</code>, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once. You can return the answer in <strong>any order</strong>.</p> <p>You must write an&nbsp;algorithm that runs in linear runtime complexi...
Medium
513.9K
727K
513,870
726,962
70.7%
['single-number', 'single-number-ii', 'find-the-original-array-of-prefix-xor', 'find-the-xor-of-numbers-which-appear-twice']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> singleNumber(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] singleNumber(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,2,1,3,2,5]
{ "name": "singleNumber", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation']
261
Graph Valid Tree
graph-valid-tree
null
Medium
469.8K
955.5K
469,793
955,477
49.2%
['course-schedule', 'number-of-connected-components-in-an-undirected-graph', 'keys-and-rooms']
[]
Algorithms
null
5 [[0,1],[0,2],[0,3],[1,4]]
{ "name": "validTree", "params": [ { "name": "n", "type": "integer" }, { "name": "edges", "type": "integer[][]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Union Find', 'Graph']
262
Trips and Users
trips-and-users
<p>Table: <code>Trips</code></p> <pre> +-------------+----------+ | Column Name | Type | +-------------+----------+ | id | int | | client_id | int | | driver_id | int | | city_id | int | | status | enum | | request_at | varchar | +-------------+----------+ id is...
Hard
222.4K
600.2K
222,391
600,184
37.1%
['hopper-company-queries-i', 'hopper-company-queries-ii', 'hopper-company-queries-iii']
["Create table If Not Exists Trips (id int, client_id int, driver_id int, city_id int, status ENUM('completed', 'cancelled_by_driver', 'cancelled_by_client'), request_at varchar(50))", "Create table If Not Exists Users (users_id int, banned varchar(50), role ENUM('client', 'driver', 'partner'))", 'Truncate table Trips'...
Database
[{"value": "mysql", "text": "MySQL", "defaultCode": "# Write your MySQL query statement below\n"}, {"value": "mssql", "text": "MS SQL Server", "defaultCode": "/* Write your T-SQL query statement below */\n"}, {"value": "oraclesql", "text": "Oracle", "defaultCode": "/* Write your PL/SQL query statement below */\n"}, {"v...
{"headers": {"Trips": ["id", "client_id", "driver_id", "city_id", "status", "request_at"], "Users": ["users_id", "banned", "role"]}, "rows": {"Trips": [["1", "1", "10", "1", "completed", "2013-10-01"], ["2", "2", "11", "1", "cancelled_by_driver", "2013-10-01"], ["3", "3", "12", "6", "completed", "2013-10-01"], ["4", "4...
{"mysql": ["Create table If Not Exists Trips (id int, client_id int, driver_id int, city_id int, status ENUM('completed', 'cancelled_by_driver', 'cancelled_by_client'), request_at varchar(50))", "Create table If Not Exists Users (users_id int, banned varchar(50), role ENUM('client', 'driver', 'partner'))"], "mssql": ["...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
263
Ugly Number
ugly-number
<p>An <strong>ugly number</strong> is a <em>positive</em> integer which does not have a prime factor other than 2, 3, and 5.</p> <p>Given an integer <code>n</code>, return <code>true</code> <em>if</em> <code>n</code> <em>is an <strong>ugly number</strong></em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:<...
Easy
621.1K
1.5M
621,071
1,470,192
42.2%
['happy-number', 'count-primes', 'ugly-number-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isUgly(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isUgly(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution(...
6
{ "name": "isUgly", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math']
264
Ugly Number II
ugly-number-ii
<p>An <strong>ugly number</strong> is a positive integer whose prime factors are limited to <code>2</code>, <code>3</code>, and <code>5</code>.</p> <p>Given an integer <code>n</code>, return <em>the</em> <code>n<sup>th</sup></code> <em><strong>ugly number</strong></em>.</p> <p>&nbsp;</p> <p><strong class="example">Ex...
Medium
483.6K
983.3K
483,635
983,268
49.2%
['merge-k-sorted-lists', 'count-primes', 'ugly-number', 'perfect-squares', 'super-ugly-number', 'ugly-number-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int nthUglyNumber(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int nthUglyNumber(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
10
{ "name": "nthUglyNumber", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Math', 'Dynamic Programming', 'Heap (Priority Queue)']
265
Paint House II
paint-house-ii
null
Hard
135.6K
241.3K
135,600
241,340
56.2%
['product-of-array-except-self', 'sliding-window-maximum', 'paint-house', 'paint-fence']
[]
Algorithms
null
[[1,5,3],[2,9,4]]
{ "name": "minCostII", "params": [ { "name": "costs", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
266
Palindrome Permutation
palindrome-permutation
null
Easy
225.4K
329.4K
225,431
329,373
68.4%
['longest-palindromic-substring', 'valid-anagram', 'palindrome-permutation-ii', 'longest-palindrome']
[]
Algorithms
null
"code"
{ "name": "canPermutePalindrome", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Bit Manipulation']
267
Palindrome Permutation II
palindrome-permutation-ii
null
Medium
73.3K
174.2K
73,288
174,192
42.1%
['next-permutation', 'permutations-ii', 'palindrome-permutation']
[]
Algorithms
null
"aabb"
{ "name": "generatePalindromes", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Backtracking']
268
Missing Number
missing-number
<p>Given an array <code>nums</code> containing <code>n</code> distinct numbers in the range <code>[0, n]</code>, return <em>the only number in the range that is missing from the array.</em></p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</strong> <spa...
Easy
2.9M
4.2M
2,943,891
4,229,410
69.6%
['first-missing-positive', 'single-number', 'find-the-duplicate-number', 'couples-holding-hands', 'find-unique-binary-string', 'find-the-largest-almost-missing-integer']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int missingNumber(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int missingNumber(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[3,0,1]
{ "name": "missingNumber", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Binary Search', 'Bit Manipulation', 'Sorting']
269
Alien Dictionary
alien-dictionary
null
Hard
435.1K
1.2M
435,076
1,190,955
36.5%
['course-schedule-ii']
[]
Algorithms
null
["wrt","wrf","er","ett","rftt"]
{ "name": "alienOrder", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Depth-First Search', 'Breadth-First Search', 'Graph', 'Topological Sort']
270
Closest Binary Search Tree Value
closest-binary-search-tree-value
null
Easy
409.5K
818.9K
409,531
818,943
50.0%
['count-complete-tree-nodes', 'closest-binary-search-tree-value-ii', 'search-in-a-binary-search-tree', 'closest-nodes-queries-in-a-binary-search-tree']
[]
Algorithms
null
[4,2,5,1,3] 3.714286
{ "name": "closestValue", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "target", "type": "double" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Binary Search', 'Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
271
Encode and Decode Strings
encode-and-decode-strings
null
Medium
249.5K
507K
249,544
507,040
49.2%
['count-and-say', 'serialize-and-deserialize-binary-tree', 'string-compression', 'count-binary-substrings']
[]
Algorithms
null
["Hello","World"]
{ "name": "encode", "params": [ { "name": "dummy_input", "type": "list<string>" } ], "return": { "type": "list<string>" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Design']
272
Closest Binary Search Tree Value II
closest-binary-search-tree-value-ii
null
Hard
128.3K
213.5K
128,275
213,477
60.1%
['binary-tree-inorder-traversal', 'closest-binary-search-tree-value', 'closest-nodes-queries-in-a-binary-search-tree']
[]
Algorithms
null
[4,2,5,1,3] 3.714286 2
{ "name": "closestKValues", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "target", "type": "double" }, { "name": "k", "type": "integer" } ], "return": { "type": "list<integer>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'Stack', 'Tree', 'Depth-First Search', 'Binary Search Tree', 'Heap (Priority Queue)', 'Binary Tree']
273
Integer to English Words
integer-to-english-words
<p>Convert a non-negative integer <code>num</code> to its English words representation.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> num = 123 <strong>Output:</strong> &quot;One Hundred Twenty Three&quot; </pre> <p><strong class="example">Example 2:</strong></p> ...
Hard
537.4K
1.6M
537,445
1,568,030
34.3%
['integer-to-roman']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string numberToWords(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String numberToWords(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
123
{ "name": "numberToWords", "params": [ { "name": "num", "type": "integer" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Recursion']
274
H-Index
h-index
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return <em>the researcher&#39;s h-index</em>.</p> <p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_blank">defini...
Medium
694.2K
1.7M
694,175
1,733,585
40.0%
['h-index-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int hIndex(vector<int>& citations) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int hIndex(int[] citations) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[3,0,6,1,5]
{ "name": "hIndex", "params": [ { "name": "citations", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting', 'Counting Sort']
275
H-Index II
h-index-ii
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper and <code>citations</code> is sorted in <strong>non-descending order</strong>, return <em>the researcher&#39;s h-index</em>.</p> <p>According...
Medium
234.5K
605.5K
234,480
605,482
38.7%
['h-index']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int hIndex(vector<int>& citations) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int hIndex(int[] citations) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[0,1,3,5,6]
{ "name": "hIndex", "params": [ { "name": "citations", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
276
Paint Fence
paint-fence
null
Medium
121.8K
256K
121,811
256,048
47.6%
['house-robber', 'house-robber-ii', 'paint-house', 'paint-house-ii']
[]
Algorithms
null
3 2
{ "name": "numWays", "params": [ { "name": "n", "type": "integer" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming']
277
Find the Celebrity
find-the-celebrity
null
Medium
299.1K
619.2K
299,073
619,214
48.3%
['find-the-town-judge']
[]
Algorithms
null
[[1,1,0],[0,1,0],[1,1,1]]
{ "name": "findCelebrity", "params": [ { "name": "graph", "type": "integer[][]", "internal": true } ], "return": { "type": "integer" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'Graph', 'Interactive']
278
First Bad Version
first-bad-version
<p>You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.</p> <p>Suppose you have <code>n</code> version...
Easy
1.9M
4.2M
1,903,477
4,166,022
45.7%
['find-first-and-last-position-of-element-in-sorted-array', 'search-insert-position', 'guess-number-higher-or-lower']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "// The API isBadVersion is defined for you.\n// bool isBadVersion(int version);\n\nclass Solution {\npublic:\n int firstBadVersion(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "/* The isBadVersion API is defined in the parent class...
5 4
{ "name": "firstBadVersion", "params": [ { "name": "n", "type": "integer" }, { "name": "bad", "type": "integer" } ], "return": { "type": "integer" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Binary Search', 'Interactive']
279
Perfect Squares
perfect-squares
<p>Given an integer <code>n</code>, return <em>the least number of perfect square numbers that sum to</em> <code>n</code>.</p> <p>A <strong>perfect square</strong> is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, <code>1</code>, <code>4</code>,...
Medium
944.6K
1.7M
944,559
1,701,434
55.5%
['count-primes', 'ugly-number-ii', 'ways-to-express-an-integer-as-sum-of-powers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSquares(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSquares(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Soluti...
12
{ "name": "numSquares", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Breadth-First Search']
280
Wiggle Sort
wiggle-sort
null
Medium
151.2K
221.9K
151,196
221,912
68.1%
['sort-colors', 'wiggle-sort-ii', 'array-with-elements-not-equal-to-average-of-neighbors']
[]
Algorithms
null
[3,5,2,1,6,4]
{ "name": "wiggleSort", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "void" }, "output": { "paramindex": 0 } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
281
Zigzag Iterator
zigzag-iterator
null
Medium
102.8K
157.3K
102,844
157,267
65.4%
['binary-search-tree-iterator', 'flatten-2d-vector', 'peeking-iterator', 'flatten-nested-list-iterator', 'merge-strings-alternately']
[]
Algorithms
null
[1,2] [3,4,5,6]
{ "name": "ZigzagIterator", "params": [ { "name": "v1", "type": "list<integer>" }, { "name": "v2", "type": "list<integer>" } ], "return": { "type": "list<integer>", "dealloc": true }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Design', 'Queue', 'Iterator']
282
Expression Add Operators
expression-add-operators
<p>Given a string <code>num</code> that contains only digits and an integer <code>target</code>, return <em><strong>all possibilities</strong> to insert the binary operators </em><code>&#39;+&#39;</code><em>, </em><code>&#39;-&#39;</code><em>, and/or </em><code>&#39;*&#39;</code><em> between the digits of </em><code>nu...
Hard
268.7K
650.5K
268,697
650,514
41.3%
['evaluate-reverse-polish-notation', 'basic-calculator', 'basic-calculator-ii', 'different-ways-to-add-parentheses', 'target-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> addOperators(string num, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> addOperators(String num, int target) {\n \n }\n}"}, {"value"...
"123" 6
{ "name":"addOperators", "params":[ { "name":"num", "type":"string" }, { "name":"target", "type":"integer" } ], "return":{ "type":"list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Backtracking']
283
Move Zeroes
move-zeroes
<p>Given an integer array <code>nums</code>, move all <code>0</code>&#39;s to the end of it while maintaining the relative order of the non-zero elements.</p> <p><strong>Note</strong> that you must do this in-place without making a copy of the array.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p...
Easy
3.9M
6.2M
3,909,743
6,241,388
62.6%
['remove-element', 'apply-operations-to-an-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n void moveZeroes(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public void moveZeroes(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[0,1,0,3,12]
{ "name": "moveZeroes", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "void" }, "output": { "paramindex": 0 } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers']
284
Peeking Iterator
peeking-iterator
<p>Design an iterator that supports the <code>peek</code> operation on an existing iterator in addition to the <code>hasNext</code> and the <code>next</code> operations.</p> <p>Implement the <code>PeekingIterator</code> class:</p> <ul> <li><code>PeekingIterator(Iterator&lt;int&gt; nums)</code> Initializes the object...
Medium
235.1K
388.6K
235,060
388,554
60.5%
['binary-search-tree-iterator', 'flatten-2d-vector', 'zigzag-iterator']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n * Below is the interface for Iterator, which is already defined for you.\n * **DO NOT** modify the interface for Iterator.\n *\n * class Iterator {\n *\t\tstruct Data;\n * \t\tData* data;\n * public:\n *\t\tIterator(const vector<int>& nums);\n * \t\tIterator(const...
["PeekingIterator","next","peek","next","next","hasNext"] [[[1,2,3]],[],[],[],[],[]]
{ "name": "PeekingIterator", "params": [ { "name": "nums", "type": "list<integer>" }, { "name": "commands", "type": "list<integer>" } ], "return": { "type": "list<string>", "dealloc": true }, "languages": [ "cpp", "java", "python", "python3", ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Design', 'Iterator']
285
Inorder Successor in BST
inorder-successor-in-bst
null
Medium
352.7K
697.8K
352,735
697,818
50.5%
['binary-tree-inorder-traversal', 'binary-search-tree-iterator', 'inorder-successor-in-bst-ii']
[]
Algorithms
null
[2,1,3] 1
{ "name": "inorderSuccessor", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "p", "type": "integer", "dealloc": false, "deserialize": false } ], "return": { "type": "TreeNode", "serializevalue": true }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
286
Walls and Gates
walls-and-gates
null
Medium
373.1K
595K
373,055
594,961
62.7%
['surrounded-regions', 'number-of-islands', 'shortest-distance-from-all-buildings', 'battleships-in-a-board', 'robot-room-cleaner', 'rotting-oranges', 'count-the-number-of-houses-at-a-certain-distance-i', 'count-the-number-of-houses-at-a-certain-distance-ii']
[]
Algorithms
null
[[2147483647,-1,0,2147483647],[2147483647,2147483647,2147483647,-1],[2147483647,-1,2147483647,-1],[0,-1,2147483647,2147483647]]
{ "name": "wallsAndGates", "params": [ { "name": "rooms", "type": "integer[][]" } ], "return": { "type": "void" }, "output": { "paramindex": 0 } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Breadth-First Search', 'Matrix']
287
Find the Duplicate Number
find-the-duplicate-number
<p>Given an array of integers <code>nums</code> containing&nbsp;<code>n + 1</code> integers where each integer is in the range <code>[1, n]</code> inclusive.</p> <p>There is only <strong>one repeated number</strong> in <code>nums</code>, return <em>this&nbsp;repeated&nbsp;number</em>.</p> <p>You must solve the proble...
Medium
2.1M
3.3M
2,094,069
3,349,910
62.5%
['first-missing-positive', 'single-number', 'linked-list-cycle-ii', 'missing-number', 'set-mismatch']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findDuplicate(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findDuplicate(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[1,3,4,2,2]
{ "name": "findDuplicate", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Bit Manipulation']
288
Unique Word Abbreviation
unique-word-abbreviation
null
Medium
77K
285.9K
77,015
285,892
26.9%
['two-sum-iii-data-structure-design', 'generalized-abbreviation']
[]
Algorithms
null
["ValidWordAbbr","isUnique","isUnique","isUnique","isUnique","isUnique"] [[["deer","door","cake","card"]],["dear"],["cart"],["cane"],["make"],["cake"]]
{ "classname": "ValidWordAbbr", "maxbytesperline": 470000, "constructor": { "params": [ { "type": "string[]", "name": "dictionary" }, { "type": "integer", "name": "dictionarySize", "lang": "c", "value": "size_1" ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Design']
289
Game of Life
game-of-life
<p>According to <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank">Wikipedia&#39;s article</a>: &quot;The <b>Game of Life</b>, also known simply as <b>Life</b>, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.&quot;</p> <p>The board is made up of an ...
Medium
556.6K
782.7K
556,563
782,712
71.1%
['set-matrix-zeroes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n void gameOfLife(vector<vector<int>>& board) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public void gameOfLife(int[][] board) {\n \n }\n}"}, {"value": "python", "text": "Python...
[[0,1,0],[0,0,1],[1,1,1],[0,0,0]]
{ "name": "gameOfLife", "params": [ { "name": "board", "type": "integer[][]" } ], "return": { "type": "void" }, "output": { "paramindex": 0 } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix', 'Simulation']
290
Word Pattern
word-pattern
<p>Given a <code>pattern</code> and a string <code>s</code>, find if <code>s</code>&nbsp;follows the same pattern.</p> <p>Here <b>follow</b> means a full match, such that there is a bijection between a letter in <code>pattern</code> and a <b>non-empty</b> word in <code>s</code>. Specifically:</p> <ul> <li>Each lette...
Easy
914.3K
2.1M
914,317
2,130,828
42.9%
['isomorphic-strings', 'word-pattern-ii', 'find-and-replace-pattern']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool wordPattern(string pattern, string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean wordPattern(String pattern, String s) {\n \n }\n}"}, {"value": "python", "...
"abba" "dog cat cat dog"
{ "name": "wordPattern", "params": [ { "name": "pattern", "type": "string" }, { "name": "s", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String']
291
Word Pattern II
word-pattern-ii
null
Medium
80.9K
166.5K
80,869
166,489
48.6%
['word-pattern']
[]
Algorithms
null
"abab" "redblueredblue"
{ "name": "wordPatternMatch", "params": [ { "name": "pattern", "type": "string" }, { "name": "s", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Backtracking']
292
Nim Game
nim-game
<p>You are playing the following Nim Game with your friend:</p> <ul> <li>Initially, there is a heap of stones on the table.</li> <li>You and your friend will alternate taking turns, and <strong>you go first</strong>.</li> <li>On each turn, the person whose turn it is will remove 1 to 3 stones from the heap.</li> <...
Easy
441.2K
761.7K
441,217
761,703
57.9%
['flip-game-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canWinNim(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canWinNim(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Sol...
4
{ "name": "canWinNim", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Brainteaser', 'Game Theory']
293
Flip Game
flip-game
null
Easy
76.6K
118.1K
76,603
118,102
64.9%
['flip-game-ii']
[]
Algorithms
null
"++++"
{ "name": "generatePossibleNextMoves", "params": [ { "name": "currentState", "type": "string" } ], "return": { "type": "list<string>", "dealloc": true } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String']
294
Flip Game II
flip-game-ii
null
Medium
73.5K
140.8K
73,517
140,824
52.2%
['nim-game', 'flip-game', 'guess-number-higher-or-lower-ii', 'can-i-win']
[]
Algorithms
null
"++++"
{ "name": "canWin", "params": [ { "name": "currentState", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Backtracking', 'Memoization', 'Game Theory']
295
Find Median from Data Stream
find-median-from-data-stream
<p>The <strong>median</strong> is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of the two middle values.</p> <ul> <li>For example, for <code>arr = [2,3,4]</code>, the median is <code>3</code>.</li> <li>For example, for <code>arr = ...
Hard
974.3K
1.8M
974,253
1,834,120
53.1%
['sliding-window-median', 'finding-mk-average', 'sequentially-ordinal-rank-tracker', 'minimum-operations-to-make-median-of-array-equal-to-k', 'minimum-operations-to-make-subarray-elements-equal', 'minimum-operations-to-make-elements-within-k-subarrays-equal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MedianFinder {\npublic:\n MedianFinder() {\n \n }\n \n void addNum(int num) {\n \n }\n \n double findMedian() {\n \n }\n};\n\n/**\n * Your MedianFinder object will be instantiated and called as such:\n * MedianFinder* ob...
["MedianFinder","addNum","addNum","findMedian","addNum","findMedian"] [[],[1],[2],[],[3],[]]
{ "classname": "MedianFinder", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "num" } ], "name": "addNum", "return": { "type": "void" } }, { "params": [], "name": "find...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'Design', 'Sorting', 'Heap (Priority Queue)', 'Data Stream']
296
Best Meeting Point
best-meeting-point
null
Hard
91.5K
149.5K
91,542
149,525
61.2%
['shortest-distance-from-all-buildings', 'minimum-moves-to-equal-array-elements-ii']
[]
Algorithms
null
[[1,0,0,0,1],[0,0,0,0,0],[0,0,1,0,0]]
{ "name": "minTotalDistance", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Sorting', 'Matrix']
297
Serialize and Deserialize Binary Tree
serialize-and-deserialize-binary-tree
<p>Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.</p> <p>Design an algorithm to serialize and deseri...
Hard
1M
1.7M
1,008,174
1,721,993
58.5%
['encode-and-decode-strings', 'serialize-and-deserialize-bst', 'find-duplicate-subtrees', 'serialize-and-deserialize-n-ary-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Codec {\npublic:\n\n // Encodes a tree to a single string...
[1,2,3,null,null,4,5]
{ "name": "Codec", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "string" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Tree', 'Depth-First Search', 'Breadth-First Search', 'Design', 'Binary Tree']
298
Binary Tree Longest Consecutive Sequence
binary-tree-longest-consecutive-sequence
null
Medium
155.1K
287K
155,094
287,027
54.0%
['longest-consecutive-sequence', 'binary-tree-longest-consecutive-sequence-ii', 'check-if-an-array-is-consecutive']
[]
Algorithms
null
[1,null,3,2,4,null,null,null,5]
{ "name": "longestConsecutive", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
299
Bulls and Cows
bulls-and-cows
<p>You are playing the <strong><a href="https://en.wikipedia.org/wiki/Bulls_and_Cows" target="_blank">Bulls and Cows</a></strong> game with your friend.</p> <p>You write down a secret number and ask your friend to guess what the number is. When your friend makes a guess, you provide a hint with the following info:</p>...
Medium
405.3K
791.8K
405,289
791,815
51.2%
['make-number-of-distinct-characters-equal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string getHint(string secret, string guess) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String getHint(String secret, String guess) {\n \n }\n}"}, {"value": "python", "t...
"1807" "7810"
{ "name": "getHint", "params": [ { "name": "secret", "type": "string" }, { "name": "guess", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Counting']
300
Longest Increasing Subsequence
longest-increasing-subsequence
<p>Given an integer array <code>nums</code>, return <em>the length of the longest <strong>strictly increasing </strong></em><span data-keyword="subsequence-array"><em><strong>subsequence</strong></em></span>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> nums = [10...
Medium
2.1M
3.7M
2,100,739
3,660,685
57.4%
['increasing-triplet-subsequence', 'russian-doll-envelopes', 'maximum-length-of-pair-chain', 'number-of-longest-increasing-subsequence', 'minimum-ascii-delete-sum-for-two-strings', 'minimum-number-of-removals-to-make-mountain-array', 'find-the-longest-valid-obstacle-course-at-each-position', 'minimum-operations-to-make...
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int lengthOfLIS(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int lengthOfLIS(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[10,9,2,5,3,7,101,18]
{ "name": "lengthOfLIS", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Dynamic Programming']