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
501
Find Mode in Binary Search Tree
find-mode-in-binary-search-tree
<p>Given the <code>root</code> of a binary search tree (BST) with duplicates, return <em>all the <a href="https://en.wikipedia.org/wiki/Mode_(statistics)" target="_blank">mode(s)</a> (i.e., the most frequently occurred element) in it</em>.</p> <p>If the tree has more than one mode, return them in <strong>any order</st...
Easy
344.6K
601.6K
344,638
601,555
57.3%
['validate-binary-search-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...
[1,null,2,2]
{ "name": "findMode", "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 Search Tree', 'Binary Tree']
502
IPO
ipo
<p>Suppose LeetCode will start its <strong>IPO</strong> soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the <strong>IPO</strong>. Since it has limited resources, it can only finish at most <code>k</code> distinct projects ...
Hard
264.8K
499.5K
264,756
499,459
53.0%
['maximum-subsequence-score', 'maximum-elegance-of-a-k-length-subsequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findMaximizedCapital(int k, int w, vector<int>& profits, vector<int>& capital) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findMaximizedCapital(int k, int w, int[] profits...
2 0 [1,2,3] [0,1,1]
{ "name": "findMaximizedCapital", "params": [ { "name": "k", "type": "integer" }, { "name": "w", "type": "integer" }, { "name": "profits", "type": "integer[]" }, { "name": "capital", "type": "integer[]" } ], "return": { "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...
['Array', 'Greedy', 'Sorting', 'Heap (Priority Queue)']
503
Next Greater Element II
next-greater-element-ii
<p>Given a circular integer array <code>nums</code> (i.e., the next element of <code>nums[nums.length - 1]</code> is <code>nums[0]</code>), return <em>the <strong>next greater number</strong> for every element in</em> <code>nums</code>.</p> <p>The <strong>next greater number</strong> of a number <code>x</code> is the ...
Medium
545.4K
829K
545,392
828,965
65.8%
['next-greater-element-i', 'next-greater-element-iii', 'maximum-and-minimum-sums-of-at-most-size-k-subarrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> nextGreaterElements(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] nextGreaterElements(int[] nums) {\n \n }\n}"}, {"value": "python", "...
[1,2,1]
{ "name": "nextGreaterElements", "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', 'Stack', 'Monotonic Stack']
504
Base 7
base-7
<p>Given an integer <code>num</code>, return <em>a string of its <strong>base 7</strong> representation</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre><strong>Input:</strong> num = 100 <strong>Output:</strong> "202" </pre><p><strong class="example">Example 2:</strong></p> <pre><strong>...
Easy
161K
311.8K
161,046
311,768
51.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string convertToBase7(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String convertToBase7(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
100
{ "name": "convertToBase7", "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']
505
The Maze II
the-maze-ii
null
Medium
116.8K
216K
116,759
216,039
54.0%
['the-maze', 'the-maze-iii']
[]
Algorithms
null
[[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]] [0,4] [4,4]
{ "name": "shortestDistance", "params": [ { "name": "maze", "type": "integer[][]" }, { "name": "start", "type": "integer[]" }, { "name": "destination", "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', 'Depth-First Search', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path']
506
Relative Ranks
relative-ranks
<p>You are given an integer array <code>score</code> of size <code>n</code>, where <code>score[i]</code> is the score of the <code>i<sup>th</sup></code> athlete in a competition. All the scores are guaranteed to be <strong>unique</strong>.</p> <p>The athletes are <strong>placed</strong> based on their scores, where th...
Easy
342.6K
469.1K
342,596
469,055
73.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> findRelativeRanks(vector<int>& score) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String[] findRelativeRanks(int[] score) {\n \n }\n}"}, {"value": "python...
[5,4,3,2,1]
{ "name": "findRelativeRanks", "params": [ { "name": "score", "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...
['Array', 'Sorting', 'Heap (Priority Queue)']
507
Perfect Number
perfect-number
<p>A <a href="https://en.wikipedia.org/wiki/Perfect_number" target="_blank"><strong>perfect number</strong></a> is a <strong>positive integer</strong> that is equal to the sum of its <strong>positive divisors</strong>, excluding the number itself. A <strong>divisor</strong> of an integer <code>x</code> is an integer th...
Easy
260.6K
588.5K
260,631
588,520
44.3%
['self-dividing-numbers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool checkPerfectNumber(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean checkPerfectNumber(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
28
{ "name": "checkPerfectNumber", "params": [ { "name": "num", "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']
508
Most Frequent Subtree Sum
most-frequent-subtree-sum
<p>Given the <code>root</code> of a binary tree, return the most frequent <strong>subtree sum</strong>. If there is a tie, return all the values with the highest frequency in any order.</p> <p>The <strong>subtree sum</strong> of a node is defined as the sum of all the node values formed by the subtree rooted at that n...
Medium
157.1K
232.3K
157,069
232,317
67.6%
['subtree-of-another-tree', 'count-nodes-equal-to-sum-of-descendants']
[]
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...
[5,2,-3]
{ "name": "findFrequentTreeSum", "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...
['Hash Table', 'Tree', 'Depth-First Search', 'Binary Tree']
509
Fibonacci Number
fibonacci-number
<p>The <b>Fibonacci numbers</b>, commonly denoted <code>F(n)</code> form a sequence, called the <b>Fibonacci sequence</b>, such that each number is the sum of the two preceding ones, starting from <code>0</code> and <code>1</code>. That is,</p> <pre> F(0) = 0, F(1) = 1 F(n) = F(n - 1) + F(n - 2), for n &gt; 1. </pre> ...
Easy
2.3M
3.2M
2,327,335
3,201,989
72.7%
['climbing-stairs', 'split-array-into-fibonacci-sequence', 'length-of-longest-fibonacci-subsequence', 'n-th-tribonacci-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int fib(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int fib(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution(object):\n ...
2
{ "name": "fib", "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', 'Memoization']
510
Inorder Successor in BST II
inorder-successor-in-bst-ii
null
Medium
70.3K
115.3K
70,289
115,334
60.9%
['inorder-successor-in-bst']
[]
Algorithms
null
[2,1,3] 1
{ "name": "inorderSuccessor", "params": [ { "name": "tree", "type": "TreeNode" }, { "name": "node", "type": "integer" } ], "return": { "type": "TreeNode" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "kot...
{"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', 'Binary Search Tree', 'Binary Tree']
511
Game Play Analysis I
game-play-analysis-i
<p>Table: <code>Activity</code></p> <pre> +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ (player_id, event_date) is the primary key (combination of co...
Easy
357.8K
473.6K
357,816
473,589
75.6%
['game-play-analysis-ii']
['Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)', 'Truncate table Activity', "insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')", "insert into Activity (player_id, device_id, event_date, games_played) values...
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":{"Activity":["player_id","device_id","event_date","games_played"]},"rows":{"Activity":[[1,2,"2016-03-01",5],[1,2,"2016-05-02",6],[2,3,"2017-06-25",1],[3,1,"2016-03-02",0],[3,4,"2018-07-03",5]]}}
{"mysql": ["Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)"], "mssql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int)"], "oraclesql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int...
{"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']
512
Game Play Analysis II
game-play-analysis-ii
null
Easy
96.4K
179.2K
96,428
179,190
53.8%
['game-play-analysis-i', 'game-play-analysis-iii']
['Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)', 'Truncate table Activity', "insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')", "insert into Activity (player_id, device_id, event_date, games_played) values...
Database
null
{"headers":{"Activity":["player_id","device_id","event_date","games_played"]},"rows":{"Activity":[[1,2,"2016-03-01",5],[1,2,"2016-05-02",6],[2,3,"2017-06-25",1],[3,1,"2016-03-02",0],[3,4,"2018-07-03",5]]}}
{"mysql": ["Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)"], "mssql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int)"], "oraclesql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int...
{"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']
513
Find Bottom Left Tree Value
find-bottom-left-tree-value
<p>Given the <code>root</code> of a binary tree, return the leftmost value in the last row of the tree.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2020/12/14/tree1.jpg" style="width: 302px; height: 182px;" /> <pre> <strong>Input:</strong> r...
Medium
397K
554.1K
396,955
554,082
71.6%
[]
[]
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...
[2,1,3]
{ "name": "findBottomLeftValue", "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', 'Breadth-First Search', 'Binary Tree']
514
Freedom Trail
freedom-trail
<p>In the video game Fallout 4, the quest <strong>&quot;Road to Freedom&quot;</strong> requires players to reach a metal dial called the <strong>&quot;Freedom Trail Ring&quot;</strong> and use the dial to spell a specific keyword to open the door.</p> <p>Given a string <code>ring</code> that represents the code engrav...
Hard
115.3K
196K
115,342
196,044
58.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findRotateSteps(string ring, string key) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findRotateSteps(String ring, String key) {\n \n }\n}"}, {"value": "python", ...
"godding" "gd"
{ "name": "findRotateSteps", "params": [ { "name": "ring", "type": "string" }, { "name": "key", "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...
['String', 'Dynamic Programming', 'Depth-First Search', 'Breadth-First Search']
515
Find Largest Value in Each Tree Row
find-largest-value-in-each-tree-row
<p>Given the <code>root</code> of a binary tree, return <em>an array of the largest value in each row</em> of the tree <strong>(0-indexed)</strong>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2020/08/21/largest_e1.jpg" style="width: 300px; ...
Medium
473.9K
715K
473,929
715,040
66.3%
[]
[]
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,3,2,5,3,null,9]
{ "name": "largestValues", "params": [ { "name": "root", "type": "TreeNode" } ], "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...
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree']
516
Longest Palindromic Subsequence
longest-palindromic-subsequence
<p>Given a string <code>s</code>, find <em>the longest palindromic <strong>subsequence</strong>&#39;s length in</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.</p> <...
Medium
602.6K
944.6K
602,648
944,625
63.8%
['longest-palindromic-substring', 'palindromic-substrings', 'count-different-palindromic-subsequences', 'longest-common-subsequence', 'longest-palindromic-subsequence-ii', 'maximize-palindrome-length-from-subsequences', 'maximum-product-of-the-length-of-two-palindromic-subsequences']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestPalindromeSubseq(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestPalindromeSubseq(String s) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
"bbbab"
{ "name": "longestPalindromeSubseq", "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...
['String', 'Dynamic Programming']
517
Super Washing Machines
super-washing-machines
<p>You have <code>n</code> super washing machines on a line. Initially, each washing machine has some dresses or is empty.</p> <p>For each move, you could choose any <code>m</code> (<code>1 &lt;= m &lt;= n</code>) washing machines, and pass one dress of each washing machine to one of its adjacent washing machines at t...
Hard
33.6K
79.7K
33,648
79,707
42.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findMinMoves(vector<int>& machines) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findMinMoves(int[] machines) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[1,0,5]
{ "name": "findMinMoves", "params": [ { "name": "machines", "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', 'Greedy']
518
Coin Change II
coin-change-ii
<p>You are given an integer array <code>coins</code> representing coins of different denominations and an integer <code>amount</code> representing a total amount of money.</p> <p>Return <em>the number of combinations that make up that amount</em>. If that amount of money cannot be made up by any combination of the coi...
Medium
779.1K
1.2M
779,111
1,238,840
62.9%
['maximum-value-of-k-coins-from-piles', 'number-of-ways-to-earn-points', 'count-of-sub-multisets-with-bounded-sum', 'length-of-the-longest-subsequence-that-sums-to-target', 'the-number-of-ways-to-make-the-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int change(int amount, vector<int>& coins) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int change(int amount, int[] coins) {\n \n }\n}"}, {"value": "python", "text": "Py...
5 [1,2,5]
{ "name": "change", "params": [ { "name": "amount", "type": "integer" }, { "name": "coins", "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']
519
Random Flip Matrix
random-flip-matrix
<p>There is an <code>m x n</code> binary grid <code>matrix</code> with all the values set <code>0</code> initially. Design an algorithm to randomly pick an index <code>(i, j)</code> where <code>matrix[i][j] == 0</code> and flips it to <code>1</code>. All the indices <code>(i, j)</code> where <code>matrix[i][j] == 0</co...
Medium
25.2K
58.2K
25,169
58,164
43.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n Solution(int m, int n) {\n \n }\n \n vector<int> flip() {\n \n }\n \n void reset() {\n \n }\n};\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution* obj = new Solut...
["Solution","flip","flip","flip","reset","flip"] [[3,1],[],[],[],[],[]]
{ "classname": "Solution", "maxbytesperline": 200000, "constructor": { "params": [ { "name": "m", "type": "integer" }, { "name": "n", "type": "integer" } ] }, "methods": [ { "name": "flip", "params": [], "return": { ...
{"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', 'Reservoir Sampling', 'Randomized']
520
Detect Capital
detect-capital
<p>We define the usage of capitals in a word to be right when one of the following cases holds:</p> <ul> <li>All letters in this word are capitals, like <code>&quot;USA&quot;</code>.</li> <li>All letters in this word are not capitals, like <code>&quot;leetcode&quot;</code>.</li> <li>Only the first letter in this wo...
Easy
478.5K
852.4K
478,499
852,439
56.1%
['capitalize-the-title', 'count-the-number-of-special-characters-ii', 'count-the-number-of-special-characters-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool detectCapitalUse(string word) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean detectCapitalUse(String word) {\n \n }\n}"}, {"value": "python", "text": "Python",...
"USA"
{ "name": "detectCapitalUse", "params": [ { "name": "word", "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...
['String']
521
Longest Uncommon Subsequence I
longest-uncommon-subsequence-i
<p>Given two strings <code>a</code> and <code>b</code>, return <em>the length of the <strong>longest uncommon subsequence</strong> between </em><code>a</code> <em>and</em> <code>b</code>. <em>If no such uncommon subsequence exists, return</em> <code>-1</code><em>.</em></p> <p>An <strong>uncommon subsequence</strong> b...
Easy
129.9K
212.2K
129,896
212,217
61.2%
['longest-uncommon-subsequence-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLUSlength(string a, string b) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLUSlength(String a, String b) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
"aba" "cdc"
{ "name": "findLUSlength", "params": [ { "name": "a", "type": "string" }, { "name": "b", "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...
['String']
522
Longest Uncommon Subsequence II
longest-uncommon-subsequence-ii
<p>Given an array of strings <code>strs</code>, return <em>the length of the <strong>longest uncommon subsequence</strong> between them</em>. If the longest uncommon subsequence does not exist, return <code>-1</code>.</p> <p>An <strong>uncommon subsequence</strong> between an array of strings is a string that is a <st...
Medium
58.8K
137.6K
58,830
137,560
42.8%
['longest-uncommon-subsequence-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLUSlength(vector<string>& strs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLUSlength(String[] strs) {\n \n }\n}"}, {"value": "python", "text": "Python",...
["aba","cdc","eae"]
{ "name": "findLUSlength", "params": [ { "name": "strs", "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', 'Hash Table', 'Two Pointers', 'String', 'Sorting']
523
Continuous Subarray Sum
continuous-subarray-sum
<p>Given an integer array nums and an integer k, return <code>true</code> <em>if </em><code>nums</code><em> has a <strong>good subarray</strong> or </em><code>false</code><em> otherwise</em>.</p> <p>A <strong>good subarray</strong> is a subarray where:</p> <ul> <li>its length is <strong>at least two</strong>, and</l...
Medium
666K
2.2M
666,015
2,163,511
30.8%
['subarray-sum-equals-k', 'minimum-number-of-operations-to-make-array-continuous', 'intervals-between-identical-elements', 'apply-operations-to-make-all-array-elements-equal-to-zero']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool checkSubarraySum(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean checkSubarraySum(int[] nums, int k) {\n \n }\n}"}, {"value": "python"...
[23,2,4,6,7] 6
{ "name": "checkSubarraySum", "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', 'Math', 'Prefix Sum']
524
Longest Word in Dictionary through Deleting
longest-word-in-dictionary-through-deleting
<p>Given a string <code>s</code> and a string array <code>dictionary</code>, return <em>the longest string in the dictionary that can be formed by deleting some of the given string characters</em>. If there is more than one possible result, return the longest word with the smallest lexicographical order. If there is no...
Medium
166.5K
322.3K
166,473
322,316
51.6%
['longest-word-in-dictionary']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string findLongestWord(string s, vector<string>& dictionary) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String findLongestWord(String s, List<String> dictionary) {\n \n ...
"abpcplea" ["ale","apple","monkey","plea"]
{ "name": "findLongestWord", "params": [ { "name": "s", "type": "string" }, { "name": "dictionary", "type": "list<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', 'Two Pointers', 'String', 'Sorting']
525
Contiguous Array
contiguous-array
<p>Given a binary array <code>nums</code>, return <em>the maximum length of a contiguous subarray with an equal number of </em><code>0</code><em> and </em><code>1</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> nums = [0,1] <strong>Output:</strong> 2 <strong>...
Medium
546.6K
1.1M
546,625
1,114,908
49.0%
['maximum-size-subarray-sum-equals-k', 'find-all-possible-stable-binary-arrays-i', 'find-all-possible-stable-binary-arrays-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findMaxLength(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findMaxLength(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[0,1]
{ "name": "findMaxLength", "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', 'Prefix Sum']
526
Beautiful Arrangement
beautiful-arrangement
<p>Suppose you have <code>n</code> integers labeled <code>1</code> through <code>n</code>. A permutation of those <code>n</code> integers <code>perm</code> (<strong>1-indexed</strong>) is considered a <strong>beautiful arrangement</strong> if for every <code>i</code> (<code>1 &lt;= i &lt;= n</code>), <strong>either</st...
Medium
193.8K
300.6K
193,820
300,640
64.5%
['beautiful-arrangement-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countArrangement(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countArrangement(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
2
{ "name": "countArrangement", "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', 'Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'Bitmask']
527
Word Abbreviation
word-abbreviation
null
Hard
29.7K
48K
29,652
48,029
61.7%
['valid-word-abbreviation', 'minimum-unique-word-abbreviation', 'check-if-a-string-is-an-acronym-of-words']
[]
Algorithms
null
["like","god","internal","me","internet","interval","intension","face","intrusion"]
{ "name": "wordsAbbreviation", "params": [ { "name": "words", "type": "list<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', 'Greedy', 'Trie', 'Sorting']
528
Random Pick with Weight
random-pick-with-weight
<p>You are given a <strong>0-indexed</strong> array of positive integers <code>w</code> where <code>w[i]</code> describes the <strong>weight</strong> of the <code>i<sup>th</sup></code> index.</p> <p>You need to implement the function <code>pickIndex()</code>, which <strong>randomly</strong> picks an index in the range...
Medium
595.3K
1.2M
595,330
1,231,809
48.3%
['random-pick-index', 'random-pick-with-blacklist', 'random-point-in-non-overlapping-rectangles']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n Solution(vector<int>& w) {\n \n }\n \n int pickIndex() {\n \n }\n};\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution* obj = new Solution(w);\n * int param_1 = obj->pickIndex();\...
["Solution","pickIndex"] [[[1]],[]]
{ "classname": "Solution", "maxbytesperline": 200000, "constructor": { "params": [ { "name": "w", "type": "integer[]" }, { "name": "wSize", "type": "integer", "lang": "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...
['Array', 'Math', 'Binary Search', 'Prefix Sum', 'Randomized']
529
Minesweeper
minesweeper
<p>Let&#39;s play the minesweeper game (<a href="https://en.wikipedia.org/wiki/Minesweeper_(video_game)" target="_blank">Wikipedia</a>, <a href="http://minesweeperonline.com" target="_blank">online game</a>)!</p> <p>You are given an <code>m x n</code> char matrix <code>board</code> representing the game board where:</...
Medium
182.3K
268.5K
182,268
268,531
67.9%
['detonate-the-maximum-bombs']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<char>> updateBoard(vector<vector<char>>& board, vector<int>& click) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public char[][] updateBoard(char[][] board, int[] click) {\n...
[["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]] [3,0]
{ "name": "updateBoard", "params": [ { "name": "board", "type": "character[][]" }, { "name":"click", "type":"integer[]" } ], "return": { "type": "character[][]" } }
{"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', 'Depth-First Search', 'Breadth-First Search', 'Matrix']
530
Minimum Absolute Difference in BST
minimum-absolute-difference-in-bst
<p>Given the <code>root</code> of a Binary Search Tree (BST), return <em>the minimum absolute difference between the values of any two different nodes in the tree</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/02/05/bst1.jpg" style="...
Easy
500.9K
853.1K
500,911
853,051
58.7%
['k-diff-pairs-in-an-array']
[]
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,6,1,3]
{ "name": "getMinimumDifference", "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', 'Breadth-First Search', 'Binary Search Tree', 'Binary Tree']
531
Lonely Pixel I
lonely-pixel-i
null
Medium
45.8K
73.3K
45,781
73,264
62.5%
['lonely-pixel-ii']
[]
Algorithms
null
[["W","W","B"],["W","B","W"],["B","W","W"]]
{ "name": "findLonelyPixel", "params": [ { "name": "picture", "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', 'Hash Table', 'Matrix']
532
K-diff Pairs in an Array
k-diff-pairs-in-an-array
<p>Given an array of integers <code>nums</code> and an integer <code>k</code>, return <em>the number of <b>unique</b> k-diff pairs in the array</em>.</p> <p>A <strong>k-diff</strong> pair is an integer pair <code>(nums[i], nums[j])</code>, where the following are true:</p> <ul> <li><code>0 &lt;= i, j &lt; nums.lengt...
Medium
383.4K
863.5K
383,396
863,495
44.4%
['minimum-absolute-difference-in-bst', 'count-number-of-pairs-with-absolute-difference-k', 'kth-smallest-product-of-two-sorted-arrays', 'count-number-of-bad-pairs', 'number-of-pairs-satisfying-inequality', 'minimum-absolute-difference-between-elements-with-constraint']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findPairs(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findPairs(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[3,1,4,1,5] 2
{ "name": "findPairs", "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', 'Hash Table', 'Two Pointers', 'Binary Search', 'Sorting']
533
Lonely Pixel II
lonely-pixel-ii
null
Medium
13.8K
28.5K
13,835
28,452
48.6%
['lonely-pixel-i']
[]
Algorithms
null
[["W","B","W","B","B","W"],["W","B","W","B","B","W"],["W","B","W","B","B","W"],["W","W","B","W","B","W"]] 3
{ "name": "findBlackPixel", "params": [ { "name": "picture", "type": "character[][]" }, { "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', 'Hash Table', 'Matrix']
534
Game Play Analysis III
game-play-analysis-iii
null
Medium
86.4K
106.4K
86,355
106,366
81.2%
['game-play-analysis-ii', 'game-play-analysis-iv']
['Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)', 'Truncate table Activity', "insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')", "insert into Activity (player_id, device_id, event_date, games_played) values...
Database
null
{"headers":{"Activity":["player_id","device_id","event_date","games_played"]},"rows":{"Activity":[[1,2,"2016-03-01",5],[1,2,"2016-05-02",6],[1,3,"2017-06-25",1],[3,1,"2016-03-02",0],[3,4,"2018-07-03",5]]}}
{"mysql": ["Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)"], "mssql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int)"], "oraclesql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int...
{"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>"]}
['Database']
535
Encode and Decode TinyURL
encode-and-decode-tinyurl
<blockquote>Note: This is a companion problem to the <a href="https://leetcode.com/discuss/interview-question/system-design/" target="_blank">System Design</a> problem: <a href="https://leetcode.com/discuss/interview-question/124658/Design-a-URL-Shortener-(-TinyURL-)-System/" target="_blank">Design TinyURL</a>.</blockq...
Medium
281.7K
325.2K
281,698
325,176
86.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n\n // Encodes a URL to a shortened URL.\n string encode(string longUrl) {\n \n }\n\n // Decodes a shortened URL to its original URL.\n string decode(string shortUrl) {\n \n }\n};\n\n// Your Solution object will b...
"https://leetcode.com/problems/design-tinyurl"
{ "name": "CodecDriver", "params": [ { "name": "url", "type": "string" } ], "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...
['Hash Table', 'String', 'Design', 'Hash Function']
536
Construct Binary Tree from String
construct-binary-tree-from-string
null
Medium
115.9K
199.3K
115,928
199,315
58.2%
['construct-string-from-binary-tree']
[]
Algorithms
null
"4(2(3)(1))(6(5))"
{ "name": "str2tree", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "TreeNode", "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', 'Stack', 'Tree', 'Depth-First Search', 'Binary Tree']
537
Complex Number Multiplication
complex-number-multiplication
<p>A <a href="https://en.wikipedia.org/wiki/Complex_number" target="_blank">complex number</a> can be represented as a string on the form <code>&quot;<strong>real</strong>+<strong>imaginary</strong>i&quot;</code> where:</p> <ul> <li><code>real</code> is the real part and is an integer in the range <code>[-100, 100]</...
Medium
102.3K
141.6K
102,340
141,599
72.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string complexNumberMultiply(string num1, string num2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String complexNumberMultiply(String num1, String num2) {\n \n }\n}"}, ...
"1+1i" "1+1i"
{ "name": "complexNumberMultiply", "params": [ { "name": "num1", "type": "string" }, { "name": "num2", "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...
['Math', 'String', 'Simulation']
538
Convert BST to Greater Tree
convert-bst-to-greater-tree
<p>Given the <code>root</code> of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.</p> <p>As a reminder, a <em>binary search tree</em> is a tree that satisfies these constraints...
Medium
324.8K
462K
324,756
462,002
70.3%
[]
[]
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,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
{ "name": "convertBST", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" }, "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...
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
539
Minimum Time Difference
minimum-time-difference
Given a list of 24-hour clock time points in <strong>&quot;HH:MM&quot;</strong> format, return <em>the minimum <b>minutes</b> difference between any two time-points in the list</em>. <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre><strong>Input:</strong> timePoints = ["23:59","00:00"] <strong>Outp...
Medium
318.8K
511.8K
318,809
511,813
62.3%
['minimum-cost-to-set-cooking-time']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findMinDifference(vector<string>& timePoints) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findMinDifference(List<String> timePoints) {\n \n }\n}"}, {"value": "py...
["23:59","00:00"]
{ "name": "findMinDifference", "params": [ { "name": "timePoints", "type": "list<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', 'Math', 'String', 'Sorting']
540
Single Element in a Sorted Array
single-element-in-a-sorted-array
<p>You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.</p> <p>Return <em>the single element that appears only once</em>.</p> <p>Your solution must run in <code>O(log n)</code> time and <code>O(1)</code> space.</p> <p>&...
Medium
879.4K
1.5M
879,374
1,485,920
59.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int singleNonDuplicate(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int singleNonDuplicate(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,1,2,3,3,4,4,8,8]
{ "name": "singleNonDuplicate", "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', 'Binary Search']
541
Reverse String II
reverse-string-ii
<p>Given a string <code>s</code> and an integer <code>k</code>, reverse the first <code>k</code> characters for every <code>2k</code> characters counting from the start of the string.</p> <p>If there are fewer than <code>k</code> characters left, reverse all of them. If there are less than <code>2k</code> but greater ...
Easy
298.7K
575.7K
298,727
575,677
51.9%
['reverse-string', 'reverse-words-in-a-string-iii', 'faulty-keyboard']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string reverseStr(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String reverseStr(String s, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "d...
"abcdefg" 2
{ "name": "reverseStr", "params": [ { "name": "s", "type": "string" }, { "name": "k", "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...
['Two Pointers', 'String']
542
01 Matrix
01-matrix
<p>Given an <code>m x n</code> binary matrix <code>mat</code>, return <em>the distance of the nearest </em><code>0</code><em> for each cell</em>.</p> <p>The distance between two cells sharing a common edge is <code>1</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https:/...
Medium
710.8K
1.4M
710,847
1,395,200
50.9%
['shortest-path-to-get-food', 'minimum-operations-to-remove-adjacent-ones-in-matrix', 'difference-between-ones-and-zeros-in-row-and-column']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> updateMatrix(vector<vector<int>>& mat) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] updateMatrix(int[][] mat) {\n \n }\n}"}, {"value": "python...
[[0,0,0],[0,1,0],[0,0,0]]
{ "name": "updateMatrix", "params": [ { "name": "mat", "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', 'Breadth-First Search', 'Matrix']
543
Diameter of Binary Tree
diameter-of-binary-tree
<p>Given the <code>root</code> of a binary tree, return <em>the length of the <strong>diameter</strong> of the tree</em>.</p> <p>The <strong>diameter</strong> of a binary tree is the <strong>length</strong> of the longest path between any two nodes in a tree. This path may or may not pass through the <code>root</code>...
Easy
2M
3.1M
1,952,394
3,096,417
63.1%
['diameter-of-n-ary-tree', 'longest-path-with-different-adjacent-characters']
[]
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]
{ "name": "diameterOfBinaryTree", "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']
544
Output Contest Matches
output-contest-matches
null
Medium
27.8K
36K
27,846
35,992
77.4%
[]
[]
Algorithms
null
4
{ "name": "findContestMatch", "params": [ { "name": "n", "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...
['String', 'Recursion', 'Simulation']
545
Boundary of Binary Tree
boundary-of-binary-tree
null
Medium
155.5K
331.4K
155,547
331,447
46.9%
['binary-tree-right-side-view']
[]
Algorithms
null
[1,null,2,3,4]
{ "name": "boundaryOfBinaryTree", "params": [ { "name": "root", "type": "TreeNode" } ], "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...
['Tree', 'Depth-First Search', 'Binary Tree']
546
Remove Boxes
remove-boxes
<p>You are given several <code>boxes</code> with different colors represented by different positive numbers.</p> <p>You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (i.e., composed of <code>k</code> boxes, <code>k &gt;= 1</...
Hard
52.2K
108.4K
52,239
108,390
48.2%
['strange-printer', 'number-of-unique-flavors-after-sharing-k-candies']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int removeBoxes(vector<int>& boxes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int removeBoxes(int[] boxes) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[1,3,2,2,2,3,4,3,1]
{ "name": "removeBoxes", "params": [ { "name": "boxes", "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', 'Memoization']
547
Number of Provinces
number-of-provinces
<p>There are <code>n</code> cities. Some of them are connected, while some are not. If city <code>a</code> is connected directly with city <code>b</code>, and city <code>b</code> is connected directly with city <code>c</code>, then city <code>a</code> is connected indirectly with city <code>c</code>.</p> <p>A <strong>...
Medium
1.2M
1.7M
1,166,194
1,709,955
68.2%
['number-of-connected-components-in-an-undirected-graph', 'robot-return-to-origin', 'sentence-similarity', 'sentence-similarity-ii', 'the-earliest-moment-when-everyone-become-friends', 'detonate-the-maximum-bombs']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findCircleNum(vector<vector<int>>& isConnected) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findCircleNum(int[][] isConnected) {\n \n }\n}"}, {"value": "python",...
[[1,1,0],[1,1,0],[0,0,1]]
{ "name": "findCircleNum", "params": [ { "name": "isConnected", "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...
['Depth-First Search', 'Breadth-First Search', 'Union Find', 'Graph']
548
Split Array with Equal Sum
split-array-with-equal-sum
null
Hard
24.5K
48.9K
24,502
48,866
50.1%
['fair-distribution-of-cookies', 'number-of-ways-to-split-a-string']
[]
Algorithms
null
[1,2,1,2,1,2,1]
{ "name": "splitArray", "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', 'Prefix Sum']
549
Binary Tree Longest Consecutive Sequence II
binary-tree-longest-consecutive-sequence-ii
null
Medium
56.6K
114.2K
56,602
114,213
49.6%
['binary-tree-longest-consecutive-sequence', 'check-if-an-array-is-consecutive']
[]
Algorithms
null
[1,2,3]
{ "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']
550
Game Play Analysis IV
game-play-analysis-iv
<p>Table: <code>Activity</code></p> <pre> +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ (player_id, event_date) is the primary key (combination of co...
Medium
299.5K
765.5K
299,490
765,453
39.1%
['game-play-analysis-iii', 'game-play-analysis-v']
['Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)', 'Truncate table Activity', "insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')", "insert into Activity (player_id, device_id, event_date, games_played) values...
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":{"Activity":["player_id","device_id","event_date","games_played"]},"rows":{"Activity":[[1,2,"2016-03-01",5],[1,2,"2016-03-02",6],[2,3,"2017-06-25",1],[3,1,"2016-03-02",0],[3,4,"2018-07-03",5]]}}
{"mysql": ["Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)"], "mssql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int)"], "oraclesql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int...
{"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']
551
Student Attendance Record I
student-attendance-record-i
<p>You are given a string <code>s</code> representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:</p> <ul> <li><code>&#39;A&#39;</code>: Absent.</li> <li><code>&#39;L&#39;</cod...
Easy
250.8K
506.7K
250,834
506,697
49.5%
['student-attendance-record-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool checkRecord(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean checkRecord(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": ...
"PPALLP"
{ "name": "checkRecord", "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...
['String']
552
Student Attendance Record II
student-attendance-record-ii
<p>An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day. The record only contains the following three characters:</p> <ul> <li><code>&#39;A&#39;</code>: Absent.</li> <li><code>&#39;L&#39;</code>: Late.</li> <li>...
Hard
147.2K
264.3K
147,152
264,315
55.7%
['student-attendance-record-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int checkRecord(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int checkRecord(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solu...
2
{ "name": "checkRecord", "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...
['Dynamic Programming']
553
Optimal Division
optimal-division
<p>You are given an integer array <code>nums</code>. The adjacent integers in <code>nums</code> will perform the float division.</p> <ul> <li>For example, for <code>nums = [2,3,4]</code>, we will evaluate the expression <code>&quot;2/3/4&quot;</code>.</li> </ul> <p>However, you can add any number of parenthesis at a...
Medium
45K
73.2K
45,022
73,161
61.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string optimalDivision(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String optimalDivision(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1000,100,10,2]
{ "name": "optimalDivision", "params": [ { "name": "nums", "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...
['Array', 'Math', 'Dynamic Programming']
554
Brick Wall
brick-wall
<p>There is a rectangular brick wall in front of you with <code>n</code> rows of bricks. The <code>i<sup>th</sup></code> row has some number of bricks each of the same height (i.e., one unit) but they can be of different widths. The total width of each row is the same.</p> <p>Draw a vertical line from the top to the b...
Medium
156.3K
280.1K
156,268
280,061
55.8%
['number-of-ways-to-build-sturdy-brick-wall']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int leastBricks(vector<vector<int>>& wall) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int leastBricks(List<List<Integer>> wall) {\n \n }\n}"}, {"value": "python", "text...
[[1,2,2,1],[3,1,2],[1,3,2],[2,4],[3,1,2],[1,3,1,1]]
{ "name": "leastBricks", "params": [ { "name": "wall", "type": "list<list<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']
555
Split Concatenated Strings
split-concatenated-strings
null
Medium
7.1K
16.5K
7,135
16,483
43.3%
[]
[]
Algorithms
null
["abc","xyz"]
{ "name": "splitLoopedString", "params": [ { "name": "strs", "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', 'Greedy']
556
Next Greater Element III
next-greater-element-iii
<p>Given a positive integer <code>n</code>, find <em>the smallest integer which has exactly the same digits existing in the integer</em> <code>n</code> <em>and is greater in value than</em> <code>n</code>. If no such positive integer exists, return <code>-1</code>.</p> <p><strong>Note</strong> that the returned intege...
Medium
178.8K
518.8K
178,773
518,779
34.5%
['next-greater-element-i', 'next-greater-element-ii', 'next-palindrome-using-same-digits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int nextGreaterElement(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int nextGreaterElement(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
12
{ "name": "nextGreaterElement", "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', 'Two Pointers', 'String']
557
Reverse Words in a String III
reverse-words-in-a-string-iii
<p>Given a string <code>s</code>, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> s = &quot;Let&#39;s take LeetCode contest&quot; <strong>Output:<...
Easy
1M
1.2M
1,001,996
1,199,017
83.6%
['reverse-string-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string reverseWords(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String reverseWords(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
"Let's take LeetCode contest"
{ "name": "reverseWords", "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...
['Two Pointers', 'String']
558
Logical OR of Two Binary Grids Represented as Quad-Trees
logical-or-of-two-binary-grids-represented-as-quad-trees
<p>A Binary Matrix is a matrix in which all the elements are either <strong>0</strong> or <strong>1</strong>.</p> <p>Given <code>quadTree1</code> and <code>quadTree2</code>. <code>quadTree1</code> represents a <code>n * n</code> binary matrix and <code>quadTree2</code> represents another <code>n * n</code> binary matr...
Medium
16.6K
33.2K
16,625
33,156
50.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n// Definition for a QuadTree node.\nclass Node {\npublic:\n bool val;\n bool isLeaf;\n Node* topLeft;\n Node* topRight;\n Node* bottomLeft;\n Node* bottomRight;\n \n Node() {\n val = false;\n isLeaf = false;\n topLeft = NU...
[[0,1],[1,1],[1,1],[1,0],[1,0]] [[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]]
{ "name": "intersect", "params": [ { "name": "quadTree1", "type": "integer[][]" }, { "name": "quadTree2", "type": "integer[][]" } ], "return": { "type": "integer[][]" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "pytho...
{"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...
['Divide and Conquer', 'Tree']
559
Maximum Depth of N-ary Tree
maximum-depth-of-n-ary-tree
<p>Given a n-ary tree, find its maximum depth.</p> <p>The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.</p> <p><em>Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See ex...
Easy
316.9K
435.5K
316,942
435,465
72.8%
['maximum-depth-of-binary-tree', 'the-time-when-the-network-becomes-idle', 'count-the-number-of-good-nodes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n// Definition for a Node.\nclass Node {\npublic:\n int val;\n vector<Node*> children;\n\n Node() {}\n\n Node(int _val) {\n val = _val;\n }\n\n Node(int _val, vector<Node*> _children) {\n val = _val;\n children = _children;\n ...
[1,null,3,2,4,null,5,6]
{ "name": "maxDepth", "params": [ { "name": "root", "type": "integer" } ], "return": { "type": "integer" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "golang", "ruby", "c", "kotlin", "scala", "php", ...
{"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']
560
Subarray Sum Equals K
subarray-sum-equals-k
<p>Given an array of integers <code>nums</code> and an integer <code>k</code>, return <em>the total number of subarrays whose sum equals to</em> <code>k</code>.</p> <p>A subarray is a contiguous <strong>non-empty</strong> sequence of elements within an array.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</s...
Medium
1.7M
3.8M
1,693,455
3,753,161
45.1%
['two-sum', 'continuous-subarray-sum', 'subarray-product-less-than-k', 'find-pivot-index', 'subarray-sums-divisible-by-k', 'minimum-operations-to-reduce-x-to-zero', 'k-radius-subarray-averages', 'maximum-sum-score-of-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int subarraySum(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int subarraySum(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,1,1] 2
{ "name": "subarraySum", "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', 'Hash Table', 'Prefix Sum']
561
Array Partition
array-partition
<p>Given an integer array <code>nums</code> of <code>2n</code> integers, group these integers into <code>n</code> pairs <code>(a<sub>1</sub>, b<sub>1</sub>), (a<sub>2</sub>, b<sub>2</sub>), ..., (a<sub>n</sub>, b<sub>n</sub>)</code> such that the sum of <code>min(a<sub>i</sub>, b<sub>i</sub>)</code> for all <code>i</co...
Easy
559.9K
698.3K
559,948
698,321
80.2%
['minimum-difference-between-highest-and-lowest-of-k-scores', 'minimum-cost-of-buying-candies-with-discount', 'all-divisions-with-the-highest-score-of-a-binary-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int arrayPairSum(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int arrayPairSum(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[1,4,3,2]
{ "name": "arrayPairSum", "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', 'Greedy', 'Sorting', 'Counting Sort']
562
Longest Line of Consecutive One in Matrix
longest-line-of-consecutive-one-in-matrix
null
Medium
78.9K
156.3K
78,948
156,331
50.5%
[]
[]
Algorithms
null
[[0,1,1,0],[0,1,1,0],[0,0,0,1]]
{ "name": "longestLine", "params": [ { "name": "mat", "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', 'Matrix']
563
Binary Tree Tilt
binary-tree-tilt
<p>Given the <code>root</code> of a binary tree, return <em>the sum of every tree node&#39;s <strong>tilt</strong>.</em></p> <p>The <strong>tilt</strong> of a tree node is the <strong>absolute difference</strong> between the sum of all left subtree node <strong>values</strong> and all right subtree node <strong>values...
Easy
237.5K
372.9K
237,473
372,920
63.7%
['find-all-the-lonely-nodes']
[]
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]
{ "name": "findTilt", "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']
564
Find the Closest Palindrome
find-the-closest-palindrome
<p>Given a string <code>n</code> representing an integer, return <em>the closest integer (not including itself), which is a palindrome</em>. If there is a tie, return <em><strong>the smaller one</strong></em>.</p> <p>The closest is defined as the absolute difference minimized between two integers.</p> <p>&nbsp;</p> <...
Hard
125.6K
397.8K
125,609
397,825
31.6%
['find-palindrome-with-fixed-length', 'next-palindrome-using-same-digits', 'find-the-count-of-good-integers', 'find-the-largest-palindrome-divisible-by-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string nearestPalindromic(string n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String nearestPalindromic(String n) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"123"
{ "name": "nearestPalindromic", "params": [ { "name": "n", "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...
['Math', 'String']
565
Array Nesting
array-nesting
<p>You are given an integer array <code>nums</code> of length <code>n</code> where <code>nums</code> is a permutation of the numbers in the range <code>[0, n - 1]</code>.</p> <p>You should build a set <code>s[k] = {nums[k], nums[nums[k]], nums[nums[nums[k]]], ... }</code> subjected to the following rule:</p> <ul> <l...
Medium
138.8K
248.2K
138,757
248,172
55.9%
['nested-list-weight-sum', 'flatten-nested-list-iterator', 'nested-list-weight-sum-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int arrayNesting(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int arrayNesting(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[5,4,0,3,1,6,2]
{ "name": "arrayNesting", "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', 'Depth-First Search']
566
Reshape the Matrix
reshape-the-matrix
<p>In MATLAB, there is a handy function called <code>reshape</code> which can reshape an <code>m x n</code> matrix into a new one with a different size <code>r x c</code> keeping its original data.</p> <p>You are given an <code>m x n</code> matrix <code>mat</code> and two integers <code>r</code> and <code>c</code> rep...
Easy
416.6K
653.5K
416,596
653,451
63.8%
['convert-1d-array-into-2d-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> matrixReshape(vector<vector<int>>& mat, int r, int c) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] matrixReshape(int[][] mat, int r, int c) {\n \...
[[1,2],[3,4]] 1 4
{ "name": "matrixReshape", "params": [ { "name": "mat", "type": "integer[][]" }, { "name": "r", "type": "integer" }, { "name": "c", "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', 'Matrix', 'Simulation']
567
Permutation in String
permutation-in-string
<p>Given two strings <code>s1</code> and <code>s2</code>, return <code>true</code> if <code>s2</code> contains a <span data-keyword="permutation-string">permutation</span> of <code>s1</code>, or <code>false</code> otherwise.</p> <p>In other words, return <code>true</code> if one of <code>s1</code>&#39;s permutations i...
Medium
1.2M
2.5M
1,178,949
2,510,200
47.0%
['minimum-window-substring', 'find-all-anagrams-in-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool checkInclusion(string s1, string s2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean checkInclusion(String s1, String s2) {\n \n }\n}"}, {"value": "python", "te...
"ab" "eidbaooo"
{ "name": "checkInclusion", "params": [ { "name": "s1", "type": "string" }, { "name": "s2", "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', 'Sliding Window']
568
Maximum Vacation Days
maximum-vacation-days
null
Hard
39.8K
86K
39,758
85,950
46.3%
['cheapest-flights-within-k-stops']
[]
Algorithms
null
[[0,1,1],[1,0,1],[1,1,0]] [[1,3,1],[6,0,3],[3,3,3]]
{ "name": "maxVacationDays", "params": [ { "name": "flights", "type": "integer[][]" }, { "name": "days", "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', 'Matrix']
569
Median Employee Salary
median-employee-salary
null
Hard
45.4K
68.4K
45,354
68,445
66.3%
['find-median-given-frequency-of-numbers']
['Create table If Not Exists Employee (id int, company varchar(255), salary int)', 'Truncate table Employee', "insert into Employee (id, company, salary) values ('1', 'A', '2341')", "insert into Employee (id, company, salary) values ('2', 'A', '341')", "insert into Employee (id, company, salary) values ('3', 'A', '15')...
Database
null
{"headers": {"Employee": ["id", "company", "salary"]}, "rows": {"Employee": [[1, "A", 2341],[2, "A", 341],[3, "A", 15],[4, "A", 15314],[5, "A", 451],[6, "A", 513],[7, "B", 15],[8, "B", 13],[9, "B", 1154],[10, "B", 1345],[11, "B", 1221],[12, "B", 234],[13, "C", 2345],[14, "C", 2645],[15, "C", 2645],[16, "C", 2652],[17, ...
{"mysql": ["Create table If Not Exists Employee (id int, company varchar(255), salary int)"], "mssql": ["Create table Employee (id int, company varchar(255), salary int)"], "oraclesql": ["Create table Employee (id int, company varchar(255), salary int)"], "database": true, "name": "median_employee_salary", "pythondata"...
{"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']
570
Managers with at Least 5 Direct Reports
managers-with-at-least-5-direct-reports
<p>Table: <code>Employee</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | | department | varchar | | managerId | int | +-------------+---------+ id is the primary key (column with unique values) for this table. Eac...
Medium
649.1K
1.3M
649,051
1,323,795
49.0%
[]
['Create table If Not Exists Employee (id int, name varchar(255), department varchar(255), managerId int)', 'Truncate table Employee', "insert into Employee (id, name, department, managerId) values ('101', 'John', 'A', NULL)", "insert into Employee (id, name, department, managerId) values ('102', 'Dan', 'A', '101')", "...
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": {"Employee": ["id", "name", "department", "managerId"]}, "rows": {"Employee": [[101, "John", "A", null],[102, "Dan", "A", 101], [103, "James", "A", 101], [104, "Amy", "A", 101], [105, "Anne", "A", 101], [106, "Ron", "B", 101]]}}
{"mysql": ["Create table If Not Exists Employee (id int, name varchar(255), department varchar(255), managerId int)"], "mssql": ["Create table Employee (id int, name varchar(255), department varchar(255), managerId int)"], "oraclesql": ["Create table Employee (id int, name varchar(255), department varchar(255), manager...
{"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']
571
Find Median Given Frequency of Numbers
find-median-given-frequency-of-numbers
null
Hard
32.4K
76.2K
32,427
76,182
42.6%
['median-employee-salary']
['Create table If Not Exists Numbers (num int, frequency int)', 'Truncate table Numbers', "insert into Numbers (num, frequency) values ('0', '7')", "insert into Numbers (num, frequency) values ('1', '1')", "insert into Numbers (num, frequency) values ('2', '3')", "insert into Numbers (num, frequency) values ('3', '1')"...
Database
null
{"headers": {"Numbers": ["num", "frequency"]}, "rows": {"Numbers": [[0, 7], [1, 1], [2, 3], [3, 1]]}}
{"mysql": ["Create table If Not Exists Numbers (num int, frequency int)"], "mssql": ["Create table Numbers (num int, frequency int)"], "oraclesql": ["Create table Numbers (num int, frequency int)"], "database": true, "name": "median_frequency", "pythondata": ["Numbers = pd.DataFrame([], columns=['num', 'frequency']).as...
{"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']
572
Subtree of Another Tree
subtree-of-another-tree
<p>Given the roots of two binary trees <code>root</code> and <code>subRoot</code>, return <code>true</code> if there is a subtree of <code>root</code> with the same structure and node values of<code> subRoot</code> and <code>false</code> otherwise.</p> <p>A subtree of a binary tree <code>tree</code> is a tree that con...
Easy
1M
2.1M
1,034,353
2,083,781
49.6%
['count-univalue-subtrees', 'most-frequent-subtree-sum']
[]
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,4,5,1,2] [4,1,2]
{ "name": "isSubtree", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "subRoot", "type": "TreeNode" } ], "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...
['Tree', 'Depth-First Search', 'String Matching', 'Binary Tree', 'Hash Function']
573
Squirrel Simulation
squirrel-simulation
null
Medium
23.5K
41K
23,463
40,990
57.2%
[]
[]
Algorithms
null
5 7 [2,2] [4,4] [[3,0], [2,5]]
{ "name": "minDistance", "params": [ { "name": "height", "type": "integer" }, { "name": "width", "type": "integer" }, { "name": "tree", "type": "integer[]" }, { "name": "squirrel", "type": "integer[]" }, { "name": "nuts", ...
{"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']
574
Winning Candidate
winning-candidate
null
Medium
70.8K
114.6K
70,816
114,567
61.8%
[]
['Create table If Not Exists Candidate (id int, name varchar(255))', 'Create table If Not Exists Vote (id int, candidateId int)', 'Truncate table Candidate', "insert into Candidate (id, name) values ('1', 'A')", "insert into Candidate (id, name) values ('2', 'B')", "insert into Candidate (id, name) values ('3', 'C')", ...
Database
null
{"headers":{"Candidate":["id","name"],"Vote":["id","candidateId"]},"rows":{"Candidate":[[1,"A"],[2,"B"],[3,"C"],[4,"D"],[5,"E"]],"Vote":[[1,2],[2,4],[3,3],[4,2],[5,5]]}}
{"mysql": ["Create table If Not Exists Candidate (id int, name varchar(255))", "Create table If Not Exists Vote (id int, candidateId int)"], "mssql": ["Create table Candidate (id int, name varchar(255))", "Create table Vote (id int, candidateId int)"], "oraclesql": ["Create table Candidate (id int, name varchar(255))",...
{"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']
575
Distribute Candies
distribute-candies
<p>Alice has <code>n</code> candies, where the <code>i<sup>th</sup></code> candy is of type <code>candyType[i]</code>. Alice noticed that she started to gain weight, so she visited a doctor.</p> <p>The doctor advised Alice to only eat <code>n / 2</code> of the candies she has (<code>n</code> is always even). Alice lik...
Easy
334.6K
483.2K
334,639
483,213
69.3%
['minimum-number-of-operations-to-satisfy-conditions', 'check-if-grid-satisfies-conditions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int distributeCandies(vector<int>& candyType) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int distributeCandies(int[] candyType) {\n \n }\n}"}, {"value": "python", "text...
[1,1,2,2,3,3]
{ "name": "distributeCandies", "params": [ { "name": "candyType", "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']
576
Out of Boundary Paths
out-of-boundary-paths
<p>There is an <code>m x n</code> grid with a ball. The ball is initially at the position <code>[startRow, startColumn]</code>. You are allowed to move the ball to one of the four adjacent cells in the grid (possibly out of the grid crossing the grid boundary). You can apply <strong>at most</strong> <code>maxMove</code...
Medium
217.9K
452.9K
217,905
452,897
48.1%
['knight-probability-in-chessboard', 'execution-of-all-suffix-instructions-staying-in-a-grid']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findPaths(int m, int n, int maxMove, int startRow, int startColumn) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findPaths(int m, int n, int maxMove, int startRow, int star...
2 2 2 0 0
{ "name": "findPaths", "params": [ { "name": "m", "type": "integer" }, { "name": "n", "type": "integer" }, { "name": "maxMove", "type": "integer" }, { "name": "startRow", "type": "integer" }, { "name": "startColumn", "ty...
{"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']
577
Employee Bonus
employee-bonus
<p>Table: <code>Employee</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | empId | int | | name | varchar | | supervisor | int | | salary | int | +-------------+---------+ empId is the column with unique values for this table. Each row of th...
Easy
694.8K
901.4K
694,765
901,449
77.1%
['combine-two-tables']
['Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int)', 'Create table If Not Exists Bonus (empId int, bonus int)', 'Truncate table Employee', "insert into Employee (empId, name, supervisor, salary) values ('3', 'Brad', NULL, '4000')", "insert into Employee (empId, name, superv...
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":{"Employee":["empId","name","supervisor","salary"],"Bonus":["empId","bonus"]},"rows":{"Employee":[[3,"Brad",null,4000],[1,"John",3,1000],[2,"Dan",3,2000],[4,"Thomas",3,4000]],"Bonus":[[2,500],[4,2000]]}}
{"mysql": ["Create table If Not Exists Employee (empId int, name varchar(255), supervisor int, salary int)", "Create table If Not Exists Bonus (empId int, bonus int)"], "mssql": ["Create table Employee (empId int, name varchar(255), supervisor int, salary int)", "Create table Bonus (empId int, bonus int)"], "oraclesql"...
{"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']
578
Get Highest Answer Rate Question
get-highest-answer-rate-question
null
Medium
62.3K
154.9K
62,332
154,902
40.2%
[]
['Create table If Not Exists SurveyLog (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int)', 'Truncate table SurveyLog', "insert into SurveyLog (id, action, question_id, answer_id, q_num, timestamp) values ('5', 'show', '285', NULL, '1', '123')", "insert into SurveyLog (id, action, q...
Database
null
{"headers": {"SurveyLog": ["id", "action", "question_id", "answer_id", "q_num", "timestamp"]},"rows": {"SurveyLog": [[5, "show", 285, null, 1, 123], [5, "answer", 285, 124124, 1, 124], [5, "show", 369, null, 2, 125], [5, "skip", 369, null, 2, 126]]}}
{"mysql": ["Create table If Not Exists SurveyLog (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int)"], "mssql": ["Create table SurveyLog (id int, action varchar(255), question_id int, answer_id int, q_num int, timestamp int)"], "oraclesql": ["Create table SurveyLog (id int, action v...
{"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']
579
Find Cumulative Salary of an Employee
find-cumulative-salary-of-an-employee
null
Hard
39.3K
80.9K
39,261
80,909
48.5%
[]
['Create table If Not Exists Employee (id int, month int, salary int)', 'Truncate table Employee', "insert into Employee (id, month, salary) values ('1', '1', '20')", "insert into Employee (id, month, salary) values ('2', '1', '20')", "insert into Employee (id, month, salary) values ('1', '2', '30')", "insert into Empl...
Database
null
{"headers":{"Employee":["id","month","salary"]},"rows":{"Employee":[[1,1,20],[2,1,20],[1,2,30],[2,2,30],[3,2,40],[1,3,40],[3,3,60],[1,4,60],[3,4,70],[1,7,90],[1,8,90]]}}
{"mysql": ["Create table If Not Exists Employee (id int, month int, salary int)"], "mssql": ["Create table Employee (id int, month int, salary int)"], "oraclesql": ["Create table Employee (id int, month int, salary int)"], "database": true, "name": "cumulative_salary", "pythondata": ["Employee = pd.DataFrame([], column...
{"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']
580
Count Student Number in Departments
count-student-number-in-departments
null
Medium
72.9K
122.2K
72,922
122,218
59.7%
[]
['Create table If Not Exists Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int)', 'Create table If Not Exists Department (dept_id int, dept_name varchar(255))', 'Truncate table Student', "insert into Student (student_id, student_name, gender, dept_id) values ('1', 'Jack', 'M', '1')", "ins...
Database
null
{"headers":{"Student":["student_id","student_name","gender","dept_id"],"Department":["dept_id","dept_name"]},"rows":{"Student":[[1,"Jack","M",1],[2,"Jane","F",1],[3,"Mark","M",2]],"Department":[[1,"Engineering"],[2,"Science"],[3,"Law"]]}}
{"mysql": ["Create table If Not Exists Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int)", "Create table If Not Exists Department (dept_id int, dept_name varchar(255))"], "mssql": ["Create table Student (student_id int,student_name varchar(45), gender varchar(6), dept_id int)", "Create t...
{"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']
581
Shortest Unsorted Continuous Subarray
shortest-unsorted-continuous-subarray
<p>Given an integer array <code>nums</code>, you need to find one <b>continuous subarray</b> such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.</p> <p>Return <em>the shortest such subarray and output its length</em>.</p> <p>&nbsp;</p> <p><str...
Medium
353.5K
947.7K
353,534
947,651
37.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findUnsortedSubarray(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findUnsortedSubarray(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "...
[2,6,4,8,10,9,15]
{ "name": "findUnsortedSubarray", "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', 'Stack', 'Greedy', 'Sorting', 'Monotonic Stack']
582
Kill Process
kill-process
null
Medium
91.8K
131.1K
91,799
131,130
70.0%
[]
[]
Algorithms
null
[1,3,10,5] [3,0,5,3] 5
{ "name": "killProcess", "params": [ { "name": "pid", "type": "list<integer>" }, { "name": "ppid", "type": "list<integer>" }, { "name": "kill", "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', 'Tree', 'Depth-First Search', 'Breadth-First Search']
583
Delete Operation for Two Strings
delete-operation-for-two-strings
<p>Given two strings <code>word1</code> and <code>word2</code>, return <em>the minimum number of <strong>steps</strong> required to make</em> <code>word1</code> <em>and</em> <code>word2</code> <em>the same</em>.</p> <p>In one <strong>step</strong>, you can delete exactly one character in either string.</p> <p>&nbsp;<...
Medium
306.2K
483.9K
306,238
483,879
63.3%
['edit-distance', 'minimum-ascii-delete-sum-for-two-strings', 'longest-common-subsequence', 'make-three-strings-equal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minDistance(string word1, string word2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minDistance(String word1, String word2) {\n \n }\n}"}, {"value": "python", "t...
"sea" "eat"
{ "name": "minDistance", "params": [ { "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...
['String', 'Dynamic Programming']
584
Find Customer Referee
find-customer-referee
<p>Table: <code>Customer</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | | referee_id | int | +-------------+---------+ In SQL, id is the primary key column for this table. Each row of this table indicates the id of...
Easy
1.5M
2.1M
1,512,808
2,110,721
71.7%
[]
['Create table If Not Exists Customer (id int, name varchar(25), referee_id int)', 'Truncate table Customer', "insert into Customer (id, name, referee_id) values ('1', 'Will', NULL)", "insert into Customer (id, name, referee_id) values ('2', 'Jane', NULL)", "insert into Customer (id, name, referee_id) values ('3', 'Ale...
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":{"Customer":["id","name","referee_id"]},"rows":{"Customer":[[1,"Will",null],[2,"Jane",null],[3,"Alex",2],[4,"Bill",null],[5,"Zack",1],[6,"Mark",2]]}}
{"mysql": ["Create table If Not Exists Customer (id int, name varchar(25), referee_id int)"], "mssql": ["Create table Customer (id int, name varchar(25), referee_id int)"], "oraclesql": ["Create table Customer (id int, name varchar(25), referee_id int)"], "database": true, "name": "find_customer_referee", "pythondata":...
{"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']
585
Investments in 2016
investments-in-2016
<p>Table: <code>Insurance</code></p> <pre> +-------------+-------+ | Column Name | Type | +-------------+-------+ | pid | int | | tiv_2015 | float | | tiv_2016 | float | | lat | float | | lon | float | +-------------+-------+ pid is the primary key (column with unique values) for this ...
Medium
196K
393.3K
196,041
393,310
49.8%
[]
['Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)', 'Truncate table Insurance', "insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('1', '10', '5', '10', '10')", "insert into Insurance (pid, tiv_2015, tiv_2016, lat, lon) values ('2', '20', '20', '20', ...
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":{"Insurance":["pid","tiv_2015","tiv_2016","lat","lon"]},"rows":{"Insurance":[[1,10,5,10,10],[2,20,20,20,20],[3,10,30,20,20],[4,10,40,40,40]]}}
{"mysql": ["Create Table If Not Exists Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)"], "mssql": ["Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)"], "oraclesql": ["Create Table Insurance (pid int, tiv_2015 float, tiv_2016 float, lat float, lon float)"]...
{"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']
586
Customer Placing the Largest Number of Orders
customer-placing-the-largest-number-of-orders
<p>Table: <code>Orders</code></p> <pre> +-----------------+----------+ | Column Name | Type | +-----------------+----------+ | order_number | int | | customer_number | int | +-----------------+----------+ order_number is the primary key (column with unique values) for this table. This table contai...
Easy
332.3K
515.3K
332,320
515,341
64.5%
[]
['Create table If Not Exists orders (order_number int, customer_number int)', 'Truncate table orders', "insert into orders (order_number, customer_number) values ('1', '1')", "insert into orders (order_number, customer_number) values ('2', '2')", "insert into orders (order_number, customer_number) values ('3', '3')", "...
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":{"orders":["order_number","customer_number"]},"rows":{"orders":[[1,1],[2,2],[3,3],[4,3]]}}
{"mysql": ["Create table If Not Exists orders (order_number int, customer_number int)"], "mssql": ["Create table orders (order_number int, customer_number int)"], "oraclesql": ["Create table orders (order_number int, customer_number int)"], "database": true, "name": "largest_orders", "pythondata": ["orders = pd.DataFra...
{"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']
587
Erect the Fence
erect-the-fence
<p>You are given an array <code>trees</code> where <code>trees[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents the location of a tree in the garden.</p> <p>Fence the entire garden using the minimum length of rope, as it is expensive. The garden is well-fenced only if <strong>all the trees are enclosed</strong>.<...
Hard
61.6K
118.3K
61,637
118,325
52.1%
['erect-the-fence-ii', 'sort-the-students-by-their-kth-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> outerTrees(vector<vector<int>>& trees) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] outerTrees(int[][] trees) {\n \n }\n}"}, {"value": "python...
[[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]]
{ "name": "outerTrees", "params": [ { "name": "trees", "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', 'Geometry']
588
Design In-Memory File System
design-in-memory-file-system
null
Hard
119.3K
248K
119,283
247,963
48.1%
['lru-cache', 'lfu-cache', 'design-log-storage-system']
[]
Algorithms
null
["FileSystem","ls","mkdir","addContentToFile","ls","readContentFromFile"] [[],["/"],["/a/b/c"],["/a/b/c/d","hello"],["/"],["/a/b/c/d"]]
{ "classname": "FileSystem", "maxbytesperline": 200000, "constructor": { "params": [ ] }, "methods": [ { "name" : "ls", "params": [ { "type": "string", "name": "path" } ...
{"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', 'Sorting']
589
N-ary Tree Preorder Traversal
n-ary-tree-preorder-traversal
<p>Given the <code>root</code> of an n-ary tree, return <em>the preorder traversal of its nodes&#39; values</em>.</p> <p>Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)</p> <p>&nbsp;</p> <p><strong class="example">Exampl...
Easy
460.8K
605.5K
460,779
605,545
76.1%
['binary-tree-preorder-traversal', 'n-ary-tree-level-order-traversal', 'n-ary-tree-postorder-traversal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n// Definition for a Node.\nclass Node {\npublic:\n int val;\n vector<Node*> children;\n\n Node() {}\n\n Node(int _val) {\n val = _val;\n }\n\n Node(int _val, vector<Node*> _children) {\n val = _val;\n children = _children;\n ...
[1,null,3,2,4,null,5,6]
{ "name": "preorder", "params": [ { "name": "root", "type": "integer" } ], "return": { "type": "list<integer>" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "golang", "ruby", "c", "kotlin", "scala", "php"...
{"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', 'Tree', 'Depth-First Search']
590
N-ary Tree Postorder Traversal
n-ary-tree-postorder-traversal
<p>Given the <code>root</code> of an n-ary tree, return <em>the postorder traversal of its nodes&#39; values</em>.</p> <p>Nary-Tree input serialization is represented in their level order traversal. Each group of children is separated by the null value (See examples)</p> <p>&nbsp;</p> <p><strong class="example">Examp...
Easy
395.2K
490.4K
395,176
490,354
80.6%
['binary-tree-postorder-traversal', 'n-ary-tree-level-order-traversal', 'n-ary-tree-preorder-traversal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/*\n// Definition for a Node.\nclass Node {\npublic:\n int val;\n vector<Node*> children;\n\n Node() {}\n\n Node(int _val) {\n val = _val;\n }\n\n Node(int _val, vector<Node*> _children) {\n val = _val;\n children = _children;\n ...
[1,null,3,2,4,null,5,6]
{ "name": "postorder", "params": [ { "name": "root", "type": "integer" } ], "return": { "type": "list<integer>" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "golang", "ruby", "c", "kotlin", "scala", "php...
{"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', 'Tree', 'Depth-First Search']
591
Tag Validator
tag-validator
<p>Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.</p> <p>A code snippet is valid if all the following rules hold:</p> <ol> <li>The code must be wrapped in a <b>valid closed tag</b>. Otherwise, the code is invalid.</li> <li>A <b>closed tag</b> ...
Hard
17.6K
45.2K
17,550
45,235
38.8%
['add-bold-tag-in-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isValid(string code) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isValid(String code) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "c...
"<DIV>This is the first line <![CDATA[<div>]]></DIV>"
{ "name": "isValid", "params": [ { "name": "code", "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...
['String', 'Stack']
592
Fraction Addition and Subtraction
fraction-addition-and-subtraction
<p>Given a string <code>expression</code> representing an expression of fraction addition and subtraction, return the calculation result in string format.</p> <p>The final result should be an <a href="https://en.wikipedia.org/wiki/Irreducible_fraction" target="_blank">irreducible fraction</a>. If your final result is ...
Medium
131.5K
198.9K
131,514
198,913
66.1%
['solve-the-equation']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string fractionAddition(string expression) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String fractionAddition(String expression) {\n \n }\n}"}, {"value": "python", "tex...
"-1/2+1/2"
{ "name": "fractionAddition", "params": [ { "name": "expression", "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...
['Math', 'String', 'Simulation']
593
Valid Square
valid-square
<p>Given the coordinates of four points in 2D space <code>p1</code>, <code>p2</code>, <code>p3</code> and <code>p4</code>, return <code>true</code> <em>if the four points construct a square</em>.</p> <p>The coordinate of a point <code>p<sub>i</sub></code> is represented as <code>[x<sub>i</sub>, y<sub>i</sub>]</code>. ...
Medium
118.2K
267.4K
118,170
267,358
44.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool validSquare(vector<int>& p1, vector<int>& p2, vector<int>& p3, vector<int>& p4) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean validSquare(int[] p1, int[] p2, int[] p3, ...
[0,0] [1,1] [1,0] [0,1]
{ "name": "validSquare", "params": [ { "name": "p1", "type": "integer[]" }, { "name": "p2", "type": "integer[]" }, { "name": "p3", "type": "integer[]" }, { "name": "p4", "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', 'Geometry']
594
Longest Harmonious Subsequence
longest-harmonious-subsequence
<p>We define a harmonious array as an array where the difference between its maximum value and its minimum value is <b>exactly</b> <code>1</code>.</p> <p>Given an integer array <code>nums</code>, return the length of its longest harmonious <span data-keyword="subsequence-array">subsequence</span> among all its possibl...
Easy
196K
345.5K
195,987
345,536
56.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLHS(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLHS(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "c...
[1,3,2,2,5,2,3,7]
{ "name": "findLHS", "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', 'Sliding Window', 'Sorting', 'Counting']
595
Big Countries
big-countries
<p>Table: <code>World</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | | area | int | | population | int | | gdp | bigint | +-------------+---------+ name is the primary key (column with unique va...
Easy
1.8M
2.6M
1,780,835
2,611,423
68.2%
[]
['Create table If Not Exists World (name varchar(255), continent varchar(255), area int, population int, gdp bigint)', 'Truncate table World', "insert into World (name, continent, area, population, gdp) values ('Afghanistan', 'Asia', '652230', '25500100', '20343000000')", "insert into World (name, continent, area, popu...
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": {"World": ["name", "continent", "area", "population", "gdp"]}, "rows": {"World": [["Afghanistan", "Asia", 652230, 25500100, 20343000000], ["Albania", "Europe", 28748, 2831741, 12960000000], ["Algeria", "Africa", 2381741, 37100000, 188681000000], ["Andorra", "Europe", 468, 78115, 3712000000], ["Angola", "Afr...
{"mysql": ["Create table If Not Exists World (name varchar(255), continent varchar(255), area int, population int, gdp bigint)"], "mssql": ["Create table World (name varchar(255), continent varchar(255), area int, population int, gdp bigint)"], "oraclesql": ["Create table World (name varchar(255), continent varchar(255...
{"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']
596
Classes More Than 5 Students
classes-more-than-5-students
<p>Table: <code>Courses</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | student | varchar | | class | varchar | +-------------+---------+ (student, class) is the primary key (combination of columns with unique values) for this table. Each row of this table ind...
Easy
605K
1M
604,985
1,007,751
60.0%
[]
['Create table If Not Exists Courses (student varchar(255), class varchar(255))', 'Truncate table Courses', "insert into Courses (student, class) values ('A', 'Math')", "insert into Courses (student, class) values ('B', 'English')", "insert into Courses (student, class) values ('C', 'Math')", "insert into Courses (stud...
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": {"Courses": ["student", "class"]}, "rows": {"Courses": [["A", "Math"], ["B", "English"], ["C", "Math"], ["D", "Biology"], ["E", "Math"], ["F", "Computer"], ["G", "Math"], ["H", "Math"], ["I", "Math"]]}}
{"mysql": ["Create table If Not Exists Courses (student varchar(255), class varchar(255))"], "mssql": ["Create table Courses (student varchar(255), class varchar(255))"], "oraclesql": ["Create table Courses (student varchar(255), class varchar(255))"], "database": true, "name": "find_classes", "pythondata": ["Courses =...
{"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']
597
Friend Requests I: Overall Acceptance Rate
friend-requests-i-overall-acceptance-rate
null
Easy
81K
195.4K
81,036
195,415
41.5%
[]
['Create table If Not Exists FriendRequest (sender_id int, send_to_id int, request_date date)', 'Create table If Not Exists RequestAccepted (requester_id int, accepter_id int, accept_date date)', 'Truncate table FriendRequest', "insert into FriendRequest (sender_id, send_to_id, request_date) values ('1', '2', '2016/06/...
Database
null
{"headers":{"FriendRequest":["sender_id","send_to_id","request_date"],"RequestAccepted":["requester_id","accepter_id","accept_date"]},"rows":{"FriendRequest":[[1,2,"2016/06/01"],[1,3,"2016/06/01"],[1,4,"2016/06/01"],[2,3,"2016/06/02"],[3,4,"2016/06/09"]],"RequestAccepted":[[1,2,"2016/06/03"],[1,3,"2016/06/08"],[2,3,"20...
{"mysql": ["Create table If Not Exists FriendRequest (sender_id int, send_to_id int, request_date date)", "Create table If Not Exists RequestAccepted (requester_id int, accepter_id int, accept_date date)"], "mssql": ["Create table FriendRequest (sender_id int, send_to_id int, request_date date)", "Create table RequestA...
{"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']
598
Range Addition II
range-addition-ii
<p>You are given an <code>m x n</code> matrix <code>M</code> initialized with all <code>0</code>&#39;s and an array of operations <code>ops</code>, where <code>ops[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> means <code>M[x][y]</code> should be incremented by one for all <code>0 &lt;= x &lt; a<sub>i</sub></code> and <co...
Easy
115.2K
201.8K
115,225
201,808
57.1%
['range-addition', 'sum-of-matrix-after-queries']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxCount(int m, int n, vector<vector<int>>& ops) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxCount(int m, int n, int[][] ops) {\n \n }\n}"}, {"value": "python...
3 3 [[2,2],[3,3]]
{ "name": "maxCount", "params": [ { "name": "m", "type": "integer" }, { "name": "n", "type": "integer" }, { "name": "ops", "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']
599
Minimum Index Sum of Two Lists
minimum-index-sum-of-two-lists
<p>Given two arrays of strings <code>list1</code> and <code>list2</code>, find the <strong>common strings with the least index sum</strong>.</p> <p>A <strong>common string</strong> is a string that appeared in both <code>list1</code> and <code>list2</code>.</p> <p>A <strong>common string with the least index sum</str...
Easy
270.1K
469.1K
270,137
469,064
57.6%
['intersection-of-two-linked-lists']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> findRestaurant(vector<string>& list1, vector<string>& list2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String[] findRestaurant(String[] list1, String[] list2) {\n...
["Shogun","Tapioca Express","Burger King","KFC"] ["Piatti","The Grill at Torrey Pines","Hungry Hunter Steakhouse","Shogun"]
{ "name": "findRestaurant", "params": [ { "name": "list1", "type": "string[]" }, { "name": "list2", "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', 'Hash Table', 'String']
600
Non-negative Integers without Consecutive Ones
non-negative-integers-without-consecutive-ones
<p>Given a positive integer <code>n</code>, return the number of the integers in the range <code>[0, n]</code> whose binary representations <strong>do not</strong> contain consecutive ones.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 5 <strong>Output:</strong...
Hard
43.8K
109.3K
43,813
109,279
40.1%
['house-robber', 'house-robber-ii', 'ones-and-zeroes', 'generate-binary-strings-without-adjacent-zeros']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findIntegers(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findIntegers(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class So...
5
{ "name": "findIntegers", "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...
['Dynamic Programming']