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,001
Grid Illumination
grid-illumination
<p>There is a 2D <code>grid</code> of size <code>n x n</code> where each cell of this grid has a lamp that is initially <strong>turned off</strong>.</p> <p>You are given a 2D array of lamp positions <code>lamps</code>, where <code>lamps[i] = [row<sub>i</sub>, col<sub>i</sub>]</code> indicates that the lamp at <code>gr...
Hard
23.8K
63K
23,837
63,043
37.8%
['n-queens']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> gridIllumination(int n, vector<vector<int>>& lamps, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] gridIllumination(int n, int[][] lam...
5 [[0,0],[4,4]] [[1,1],[1,0]]
{ "name": "gridIllumination", "params": [ { "name": "n", "type": "integer" }, { "name": "lamps", "type": "integer[][]" }, { "name": "queries", "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']
1,002
Find Common Characters
find-common-characters
<p>Given a string array <code>words</code>, return <em>an array of all characters that show up in all strings within the </em><code>words</code><em> (including duplicates)</em>. You may return the answer in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre><strong>In...
Easy
391K
524.8K
391,000
524,792
74.5%
['intersection-of-two-arrays-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> commonChars(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> commonChars(String[] words) {\n \n }\n}"}, {"value": "python",...
["bella","label","roller"]
{ "name": "commonChars", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String']
1,003
Check If Word Is Valid After Substitutions
check-if-word-is-valid-after-substitutions
<p>Given a string <code>s</code>, determine if it is <strong>valid</strong>.</p> <p>A string <code>s</code> is <strong>valid</strong> if, starting with an empty string <code>t = &quot;&quot;</code>, you can <strong>transform </strong><code>t</code><strong> into </strong><code>s</code> after performing the following op...
Medium
74K
123.4K
74,000
123,401
60.0%
['valid-parentheses']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isValid(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isValid(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class S...
"aabcbc"
{ "name": "isValid", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Stack']
1,004
Max Consecutive Ones III
max-consecutive-ones-iii
<p>Given a binary array <code>nums</code> and an integer <code>k</code>, return <em>the maximum number of consecutive </em><code>1</code><em>&#39;s in the array if you can flip at most</em> <code>k</code> <code>0</code>&#39;s.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</...
Medium
933.9K
1.4M
933,869
1,425,761
65.5%
['longest-substring-with-at-most-k-distinct-characters', 'longest-repeating-character-replacement', 'max-consecutive-ones', 'max-consecutive-ones-ii', 'longest-subarray-of-1s-after-deleting-one-element', 'maximize-the-confusion-of-an-exam', 'minimum-recolors-to-get-k-consecutive-black-blocks', 'longest-nice-subarray', ...
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestOnes(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestOnes(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,1,1,0,0,0,1,1,1,1,0] 2
{ "name": "longestOnes", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Sliding Window', 'Prefix Sum']
1,005
Maximize Sum Of Array After K Negations
maximize-sum-of-array-after-k-negations
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, modify the array in the following way:</p> <ul> <li>choose an index <code>i</code> and replace <code>nums[i]</code> with <code>-nums[i]</code>.</li> </ul> <p>You should apply this process exactly <code>k</code> times. You may choose the same ...
Easy
110.3K
211.7K
110,272
211,674
52.1%
['find-subsequence-of-length-k-with-the-largest-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int largestSumAfterKNegations(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int largestSumAfterKNegations(int[] nums, int k) {\n \n }\n}"}, {"val...
[4,2,3] 1
{ "name": "largestSumAfterKNegations", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
1,006
Clumsy Factorial
clumsy-factorial
<p>The <strong>factorial</strong> of a positive integer <code>n</code> is the product of all positive integers less than or equal to <code>n</code>.</p> <ul> <li>For example, <code>factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1</code>.</li> </ul> <p>We make a <strong>clumsy factorial</strong> using the integ...
Medium
38.1K
64.7K
38,114
64,737
58.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int clumsy(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int clumsy(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution(objec...
4
{ "name": "clumsy", "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', 'Stack', 'Simulation']
1,007
Minimum Domino Rotations For Equal Row
minimum-domino-rotations-for-equal-row
<p>In a row of dominoes, <code>tops[i]</code> and <code>bottoms[i]</code> represent the top and bottom halves of the <code>i<sup>th</sup></code> domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.)</p> <p>We may rotate the <code>i<sup>th</sup></code> domino, so that <code>tops[i]</...
Medium
213.7K
408.8K
213,739
408,762
52.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minDominoRotations(vector<int>& tops, vector<int>& bottoms) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minDominoRotations(int[] tops, int[] bottoms) {\n \n }\n}...
[2,1,2,4,2,2] [5,2,6,2,3,2]
{ "name": "minDominoRotations", "params": [ { "name": "tops", "type": "integer[]" }, { "name": "bottoms", "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']
1,008
Construct Binary Search Tree from Preorder Traversal
construct-binary-search-tree-from-preorder-traversal
<p>Given an array of integers preorder, which represents the <strong>preorder traversal</strong> of a BST (i.e., <strong>binary search tree</strong>), construct the tree and return <em>its root</em>.</p> <p>It is <strong>guaranteed</strong> that there is always possible to find a binary search tree with the given requ...
Medium
439.2K
528.8K
439,201
528,794
83.1%
[]
[]
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...
[8,5,1,7,10,12]
{ "name": "bstFromPreorder", "params": [ { "name": "preorder", "type": "integer[]" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Stack', 'Tree', 'Binary Search Tree', 'Monotonic Stack', 'Binary Tree']
1,009
Complement of Base 10 Integer
complement-of-base-10-integer
<p>The <strong>complement</strong> of an integer is the integer you get when you flip all the <code>0</code>&#39;s to <code>1</code>&#39;s and all the <code>1</code>&#39;s to <code>0</code>&#39;s in its binary representation.</p> <ul> <li>For example, The integer <code>5</code> is <code>&quot;101&quot;</code> in bina...
Easy
287.6K
473.4K
287,597
473,403
60.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int bitwiseComplement(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int bitwiseComplement(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
5
{ "name": "bitwiseComplement", "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...
['Bit Manipulation']
1,010
Pairs of Songs With Total Durations Divisible by 60
pairs-of-songs-with-total-durations-divisible-by-60
<p>You are given a list of songs where the <code>i<sup>th</sup></code> song has a duration of <code>time[i]</code> seconds.</p> <p>Return <em>the number of pairs of songs for which their total duration in seconds is divisible by</em> <code>60</code>. Formally, we want the number of indices <code>i</code>, <code>j</cod...
Medium
303K
569.7K
302,999
569,667
53.2%
['destroy-sequential-targets', 'count-pairs-that-form-a-complete-day-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numPairsDivisibleBy60(vector<int>& time) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numPairsDivisibleBy60(int[] time) {\n \n }\n}"}, {"value": "python", "text":...
[30,20,150,100,40]
{ "name": "numPairsDivisibleBy60", "params": [ { "name": "time", "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', 'Counting']
1,011
Capacity To Ship Packages Within D Days
capacity-to-ship-packages-within-d-days
<p>A conveyor belt has packages that must be shipped from one port to another within <code>days</code> days.</p> <p>The <code>i<sup>th</sup></code> package on the conveyor belt has a weight of <code>weights[i]</code>. Each day, we load the ship with packages on the conveyor belt (in the order given by <code>weights</c...
Medium
533.9K
745.4K
533,913
745,406
71.6%
['split-array-largest-sum', 'divide-chocolate', 'cutting-ribbons', 'minimized-maximum-of-products-distributed-to-any-store', 'maximum-bags-with-full-capacity-of-rocks', 'minimum-total-distance-traveled']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int shipWithinDays(vector<int>& weights, int days) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int shipWithinDays(int[] weights, int days) {\n \n }\n}"}, {"value": "pyth...
[1,2,3,4,5,6,7,8,9,10] 5
{ "name": "shipWithinDays", "params": [ { "name": "weights", "type": "integer[]" }, { "name": "days", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
1,012
Numbers With Repeated Digits
numbers-with-repeated-digits
<p>Given an integer <code>n</code>, return <em>the number of positive integers in the range </em><code>[1, n]</code><em> that have <strong>at least one</strong> repeated digit</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 20 <strong>Output:</strong> 1 <st...
Hard
20K
46.5K
20,025
46,503
43.1%
['count-the-number-of-powerful-integers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numDupDigitsAtMostN(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numDupDigitsAtMostN(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
20
{ "name": "numDupDigitsAtMostN", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming']
1,013
Partition Array Into Three Parts With Equal Sum
partition-array-into-three-parts-with-equal-sum
<p>Given an array of integers <code>arr</code>, return <code>true</code> if we can partition the array into three <strong>non-empty</strong> parts with equal sums.</p> <p>Formally, we can partition the array if we can find indexes <code>i + 1 &lt; j</code> with <code>(arr[0] + arr[1] + ... + arr[i] == arr[i + 1] + arr...
Easy
108.1K
257.4K
108,065
257,359
42.0%
['find-the-middle-index-in-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canThreePartsEqualSum(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canThreePartsEqualSum(int[] arr) {\n \n }\n}"}, {"value": "python", "tex...
[0,2,1,-6,6,-7,9,1,2,0,1]
{ "name": "canThreePartsEqualSum", "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', 'Greedy']
1,014
Best Sightseeing Pair
best-sightseeing-pair
<p>You are given an integer array <code>values</code> where values[i] represents the value of the <code>i<sup>th</sup></code> sightseeing spot. Two sightseeing spots <code>i</code> and <code>j</code> have a <strong>distance</strong> <code>j - i</code> between them.</p> <p>The score of a pair (<code>i &lt; j</code>) of...
Medium
205.5K
328.2K
205,458
328,207
62.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxScoreSightseeingPair(vector<int>& values) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxScoreSightseeingPair(int[] values) {\n \n }\n}"}, {"value": "python",...
[8,1,5,2,6]
{ "name": "maxScoreSightseeingPair", "params": [ { "name": "values", "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']
1,015
Smallest Integer Divisible by K
smallest-integer-divisible-by-k
<p>Given a positive integer <code>k</code>, you need to find the <strong>length</strong> of the <strong>smallest</strong> positive integer <code>n</code> such that <code>n</code> is divisible by <code>k</code>, and <code>n</code> only contains the digit <code>1</code>.</p> <p>Return <em>the <strong>length</strong> of ...
Medium
66.6K
143.2K
66,592
143,160
46.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int smallestRepunitDivByK(int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int smallestRepunitDivByK(int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
1
{ "name": "smallestRepunitDivByK", "params": [ { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Math']
1,016
Binary String With Substrings Representing 1 To N
binary-string-with-substrings-representing-1-to-n
<p>Given a binary string <code>s</code> and a positive integer <code>n</code>, return <code>true</code><em> if the binary representation of all the integers in the range </em><code>[1, n]</code><em> are <strong>substrings</strong> of </em><code>s</code><em>, or </em><code>false</code><em> otherwise</em>.</p> <p>A <str...
Medium
42.7K
73.7K
42,673
73,716
57.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool queryString(string s, int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean queryString(String s, int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
"0110" 3
{ "name": "queryString", "params": [ { "name": "s", "type": "string" }, { "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...
['String']
1,017
Convert to Base -2
convert-to-base-2
<p>Given an integer <code>n</code>, return <em>a binary string representing its representation in base</em> <code>-2</code>.</p> <p><strong>Note</strong> that the returned string should not have leading zeros unless the string is <code>&quot;0&quot;</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</str...
Medium
32K
52.3K
31,979
52,322
61.1%
['encode-number', 'convert-date-to-binary']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string baseNeg2(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String baseNeg2(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solu...
2
{ "name": "baseNeg2", "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...
['Math']
1,018
Binary Prefix Divisible By 5
binary-prefix-divisible-by-5
<p>You are given a binary array <code>nums</code> (<strong>0-indexed</strong>).</p> <p>We define <code>x<sub>i</sub></code> as the number whose binary representation is the subarray <code>nums[0..i]</code> (from most-significant-bit to least-significant-bit).</p> <ul> <li>For example, if <code>nums = [1,0,1]</code>,...
Easy
63.7K
135.9K
63,743
135,874
46.9%
['average-value-of-even-numbers-that-are-divisible-by-three', 'find-the-maximum-divisibility-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<bool> prefixesDivBy5(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Boolean> prefixesDivBy5(int[] nums) {\n \n }\n}"}, {"value": "python", "t...
[0,1,1]
{ "name": "prefixesDivBy5", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "list<boolean>" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation']
1,019
Next Greater Node In Linked List
next-greater-node-in-linked-list
<p>You are given the <code>head</code> of a linked list with <code>n</code> nodes.</p> <p>For each node in the list, find the value of the <strong>next greater node</strong>. That is, for each node, find the value of the first node that is next to it and has a <strong>strictly larger</strong> value than it.</p> <p>Re...
Medium
183.6K
296.1K
183,587
296,119
62.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[2,1,5]
{ "name": "nextLargerNodes", "params": [ { "name": "head", "type": "ListNode" } ], "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', 'Linked List', 'Stack', 'Monotonic Stack']
1,020
Number of Enclaves
number-of-enclaves
<p>You are given an <code>m x n</code> binary matrix <code>grid</code>, where <code>0</code> represents a sea cell and <code>1</code> represents a land cell.</p> <p>A <strong>move</strong> consists of walking from one land cell to another adjacent (<strong>4-directionally</strong>) land cell or walking off the boundar...
Medium
298.8K
425.9K
298,842
425,920
70.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numEnclaves(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numEnclaves(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]]
{ "name": "numEnclaves", "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', 'Union Find', 'Matrix']
1,021
Remove Outermost Parentheses
remove-outermost-parentheses
<p>A valid parentheses string is either empty <code>&quot;&quot;</code>, <code>&quot;(&quot; + A + &quot;)&quot;</code>, or <code>A + B</code>, where <code>A</code> and <code>B</code> are valid parentheses strings, and <code>+</code> represents string concatenation.</p> <ul> <li>For example, <code>&quot;&quot;</code>...
Easy
457.7K
537.5K
457,726
537,464
85.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string removeOuterParentheses(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String removeOuterParentheses(String s) {\n \n }\n}"}, {"value": "python", "text": "P...
"(()())(())"
{ "name": "removeOuterParentheses", "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,022
Sum of Root To Leaf Binary Numbers
sum-of-root-to-leaf-binary-numbers
<p>You are given the <code>root</code> of a binary tree where each node has a value <code>0</code> or <code>1</code>. Each root-to-leaf path represents a binary number starting with the most significant bit.</p> <ul> <li>For example, if the path is <code>0 -&gt; 1 -&gt; 1 -&gt; 0 -&gt; 1</code>, then this could repre...
Easy
230.8K
314.7K
230,768
314,706
73.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,0,1,0,1,0,1]
{ "name": "sumRootToLeaf", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
1,023
Camelcase Matching
camelcase-matching
<p>Given an array of strings <code>queries</code> and a string <code>pattern</code>, return a boolean array <code>answer</code> where <code>answer[i]</code> is <code>true</code> if <code>queries[i]</code> matches <code>pattern</code>, and <code>false</code> otherwise.</p> <p>A query word <code>queries[i]</code> matche...
Medium
55.9K
88K
55,862
88,036
63.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<bool> camelMatch(vector<string>& queries, string pattern) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Boolean> camelMatch(String[] queries, String pattern) {\n ...
["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"] "FB"
{ "name": "camelMatch", "params": [ { "name": "queries", "type": "string[]" }, { "name": "pattern", "type": "string" } ], "return": { "type": "list<boolean>" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'String', 'Trie', 'String Matching']
1,024
Video Stitching
video-stitching
<p>You are given a series of video clips from a sporting event that lasted <code>time</code> seconds. These video clips can be overlapping with each other and have varying lengths.</p> <p>Each video clip is described by an array <code>clips</code> where <code>clips[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> indi...
Medium
76.8K
148.1K
76,804
148,147
51.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int videoStitching(vector<vector<int>>& clips, int time) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int videoStitching(int[][] clips, int time) {\n \n }\n}"}, {"value":...
[[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]] 10
{ "name": "videoStitching", "params": [ { "name": "clips", "type": "integer[][]" }, { "name": "time", "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,025
Divisor Game
divisor-game
<p>Alice and Bob take turns playing a game, with Alice starting first.</p> <p>Initially, there is a number <code>n</code> on the chalkboard. On each player&#39;s turn, that player makes a move consisting of:</p> <ul> <li>Choosing any <code>x</code> with <code>0 &lt; x &lt; n</code> and <code>n % x == 0</code>.</li> ...
Easy
309.7K
442.1K
309,700
442,104
70.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool divisorGame(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean divisorGame(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class...
2
{ "name": "divisorGame", "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', 'Brainteaser', 'Game Theory']
1,026
Maximum Difference Between Node and Ancestor
maximum-difference-between-node-and-ancestor
<p>Given the <code>root</code> of a binary tree, find the maximum value <code>v</code> for which there exist <strong>different</strong> nodes <code>a</code> and <code>b</code> where <code>v = |a.val - b.val|</code> and <code>a</code> is an ancestor of <code>b</code>.</p> <p>A node <code>a</code> is an ancestor of <cod...
Medium
352.8K
452K
352,764
451,983
78.0%
[]
[]
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...
[8,3,10,1,6,null,14,null,null,4,7,13]
{ "name": "maxAncestorDiff", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
1,027
Longest Arithmetic Subsequence
longest-arithmetic-subsequence
<p>Given an array <code>nums</code> of integers, return <em>the length of the longest arithmetic subsequence in</em> <code>nums</code>.</p> <p><strong>Note</strong> that:</p> <ul> <li>A <strong>subsequence</strong> is an array that can be derived from another array by deleting some or no elements without changing th...
Medium
193K
390.7K
193,005
390,736
49.4%
['destroy-sequential-targets']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestArithSeqLength(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestArithSeqLength(int[] nums) {\n \n }\n}"}, {"value": "python", "text":...
[3,6,9,12]
{ "name": "longestArithSeqLength", "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', 'Binary Search', 'Dynamic Programming']
1,028
Recover a Tree From Preorder Traversal
recover-a-tree-from-preorder-traversal
<p>We run a&nbsp;preorder&nbsp;depth-first search (DFS) on the <code>root</code> of a binary tree.</p> <p>At each node in this traversal, we output <code>D</code> dashes (where <code>D</code> is the depth of this node), then we output the value of this node.&nbsp; If the depth of a node is <code>D</code>, the depth of...
Hard
154.7K
185.8K
154,690
185,782
83.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
"1-2--3--4-5--6--7"
{ "name": "recoverFromPreorder", "params": [ { "name": "traversal", "type": "string" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Tree', 'Depth-First Search', 'Binary Tree']
1,029
Two City Scheduling
two-city-scheduling
<p>A company is planning to interview <code>2n</code> people. Given the array <code>costs</code> where <code>costs[i] = [aCost<sub>i</sub>, bCost<sub>i</sub>]</code>,&nbsp;the cost of flying the <code>i<sup>th</sup></code> person to city <code>a</code> is <code>aCost<sub>i</sub></code>, and the cost of flying the <code...
Medium
263.7K
390.6K
263,714
390,576
67.5%
['rearrange-array-to-maximize-prefix-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int twoCitySchedCost(vector<vector<int>>& costs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int twoCitySchedCost(int[][] costs) {\n \n }\n}"}, {"value": "python", "text...
[[10,20],[30,200],[400,50],[30,20]]
{ "name": "twoCitySchedCost", "params": [ { "name": "costs", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
1,030
Matrix Cells in Distance Order
matrix-cells-in-distance-order
<p>You are given four integers <code>row</code>, <code>cols</code>, <code>rCenter</code>, and <code>cCenter</code>. There is a <code>rows x cols</code> matrix and you are on the cell with the coordinates <code>(rCenter, cCenter)</code>.</p> <p>Return <em>the coordinates of all cells in the matrix, sorted by their <str...
Easy
67.8K
93.6K
67,827
93,594
72.5%
['cells-in-a-range-on-an-excel-sheet']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> allCellsDistOrder(int rows, int cols, int rCenter, int cCenter) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] allCellsDistOrder(int rows, int cols, int r...
1 2 0 0
{ "name": "allCellsDistOrder", "params": [ { "name": "rows", "type": "integer" }, { "name": "cols", "type": "integer" }, { "name": "rCenter", "type": "integer" }, { "name": "cCenter", "type": "integer" } ], "return": { "type": "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Geometry', 'Sorting', 'Matrix']
1,031
Maximum Sum of Two Non-Overlapping Subarrays
maximum-sum-of-two-non-overlapping-subarrays
<p>Given an integer array <code>nums</code> and two integers <code>firstLen</code> and <code>secondLen</code>, return <em>the maximum sum of elements in two non-overlapping <strong>subarrays</strong> with lengths </em><code>firstLen</code><em> and </em><code>secondLen</code>.</p> <p>The array with length <code>firstLe...
Medium
77.5K
128.8K
77,465
128,834
60.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSumTwoNoOverlap(vector<int>& nums, int firstLen, int secondLen) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSumTwoNoOverlap(int[] nums, int firstLen, int secondLen) ...
[0,6,5,2,2,5,1,9,4] 1 2
{ "name": "maxSumTwoNoOverlap", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "firstLen", "type": "integer" }, { "name": "secondLen", "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', 'Sliding Window']
1,032
Stream of Characters
stream-of-characters
<p>Design an algorithm that accepts a stream of characters and checks if a suffix of these characters is a string of a given array of strings <code>words</code>.</p> <p>For example, if <code>words = [&quot;abc&quot;, &quot;xyz&quot;]</code>&nbsp;and the stream added the four characters (one by one) <code>&#39;a&#39;</...
Hard
96.2K
183.7K
96,156
183,673
52.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class StreamChecker {\npublic:\n StreamChecker(vector<string>& words) {\n \n }\n \n bool query(char letter) {\n \n }\n};\n\n/**\n * Your StreamChecker object will be instantiated and called as such:\n * StreamChecker* obj = new StreamChecker(...
["StreamChecker","query","query","query","query","query","query","query","query","query","query","query","query"] [[["cd","f","kl"]],["a"],["b"],["c"],["d"],["e"],["f"],["g"],["h"],["i"],["j"],["k"],["l"]]
{ "classname": "StreamChecker", "maxbytesperline": 500000, "constructor": { "params": [ { "type": "string[]", "name": "words" }] }, "methods": [ { "name" : "query", "params": [ { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Design', 'Trie', 'Data Stream']
1,033
Moving Stones Until Consecutive
moving-stones-until-consecutive
<p>There are three stones in different positions on the X-axis. You are given three integers <code>a</code>, <code>b</code>, and <code>c</code>, the positions of the stones.</p> <p>In one move, you pick up a stone at an endpoint (i.e., either the lowest or highest position stone), and move it to an unoccupied position...
Medium
28.5K
58K
28,531
57,980
49.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> numMovesStones(int a, int b, int c) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] numMovesStones(int a, int b, int c) {\n \n }\n}"}, {"value": "python", ...
1 2 5
{ "name": "numMovesStones", "params": [ { "name": "a", "type": "integer" }, { "name": "b", "type": "integer" }, { "name": "c", "type": "integer" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Brainteaser']
1,034
Coloring A Border
coloring-a-border
<p>You are given an <code>m x n</code> integer matrix <code>grid</code>, and three integers <code>row</code>, <code>col</code>, and <code>color</code>. Each value in the grid represents the color of the grid square at that location.</p> <p>Two squares are called <strong>adjacent</strong> if they are next to each other...
Medium
41.6K
83.9K
41,602
83,875
49.6%
['island-perimeter']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> colorBorder(vector<vector<int>>& grid, int row, int col, int color) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] colorBorder(int[][] grid, int row, int ...
[[1,1],[1,2]] 0 0 3
{ "name": "colorBorder", "params": [ { "name": "grid", "type": "integer[][]" }, { "name": "row", "type": "integer" }, { "name": "col", "type": "integer" }, { "name": "color", "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']
1,035
Uncrossed Lines
uncrossed-lines
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code>. We write the integers of <code>nums1</code> and <code>nums2</code> (in the order they are given) on two separate horizontal lines.</p> <p>We may draw connecting lines: a straight line connecting two numbers <code>nums1[i]</code> and <code>n...
Medium
175.4K
273.7K
175,379
273,670
64.1%
['edit-distance']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxUncrossedLines(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxUncrossedLines(int[] nums1, int[] nums2) {\n \n }\n}"}, ...
[1,4,2] [1,2,4]
{ "name": "maxUncrossedLines", "params": [ { "name": "nums1", "type": "integer[]" }, { "name": "nums2", "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']
1,036
Escape a Large Maze
escape-a-large-maze
<p>There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are <code>(x, y)</code>.</p> <p>We start at the <code>source = [s<sub>x</sub>, s<sub>y</sub>]</code> square and want to reach the <code>target = [t<sub>x</sub>, t<sub>y</sub>]</code> square. There is also an array of <cod...
Hard
24.6K
70K
24,630
69,990
35.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isEscapePossible(vector<vector<int>>& blocked, vector<int>& source, vector<int>& target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isEscapePossible(int[][] blocked,...
[[0,1],[1,0]] [0,0] [0,2]
{ "name": "isEscapePossible", "params": [ { "name": "blocked", "type": "integer[][]" }, { "name": "source", "type": "integer[]" }, { "name": "target", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Depth-First Search', 'Breadth-First Search']
1,037
Valid Boomerang
valid-boomerang
<p>Given an array <code>points</code> where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> represents a point on the <strong>X-Y</strong> plane, return <code>true</code> <em>if these points are a <strong>boomerang</strong></em>.</p> <p>A <strong>boomerang</strong> is a set of three points that are <strong>all...
Easy
62.7K
166.2K
62,710
166,184
37.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isBoomerang(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isBoomerang(int[][] points) {\n \n }\n}"}, {"value": "python", "text": ...
[[1,1],[2,3],[3,2]]
{ "name": "isBoomerang", "params": [ { "name": "points", "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', 'Math', 'Geometry']
1,038
Binary Search Tree to Greater Sum Tree
binary-search-tree-to-greater-sum-tree
<p>Given the <code>root</code> of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.</p> <p>As a reminder, a <em>binary search tree</em> is a tree that satisfies these constraints...
Medium
310.7K
352.2K
310,710
352,173
88.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[4,1,6,0,2,5,7,null,null,null,3,null,null,null,8]
{ "name": "bstToGst", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
1,039
Minimum Score Triangulation of Polygon
minimum-score-triangulation-of-polygon
<p>You have a convex <code>n</code>-sided polygon where each vertex has an integer value. You are given an integer array <code>values</code> where <code>values[i]</code> is the value of the <code>i<sup>th</sup></code> vertex in <strong>clockwise order</strong>.</p> <p><strong>Polygon</strong> <strong>triangulation</st...
Medium
60.3K
100.6K
60,291
100,574
59.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minScoreTriangulation(vector<int>& values) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minScoreTriangulation(int[] values) {\n \n }\n}"}, {"value": "python", "te...
[1,2,3]
{ "name": "minScoreTriangulation", "params": [ { "name": "values", "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']
1,040
Moving Stones Until Consecutive II
moving-stones-until-consecutive-ii
<p>There are some stones in different positions on the X-axis. You are given an integer array <code>stones</code>, the positions of the stones.</p> <p>Call a stone an <strong>endpoint stone</strong> if it has the smallest or largest position. In one move, you pick up an <strong>endpoint stone</strong> and move it to a...
Medium
12.3K
21.7K
12,344
21,687
56.9%
['minimum-number-of-operations-to-make-array-continuous']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> numMovesStonesII(vector<int>& stones) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] numMovesStonesII(int[] stones) {\n \n }\n}"}, {"value": "python", "te...
[7,4,9]
{ "name": "numMovesStonesII", "params": [ { "name": "stones", "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', 'Two Pointers', 'Sorting']
1,041
Robot Bounded In Circle
robot-bounded-in-circle
<p>On an infinite plane, a robot initially stands at <code>(0, 0)</code> and faces north. Note that:</p> <ul> <li>The <strong>north direction</strong> is the positive direction of the y-axis.</li> <li>The <strong>south direction</strong> is the negative direction of the y-axis.</li> <li>The <strong>east direction</...
Medium
257K
457.5K
256,972
457,505
56.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isRobotBounded(string instructions) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isRobotBounded(String instructions) {\n \n }\n}"}, {"value": "python", "text...
"GGLLGG"
{ "name": "isRobotBounded", "params": [ { "name": "instructions", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Simulation']
1,042
Flower Planting With No Adjacent
flower-planting-with-no-adjacent
<p>You have <code>n</code> gardens, labeled from <code>1</code> to <code>n</code>, and an array <code>paths</code> where <code>paths[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> describes a bidirectional path between garden <code>x<sub>i</sub></code> to garden <code>y<sub>i</sub></code>. In each garden, you want to plant...
Medium
89.9K
172.6K
89,940
172,565
52.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> gardenNoAdj(int n, vector<vector<int>>& paths) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] gardenNoAdj(int n, int[][] paths) {\n \n }\n}"}, {"value": "...
3 [[1,2],[2,3],[3,1]]
{ "name": "gardenNoAdj", "params": [ { "name": "n", "type": "integer" }, { "name": "paths", "type": "integer[][]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Graph']
1,043
Partition Array for Maximum Sum
partition-array-for-maximum-sum
<p>Given an integer array <code>arr</code>, partition the array into (contiguous) subarrays of length <strong>at most</strong> <code>k</code>. After partitioning, each subarray has their values changed to become the maximum value of that subarray.</p> <p>Return <em>the largest sum of the given array after partitioning...
Medium
222.2K
289.1K
222,200
289,061
76.9%
['subsequence-of-size-k-with-the-largest-even-sum', 'partition-string-into-minimum-beautiful-substrings', 'minimum-substring-partition-of-equal-character-frequency']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSumAfterPartitioning(vector<int>& arr, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSumAfterPartitioning(int[] arr, int k) {\n \n }\n}"}, {"value": "...
[1,15,7,9,2,5,10] 3
{ "name": "maxSumAfterPartitioning", "params": [ { "name": "arr", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
1,044
Longest Duplicate Substring
longest-duplicate-substring
<p>Given a string <code>s</code>, consider all <em>duplicated substrings</em>: (contiguous) substrings of s that occur 2 or more times.&nbsp;The occurrences&nbsp;may overlap.</p> <p>Return <strong>any</strong> duplicated&nbsp;substring that has the longest possible length.&nbsp;If <code>s</code> does not have a duplic...
Hard
75K
244.5K
75,020
244,506
30.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string longestDupSubstring(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String longestDupSubstring(String s) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"banana"
{ "name": "longestDupSubstring", "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', 'Binary Search', 'Sliding Window', 'Rolling Hash', 'Suffix Array', 'Hash Function']
1,045
Customers Who Bought All Products
customers-who-bought-all-products
<p>Table: <code>Customer</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | customer_id | int | | product_key | int | +-------------+---------+ This table may contain duplicates rows. <code>customer_id</code> is not NULL<code>.</code> product_key is a foreign key ...
Medium
315.2K
500.6K
315,240
500,606
63.0%
[]
['Create table If Not Exists Customer (customer_id int, product_key int)', 'Create table Product (product_key int)', 'Truncate table Customer', "insert into Customer (customer_id, product_key) values ('1', '5')", "insert into Customer (customer_id, product_key) values ('2', '6')", "insert into Customer (customer_id, pr...
Database
[{"value": "mysql", "text": "MySQL", "defaultCode": "# Write your MySQL query statement below\n"}, {"value": "mssql", "text": "MS SQL Server", "defaultCode": "/* Write your T-SQL query statement below */\n"}, {"value": "oraclesql", "text": "Oracle", "defaultCode": "/* Write your PL/SQL query statement below */\n"}, {"v...
{"headers":{"Customer":["customer_id","product_key"],"Product":["product_key"]},"rows":{"Customer":[[1,5],[2,6],[3,5],[3,6],[1,6]],"Product":[[5],[6]]}}
{"mysql": ["Create table If Not Exists Customer (customer_id int, product_key int)", "Create table Product (product_key int)"], "mssql": ["Create table Customer (customer_id int, product_key int)", "Create table Product (product_key int)"], "oraclesql": ["Create table Customer (customer_id int, product_key int)", "Crea...
{"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,046
Last Stone Weight
last-stone-weight
<p>You are given an array of integers <code>stones</code> where <code>stones[i]</code> is the weight of the <code>i<sup>th</sup></code> stone.</p> <p>We are playing a game with the stones. On each turn, we choose the <strong>heaviest two stones</strong> and smash them together. Suppose the heaviest two stones have wei...
Easy
750.5K
1.1M
750,537
1,140,090
65.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int lastStoneWeight(vector<int>& stones) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int lastStoneWeight(int[] stones) {\n \n }\n}"}, {"value": "python", "text": "Python...
[2,7,4,1,8,1]
{ "name": "lastStoneWeight", "params": [ { "name": "stones", "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', 'Heap (Priority Queue)']
1,047
Remove All Adjacent Duplicates In String
remove-all-adjacent-duplicates-in-string
<p>You are given a string <code>s</code> consisting of lowercase English letters. A <strong>duplicate removal</strong> consists of choosing two <strong>adjacent</strong> and <strong>equal</strong> letters and removing them.</p> <p>We repeatedly make <strong>duplicate removals</strong> on <code>s</code> until we no lon...
Easy
703.1K
987K
703,071
986,952
71.2%
['remove-all-adjacent-duplicates-in-string-ii', 'removing-stars-from-a-string', 'minimize-string-length']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string removeDuplicates(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String removeDuplicates(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "def...
"abbaca"
{ "name": "removeDuplicates", "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,048
Longest String Chain
longest-string-chain
<p>You are given an array of <code>words</code> where each word consists of lowercase English letters.</p> <p><code>word<sub>A</sub></code> is a <strong>predecessor</strong> of <code>word<sub>B</sub></code> if and only if we can insert <strong>exactly one</strong> letter anywhere in <code>word<sub>A</sub></code> <stro...
Medium
456.8K
739.2K
456,782
739,221
61.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestStrChain(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestStrChain(String[] words) {\n \n }\n}"}, {"value": "python", "text": "Py...
["a","b","ba","bca","bda","bdca"]
{ "name": "longestStrChain", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Two Pointers', 'String', 'Dynamic Programming', 'Sorting']
1,049
Last Stone Weight II
last-stone-weight-ii
<p>You are given an array of integers <code>stones</code> where <code>stones[i]</code> is the weight of the <code>i<sup>th</sup></code> stone.</p> <p>We are playing a game with the stones. On each turn, we choose any two stones and smash them together. Suppose the stones have weights <code>x</code> and <code>y</code> ...
Medium
106.9K
187K
106,895
187,015
57.2%
['partition-array-into-two-arrays-to-minimize-sum-difference']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int lastStoneWeightII(vector<int>& stones) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int lastStoneWeightII(int[] stones) {\n \n }\n}"}, {"value": "python", "text": "Py...
[2,7,4,1,8,1]
{ "name": "lastStoneWeightII", "params": [ { "name": "stones", "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']
1,050
Actors and Directors Who Cooperated At Least Three Times
actors-and-directors-who-cooperated-at-least-three-times
<p>Table: <code>ActorDirector</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | actor_id | int | | director_id | int | | timestamp | int | +-------------+---------+ timestamp is the primary key (column with unique values) for this table. </pre> <p>&nbsp;...
Easy
228.3K
323.8K
228,315
323,772
70.5%
[]
['Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)', 'Truncate table ActorDirector', "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '0')", "insert into ActorDirector (actor_id, director_id, timestamp) values ('1', '1', '1')", "insert into ActorDire...
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":{"ActorDirector":["actor_id","director_id","timestamp"]},"rows":{"ActorDirector":[[1,1,0],[1,1,1],[1,1,2],[1,2,3],[1,2,4],[2,1,5],[2,1,6]]}}
{"mysql": ["Create table If Not Exists ActorDirector (actor_id int, director_id int, timestamp int)"], "mssql": ["Create table ActorDirector (actor_id int, director_id int, timestamp int)"], "oraclesql": ["Create table ActorDirector (actor_id int, director_id int, timestamp int)"], "database": true, "name": "actors_and...
{"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,051
Height Checker
height-checker
<p>A school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in <strong>non-decreasing order</strong> by height. Let this ordering be represented by the integer array <code>expected</code> where <code>expected[i]</code> is the expected height of the <code>i<su...
Easy
559.2K
689.9K
559,219
689,920
81.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int heightChecker(vector<int>& heights) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int heightChecker(int[] heights) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[1,1,4,2,1,3]
{ "name": "heightChecker", "params": [ { "name": "heights", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting', 'Counting Sort']
1,052
Grumpy Bookstore Owner
grumpy-bookstore-owner
<p>There is a bookstore owner that has a store open for <code>n</code> minutes. You are given an integer array <code>customers</code> of length <code>n</code> where <code>customers[i]</code> is the number of the customers that enter the store at the start of the <code>i<sup>th</sup></code> minute and all those customer...
Medium
210.1K
327.8K
210,099
327,843
64.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int minutes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSatisfied(int[] customers, int[] grumpy, int minutes)...
[1,0,1,2,1,1,7,5] [0,1,0,1,0,1,0,1] 3
{ "name": "maxSatisfied", "params": [ { "name": "customers", "type": "integer[]" }, { "name": "grumpy", "type": "integer[]" }, { "name": "minutes", "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', 'Sliding Window']
1,053
Previous Permutation With One Swap
previous-permutation-with-one-swap
<p>Given an array of positive integers <code>arr</code> (not necessarily distinct), return <em>the </em><span data-keyword="lexicographically-smaller-array"><em>lexicographically</em></span><em> largest permutation that is smaller than</em> <code>arr</code>, that can be <strong>made with exactly one swap</strong>. If i...
Medium
44.1K
89.4K
44,148
89,358
49.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> prevPermOpt1(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] prevPermOpt1(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[3,2,1]
{ "name": "prevPermOpt1", "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', 'Greedy']
1,054
Distant Barcodes
distant-barcodes
<p>In a warehouse, there is a row of barcodes, where the <code>i<sup>th</sup></code> barcode is <code>barcodes[i]</code>.</p> <p>Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:<...
Medium
49.2K
104.2K
49,234
104,199
47.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> rearrangeBarcodes(vector<int>& barcodes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] rearrangeBarcodes(int[] barcodes) {\n \n }\n}"}, {"value": "python...
[1,1,1,2,2,2]
{ "name": "rearrangeBarcodes", "params": [ { "name": "barcodes", "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', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'Counting']
1,055
Shortest Way to Form String
shortest-way-to-form-string
null
Medium
102.3K
167.1K
102,329
167,102
61.2%
['is-subsequence', 'number-of-matching-subsequences']
[]
Algorithms
null
"abc" "abcbc"
{ "name": "shortestWay", "params": [ { "name": "source", "type": "string" }, { "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...
['Two Pointers', 'String', 'Binary Search', 'Greedy']
1,056
Confusing Number
confusing-number
null
Easy
51.2K
104K
51,163
104,035
49.2%
['strobogrammatic-number', 'confusing-number-ii']
[]
Algorithms
null
6
{ "name": "confusingNumber", "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']
1,057
Campus Bikes
campus-bikes
null
Medium
75.1K
127.5K
75,097
127,508
58.9%
['campus-bikes-ii']
[]
Algorithms
null
[[0,0],[2,1]] [[1,2],[3,3]]
{ "name": "assignBikes", "params": [ { "name": "workers", "type": "integer[][]" }, { "name": "bikes", "type": "integer[][]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting', 'Heap (Priority Queue)']
1,058
Minimize Rounding Error to Meet Target
minimize-rounding-error-to-meet-target
null
Medium
10.5K
23.1K
10,453
23,053
45.3%
[]
[]
Algorithms
null
["0.700","2.800","4.900"] 8
{ "name": "minimizeError", "params": [ { "name": "prices", "type": "string[]" }, { "name": "target", "type": "integer" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'String', 'Greedy', 'Sorting']
1,059
All Paths from Source Lead to Destination
all-paths-from-source-lead-to-destination
null
Medium
68.5K
184.8K
68,527
184,806
37.1%
[]
[]
Algorithms
null
3 [[0,1],[0,2]] 0 2
{ "name": "leadsToDestination", "params": [ { "name": "n", "type": "integer" }, { "name": "edges", "type": "integer[][]" }, { "name": "source", "type": "integer" }, { "name": "destination", "type": "integer" } ], "return": { "ty...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Graph', 'Topological Sort']
1,060
Missing Element in Sorted Array
missing-element-in-sorted-array
null
Medium
152.8K
261.8K
152,781
261,759
58.4%
[]
[]
Algorithms
null
[4,7,9,10] 1
{ "name": "missingElement", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
1,061
Lexicographically Smallest Equivalent String
lexicographically-smallest-equivalent-string
<p>You are given two strings of the same length <code>s1</code> and <code>s2</code> and a string <code>baseStr</code>.</p> <p>We say <code>s1[i]</code> and <code>s2[i]</code> are equivalent characters.</p> <ul> <li>For example, if <code>s1 = &quot;abc&quot;</code> and <code>s2 = &quot;cde&quot;</code>, then we have ...
Medium
87.5K
114.3K
87,529
114,328
76.6%
['lexicographically-smallest-generated-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string smallestEquivalentString(string s1, string s2, string baseStr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String smallestEquivalentString(String s1, String s2, String base...
"parker" "morris" "parser"
{ "name": "smallestEquivalentString", "params": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" }, { "name": "baseStr", "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', 'Union Find']
1,062
Longest Repeating Substring
longest-repeating-substring
null
Medium
53.5K
85K
53,483
85,009
62.9%
[]
[]
Algorithms
null
"abcd"
{ "name": "longestRepeatingSubstring", "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', 'Binary Search', 'Dynamic Programming', 'Rolling Hash', 'Suffix Array', 'Hash Function']
1,063
Number of Valid Subarrays
number-of-valid-subarrays
null
Hard
16.3K
20.5K
16,253
20,538
79.1%
['number-of-smooth-descent-periods-of-a-stock']
[]
Algorithms
null
[1,4,2,5,3]
{ "name": "validSubarrays", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Stack', 'Monotonic Stack']
1,064
Fixed Point
fixed-point
null
Easy
47.3K
73.9K
47,263
73,936
63.9%
[]
[]
Algorithms
null
[-10,-5,0,3,7]
{ "name": "fixedPoint", "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', 'Binary Search']
1,065
Index Pairs of a String
index-pairs-of-a-string
null
Easy
29.7K
43.6K
29,726
43,642
68.1%
[]
[]
Algorithms
null
"thestoryofleetcodeandme" ["story","fleet","leetcode"]
{ "name": "indexPairs", "params": [ { "name": "text", "type": "string" }, { "name": "words", "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', 'Trie', 'Sorting']
1,066
Campus Bikes II
campus-bikes-ii
null
Medium
52.9K
95.8K
52,945
95,808
55.3%
['campus-bikes']
[]
Algorithms
null
[[0,0],[2,1]] [[1,2],[3,3]]
{ "name": "assignBikes", "params": [ { "name": "workers", "type": "integer[][]" }, { "name": "bikes", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Backtracking', 'Bit Manipulation', 'Bitmask']
1,067
Digit Count in Range
digit-count-in-range
null
Hard
4.4K
9.5K
4,385
9,531
46.0%
['number-of-digit-one', 'sum-of-numbers-with-units-digit-k']
[]
Algorithms
null
1 1 13
{ "name": "digitsCount", "params": [ { "name": "d", "type": "integer" }, { "name": "low", "type": "integer" }, { "name": "high", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming']
1,068
Product Sales Analysis I
product-sales-analysis-i
<p>Table: <code>Sales</code></p> <pre> +-------------+-------+ | Column Name | Type | +-------------+-------+ | sale_id | int | | product_id | int | | year | int | | quantity | int | | price | int | +-------------+-------+ (sale_id, year) is the primary key (combination of columns with ...
Easy
916.1K
1.1M
916,092
1,087,315
84.3%
['product-sales-analysis-ii', 'product-sales-analysis-iv', 'product-sales-analysis-v']
['Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)', 'Create table If Not Exists Product (product_id int, product_name varchar(10))', 'Truncate table Sales', "insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000')", "inse...
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":{"Sales":["sale_id","product_id","year","quantity","price"],"Product":["product_id","product_name"]},"rows":{"Sales":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],"Product":[[100,"Nokia"],[200,"Apple"],[300,"Samsung"]]}}
{"mysql": ["Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table If Not Exists Product (product_id int, product_name varchar(10))"], "mssql": ["Create table Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table Product (produc...
{"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,069
Product Sales Analysis II
product-sales-analysis-ii
null
Easy
58.1K
70.8K
58,118
70,775
82.1%
['product-sales-analysis-i', 'product-sales-analysis-iii', 'product-sales-analysis-iv', 'product-sales-analysis-v']
['Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)', 'Create table If Not Exists Product (product_id int, product_name varchar(10))', 'Truncate table Sales', "insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000')", "inse...
Database
null
{"headers":{"Sales":["sale_id","product_id","year","quantity","price"],"Product":["product_id","product_name"]},"rows":{"Sales":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],"Product":[[100,"Nokia"],[200,"Apple"],[300,"Samsung"]]}}
{"mysql": ["Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table If Not Exists Product (product_id int, product_name varchar(10))"], "mssql": ["Create table Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table Product (produc...
{"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,070
Product Sales Analysis III
product-sales-analysis-iii
<p>Table: <code>Sales</code></p> <pre> +-------------+-------+ | Column Name | Type | +-------------+-------+ | sale_id | int | | product_id | int | | year | int | | quantity | int | | price | int | +-------------+-------+ (sale_id, year) is the primary key (combination of columns with ...
Medium
289.2K
656K
289,171
655,995
44.1%
['product-sales-analysis-ii', 'product-sales-analysis-iv', 'product-sales-analysis-v']
['Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)', 'Create table If Not Exists Product (product_id int, product_name varchar(10))', 'Truncate table Sales', "insert into Sales (sale_id, product_id, year, quantity, price) values ('1', '100', '2008', '10', '5000')", "inse...
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":{"Sales":["sale_id","product_id","year","quantity","price"],"Product":["product_id","product_name"]},"rows":{"Sales":[[1,100,2008,10,5000],[2,100,2009,12,5000],[7,200,2011,15,9000]],"Product":[[100,"Nokia"],[200,"Apple"],[300,"Samsung"]]}}
{"mysql": ["Create table If Not Exists Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table If Not Exists Product (product_id int, product_name varchar(10))"], "mssql": ["Create table Sales (sale_id int, product_id int, year int, quantity int, price int)", "Create table Product (produc...
{"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,071
Greatest Common Divisor of Strings
greatest-common-divisor-of-strings
<p>For two strings <code>s</code> and <code>t</code>, we say &quot;<code>t</code> divides <code>s</code>&quot; if and only if <code>s = t + t + t + ... + t + t</code> (i.e., <code>t</code> is concatenated with itself one or more times).</p> <p>Given two strings <code>str1</code> and <code>str2</code>, return <em>the l...
Easy
743.2K
1.4M
743,215
1,410,151
52.7%
['find-greatest-common-divisor-of-array', 'smallest-even-multiple', 'find-the-maximum-factor-score-of-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string gcdOfStrings(string str1, string str2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String gcdOfStrings(String str1, String str2) {\n \n }\n}"}, {"value": "python"...
"ABCABC" "ABC"
{ "name": "gcdOfStrings", "params": [ { "name": "str1", "type": "string" }, { "name": "str2", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String']
1,072
Flip Columns For Maximum Number of Equal Rows
flip-columns-for-maximum-number-of-equal-rows
<p>You are given an <code>m x n</code> binary matrix <code>matrix</code>.</p> <p>You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the cell from <code>0</code> to <code>1</code> or vice versa).</p> <p>Return <em>the maximum number of rows that have all va...
Medium
113.7K
144.9K
113,738
144,906
78.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxEqualRowsAfterFlips(vector<vector<int>>& matrix) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxEqualRowsAfterFlips(int[][] matrix) {\n \n }\n}"}, {"value": "...
[[0,1],[1,1]]
{ "name": "maxEqualRowsAfterFlips", "params": [ { "name": "matrix", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Matrix']
1,073
Adding Two Negabinary Numbers
adding-two-negabinary-numbers
<p>Given two numbers <code>arr1</code> and <code>arr2</code> in base <strong>-2</strong>, return the result of adding them together.</p> <p>Each number is given in <em>array format</em>:&nbsp; as an array of 0s and 1s, from most significant bit to least significant bit.&nbsp; For example, <code>arr = [1,1,0,1]</code> ...
Medium
19.7K
53.5K
19,686
53,537
36.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> addNegabinary(vector<int>& arr1, vector<int>& arr2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] addNegabinary(int[] arr1, int[] arr2) {\n \n }\n}"}, {"...
[1,1,1,1,1] [1,0,1]
{ "name": "addNegabinary", "params": [ { "name": "arr1", "type": "integer[]" }, { "name": "arr2", "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']
1,074
Number of Submatrices That Sum to Target
number-of-submatrices-that-sum-to-target
<p>Given a <code>matrix</code>&nbsp;and a <code>target</code>, return the number of non-empty submatrices that sum to <font face="monospace">target</font>.</p> <p>A submatrix <code>x1, y1, x2, y2</code> is the set of all cells <code>matrix[x][y]</code> with <code>x1 &lt;= x &lt;= x2</code> and <code>y1 &lt;= y &lt;= y...
Hard
162.2K
218K
162,190
217,952
74.4%
['disconnect-path-in-a-binary-matrix-by-at-most-one-flip']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSubmatrixSumTarget(vector<vector<int>>& matrix, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSubmatrixSumTarget(int[][] matrix, int target) {\n \n ...
[[0,1,0],[1,1,1],[0,1,0]] 0
{ "name": "numSubmatrixSumTarget", "params": [ { "name": "matrix", "type": "integer[][]" }, { "name": "target", "type": "integer" } ], "return": { "type": "integer" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Matrix', 'Prefix Sum']
1,075
Project Employees I
project-employees-i
<p>Table: <code>Project</code></p> <pre> +-------------+---------+ | Column Name | Type | +-------------+---------+ | project_id | int | | employee_id | int | +-------------+---------+ (project_id, employee_id) is the primary key of this table. employee_id is a foreign key to <code>Employee</code> table. E...
Easy
449.6K
688.6K
449,553
688,557
65.3%
['project-employees-ii']
['Create table If Not Exists Project (project_id int, employee_id int)', 'Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)', 'Truncate table Project', "insert into Project (project_id, employee_id) values ('1', '1')", "insert into Project (project_id, employee_id) values ('1...
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":{"Project":["project_id","employee_id"],"Employee":["employee_id","name","experience_years"]},"rows":{"Project":[[1,1],[1,2],[1,3],[2,1],[2,4]],"Employee":[[1,"Khaled",3],[2,"Ali",2],[3,"John",1],[4,"Doe",2]]}}
{"mysql": ["Create table If Not Exists Project (project_id int, employee_id int)", "Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)"], "mssql": ["Create table Project (project_id int, employee_id int)", "Create table Employee (employee_id int, name varchar(10), experience_y...
{"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,076
Project Employees II
project-employees-ii
null
Easy
62.3K
124.1K
62,342
124,124
50.2%
['project-employees-i', 'project-employees-iii']
['Create table If Not Exists Project (project_id int, employee_id int)', 'Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)', 'Truncate table Project', "insert into Project (project_id, employee_id) values ('1', '1')", "insert into Project (project_id, employee_id) values ('1...
Database
null
{"headers":{"Project":["project_id","employee_id"],"Employee":["employee_id","name","experience_years"]},"rows":{"Project":[[1,1],[1,2],[1,3],[2,1],[2,4]],"Employee":[[1,"Khaled",3],[2,"Ali",2],[3,"John",1],[4,"Doe",2]]}}
{"mysql": ["Create table If Not Exists Project (project_id int, employee_id int)", "Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)"], "mssql": ["Create table Project (project_id int, employee_id int)", "Create table Employee (employee_id int, name varchar(10), experience_y...
{"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,077
Project Employees III
project-employees-iii
null
Medium
65.8K
85.4K
65,792
85,395
77.0%
['project-employees-ii']
['Create table If Not Exists Project (project_id int, employee_id int)', 'Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)', 'Truncate table Project', "insert into Project (project_id, employee_id) values ('1', '1')", "insert into Project (project_id, employee_id) values ('1...
Database
null
{"headers":{"Project":["project_id","employee_id"],"Employee":["employee_id","name","experience_years"]},"rows":{"Project":[[1,1],[1,2],[1,3],[2,1],[2,4]],"Employee":[[1,"Khaled",3],[2,"Ali",2],[3,"John",3],[4,"Doe",2]]}}
{"mysql": ["Create table If Not Exists Project (project_id int, employee_id int)", "Create table If Not Exists Employee (employee_id int, name varchar(10), experience_years int)"], "mssql": ["Create table Project (project_id int, employee_id int)", "Create table Employee (employee_id int, name varchar(10), experience_y...
{"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,078
Occurrences After Bigram
occurrences-after-bigram
<p>Given two strings <code>first</code> and <code>second</code>, consider occurrences in some text of the form <code>&quot;first second third&quot;</code>, where <code>second</code> comes immediately after <code>first</code>, and <code>third</code> comes immediately after <code>second</code>.</p> <p>Return <em>an arra...
Easy
82K
128.9K
81,997
128,871
63.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> findOcurrences(string text, string first, string second) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String[] findOcurrences(String text, String first, String secon...
"alice is a good girl she is a good student" "a" "good"
{ "name": "findOcurrences", "params": [ { "name": "text", "type": "string" }, { "name": "first", "type": "string" }, { "name": "second", "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,079
Letter Tile Possibilities
letter-tile-possibilities
<p>You have <code>n</code>&nbsp;&nbsp;<code>tiles</code>, where each tile has one letter <code>tiles[i]</code> printed on it.</p> <p>Return <em>the number of possible non-empty sequences of letters</em> you can make using the letters printed on those <code>tiles</code>.</p> <p>&nbsp;</p> <p><strong class="example">Ex...
Medium
234.4K
280.6K
234,428
280,638
83.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numTilePossibilities(string tiles) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numTilePossibilities(String tiles) {\n \n }\n}"}, {"value": "python", "text": "Pyt...
"AAB"
{ "name": "numTilePossibilities", "params": [ { "name": "tiles", "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', 'Counting']
1,080
Insufficient Nodes in Root to Leaf Paths
insufficient-nodes-in-root-to-leaf-paths
<p>Given the <code>root</code> of a binary tree and an integer <code>limit</code>, delete all <strong>insufficient nodes</strong> in the tree simultaneously, and return <em>the root of the resulting binary tree</em>.</p> <p>A node is <strong>insufficient</strong> if every root to <strong>leaf</strong> path intersectin...
Medium
44.6K
77.4K
44,585
77,441
57.6%
['count-nodes-equal-to-average-of-subtree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14] 1
{ "name": "sufficientSubset", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "limit", "type": "integer" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
1,081
Smallest Subsequence of Distinct Characters
smallest-subsequence-of-distinct-characters
<p>Given a string <code>s</code>, return <em>the </em><span data-keyword="lexicographically-smaller-string"><em>lexicographically smallest</em></span> <span data-keyword="subsequence-string"><em>subsequence</em></span><em> of</em> <code>s</code> <em>that contains all the distinct characters of</em> <code>s</code> <em>e...
Medium
80.1K
129.8K
80,103
129,752
61.7%
['find-the-most-competitive-subsequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string smallestSubsequence(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String smallestSubsequence(String s) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"bcabc"
{ "name": "smallestSubsequence", "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', 'Greedy', 'Monotonic Stack']
1,082
Sales Analysis I
sales-analysis-i
null
Easy
63.7K
85.3K
63,669
85,282
74.7%
['sales-analysis-ii']
['Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)', 'Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)', 'Truncate table Product', "insert into Product (product_id, product_name, unit_price) values ('1', ...
Database
null
{"headers":{"Product":["product_id","product_name","unit_price"],"Sales":["seller_id","product_id","buyer_id","sale_date","quantity","price"]},"rows":{"Product":[[1,"S8",1000],[2,"G4",800],[3,"iPhone",1400]],"Sales":[[1,1,1,"2019-01-21",2,2000],[1,2,2,"2019-02-17",1,800],[2,2,3,"2019-06-02",1,800],[3,3,4,"2019-05-13",2...
{"mysql": ["Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)", "Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)"], "mssql": ["Create table Product (product_id int, product_name varchar(10), unit_price in...
{"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,083
Sales Analysis II
sales-analysis-ii
null
Easy
62.8K
125.9K
62,793
125,872
49.9%
['sales-analysis-i', 'sales-analysis-iii']
['Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)', 'Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)', 'Truncate table Product', "insert into Product (product_id, product_name, unit_price) values ('1', ...
Database
null
{"headers":{"Product":["product_id","product_name","unit_price"],"Sales":["seller_id","product_id","buyer_id","sale_date","quantity","price"]},"rows":{"Product":[[1,"S8",1000],[2,"G4",800],[3,"iPhone",1400]],"Sales":[[1,1,1,"2019-01-21",2,2000],[1,2,2,"2019-02-17",1,800],[2,1,3,"2019-06-02",1,800],[3,3,3,"2019-05-13",2...
{"mysql": ["Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)", "Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)"], "mssql": ["Create table Product (product_id int, product_name varchar(10), unit_price in...
{"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,084
Sales Analysis III
sales-analysis-iii
<p>Table: <code>Product</code></p> <pre> +--------------+---------+ | Column Name | Type | +--------------+---------+ | product_id | int | | product_name | varchar | | unit_price | int | +--------------+---------+ product_id is the primary key (column with unique values) of this table. Each row of this...
Easy
166.4K
356.6K
166,387
356,594
46.7%
['sales-analysis-ii']
['Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)', 'Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)', 'Truncate table Product', "insert into Product (product_id, product_name, unit_price) values ('1', ...
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":{"Product":["product_id","product_name","unit_price"],"Sales":["seller_id","product_id","buyer_id","sale_date","quantity","price"]},"rows":{"Product":[[1,"S8",1000],[2,"G4",800],[3,"iPhone",1400]],"Sales":[[1,1,1,"2019-01-21",2,2000],[1,2,2,"2019-02-17",1,800],[2,2,3,"2019-06-02",1,800],[3,3,4,"2019-05-13",2...
{"mysql": ["Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)", "Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity int, price int)"], "mssql": ["Create table Product (product_id int, product_name varchar(10), unit_price in...
{"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,085
Sum of Digits in the Minimum Number
sum-of-digits-in-the-minimum-number
null
Easy
25.2K
33K
25,235
32,955
76.6%
['add-digits']
[]
Algorithms
null
[34,23,1,24,75,33,54,8]
{ "name": "sumOfDigits", "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']
1,086
High Five
high-five
null
Easy
114.7K
154.2K
114,696
154,187
74.4%
['determine-the-winner-of-a-bowling-game']
[]
Algorithms
null
[[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]
{ "name": "highFive", "params": [ { "name": "items", "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', 'Sorting', 'Heap (Priority Queue)']
1,087
Brace Expansion
brace-expansion
null
Medium
58.1K
87.1K
58,054
87,103
66.6%
['decode-string', 'letter-case-permutation', 'brace-expansion-ii']
[]
Algorithms
null
"{a,b}c{d,e}f"
{ "name": "expand", "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', 'Backtracking', 'Breadth-First Search']
1,088
Confusing Number II
confusing-number-ii
null
Hard
38.3K
81.3K
38,301
81,337
47.1%
['confusing-number']
[]
Algorithms
null
20
{ "name": "confusingNumberII", "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', 'Backtracking']
1,089
Duplicate Zeros
duplicate-zeros
<p>Given a fixed-length integer array <code>arr</code>, duplicate each occurrence of zero, shifting the remaining elements to the right.</p> <p><strong>Note</strong> that elements beyond the length of the original array are not written. Do the above modifications to the input array in place and do not return anything....
Easy
483.8K
918.9K
483,821
918,887
52.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n void duplicateZeros(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public void duplicateZeros(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[1,0,2,3,0,4,5,0]
{ "name": "duplicateZeros", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "void" }, "output": { "paramindex": 0 } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers']
1,090
Largest Values From Labels
largest-values-from-labels
<p>You are given <code>n</code> item&#39;s value and label as two integer arrays <code>values</code> and <code>labels</code>. You are also given two integers <code>numWanted</code> and <code>useLimit</code>.</p> <p>Your task is to find a subset of items with the <strong>maximum sum</strong> of their values such that:<...
Medium
43.8K
69.6K
43,808
69,616
62.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int largestValsFromLabels(vector<int>& values, vector<int>& labels, int numWanted, int useLimit) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int largestValsFromLabels(int[] values...
[5,4,3,2,1] [1,1,2,2,3] 3 1
{ "name": "largestValsFromLabels", "params": [ { "name": "values", "type": "integer[]" }, { "name": "labels", "type": "integer[]" }, { "name": "numWanted", "type": "integer" }, { "name": "useLimit", "type": "integer" } ], "return": ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Greedy', 'Sorting', 'Counting']
1,091
Shortest Path in Binary Matrix
shortest-path-in-binary-matrix
<p>Given an <code>n x n</code> binary matrix <code>grid</code>, return <em>the length of the shortest <strong>clear path</strong> in the matrix</em>. If there is no clear path, return <code>-1</code>.</p> <p>A <strong>clear path</strong> in a binary matrix is a path from the <strong>top-left</strong> cell (i.e., <code...
Medium
645.2K
1.3M
645,236
1,307,326
49.4%
['paths-in-matrix-whose-sum-is-divisible-by-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int shortestPathBinaryMatrix(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int shortestPathBinaryMatrix(int[][] grid) {\n \n }\n}"}, {"value": "...
[[0,1],[1,0]]
{ "name": "shortestPathBinaryMatrix", "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', 'Breadth-First Search', 'Matrix']
1,092
Shortest Common Supersequence
shortest-common-supersequence
<p>Given two strings <code>str1</code> and <code>str2</code>, return <em>the shortest string that has both </em><code>str1</code><em> and </em><code>str2</code><em> as <strong>subsequences</strong></em>. If there are multiple valid strings, return <strong>any</strong> of them.</p> <p>A string <code>s</code> is a <stro...
Hard
240.5K
392.6K
240,495
392,587
61.3%
['longest-common-subsequence', 'shortest-string-that-contains-three-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string shortestCommonSupersequence(string str1, string str2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String shortestCommonSupersequence(String str1, String str2) {\n \n...
"abac" "cab"
{ "name": "shortestCommonSupersequence", "params": [ { "name": "str1", "type": "string" }, { "name": "str2", "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', 'Dynamic Programming']
1,093
Statistics from a Large Sample
statistics-from-a-large-sample
<p>You are given a large sample of integers in the range <code>[0, 255]</code>. Since the sample is so large, it is represented by an array <code>count</code>&nbsp;where <code>count[k]</code> is the <strong>number of times</strong> that <code>k</code> appears in the sample.</p> <p>Calculate the following statistics:</...
Medium
22.5K
53.3K
22,455
53,277
42.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<double> sampleStats(vector<int>& count) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double[] sampleStats(int[] count) {\n \n }\n}"}, {"value": "python", "text": "...
[0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0...
{ "name": "sampleStats", "params": [ { "name": "count", "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', 'Probability and Statistics']
1,094
Car Pooling
car-pooling
<p>There is a car with <code>capacity</code> empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).</p> <p>You are given the integer <code>capacity</code> and an array <code>trips</code> where <code>trips[i] = [numPassengers<sub>i</sub>, from<sub>i</sub>, to<sub>i</sub>]</code> indicat...
Medium
255.7K
456.8K
255,704
456,814
56.0%
['meeting-rooms-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool carPooling(vector<vector<int>>& trips, int capacity) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean carPooling(int[][] trips, int capacity) {\n \n }\n}"}, {"va...
[[2,1,5],[3,3,7]] 4
{ "name": "carPooling", "params": [ { "name": "trips", "type": "integer[][]" }, { "name": "capacity", "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', 'Heap (Priority Queue)', 'Simulation', 'Prefix Sum']
1,095
Find in Mountain Array
find-in-mountain-array
<p><em>(This problem is an <strong>interactive problem</strong>.)</em></p> <p>You may recall that an array <code>arr</code> is a <strong>mountain array</strong> if and only if:</p> <ul> <li><code>arr.length &gt;= 3</code></li> <li>There exists some <code>i</code> with <code>0 &lt; i &lt; arr.length - 1</code> such ...
Hard
162K
402.4K
162,008
402,370
40.3%
['peak-index-in-a-mountain-array', 'minimum-number-of-removals-to-make-mountain-array', 'find-good-days-to-rob-the-bank', 'find-indices-of-stable-mountains']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * // This is the MountainArray's API interface.\n * // You should not implement it, or speculate about its implementation\n * class MountainArray {\n * public:\n * int get(int index);\n * int length();\n * };\n */\n\nclass Solution {\npublic:\n int fin...
[1,2,3,4,5,3,1] 3
{ "name": "findInMountainArray", "params": [ { "name": "mountainArr", "type": "integer[]" }, { "name": "target", "type": "integer" } ], "return": { "type": "integer" }, "manual": true, "typescriptCustomType": "class MountainArray {\n __secret: number[];\n ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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,096
Brace Expansion II
brace-expansion-ii
<p>Under the grammar given below, strings can represent a set of lowercase words. Let&nbsp;<code>R(expr)</code>&nbsp;denote the set of words the expression represents.</p> <p>The grammar can best be understood through simple examples:</p> <ul> <li>Single letters represent a singleton set containing that word. <ul> ...
Hard
26.8K
42.4K
26,802
42,444
63.1%
['brace-expansion']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> braceExpansionII(string expression) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> braceExpansionII(String expression) {\n \n }\n}"}, {"value": ...
"{a,b}{c,{d,e}}"
{ "name": "braceExpansionII", "params": [ { "name": "expression", "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', 'Backtracking', 'Stack', 'Breadth-First Search']
1,097
Game Play Analysis V
game-play-analysis-v
null
Hard
26.3K
51.7K
26,252
51,695
50.8%
['game-play-analysis-iv']
['Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)', 'Truncate table Activity', "insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')", "insert into Activity (player_id, device_id, event_date, games_played) values...
Database
null
{"headers":{"Activity":["player_id","device_id","event_date","games_played"]},"rows":{"Activity":[[1,2,"2016-03-01",5],[1,2,"2016-03-02",6],[2,3,"2017-06-25",1],[3,1,"2016-03-01",0],[3,4,"2018-07-03",5]]}}
{"mysql": ["Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)"], "mssql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int)"], "oraclesql": ["Create table Activity (player_id int, device_id int, event_date date, games_played int...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
1,098
Unpopular Books
unpopular-books
null
Medium
44K
101.5K
43,972
101,526
43.3%
[]
['Create table If Not Exists Books (book_id int, name varchar(50), available_from date)', 'Create table If Not Exists Orders (order_id int, book_id int, quantity int, dispatch_date date)', 'Truncate table Books', "insert into Books (book_id, name, available_from) values ('1', 'Kalila And Demna', '2010-01-01')", "insert...
Database
null
{"headers":{"Books":["book_id","name","available_from"],"Orders":["order_id","book_id","quantity","dispatch_date"]},"rows":{"Books":[[1,"Kalila And Demna","2010-01-01"],[2,"28 Letters","2012-05-12"],[3,"The Hobbit","2019-06-10"],[4,"13 Reasons Why","2019-06-01"],[5,"The Hunger Games","2008-09-21"]],"Orders":[[1,1,2,"20...
{"mysql": ["Create table If Not Exists Books (book_id int, name varchar(50), available_from date)", "Create table If Not Exists Orders (order_id int, book_id int, quantity int, dispatch_date date)"], "mssql": ["Create table Books (book_id int, name varchar(50), available_from date)", "Create table Orders (order_id int,...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
1,099
Two Sum Less Than K
two-sum-less-than-k
null
Easy
142.4K
229.8K
142,421
229,766
62.0%
['two-sum', 'two-sum-ii-input-array-is-sorted', '3sum-smaller', 'subarray-product-less-than-k']
[]
Algorithms
null
[34,23,1,24,75,33,54,8] 60
{ "name": "twoSumLessThanK", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting']
1,100
Find K-Length Substrings With No Repeated Characters
find-k-length-substrings-with-no-repeated-characters
null
Medium
51.8K
68K
51,841
68,014
76.2%
[]
[]
Algorithms
null
"havefunonleetcode" 5
{ "name": "numKLenSubstrNoRepeats", "params": [ { "name": "s", "type": "string" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Sliding Window']