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
1,501
Countries You Can Safely Invest In
countries-you-can-safely-invest-in
null
Medium
44.9K
89K
44,901
89,021
50.4%
['average-salary-departments-vs-company']
['Create table If Not Exists Person (id int, name varchar(15), phone_number varchar(11))', 'Create table If Not Exists Country (name varchar(15), country_code varchar(3))', 'Create table If Not Exists Calls (caller_id int, callee_id int, duration int)', 'Truncate table Person', "insert into Person (id, name, phone_numb...
Database
null
{"headers":{"Person":["id","name","phone_number"],"Country":["name","country_code"],"Calls":["caller_id","callee_id","duration"]},"rows":{"Person":[[3,"Jonathan","051-1234567"],[12,"Elvis","051-7654321"],[1,"Moncef","212-1234567"],[2,"Maroua","212-6523651"],[7,"Meir","972-1234567"],[9,"Rachel","972-0011100"]],"Country"...
{"mysql": ["Create table If Not Exists Person (id int, name varchar(15), phone_number varchar(11))", "Create table If Not Exists Country (name varchar(15), country_code varchar(3))", "Create table If Not Exists Calls (caller_id int, callee_id int, duration int)"], "mssql": ["Create table Person (id int, name varchar(15...
{"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']
1,502
Can Make Arithmetic Progression From Sequence
can-make-arithmetic-progression-from-sequence
<p>A sequence of numbers is called an <strong>arithmetic progression</strong> if the difference between any two consecutive elements is the same.</p> <p>Given an array of numbers <code>arr</code>, return <code>true</code> <em>if the array can be rearranged to form an <strong>arithmetic progression</strong>. Otherwise,...
Easy
272K
391.8K
271,975
391,798
69.4%
['arithmetic-subarrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canMakeArithmeticProgression(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canMakeArithmeticProgression(int[] arr) {\n \n }\n}"}, {"value": ...
[3,5,1]
{ "name": "canMakeArithmeticProgression", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting']
1,503
Last Moment Before All Ants Fall Out of a Plank
last-moment-before-all-ants-fall-out-of-a-plank
<p>We have a wooden plank of the length <code>n</code> <strong>units</strong>. Some ants are walking on the plank, each ant moves with a speed of <strong>1 unit per second</strong>. Some of the ants move to the <strong>left</strong>, the other move to the <strong>right</strong>.</p> <p>When two ants moving in two <str...
Medium
93.3K
136.8K
93,320
136,844
68.2%
['count-collisions-on-a-road', 'movement-of-robots']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int getLastMoment(int n, vector<int>& left, vector<int>& right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int getLastMoment(int n, int[] left, int[] right) {\n \n }\n}...
4 [4,3] [0,1]
{ "name": "getLastMoment", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[]", "name": "left" }, { "type": "integer[]", "name": "right" } ], "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', 'Brainteaser', 'Simulation']
1,504
Count Submatrices With All Ones
count-submatrices-with-all-ones
<p>Given an <code>m x n</code> binary matrix <code>mat</code>, <em>return the number of <strong>submatrices</strong> that have all ones</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/10/27/ones1-grid.jpg" style="width: 244px; height:...
Medium
57.6K
100.8K
57,618
100,780
57.2%
['count-submatrices-with-equal-frequency-of-x-and-y']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSubmat(vector<vector<int>>& mat) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSubmat(int[][] mat) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[[1,0,1],[1,1,0],[1,1,0]]
{ "name": "numSubmat", "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', 'Stack', 'Matrix', 'Monotonic Stack']
1,505
Minimum Possible Integer After at Most K Adjacent Swaps On Digits
minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits
<p>You are given a string <code>num</code> representing <strong>the digits</strong> of a very large integer and an integer <code>k</code>. You are allowed to swap any two adjacent digits of the integer <strong>at most</strong> <code>k</code> times.</p> <p>Return <em>the minimum integer you can obtain also as a string<...
Hard
11.5K
28.8K
11,477
28,836
39.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string minInteger(string num, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String minInteger(String num, int k) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"4321" 4
{ "name": "minInteger", "params": [ { "name": "num", "type": "string" }, { "type": "integer", "name": "k" } ], "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', 'Greedy', 'Binary Indexed Tree', 'Segment Tree']
1,506
Find Root of N-Ary Tree
find-root-of-n-ary-tree
null
Medium
37.8K
48.3K
37,835
48,262
78.4%
['move-sub-tree-of-n-ary-tree']
[]
Algorithms
null
[1,null,3,2,4,null,5,6]
{ "name": "findRoot", "params": [ { "name": "tree", "type": "integer" } ], "return": { "type": "integer" }, "languages": [ "cpp", "java", "python", "javascript", "python3", "csharp", "typescript", "ruby", "swift", "golang", "scala", "ko...
{"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', 'Bit Manipulation', 'Tree', 'Depth-First Search']
1,507
Reformat Date
reformat-date
<p>Given a <code>date</code> string in the form&nbsp;<code>Day Month Year</code>, where:</p> <ul> <li><code>Day</code>&nbsp;is in the set <code>{&quot;1st&quot;, &quot;2nd&quot;, &quot;3rd&quot;, &quot;4th&quot;, ..., &quot;30th&quot;, &quot;31st&quot;}</code>.</li> <li><code>Month</code>&nbsp;is in the set <code>{&...
Easy
85.4K
127.1K
85,423
127,128
67.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string reformatDate(string date) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String reformatDate(String date) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
"20th Oct 2052"
{ "name": "reformatDate", "params": [ { "name": "date", "type": "string" } ], "return": { "type": "string" }, "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...
['String']
1,508
Range Sum of Sorted Subarray Sums
range-sum-of-sorted-subarray-sums
<p>You are given the array <code>nums</code> consisting of <code>n</code> positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of <code>n * (n + 1) / 2</code> numbers.</p> <p><em>Return the sum of the numbers fro...
Medium
178.4K
282.7K
178,434
282,669
63.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rangeSum(vector<int>& nums, int n, int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rangeSum(int[] nums, int n, int left, int right) {\n \n }\n}"...
[1,2,3,4] 4 1 5
{ "name": "rangeSum", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "n" }, { "type": "integer", "name": "left" }, { "type": "integer", "name": "right" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting', 'Prefix Sum']
1,509
Minimum Difference Between Largest and Smallest Value in Three Moves
minimum-difference-between-largest-and-smallest-value-in-three-moves
<p>You are given an integer array <code>nums</code>.</p> <p>In one move, you can choose one element of <code>nums</code> and change it to <strong>any value</strong>.</p> <p>Return <em>the minimum difference between the largest and smallest value of <code>nums</code> <strong>after performing at most three moves</stron...
Medium
243.8K
411.9K
243,755
411,921
59.2%
['minimize-the-maximum-difference-of-pairs']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minDifference(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minDifference(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[5,3,2,4]
{ "name": "minDifference", "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']
1,510
Stone Game IV
stone-game-iv
<p>Alice and Bob take turns playing a game, with Alice starting first.</p> <p>Initially, there are <code>n</code> stones in a pile. On each player&#39;s turn, that player makes a <em>move</em> consisting of removing <strong>any</strong> non-zero <strong>square number</strong> of stones in the pile.</p> <p>Also, if a ...
Hard
78.3K
131.7K
78,325
131,728
59.5%
['stone-game-v', 'stone-game-vi', 'stone-game-vii', 'stone-game-viii', 'stone-game-ix', 'stone-removal-game']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool winnerSquareGame(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean winnerSquareGame(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCod...
1
{ "name": "winnerSquareGame", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Game Theory']
1,511
Customer Order Frequency
customer-order-frequency
null
Easy
48.3K
72.1K
48,254
72,063
67.0%
[]
['Create table If Not Exists Customers (customer_id int, name varchar(30), country varchar(30))', 'Create table If Not Exists Product (product_id int, description varchar(30), price int)\n', 'Create table If Not Exists Orders (order_id int, customer_id int, product_id int, order_date date, quantity int)\n', 'Truncate t...
Database
null
{"headers": {"Customers": ["customer_id", "name", "country"], "Product": ["product_id", "description", "price"], "Orders": ["order_id", "customer_id", "product_id", "order_date", "quantity"]}, "rows": {"Customers": [[1, "Winston", "USA"], [2, "Jonathan", "Peru"], [3, "Moustafa", "Egypt"]], "Product": [[10, "LC Phone", ...
{"mysql": ["Create table If Not Exists Customers (customer_id int, name varchar(30), country varchar(30))", "Create table If Not Exists Product (product_id int, description varchar(30), price int)\n", "Create table If Not Exists Orders (order_id int, customer_id int, product_id int, order_date date, quantity int)\n"], ...
{"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']
1,512
Number of Good Pairs
number-of-good-pairs
<p>Given an array of integers <code>nums</code>, return <em>the number of <strong>good pairs</strong></em>.</p> <p>A pair <code>(i, j)</code> is called <em>good</em> if <code>nums[i] == nums[j]</code> and <code>i</code> &lt; <code>j</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <...
Easy
912.3K
1M
912,258
1,019,021
89.5%
['number-of-pairs-of-interchangeable-rectangles', 'substrings-that-begin-and-end-with-the-same-letter']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numIdenticalPairs(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numIdenticalPairs(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,2,3,1,1,3]
{ "name": "numIdenticalPairs", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Counting']
1,513
Number of Substrings With Only 1s
number-of-substrings-with-only-1s
<p>Given a binary string <code>s</code>, return <em>the number of substrings with all characters</em> <code>1</code><em>&#39;s</em>. Since the answer may be too large, return it modulo <code>10<sup>9</sup> + 7</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> s...
Medium
51.6K
108.4K
51,620
108,415
47.6%
['count-number-of-homogenous-substrings', 'count-vowel-substrings-of-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSub(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSub(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution...
"0110111"
{ "name": "numSub", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String']
1,514
Path with Maximum Probability
path-with-maximum-probability
<p>You are given an undirected weighted graph of&nbsp;<code>n</code>&nbsp;nodes (0-indexed), represented by an edge list where&nbsp;<code>edges[i] = [a, b]</code>&nbsp;is an undirected edge connecting the nodes&nbsp;<code>a</code>&nbsp;and&nbsp;<code>b</code>&nbsp;with a probability of success of traversing that edge&n...
Medium
337.8K
517.3K
337,752
517,284
65.3%
['number-of-ways-to-arrive-at-destination']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double maxProbability(int n, vector<vector<int>>& edges, vector<double>& succProb, int start_node, int end_node) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double maxProbability(...
3 [[0,1],[1,2],[0,2]] [0.5,0.5,0.2] 0 2
{ "name": "maxProbability", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "edges" }, { "type": "double[]", "name": "succProb" }, { "type": "integer", "name": "start_node" }, { "type": "intege...
{"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', 'Graph', 'Heap (Priority Queue)', 'Shortest Path']
1,515
Best Position for a Service Centre
best-position-for-a-service-centre
<p>A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that <strong>the sum of the euclidean distances to all customers is minimum</strong>.</p> <p>Given an array <code>p...
Hard
16.9K
48.5K
16,858
48,495
34.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double getMinDistSum(vector<vector<int>>& positions) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double getMinDistSum(int[][] positions) {\n \n }\n}"}, {"value": "python...
[[0,1],[1,0],[1,2],[2,1]]
{ "name": "getMinDistSum", "params": [ { "name": "positions", "type": "integer[][]" } ], "return": { "type": "double" } }
{"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', 'Randomized']
1,516
Move Sub-Tree of N-Ary Tree
move-sub-tree-of-n-ary-tree
null
Hard
2.5K
4.1K
2,450
4,076
60.1%
['find-root-of-n-ary-tree']
[]
Algorithms
null
[1,null,2,3,null,4,5,null,6,null,7,8] 4 1
{ "name": "moveSubTree", "params": [ { "name": "root", "type": "integer" }, { "type": "integer", "name": "p" }, { "type": "integer", "name": "q" } ], "return": { "type": "integer" }, "manual": true, "languages": [ "cpp", "java", "...
{"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']
1,517
Find Users With Valid E-Mails
find-users-with-valid-e-mails
<p>Table: <code>Users</code></p> <pre> +---------------+---------+ | Column Name | Type | +---------------+---------+ | user_id | int | | name | varchar | | mail | varchar | +---------------+---------+ user_id is the primary key (column with unique values) for this table. This table co...
Easy
200.3K
452.5K
200,253
452,505
44.3%
[]
['Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))', 'Truncate table Users', "insert into Users (user_id, name, mail) values ('1', 'Winston', 'winston@leetcode.com')", "insert into Users (user_id, name, mail) values ('2', 'Jonathan', 'jonathanisgreat')", "insert into Users (user_id, na...
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":{"Users":["user_id","name","mail"]},"rows":{"Users":[[1,"Winston","winston@leetcode.com"],[2,"Jonathan","jonathanisgreat"],[3,"Annabelle","bella-@leetcode.com"],[4,"Sally","sally.come@leetcode.com"],[5,"Marwan","quarz#2020@leetcode.com"],[6,"David","david69@gmail.com"],[7,"Shapiro",".shapo@leetcode.com"]]}}
{"mysql": ["Create table If Not Exists Users (user_id int, name varchar(30), mail varchar(50))"], "mssql": ["Create table Users (user_id int, name varchar(30), mail varchar(50))"], "oraclesql": ["Create table Users (user_id int, name varchar(30), mail varchar(50))"], "database": true, "name": "valid_emails", "pythondat...
{"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']
1,518
Water Bottles
water-bottles
<p>There are <code>numBottles</code> water bottles that are initially full of water. You can exchange <code>numExchange</code> empty water bottles from the market with one full water bottle.</p> <p>The operation of drinking a full water bottle turns it into an empty bottle.</p> <p>Given the two integers <code>numBott...
Easy
257.7K
364K
257,728
363,962
70.8%
['water-bottles-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numWaterBottles(int numBottles, int numExchange) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numWaterBottles(int numBottles, int numExchange) {\n \n }\n}"}, {"va...
9 3
{ "name": "numWaterBottles", "params": [ { "name": "numBottles", "type": "integer" }, { "type": "integer", "name": "numExchange" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Simulation']
1,519
Number of Nodes in the Sub-Tree With the Same Label
number-of-nodes-in-the-sub-tree-with-the-same-label
<p>You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of <code>n</code> nodes numbered from <code>0</code> to <code>n - 1</code> and exactly <code>n - 1</code> <code>edges</code>. The <strong>root</strong> of the tree is the node <code>0</code>, and each node of the tree has <strong...
Medium
88.3K
160.7K
88,321
160,651
55.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> countSubTrees(int n, vector<vector<int>>& edges, string labels) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] countSubTrees(int n, int[][] edges, String labels) {\...
7 [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]] "abaedcd"
{ "name": "countSubTrees", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "edges" }, { "type": "string", "name": "labels" } ], "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', 'Breadth-First Search', 'Counting']
1,520
Maximum Number of Non-Overlapping Substrings
maximum-number-of-non-overlapping-substrings
<p>Given a string <code>s</code> of lowercase letters, you need to find the maximum number of <strong>non-empty</strong> substrings of <code>s</code> that meet the following conditions:</p> <ol> <li>The substrings do not overlap, that is for any two substrings <code>s[i..j]</code> and <code>s[x..y]</code>, either <co...
Hard
20.2K
51K
20,183
51,009
39.6%
['maximum-number-of-non-overlapping-palindrome-substrings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> maxNumOfSubstrings(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> maxNumOfSubstrings(String s) {\n \n }\n}"}, {"value": "python", "tex...
"adefaddaccc"
{ "name": "maxNumOfSubstrings", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Greedy']
1,521
Find a Value of a Mysterious Function Closest to Target
find-a-value-of-a-mysterious-function-closest-to-target
<p><img alt="" src="https://assets.leetcode.com/uploads/2020/07/09/change.png" style="width: 635px; height: 312px;" /></p> <p>Winston was given the above mysterious function <code>func</code>. He has an integer array <code>arr</code> and an integer <code>target</code> and he wants to find the values <code>l</code> and...
Hard
12.1K
26.6K
12,123
26,627
45.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int closestToTarget(vector<int>& arr, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int closestToTarget(int[] arr, int target) {\n \n }\n}"}, {"value": "python...
[9,12,3,7,15] 5
{ "name": "closestToTarget", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "target" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Bit Manipulation', 'Segment Tree']
1,522
Diameter of N-Ary Tree
diameter-of-n-ary-tree
null
Medium
55.6K
74.1K
55,552
74,139
74.9%
['diameter-of-binary-tree']
[]
Algorithms
null
[1,null,3,2,4,null,5,6]
{ "name": "diameter", "params": [ { "name": "root", "type": "integer" } ], "return": { "type": "integer" }, "manual": true, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "typescript", "php", "golang", "scala", ...
{"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']
1,523
Count Odd Numbers in an Interval Range
count-odd-numbers-in-an-interval-range
<p>Given two non-negative integers <code>low</code> and <code><font face="monospace">high</font></code>. Return the <em>count of odd numbers between </em><code>low</code><em> and </em><code><font face="monospace">high</font></code><em>&nbsp;(inclusive)</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</str...
Easy
368.5K
732.6K
368,544
732,619
50.3%
['check-if-bitwise-or-has-trailing-zeros']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countOdds(int low, int high) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countOdds(int low, int high) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
3 7
{ "name": "countOdds", "params": [ { "name": "low", "type": "integer" }, { "type": "integer", "name": "high" } ], "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']
1,524
Number of Sub-arrays With Odd Sum
number-of-sub-arrays-with-odd-sum
<p>Given an array of integers <code>arr</code>, return <em>the number of subarrays with an <strong>odd</strong> sum</em>.</p> <p>Since the answer can be very large, return it modulo <code>10<sup>9</sup> + 7</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr...
Medium
161.3K
287.6K
161,292
287,607
56.1%
['subsequence-of-size-k-with-the-largest-even-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numOfSubarrays(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numOfSubarrays(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[1,3,5]
{ "name": "numOfSubarrays", "params": [ { "name": "arr", "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', 'Dynamic Programming', 'Prefix Sum']
1,525
Number of Good Ways to Split a String
number-of-good-ways-to-split-a-string
<p>You are given a string <code>s</code>.</p> <p>A split is called <strong>good</strong> if you can split <code>s</code> into two non-empty strings <code>s<sub>left</sub></code> and <code>s<sub>right</sub></code> where their concatenation is equal to <code>s</code> (i.e., <code>s<sub>left</sub> + s<sub>right</sub> = s...
Medium
114K
166.9K
113,960
166,858
68.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSplits(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSplits(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class So...
"aacaba"
{ "name": "numSplits", "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...
['Hash Table', 'String', 'Dynamic Programming', 'Bit Manipulation']
1,526
Minimum Number of Increments on Subarrays to Form a Target Array
minimum-number-of-increments-on-subarrays-to-form-a-target-array
<p>You are given an integer array <code>target</code>. You have an integer array <code>initial</code> of the same size as <code>target</code> with all elements initially zeros.</p> <p>In one operation you can choose <strong>any</strong> subarray from <code>initial</code> and increment each value by one.</p> <p>Return...
Hard
60.4K
83.9K
60,417
83,875
72.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minNumberOperations(vector<int>& target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minNumberOperations(int[] target) {\n \n }\n}"}, {"value": "python", "text":...
[1,2,3,2,1]
{ "name": "minNumberOperations", "params": [ { "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', 'Dynamic Programming', 'Stack', 'Greedy', 'Monotonic Stack']
1,527
Patients With a Condition
patients-with-a-condition
<p>Table: <code>Patients</code></p> <pre> +--------------+---------+ | Column Name | Type | +--------------+---------+ | patient_id | int | | patient_name | varchar | | conditions | varchar | +--------------+---------+ patient_id is the primary key (column with unique values) for this table. &#39;condition...
Easy
324.8K
825.1K
324,772
825,123
39.4%
[]
['Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))', 'Truncate table Patients', "insert into Patients (patient_id, patient_name, conditions) values ('1', 'Daniel', 'YFEV COUGH')", "insert into Patients (patient_id, patient_name, conditions) values ('2', 'Alice', ''...
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": {"Patients": ["patient_id", "patient_name", "conditions"]}, "rows": {"Patients": [[1, "Daniel", "YFEV COUGH"], [2, "Alice", ""], [3, "Bob", "DIAB100 MYOP"], [4, "George", "ACNE DIAB100"], [5, "Alain", "DIAB201"]]}}
{"mysql": ["Create table If Not Exists Patients (patient_id int, patient_name varchar(30), conditions varchar(100))"], "mssql": ["Create table Patients (patient_id int, patient_name varchar(30), conditions varchar(100))"], "oraclesql": ["Create table Patients (patient_id int, patient_name varchar(30), conditions varcha...
{"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']
1,528
Shuffle String
shuffle-string
<p>You are given a string <code>s</code> and an integer array <code>indices</code> of the <strong>same length</strong>. The string <code>s</code> will be shuffled such that the character at the <code>i<sup>th</sup></code> position moves to <code>indices[i]</code> in the shuffled string.</p> <p>Return <em>the shuffled ...
Easy
439.8K
517K
439,761
517,032
85.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string restoreString(string s, vector<int>& indices) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String restoreString(String s, int[] indices) {\n \n }\n}"}, {"value": "...
"codeleet" [4,5,6,7,0,2,1,3]
{ "name": "restoreString", "params": [ { "name": "s", "type": "string" }, { "type": "integer[]", "name": "indices" } ], "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']
1,529
Minimum Suffix Flips
minimum-suffix-flips
<p>You are given a <strong>0-indexed</strong> binary string <code>target</code> of length <code>n</code>. You have another binary string <code>s</code> of length <code>n</code> that is initially set to all zeros. You want to make <code>s</code> equal to <code>target</code>.</p> <p>In one operation, you can pick an ind...
Medium
60.1K
81.9K
60,084
81,864
73.4%
['minimum-operations-to-make-binary-array-elements-equal-to-one-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minFlips(string target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minFlips(String target) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
"10111"
{ "name": "minFlips", "params": [ { "name": "target", "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', 'Greedy']
1,530
Number of Good Leaf Nodes Pairs
number-of-good-leaf-nodes-pairs
<p>You are given the <code>root</code> of a binary tree and an integer <code>distance</code>. A pair of two different <strong>leaf</strong> nodes of a binary tree is said to be good if the length of <strong>the shortest path</strong> between them is less than or equal to <code>distance</code>.</p> <p>Return <em>the nu...
Medium
154.6K
215.4K
154,618
215,423
71.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,2,3,null,4] 3
{ "name": "countPairs", "params": [ { "name": "root", "type": "TreeNode" }, { "type": "integer", "name": "distance" } ], "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']
1,531
String Compression II
string-compression-ii
<p><a href="http://en.wikipedia.org/wiki/Run-length_encoding">Run-length encoding</a> is a string compression method that works by&nbsp;replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). Fo...
Hard
102.1K
196.4K
102,142
196,420
52.0%
['string-compression-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int getLengthOfOptimalCompression(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int getLengthOfOptimalCompression(String s, int k) {\n \n }\n}"}, {"value"...
"aaabcccd" 2
{ "name": "getLengthOfOptimalCompression", "params": [ { "name": "s", "type": "string" }, { "type": "integer", "name": "k" } ], "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']
1,532
The Most Recent Three Orders
the-most-recent-three-orders
null
Medium
34.8K
50.5K
34,803
50,503
68.9%
['the-most-recent-orders-for-each-product']
['Create table If Not Exists Customers (customer_id int, name varchar(10))', 'Create table If Not Exists Orders (order_id int, order_date date, customer_id int, cost int)', 'Truncate table Customers', "insert into Customers (customer_id, name) values ('1', 'Winston')", "insert into Customers (customer_id, name) values ...
Database
null
{"headers":{"Customers":["customer_id","name"],"Orders":["order_id","order_date","customer_id","cost"]},"rows":{"Customers":[[1,"Winston"],[2,"Jonathan"],[3,"Annabelle"],[4,"Marwan"],[5,"Khaled"]],"Orders":[[1,"2020-07-31",1,30],[2,"2020-7-30",2,40],[3,"2020-07-31",3,70],[4,"2020-07-29",4,100],[5,"2020-06-10",1,1010],[...
{"mysql": ["Create table If Not Exists Customers (customer_id int, name varchar(10))", "Create table If Not Exists Orders (order_id int, order_date date, customer_id int, cost int)"], "mssql": ["Create table Customers (customer_id int, name varchar(10))", "Create table Orders (order_id int, order_date date, customer_id...
{"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']
1,533
Find the Index of the Large Integer
find-the-index-of-the-large-integer
null
Medium
16.1K
28.6K
16,067
28,572
56.2%
['search-in-a-sorted-array-of-unknown-size']
[]
Algorithms
null
[7,7,7,7,10,7,7,7]
{ "name": "getIndex", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" }, "manual": true, "typescriptCustomType" : "class ArrayReader {\n __secret: number[];\n __N: number;\n __guesses: number;\n __mxGuesses: number;\n\n constructor...
{"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', 'Interactive']
1,534
Count Good Triplets
count-good-triplets
<p>Given an array of integers <code>arr</code>, and three integers&nbsp;<code>a</code>,&nbsp;<code>b</code>&nbsp;and&nbsp;<code>c</code>. You need to find the number of good triplets.</p> <p>A triplet <code>(arr[i], arr[j], arr[k])</code>&nbsp;is <strong>good</strong> if the following conditions are true:</p> <ul> <...
Easy
137.9K
168.5K
137,873
168,506
81.8%
['count-special-quadruplets', 'number-of-unequal-triplets-in-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countGoodTriplets(vector<int>& arr, int a, int b, int c) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countGoodTriplets(int[] arr, int a, int b, int c) {\n \n }\n...
[3,0,1,1,9,7] 7 2 3
{ "name": "countGoodTriplets", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "a" }, { "type": "integer", "name": "b" }, { "type": "integer", "name": "c" } ], "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', 'Enumeration']
1,535
Find the Winner of an Array Game
find-the-winner-of-an-array-game
<p>Given an integer array <code>arr</code> of <strong>distinct</strong> integers and an integer <code>k</code>.</p> <p>A game will be played between the first two elements of the array (i.e. <code>arr[0]</code> and <code>arr[1]</code>). In each round of the game, we compare <code>arr[0]</code> with <code>arr[1]</code>...
Medium
119.7K
211K
119,745
211,008
56.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int getWinner(vector<int>& arr, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int getWinner(int[] arr, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[2,1,3,5,4,6,7] 2
{ "name": "getWinner", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "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', 'Simulation']
1,536
Minimum Swaps to Arrange a Binary Grid
minimum-swaps-to-arrange-a-binary-grid
<p>Given an <code>n x n</code> binary <code>grid</code>, in one step you can choose two <strong>adjacent rows</strong> of the grid and swap them.</p> <p>A grid is said to be <strong>valid</strong> if all the cells above the main diagonal are <strong>zeros</strong>.</p> <p>Return <em>the minimum number of steps</em> n...
Medium
16.8K
35.2K
16,791
35,172
47.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minSwaps(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minSwaps(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[[0,0,1],[1,1,0],[1,0,0]]
{ "name": "minSwaps", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Matrix']
1,537
Get the Maximum Score
get-the-maximum-score
<p>You are given two <strong>sorted</strong> arrays of distinct integers <code>nums1</code> and <code>nums2</code>.</p> <p>A <strong>valid<strong><em> </em></strong>path</strong> is defined as follows:</p> <ul> <li>Choose array <code>nums1</code> or <code>nums2</code> to traverse (from index-0).</li> <li>Traverse t...
Hard
30.9K
77.6K
30,917
77,605
39.8%
['maximum-score-of-a-node-sequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSum(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSum(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "python", "t...
[2,4,5,8,10] [4,6,8,9]
{ "name": "maxSum", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" } ], "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', 'Dynamic Programming', 'Greedy']
1,538
Guess the Majority in a Hidden Array
guess-the-majority-in-a-hidden-array
null
Medium
4.7K
6.8K
4,727
6,811
69.4%
[]
[]
Algorithms
null
[0,0,1,0,1,1,1,1]
{ "name": "guessMajority", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" }, "manual": true, "typescriptCustomType" : "class ArrayReader {\n __secret: number[];\n __N: number;\n __guesses: number;\n __mxGuesses: number;\n\n const...
{"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', 'Interactive']
1,539
Kth Missing Positive Number
kth-missing-positive-number
<p>Given an array <code>arr</code> of positive integers sorted in a <strong>strictly increasing order</strong>, and an integer <code>k</code>.</p> <p>Return <em>the</em> <code>k<sup>th</sup></code> <em><strong>positive</strong> integer that is <strong>missing</strong> from this array.</em></p> <p>&nbsp;</p> <p><stron...
Easy
613.6K
990K
613,603
990,047
62.0%
['append-k-integers-with-minimal-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findKthPositive(vector<int>& arr, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findKthPositive(int[] arr, int k) {\n \n }\n}"}, {"value": "python", "text":...
[2,3,4,7,11] 5
{ "name": "findKthPositive", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
1,540
Can Convert String in K Moves
can-convert-string-in-k-moves
<p>Given two strings&nbsp;<code>s</code>&nbsp;and&nbsp;<code>t</code>, your goal is to convert&nbsp;<code>s</code>&nbsp;into&nbsp;<code>t</code>&nbsp;in&nbsp;<code>k</code><strong>&nbsp;</strong>moves or less.</p> <p>During the&nbsp;<code>i<sup>th</sup></code>&nbsp;(<font face="monospace"><code>1 &lt;= i &lt;= k</code...
Medium
22.3K
62.4K
22,307
62,360
35.8%
['minimum-cost-to-convert-string-i', 'minimum-cost-to-convert-string-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canConvertString(string s, string t, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canConvertString(String s, String t, int k) {\n \n }\n}"}, {"value":...
"input" "ouput" 9
{ "name": "canConvertString", "params": [ { "name": "s", "type": "string" }, { "type": "string", "name": "t" }, { "type": "integer", "name": "k" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String']
1,541
Minimum Insertions to Balance a Parentheses String
minimum-insertions-to-balance-a-parentheses-string
<p>Given a parentheses string <code>s</code> containing only the characters <code>&#39;(&#39;</code> and <code>&#39;)&#39;</code>. A parentheses string is <strong>balanced</strong> if:</p> <ul> <li>Any left parenthesis <code>&#39;(&#39;</code> must have a corresponding two consecutive right parenthesis <code>&#39;))&...
Medium
74K
139.4K
73,956
139,399
53.1%
['minimum-number-of-swaps-to-make-the-string-balanced']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minInsertions(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minInsertions(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
"(()))"
{ "name": "minInsertions", "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', 'Stack', 'Greedy']
1,542
Find Longest Awesome Substring
find-longest-awesome-substring
<p>You are given a string <code>s</code>. An <strong>awesome</strong> substring is a non-empty substring of <code>s</code> such that we can make any number of swaps in order to make it a palindrome.</p> <p>Return <em>the length of the maximum length <strong>awesome substring</strong> of</em> <code>s</code>.</p> <p>&n...
Hard
17.3K
38.5K
17,308
38,520
44.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestAwesome(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestAwesome(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
"3242415"
{ "name": "longestAwesome", "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...
['Hash Table', 'String', 'Bit Manipulation']
1,543
Fix Product Name Format
fix-product-name-format
null
Easy
22.3K
37.7K
22,263
37,749
59.0%
[]
['Create table If Not Exists Sales (sale_id int, product_name varchar(30), sale_date date)\n', 'Truncate table Sales', "insert into Sales (sale_id, product_name, sale_date) values ('1', 'LCPHONE', '2000-01-16')", "insert into Sales (sale_id, product_name, sale_date) values ('2', 'LCPhone', '2000-01-17')", "insert into ...
Database
null
{"headers": {"Sales": ["sale_id", "product_name", "sale_date"]}, "rows": {"Sales": [[1, "LCPHONE", "2000-01-16"], [2, "LCPhone", "2000-01-17"], [3, "LcPhOnE", "2000-02-18"], [4, "LCKeyCHAiN", "2000-02-19"], [5, "LCKeyChain", "2000-02-28"], [6, "Matryoshka", "2000-03-31"]]}}
{"mysql": ["Create table If Not Exists Sales (sale_id int, product_name varchar(30), sale_date date)\n"], "mssql": ["Create table Sales (sale_id int, product_name varchar(30), sale_date date)\n"], "oraclesql": ["Create table Sales (sale_id int, product_name varchar(30), sale_date date)\n", "ALTER SESSION SET nls_date_f...
{"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']
1,544
Make The String Great
make-the-string-great
<p>Given a string <code>s</code> of lower and upper case English letters.</p> <p>A good string is a string which doesn&#39;t have <strong>two adjacent characters</strong> <code>s[i]</code> and <code>s[i + 1]</code> where:</p> <ul> <li><code>0 &lt;= i &lt;= s.length - 2</code></li> <li><code>s[i]</code> is a lower-c...
Easy
356.2K
522.2K
356,213
522,185
68.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string makeGood(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String makeGood(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "clas...
"leEeetcode"
{ "name": "makeGood", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Stack']
1,545
Find Kth Bit in Nth Binary String
find-kth-bit-in-nth-binary-string
<p>Given two positive integers <code>n</code> and <code>k</code>, the binary string <code>S<sub>n</sub></code> is formed as follows:</p> <ul> <li><code>S<sub>1</sub> = &quot;0&quot;</code></li> <li><code>S<sub>i</sub> = S<sub>i - 1</sub> + &quot;1&quot; + reverse(invert(S<sub>i - 1</sub>))</code> for <code>i &gt; 1<...
Medium
159.5K
227.2K
159,482
227,231
70.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n char findKthBit(int n, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public char findKthBit(int n, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
3 1
{ "name": "findKthBit", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "k" } ], "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...
['String', 'Recursion', 'Simulation']
1,546
Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
maximum-number-of-non-overlapping-subarrays-with-sum-equals-target
<p>Given an array <code>nums</code> and an integer <code>target</code>, return <em>the maximum number of <strong>non-empty</strong> <strong>non-overlapping</strong> subarrays such that the sum of values in each subarray is equal to</em> <code>target</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</stro...
Medium
31.6K
66.1K
31,595
66,053
47.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxNonOverlapping(vector<int>& nums, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxNonOverlapping(int[] nums, int target) {\n \n }\n}"}, {"value": "...
[1,1,1,1,1] 2
{ "name": "maxNonOverlapping", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "target" } ], "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', 'Greedy', 'Prefix Sum']
1,547
Minimum Cost to Cut a Stick
minimum-cost-to-cut-a-stick
<p>Given a wooden stick of length <code>n</code> units. The stick is labelled from <code>0</code> to <code>n</code>. For example, a stick of length <strong>6</strong> is labelled as follows:</p> <img alt="" src="https://assets.leetcode.com/uploads/2020/07/21/statement.jpg" style="width: 521px; height: 111px;" /> <p>Giv...
Hard
163.6K
264.7K
163,611
264,743
61.8%
['number-of-ways-to-divide-a-long-corridor', 'divide-an-array-into-subarrays-with-minimum-cost-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCost(int n, vector<int>& cuts) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCost(int n, int[] cuts) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
7 [1,3,4,5]
{ "name": "minCost", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[]", "name": "cuts" } ], "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', 'Sorting']
1,548
The Most Similar Path in a Graph
the-most-similar-path-in-a-graph
null
Hard
17.7K
29.8K
17,680
29,826
59.3%
[]
[]
Algorithms
null
5 [[0,2],[0,3],[1,2],[1,3],[1,4],[2,4]] ["ATL","PEK","LAX","DXB","HND"] ["ATL","DXB","HND","LAX"]
{ "name": "mostSimilar", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "roads" }, { "type": "string[]", "name": "names" }, { "type": "string[]", "name": "targetPath" } ], "return": { "type": "l...
{"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', 'Graph']
1,549
The Most Recent Orders for Each Product
the-most-recent-orders-for-each-product
null
Medium
34.8K
53.6K
34,753
53,626
64.8%
['the-most-recent-three-orders', 'the-most-frequently-ordered-products-for-each-customer']
['Create table If Not Exists Customers (customer_id int, name varchar(10))', 'Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int)', 'Create table If Not Exists Products (product_id int, product_name varchar(20), price int)', 'Truncate table Customers', "insert into Custome...
Database
null
{"headers":{"Customers":["customer_id","name"],"Orders":["order_id","order_date","customer_id","product_id"],"Products":["product_id","product_name","price"]},"rows":{"Customers":[[1,"Winston"],[2,"Jonathan"],[3,"Annabelle"],[4,"Marwan"],[5,"Khaled"]],"Orders":[[1,"2020-07-31",1,1],[2,"2020-7-30",2,2],[3,"2020-08-29",3...
{"mysql": ["Create table If Not Exists Customers (customer_id int, name varchar(10))", "Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int)", "Create table If Not Exists Products (product_id int, product_name varchar(20), price int)"], "mssql": ["Create table Customers (cu...
{"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']
1,550
Three Consecutive Odds
three-consecutive-odds
Given an integer array <code>arr</code>, return <code>true</code>&nbsp;if there are three consecutive odd numbers in the array. Otherwise, return&nbsp;<code>false</code>. <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> arr = [2,6,4,1] <strong>Output:</strong> false <b>Exp...
Easy
295.5K
434.2K
295,467
434,229
68.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool threeConsecutiveOdds(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean threeConsecutiveOdds(int[] arr) {\n \n }\n}"}, {"value": "python", "text"...
[2,6,4,1]
{ "name": "threeConsecutiveOdds", "params": [ { "name": "arr", "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']
1,551
Minimum Operations to Make Array Equal
minimum-operations-to-make-array-equal
<p>You have an array <code>arr</code> of length <code>n</code> where <code>arr[i] = (2 * i) + 1</code> for all valid values of <code>i</code> (i.e.,&nbsp;<code>0 &lt;= i &lt; n</code>).</p> <p>In one operation, you can select two indices <code>x</code> and <code>y</code> where <code>0 &lt;= x, y &lt; n</code> and subt...
Medium
107.1K
130.3K
107,136
130,326
82.2%
['minimum-number-of-operations-to-make-arrays-similar', 'minimum-operations-to-make-array-equal-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
3
{ "name": "minOperations", "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']
1,552
Magnetic Force Between Two Balls
magnetic-force-between-two-balls
<p>In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has <code>n</code> empty baskets, the <code>i<sup>th</sup></code> basket is at <code>position[i]</code>, Morty has <code>m</code> balls and needs to distribute the balls in...
Medium
186.4K
262K
186,442
261,987
71.2%
['minimized-maximum-of-products-distributed-to-any-store']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxDistance(vector<int>& position, int m) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxDistance(int[] position, int m) {\n \n }\n}"}, {"value": "python", "text...
[1,2,3,4,7] 3
{ "name": "maxDistance", "params": [ { "name": "position", "type": "integer[]" }, { "type": "integer", "name": "m" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Sorting']
1,553
Minimum Number of Days to Eat N Oranges
minimum-number-of-days-to-eat-n-oranges
<p>There are <code>n</code> oranges in the kitchen and you decided to eat some of these oranges every day as follows:</p> <ul> <li>Eat one orange.</li> <li>If the number of remaining oranges <code>n</code> is divisible by <code>2</code> then you can eat <code>n / 2</code> oranges.</li> <li>If the number of remainin...
Hard
40.3K
113.4K
40,317
113,355
35.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minDays(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minDays(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution(obj...
10
{ "name": "minDays", "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', 'Memoization']
1,554
Strings Differ by One Character
strings-differ-by-one-character
null
Medium
26.2K
63.6K
26,204
63,634
41.2%
['count-words-obtained-after-adding-a-letter']
[]
Algorithms
null
["abcd","acbd", "aacd"]
{ "name": "differByOne", "params": [ { "name": "dict", "type": "string[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Rolling Hash', 'Hash Function']
1,555
Bank Account Summary
bank-account-summary
null
Medium
20.4K
39.3K
20,384
39,315
51.8%
[]
['Create table If Not Exists Users (user_id int, user_name varchar(20), credit int)\n', 'Create table If Not Exists Transactions (trans_id int, paid_by int, paid_to int, amount int, transacted_on date)', 'Truncate table Users', "insert into Users (user_id, user_name, credit) values ('1', 'Moustafa', '100')", "insert in...
Database
null
{"headers": {"Users": ["user_id", "user_name", "credit"], "Transactions": ["trans_id", "paid_by", "paid_to", "amount", "transacted_on"]}, "rows": {"Users": [[1, "Moustafa", 100], [2, "Jonathan", 200], [3, "Winston", 10000], [4, "Luis", 800]], "Transactions": [[1, 1, 3, 400, "2020-08-01"], [2, 3, 2, 500, "2020-08-02"], ...
{"mysql": ["Create table If Not Exists Users (user_id int, user_name varchar(20), credit int)\n", "Create table If Not Exists Transactions (trans_id int, paid_by int, paid_to int, amount int, transacted_on date)"], "mssql": ["Create table Users (user_id int, user_name varchar(20), credit int)\n", "Create table Transact...
{"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']
1,556
Thousand Separator
thousand-separator
<p>Given an integer <code>n</code>, add a dot (&quot;.&quot;) as the thousands separator and return it in string format.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 987 <strong>Output:</strong> &quot;987&quot; </pre> <p><strong class="example">Example 2:</st...
Easy
59.9K
112K
59,935
111,988
53.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string thousandSeparator(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String thousandSeparator(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "default...
987
{ "name": "thousandSeparator", "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']
1,557
Minimum Number of Vertices to Reach All Nodes
minimum-number-of-vertices-to-reach-all-nodes
<p>Given a<strong>&nbsp;directed acyclic graph</strong>,&nbsp;with&nbsp;<code>n</code>&nbsp;vertices numbered from&nbsp;<code>0</code>&nbsp;to&nbsp;<code>n-1</code>,&nbsp;and an array&nbsp;<code>edges</code>&nbsp;where&nbsp;<code>edges[i] = [from<sub>i</sub>, to<sub>i</sub>]</code>&nbsp;represents a directed edge from ...
Medium
203.4K
250.8K
203,361
250,835
81.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> findSmallestSetOfVertices(int n, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> findSmallestSetOfVertices(int n, List<List<Integ...
6 [[0,1],[0,2],[2,5],[3,4],[4,2]]
{ "name": "findSmallestSetOfVertices", "params": [ { "name": "n", "type": "integer" }, { "type": "list<list<integer>>", "name": "edges" } ], "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...
['Graph']
1,558
Minimum Numbers of Function Calls to Make Target Array
minimum-numbers-of-function-calls-to-make-target-array
<p>You are given an integer array <code>nums</code>. You have an integer array <code>arr</code> of the same length with all values set to <code>0</code> initially. You also have the following <code>modify</code> function:</p> <img alt="" src="https://assets.leetcode.com/uploads/2020/07/10/sample_2_1887.png" style="widt...
Medium
23.7K
38K
23,718
37,967
62.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[1,5]
{ "name": "minOperations", "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', 'Bit Manipulation']
1,559
Detect Cycles in 2D Grid
detect-cycles-in-2d-grid
<p>Given a 2D array of characters <code>grid</code> of size <code>m x n</code>, you need to find if there exists any cycle consisting of the <strong>same value</strong> in <code>grid</code>.</p> <p>A cycle is a path of <strong>length 4 or more</strong> in the grid that starts and ends at the same cell. From a given ce...
Medium
51.3K
103K
51,300
103,013
49.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool containsCycle(vector<vector<char>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean containsCycle(char[][] grid) {\n \n }\n}"}, {"value": "python", "text"...
[["a","a","a","a"],["a","b","b","a"],["a","b","b","a"],["a","a","a","a"]]
{ "name": "containsCycle", "params": [ { "name": "grid", "type": "character[][]" } ], "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', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Matrix']
1,560
Most Visited Sector in a Circular Track
most-visited-sector-in-a-circular-track
<p>Given an integer <code>n</code> and an integer array <code>rounds</code>. We have a circular track which consists of <code>n</code> sectors labeled from <code>1</code> to <code>n</code>. A marathon will be held on this track, the marathon consists of <code>m</code> rounds. The <code>i<sup>th</sup></code> round start...
Easy
35.9K
60.8K
35,866
60,839
59.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> mostVisited(int n, vector<int>& rounds) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> mostVisited(int n, int[] rounds) {\n \n }\n}"}, {"value": "...
4 [1,3,1,2]
{ "name": "mostVisited", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[]", "name": "rounds" } ], "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', 'Simulation']
1,561
Maximum Number of Coins You Can Get
maximum-number-of-coins-you-can-get
<p>There are <code>3n</code> piles of coins of varying size, you and your friends will take piles of coins as follows:</p> <ul> <li>In each step, you will choose <strong>any </strong><code>3</code> piles of coins (not necessarily consecutive).</li> <li>Of your choice, Alice will pick the pile with the maximum number...
Medium
180.3K
213.7K
180,337
213,655
84.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxCoins(vector<int>& piles) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxCoins(int[] piles) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode"...
[2,4,1,2,7,8]
{ "name": "maxCoins", "params": [ { "name": "piles", "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', 'Greedy', 'Sorting', 'Game Theory']
1,562
Find Latest Group of Size M
find-latest-group-of-size-m
<p>Given an array <code>arr</code> that represents a permutation of numbers from <code>1</code> to <code>n</code>.</p> <p>You have a binary string of size <code>n</code> that initially has all its bits set to zero. At each step <code>i</code> (assuming both the binary string and <code>arr</code> are 1-indexed) from <c...
Medium
19.9K
46.5K
19,937
46,505
42.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLatestStep(vector<int>& arr, int m) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLatestStep(int[] arr, int m) {\n \n }\n}"}, {"value": "python", "text": "...
[3,5,1,2,4] 1
{ "name": "findLatestStep", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "m" } ], "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', 'Binary Search', 'Simulation']
1,563
Stone Game V
stone-game-v
<p>There are several stones <strong>arranged in a row</strong>, and each stone has an associated value which is an integer given in the array <code>stoneValue</code>.</p> <p>In each round of the game, Alice divides the row into <strong>two non-empty rows</strong> (i.e. left row and right row), then Bob calculates the ...
Hard
23.1K
56.2K
23,078
56,250
41.0%
['stone-game', 'stone-game-ii', 'stone-game-iii', 'stone-game-iv', 'stone-game-vi', 'stone-game-vii', 'stone-game-viii', 'stone-game-ix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int stoneGameV(vector<int>& stoneValue) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int stoneGameV(int[] stoneValue) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[6,2,3,4,5,5]
{ "name": "stoneGameV", "params": [ { "name": "stoneValue", "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', 'Dynamic Programming', 'Game Theory']
1,564
Put Boxes Into the Warehouse I
put-boxes-into-the-warehouse-i
null
Medium
17.1K
25.4K
17,083
25,449
67.1%
['put-boxes-into-the-warehouse-ii']
[]
Algorithms
null
[4,3,4,1] [5,3,3,4,1]
{ "name": "maxBoxesInWarehouse", "params": [ { "name": "boxes", "type": "integer[]" }, { "type": "integer[]", "name": "warehouse" } ], "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']
1,565
Unique Orders and Customers Per Month
unique-orders-and-customers-per-month
null
Easy
24K
29.2K
24,012
29,221
82.2%
[]
['Create table If Not Exists Orders (order_id int, order_date date, customer_id int, invoice int)', 'Truncate table Orders', "insert into Orders (order_id, order_date, customer_id, invoice) values ('1', '2020-09-15', '1', '30')", "insert into Orders (order_id, order_date, customer_id, invoice) values ('2', '2020-09-17'...
Database
null
{"headers":{"Orders":["order_id","order_date","customer_id","invoice"]},"rows":{"Orders":[[1,"2020-09-15",1,30],[2,"2020-09-17",2,90],[3,"2020-10-06",3,20],[4,"2020-10-20",3,21],[5,"2020-11-10",1,10],[6,"2020-11-21",2,15],[7,"2020-12-01",4,55],[8,"2020-12-03",4,77],[9,"2021-01-07",3,31],[10,"2021-01-15",2,20]]}}
{"mysql": ["Create table If Not Exists Orders (order_id int, order_date date, customer_id int, invoice int)"], "mssql": ["Create table Orders (order_id int, order_date date, customer_id int, invoice int)"], "oraclesql": ["Create table Orders (order_id int, order_date date, customer_id int, invoice int)", "ALTER SESSION...
{"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']
1,566
Detect Pattern of Length M Repeated K or More Times
detect-pattern-of-length-m-repeated-k-or-more-times
<p>Given an array of positive integers <code>arr</code>, find a pattern of length <code>m</code> that is repeated <code>k</code> or more times.</p> <p>A <strong>pattern</strong> is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times <strong>consecutively </strong>without ...
Easy
40.2K
92.5K
40,160
92,507
43.4%
['maximum-repeating-substring']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool containsPattern(vector<int>& arr, int m, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean containsPattern(int[] arr, int m, int k) {\n \n }\n}"}, {"value"...
[1,2,4,4,4,4] 1 3
{ "name": "containsPattern", "params": [ { "name": "arr", "type": "integer[]" }, { "type": "integer", "name": "m" }, { "type": "integer", "name": "k" } ], "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', 'Enumeration']
1,567
Maximum Length of Subarray With Positive Product
maximum-length-of-subarray-with-positive-product
<p>Given an array of integers <code>nums</code>, find the maximum length of a subarray where the product of all its elements is positive.</p> <p>A subarray of an array is a consecutive sequence of zero or more values taken out of that array.</p> <p>Return <em>the maximum length of a subarray with positive product</em...
Medium
102.9K
232.1K
102,898
232,080
44.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int getMaxLen(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int getMaxLen(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode"...
[1,-2,-3,4]
{ "name": "getMaxLen", "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', 'Dynamic Programming', 'Greedy']
1,568
Minimum Number of Days to Disconnect Island
minimum-number-of-days-to-disconnect-island
<p>You are given an <code>m x n</code> binary grid <code>grid</code> where <code>1</code> represents land and <code>0</code> represents water. An <strong>island</strong> is a maximal <strong>4-directionally</strong> (horizontal or vertical) connected group of <code>1</code>&#39;s.</p> <p>The grid is said to be <strong...
Hard
94.3K
159.5K
94,336
159,465
59.2%
['disconnect-path-in-a-binary-matrix-by-at-most-one-flip', 'minimum-runes-to-add-to-cast-spell']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minDays(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minDays(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[[0,1,1,0],[0,1,1,0],[0,0,0,0]]
{ "name": "minDays", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Strongly Connected Component']
1,569
Number of Ways to Reorder Array to Get Same BST
number-of-ways-to-reorder-array-to-get-same-bst
<p>Given an array <code>nums</code> that represents a permutation of integers from <code>1</code> to <code>n</code>. We are going to construct a binary search tree (BST) by inserting the elements of <code>nums</code> in order into an initially empty BST. Find the number of different ways to reorder <code>nums</code> so...
Hard
58.9K
110.2K
58,923
110,191
53.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numOfWays(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numOfWays(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode"...
[2,1,3]
{ "name": "numOfWays", "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', 'Math', 'Divide and Conquer', 'Dynamic Programming', 'Tree', 'Union Find', 'Binary Search Tree', 'Memoization', 'Combinatorics', 'Binary Tree']
1,570
Dot Product of Two Sparse Vectors
dot-product-of-two-sparse-vectors
null
Medium
352.9K
392.4K
352,904
392,393
89.9%
[]
[]
Algorithms
null
[1,0,0,2,3] [0,3,0,4,0]
{ "name": "dotProduct", "params": [ { "name": "v1", "type": "integer[]" }, { "type": "integer[]", "name": "v2" } ], "return": { "type": "integer" }, "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Two Pointers', 'Design']
1,571
Warehouse Manager
warehouse-manager
null
Easy
47.6K
54.4K
47,596
54,416
87.5%
[]
['Create table If Not Exists Warehouse (name varchar(50), product_id int, units int)\n', 'Create table If Not Exists Products (product_id int, product_name varchar(50), Width int,Length int,Height int)', 'Truncate table Warehouse', "insert into Warehouse (name, product_id, units) values ('LCHouse1', '1', '1')", "insert...
Database
null
{"headers": {"Warehouse": ["name", "product_id", "units"], "Products": ["product_id", "product_name", "Width", "Length", "Height"]}, "rows": {"Warehouse": [["LCHouse1", 1, 1], ["LCHouse1", 2, 10], ["LCHouse1", 3, 5], ["LCHouse2", 1, 2], ["LCHouse2", 2, 2], ["LCHouse3", 4, 1]], "Products": [[1, "LC-TV", 5, 50, 40], [2, ...
{"mysql": ["Create table If Not Exists Warehouse (name varchar(50), product_id int, units int)\n", "Create table If Not Exists Products (product_id int, product_name varchar(50), Width int,Length int,Height int)"], "mssql": ["Create table Warehouse (name varchar(50), product_id int, units int)\n", "Create table Product...
{"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']
1,572
Matrix Diagonal Sum
matrix-diagonal-sum
<p>Given a&nbsp;square&nbsp;matrix&nbsp;<code>mat</code>, return the sum of the matrix diagonals.</p> <p>Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</s...
Easy
426.5K
510.2K
426,478
510,178
83.6%
['check-if-every-row-and-column-contains-all-numbers', 'check-if-matrix-is-x-matrix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int diagonalSum(vector<vector<int>>& mat) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int diagonalSum(int[][] mat) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[[1,2,3],[4,5,6],[7,8,9]]
{ "name": "diagonalSum", "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', 'Matrix']
1,573
Number of Ways to Split a String
number-of-ways-to-split-a-string
<p>Given a binary string <code>s</code>, you can split <code>s</code> into 3 <strong>non-empty</strong> strings <code>s1</code>, <code>s2</code>, and <code>s3</code> where <code>s1 + s2 + s3 = s</code>.</p> <p>Return the number of ways <code>s</code> can be split such that the number of ones is the same in <code>s1</c...
Medium
32.8K
97.4K
32,847
97,410
33.7%
['split-array-with-equal-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numWays(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numWays(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Soluti...
"10101"
{ "name": "numWays", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String']
1,574
Shortest Subarray to be Removed to Make Array Sorted
shortest-subarray-to-be-removed-to-make-array-sorted
<p>Given an integer array <code>arr</code>, remove a subarray (can be empty) from <code>arr</code> such that the remaining elements in <code>arr</code> are <strong>non-decreasing</strong>.</p> <p>Return <em>the length of the shortest subarray to remove</em>.</p> <p>A <strong>subarray</strong> is a contiguous subseque...
Medium
118.1K
229.2K
118,123
229,247
51.5%
['count-the-number-of-incremovable-subarrays-ii', 'count-the-number-of-incremovable-subarrays-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLengthOfShortestSubarray(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLengthOfShortestSubarray(int[] arr) {\n \n }\n}"}, {"value": "pyth...
[1,2,3,10,4,2,3,5]
{ "name": "findLengthOfShortestSubarray", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Stack', 'Monotonic Stack']
1,575
Count All Possible Routes
count-all-possible-routes
<p>You are given an array of <strong>distinct</strong> positive integers locations where <code>locations[i]</code> represents the position of city <code>i</code>. You are also given integers <code>start</code>, <code>finish</code> and <code>fuel</code> representing the starting city, ending city, and the initial amount...
Hard
61.6K
94.9K
61,636
94,911
64.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countRoutes(vector<int>& locations, int start, int finish, int fuel) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countRoutes(int[] locations, int start, int finish, int fu...
[2,3,6,8,4] 1 3 5
{ "name": "countRoutes", "params": [ { "name": "locations", "type": "integer[]" }, { "type": "integer", "name": "start" }, { "type": "integer", "name": "finish" }, { "type": "integer", "name": "fuel" } ], "return": { "type": "in...
{"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']
1,576
Replace All ?'s to Avoid Consecutive Repeating Characters
replace-all-s-to-avoid-consecutive-repeating-characters
<p>Given a string <code>s</code> containing only lowercase English letters and the <code>&#39;?&#39;</code> character, convert <strong>all </strong>the <code>&#39;?&#39;</code> characters into lowercase letters such that the final string does not contain any <strong>consecutive repeating </strong>characters. You <stron...
Easy
67K
148.1K
66,970
148,105
45.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string modifyString(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String modifyString(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
"?zs"
{ "name": "modifyString", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "string" }, "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...
['String']
1,577
Number of Ways Where Square of Number Is Equal to Product of Two Numbers
number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers
<p>Given two arrays of integers <code>nums1</code> and <code>nums2</code>, return the number of triplets formed (type 1 and type 2) under the following rules:</p> <ul> <li>Type 1: Triplet (i, j, k) if <code>nums1[i]<sup>2</sup> == nums2[j] * nums2[k]</code> where <code>0 &lt;= i &lt; nums1.length</code> and <code>0 &...
Medium
23.6K
56.4K
23,560
56,383
41.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numTriplets(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numTriplets(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "p...
[7,4] [5,2,8,9]
{ "name": "numTriplets", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Two Pointers']
1,578
Minimum Time to Make Rope Colorful
minimum-time-to-make-rope-colorful
<p>Alice has <code>n</code> balloons arranged on a rope. You are given a <strong>0-indexed</strong> string <code>colors</code> where <code>colors[i]</code> is the color of the <code>i<sup>th</sup></code> balloon.</p> <p>Alice wants the rope to be <strong>colorful</strong>. She does not want <strong>two consecutive bal...
Medium
273.4K
430.7K
273,365
430,699
63.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCost(string colors, vector<int>& neededTime) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCost(String colors, int[] neededTime) {\n \n }\n}"}, {"value": "py...
"abaac" [1,2,3,4,5]
{ "name": "minCost", "params": [ { "name": "colors", "type": "string" }, { "type": "integer[]", "name": "neededTime" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Dynamic Programming', 'Greedy']
1,579
Remove Max Number of Edges to Keep Graph Fully Traversable
remove-max-number-of-edges-to-keep-graph-fully-traversable
<p>Alice and Bob have an undirected graph of <code>n</code> nodes and three types of edges:</p> <ul> <li>Type 1: Can be traversed by Alice only.</li> <li>Type 2: Can be traversed by Bob only.</li> <li>Type 3: Can be traversed by both Alice and Bob.</li> </ul> <p>Given an array <code>edges</code> where <code>edges[...
Hard
136.2K
193.3K
136,199
193,276
70.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxNumEdgesToRemove(int n, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxNumEdgesToRemove(int n, int[][] edges) {\n \n }\n}"}, {"val...
4 [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]
{ "name": "maxNumEdgesToRemove", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "edges" } ], "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...
['Union Find', 'Graph']
1,580
Put Boxes Into the Warehouse II
put-boxes-into-the-warehouse-ii
null
Medium
9.1K
13.9K
9,117
13,918
65.5%
['put-boxes-into-the-warehouse-i']
[]
Algorithms
null
[1,2,2,3,4] [3,4,1,2]
{ "name": "maxBoxesInWarehouse", "params": [ { "name": "boxes", "type": "integer[]" }, { "type": "integer[]", "name": "warehouse" } ], "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']
1,581
Customer Who Visited but Did Not Make Any Transactions
customer-who-visited-but-did-not-make-any-transactions
<p>Table: <code>Visits</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | visit_id | int | | customer_id | int | +-------------+---------+ visit_id is the column with unique values for this table. This table contains information about the customers who visited t...
Easy
803.2K
1.2M
803,197
1,190,764
67.5%
['sellers-with-no-sales']
['Create table If Not Exists Visits(visit_id int, customer_id int)', 'Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int)', 'Truncate table Visits', "insert into Visits (visit_id, customer_id) values ('1', '23')", "insert into Visits (visit_id, customer_id) values ('2', '9')", "insert ...
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":{"Visits":["visit_id","customer_id"],"Transactions":["transaction_id","visit_id","amount"]},"rows":{"Visits":[[1,23],[2,9],[4,30],[5,54],[6,96],[7,54],[8,54]],"Transactions":[[2,5,310],[3,5,300],[9,5,200],[12,1,910],[13,2,970]]}}
{"mysql": ["Create table If Not Exists Visits(visit_id int, customer_id int)", "Create table If Not Exists Transactions(transaction_id int, visit_id int, amount int)"], "mssql": ["Create table Visits(visit_id int, customer_id int)", "Create table Transactions(transaction_id int, visit_id int, amount 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']
1,582
Special Positions in a Binary Matrix
special-positions-in-a-binary-matrix
<p>Given an <code>m x n</code> binary matrix <code>mat</code>, return <em>the number of special positions in </em><code>mat</code><em>.</em></p> <p>A position <code>(i, j)</code> is called <strong>special</strong> if <code>mat[i][j] == 1</code> and all other elements in row <code>i</code> and column <code>j</code> are...
Easy
156.4K
227.7K
156,369
227,728
68.7%
['difference-between-ones-and-zeros-in-row-and-column']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSpecial(vector<vector<int>>& mat) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSpecial(int[][] mat) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[[1,0,0],[0,0,1],[1,0,0]]
{ "name": "numSpecial", "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', 'Matrix']
1,583
Count Unhappy Friends
count-unhappy-friends
<p>You are given a list of&nbsp;<code>preferences</code>&nbsp;for&nbsp;<code>n</code>&nbsp;friends, where <code>n</code> is always <strong>even</strong>.</p> <p>For each person <code>i</code>,&nbsp;<code>preferences[i]</code>&nbsp;contains&nbsp;a list of friends&nbsp;<strong>sorted</strong> in the <strong>order of pre...
Medium
31.6K
51K
31,581
51,025
61.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int unhappyFriends(int n, vector<vector<int>>& preferences, vector<vector<int>>& pairs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int unhappyFriends(int n, int[][] preferences, ...
4 [[1,2,3],[3,2,0],[3,1,0],[1,2,0]] [[0,1],[2,3]]
{ "name": "unhappyFriends", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "preferences" }, { "type": "integer[][]", "name": "pairs" } ], "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', 'Simulation']
1,584
Min Cost to Connect All Points
min-cost-to-connect-all-points
<p>You are given an array <code>points</code> representing integer coordinates of some points on a 2D-plane, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>.</p> <p>The cost of connecting two points <code>[x<sub>i</sub>, y<sub>i</sub>]</code> and <code>[x<sub>j</sub>, y<sub>j</sub>]</code> is the <strong...
Medium
365.4K
532.9K
365,421
532,901
68.6%
['minimum-number-of-lines-to-cover-points']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCostConnectPoints(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCostConnectPoints(int[][] points) {\n \n }\n}"}, {"value": "pyth...
[[0,0],[2,2],[3,10],[5,2],[7,0]]
{ "name": "minCostConnectPoints", "params": [ { "name": "points", "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', 'Union Find', 'Graph', 'Minimum Spanning Tree']
1,585
Check If String Is Transformable With Substring Sort Operations
check-if-string-is-transformable-with-substring-sort-operations
<p>Given two strings <code>s</code> and <code>t</code>, transform string <code>s</code> into string <code>t</code> using the following operation any number of times:</p> <ul> <li>Choose a <strong>non-empty</strong> substring in <code>s</code> and sort it in place so the characters are in <strong>ascending order</stro...
Hard
9.9K
20.6K
9,938
20,632
48.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isTransformable(string s, string t) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isTransformable(String s, String t) {\n \n }\n}"}, {"value": "python", "text...
"84532" "34852"
{ "name": "isTransformable", "params": [ { "name": "s", "type": "string" }, { "type": "string", "name": "t" } ], "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', 'Greedy', 'Sorting']
1,586
Binary Search Tree Iterator II
binary-search-tree-iterator-ii
null
Medium
16.1K
25.5K
16,113
25,513
63.2%
['binary-search-tree-iterator']
[]
Algorithms
null
["BSTIterator","next","next","prev","next","hasNext","next","next","next","hasNext","hasPrev","prev","prev"] [[[7,3,15,null,null,9,20]],[null],[null],[null],[null],[null],[null],[null],[null],[null],[null],[null],[null]]
{ "classname": "BSTIterator", "constructor": { "params": [ { "type": "TreeNode", "name": "root" } ] }, "methods": [ { "params": [], "name": "hasNext", "return": { "type": "boolean" } }, { "params": [], "name": "next", ...
{"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', 'Design', 'Binary Search Tree', 'Binary Tree', 'Iterator']
1,587
Bank Account Summary II
bank-account-summary-ii
<p>Table: <code>Users</code></p> <pre> +--------------+---------+ | Column Name | Type | +--------------+---------+ | account | int | | name | varchar | +--------------+---------+ account is the primary key (column with unique values) for this table. Each row of this table contains the account num...
Easy
128K
153.5K
127,959
153,536
83.3%
[]
['Create table If Not Exists Users (account int, name varchar(20))', 'Create table If Not Exists Transactions (trans_id int, account int, amount int, transacted_on date)', 'Truncate table Users', "insert into Users (account, name) values ('900001', 'Alice')", "insert into Users (account, name) values ('900002', 'Bob')"...
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": {"Users": ["account", "name"], "Transactions": ["trans_id", "account", "amount", "transacted_on"]}, "rows": {"Users": [[900001, "Alice"], [900002, "Bob"], [900003, "Charlie"]], "Transactions": [[1, 900001, 7000, "2020-08-01"], [2, 900001, 7000, "2020-09-01"], [3, 900001, -3000, "2020-09-02"], [4, 900002, 10...
{"mysql": ["Create table If Not Exists Users (account int, name varchar(20))", "Create table If Not Exists Transactions (trans_id int, account int, amount int, transacted_on date)"], "mssql": ["Create table Users (account int, name varchar(20))", "Create table Transactions (trans_id int, account int, amount int, transa...
{"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']
1,588
Sum of All Odd Length Subarrays
sum-of-all-odd-length-subarrays
<p>Given an array of positive integers <code>arr</code>, return <em>the sum of all possible <strong>odd-length subarrays</strong> of </em><code>arr</code>.</p> <p>A <strong>subarray</strong> is a contiguous subsequence of the array.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>I...
Easy
223.9K
268.3K
223,885
268,298
83.4%
['sum-of-squares-of-special-elements']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumOddLengthSubarrays(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumOddLengthSubarrays(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "...
[1,4,2,5,3]
{ "name": "sumOddLengthSubarrays", "params": [ { "name": "arr", "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', 'Prefix Sum']
1,589
Maximum Sum Obtained of Any Permutation
maximum-sum-obtained-of-any-permutation
<p>We have an array of integers, <code>nums</code>, and an array of <code>requests</code> where <code>requests[i] = [start<sub>i</sub>, end<sub>i</sub>]</code>. The <code>i<sup>th</sup></code> request asks for the sum of <code>nums[start<sub>i</sub>] + nums[start<sub>i</sub> + 1] + ... + nums[end<sub>i</sub> - 1] + num...
Medium
24.1K
61.9K
24,126
61,925
39.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSumRangeQuery(vector<int>& nums, vector<vector<int>>& requests) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSumRangeQuery(int[] nums, int[][] requests) {\n \n...
[1,2,3,4,5] [[1,3],[0,1]]
{ "name": "maxSumRangeQuery", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[][]", "name": "requests" } ], "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', 'Prefix Sum']
1,590
Make Sum Divisible by P
make-sum-divisible-by-p
<p>Given an array of positive integers <code>nums</code>, remove the <strong>smallest</strong> subarray (possibly <strong>empty</strong>) such that the <strong>sum</strong> of the remaining elements is divisible by <code>p</code>. It is <strong>not</strong> allowed to remove the whole array.</p> <p>Return <em>the leng...
Medium
139.6K
353.3K
139,565
353,321
39.5%
['subarray-sums-divisible-by-k', 'find-the-divisibility-array-of-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minSubarray(vector<int>& nums, int p) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minSubarray(int[] nums, int p) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[3,1,4,2] 6
{ "name": "minSubarray", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "p" } ], "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']
1,591
Strange Printer II
strange-printer-ii
<p>There is a strange printer with the following two special requirements:</p> <ul> <li>On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.</li> <li>Once the printer has used a color for the above operation, <strong>...
Hard
13.5K
22.7K
13,522
22,705
59.6%
['strange-printer', 'longest-cycle-in-a-graph', 'sort-array-by-moving-items-to-empty-space']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isPrintable(vector<vector<int>>& targetGrid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isPrintable(int[][] targetGrid) {\n \n }\n}"}, {"value": "python", ...
[[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
{ "name": "isPrintable", "params": [ { "name": "targetGrid", "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', 'Graph', 'Topological Sort', 'Matrix']
1,592
Rearrange Spaces Between Words
rearrange-spaces-between-words
<p>You are given a string <code>text</code> of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It&#39;s guaranteed that <code>text</code> <strong>contains at least one word</strong>.</p> <p>Rearrange the spaces so t...
Easy
65.1K
148.4K
65,140
148,390
43.9%
['text-justification']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string reorderSpaces(string text) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String reorderSpaces(String text) {\n \n }\n}"}, {"value": "python", "text": "Python", "def...
" this is a sentence "
{ "name": "reorderSpaces", "params": [ { "name": "text", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String']
1,593
Split a String Into the Max Number of Unique Substrings
split-a-string-into-the-max-number-of-unique-substrings
<p>Given a string&nbsp;<code>s</code><var>,</var>&nbsp;return <em>the maximum&nbsp;number of unique substrings that the given string can be split into</em>.</p> <p>You can split string&nbsp;<code>s</code> into any list of&nbsp;<strong>non-empty substrings</strong>, where the concatenation of the substrings forms the o...
Medium
141.1K
206.6K
141,082
206,573
68.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxUniqueSplit(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxUniqueSplit(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
"ababccc"
{ "name": "maxUniqueSplit", "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...
['Hash Table', 'String', 'Backtracking']
1,594
Maximum Non Negative Product in a Matrix
maximum-non-negative-product-in-a-matrix
<p>You are given a <code>m x n</code> matrix <code>grid</code>. Initially, you are located at the top-left corner <code>(0, 0)</code>, and in each step, you can only <strong>move right or down</strong> in the matrix.</p> <p>Among all possible paths starting from the top-left corner <code>(0, 0)</code> and ending in th...
Medium
27.6K
80.2K
27,616
80,189
34.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxProductPath(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxProductPath(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Py...
[[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]
{ "name": "maxProductPath", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Matrix']
1,595
Minimum Cost to Connect Two Groups of Points
minimum-cost-to-connect-two-groups-of-points
<p>You are given two groups of points where the first group has <code>size<sub>1</sub></code> points, the second group has <code>size<sub>2</sub></code> points, and <code>size<sub>1</sub> &gt;= size<sub>2</sub></code>.</p> <p>The <code>cost</code> of the connection between any two points are given in an <code>size<sub...
Hard
10.5K
21.8K
10,466
21,765
48.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int connectTwoGroups(vector<vector<int>>& cost) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int connectTwoGroups(List<List<Integer>> cost) {\n \n }\n}"}, {"value": "pyth...
[[15,96],[36,2]]
{ "name": "connectTwoGroups", "params": [ { "name": "cost", "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', 'Dynamic Programming', 'Bit Manipulation', 'Matrix', 'Bitmask']
1,596
The Most Frequently Ordered Products for Each Customer
the-most-frequently-ordered-products-for-each-customer
null
Medium
40.1K
51.4K
40,054
51,402
77.9%
['the-most-recent-orders-for-each-product']
['Create table If Not Exists Customers (customer_id int, name varchar(10))', 'Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int)', 'Create table If Not Exists Products (product_id int, product_name varchar(20), price int)', 'Truncate table Customers', "insert into Custome...
Database
null
{"headers":{"Customers":["customer_id","name"],"Orders":["order_id","order_date","customer_id","product_id"],"Products":["product_id","product_name","price"]},"rows":{"Customers":[[1,"Alice"],[2,"Bob"],[3,"Tom"],[4,"Jerry"],[5,"John"]],"Orders":[[1,"2020-07-31",1,1],[2,"2020-7-30",2,2],[3,"2020-08-29",3,3],[4,"2020-07-...
{"mysql": ["Create table If Not Exists Customers (customer_id int, name varchar(10))", "Create table If Not Exists Orders (order_id int, order_date date, customer_id int, product_id int)", "Create table If Not Exists Products (product_id int, product_name varchar(20), price int)"], "mssql": ["Create table Customers (cu...
{"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']
1,597
Build Binary Expression Tree From Infix Expression
build-binary-expression-tree-from-infix-expression
null
Hard
14K
22.4K
14,011
22,441
62.4%
['basic-calculator-iii', 'check-if-two-expression-trees-are-equivalent']
[]
Algorithms
null
"3*4-2*5"
{ "name": "expTree", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "TreeNode" }, "languages": [ "cpp", "java", "python", "python3", "csharp", "javascript" ], "manual": true }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Stack', 'Tree', 'Binary Tree']
1,598
Crawler Log Folder
crawler-log-folder
<p>The Leetcode file system keeps a log each time some user performs a <em>change folder</em> operation.</p> <p>The operations are described below:</p> <ul> <li><code>&quot;../&quot;</code> : Move to the parent folder of the current folder. (If you are already in the main folder, <strong>remain in the same folder</s...
Easy
267.1K
372.9K
267,051
372,940
71.6%
['baseball-game', 'backspace-string-compare']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(vector<string>& logs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(String[] logs) {\n \n }\n}"}, {"value": "python", "text": "Python",...
["d1/","d2/","../","d21/","./"]
{ "name": "minOperations", "params": [ { "name": "logs", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Stack']
1,599
Maximum Profit of Operating a Centennial Wheel
maximum-profit-of-operating-a-centennial-wheel
<p>You are the operator of a Centennial Wheel that has <strong>four gondolas</strong>, and each gondola has room for <strong>up</strong> <strong>to</strong> <strong>four people</strong>. You have the ability to rotate the gondolas <strong>counterclockwise</strong>, which costs you <code>runningCost</code> dollars.</p> ...
Medium
13.9K
31.9K
13,946
31,854
43.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperationsMaxProfit(vector<int>& customers, int boardingCost, int runningCost) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperationsMaxProfit(int[] customers, int b...
[8,3] 5 6
{ "name": "minOperationsMaxProfit", "params": [ { "name": "customers", "type": "integer[]" }, { "type": "integer", "name": "boardingCost" }, { "type": "integer", "name": "runningCost" } ], "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', 'Simulation']
1,600
Throne Inheritance
throne-inheritance
<p>A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born.</p> <p>The kingdom has a well-defined order of inheritance that consists of the king as the first member. Let&#39;s define the recursive function <code>Successor(x, curOrde...
Medium
21.2K
31.8K
21,206
31,832
66.6%
['operations-on-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class ThroneInheritance {\npublic:\n ThroneInheritance(string kingName) {\n \n }\n \n void birth(string parentName, string childName) {\n \n }\n \n void death(string name) {\n \n }\n \n vector<string> getInheritanceOrder...
["ThroneInheritance","birth","birth","birth","birth","birth","birth","getInheritanceOrder","death","getInheritanceOrder"] [["king"],["king","andy"],["king","bob"],["king","catherine"],["andy","matthew"],["bob","alex"],["bob","asha"],[null],["bob"],[null]]
{ "classname": "ThroneInheritance", "constructor": { "params": [ { "type": "string", "name": "kingName" } ] }, "methods": [ { "params": [ { "type": "string", "name": "parentName" }, { "type": "string", ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Tree', 'Depth-First Search', 'Design']