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
3,010
Divide an Array Into Subarrays With Minimum Cost I
divide-an-array-into-subarrays-with-minimum-cost-i
<p>You are given an array of integers <code>nums</code> of length <code>n</code>.</p> <p>The <strong>cost</strong> of an array is the value of its <strong>first</strong> element. For example, the cost of <code>[1,2,3]</code> is <code>1</code> while the cost of <code>[3,4,1]</code> is <code>3</code>.</p> <p>You need t...
Easy
38.2K
58.3K
38,195
58,299
65.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumCost(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumCost(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[1,2,3,12]
{ "name": "minimumCost", "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', 'Sorting', 'Enumeration']
3,011
Find if Array Can Be Sorted
find-if-array-can-be-sorted
<p>You are given a <strong>0-indexed</strong> array of <strong>positive</strong> integers <code>nums</code>.</p> <p>In one <strong>operation</strong>, you can swap any two <strong>adjacent</strong> elements if they have the <strong>same</strong> number of <span data-keyword="set-bit">set bits</span>. You are allowed t...
Medium
145K
218K
145,030
217,980
66.5%
['sort-integers-by-the-number-of-1-bits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canSortArray(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canSortArray(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "d...
[8,4,2,30,15]
{ "name": "canSortArray", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Sorting']
3,012
Minimize Length of Array Using Operations
minimize-length-of-array-using-operations
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> containing <strong>positive</strong> integers.</p> <p>Your task is to <strong>minimize</strong> the length of <code>nums</code> by performing the following operations <strong>any</strong> number of times (including zero):</p> <ul> <li>Sele...
Medium
15.5K
44.9K
15,529
44,865
34.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumArrayLength(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumArrayLength(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,4,3,1]
{ "name": "minimumArrayLength", "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', 'Greedy', 'Number Theory']
3,013
Divide an Array Into Subarrays With Minimum Cost II
divide-an-array-into-subarrays-with-minimum-cost-ii
<p>You are given a <strong>0-indexed</strong> array of integers <code>nums</code> of length <code>n</code>, and two <strong>positive</strong> integers <code>k</code> and <code>dist</code>.</p> <p>The <strong>cost</strong> of an array is the value of its <strong>first</strong> element. For example, the cost of <code>[1...
Hard
6.1K
20.7K
6,149
20,711
29.7%
['minimum-cost-to-cut-a-stick', 'minimum-cost-to-split-an-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long minimumCost(vector<int>& nums, int k, int dist) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long minimumCost(int[] nums, int k, int dist) {\n \n }\n}"}, {"valu...
[1,3,2,6,4,2] 3 3
{ "name": "minimumCost", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" }, { "type": "integer", "name": "dist" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Sliding Window', 'Heap (Priority Queue)']
3,014
Minimum Number of Pushes to Type Word I
minimum-number-of-pushes-to-type-word-i
<p>You are given a string <code>word</code> containing <strong>distinct</strong> lowercase English letters.</p> <p>Telephone keypads have keys mapped with <strong>distinct</strong> collections of lowercase English letters, which can be used to form words by pushing them. For example, the key <code>2</code> is mapped w...
Easy
45.3K
68.7K
45,344
68,698
66.0%
['letter-combinations-of-a-phone-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumPushes(string word) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumPushes(String word) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
"abcde"
{ "name": "minimumPushes", "params": [ { "name": "word", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Greedy']
3,015
Count the Number of Houses at a Certain Distance I
count-the-number-of-houses-at-a-certain-distance-i
<p>You are given three <strong>positive</strong> integers <code>n</code>, <code>x</code>, and <code>y</code>.</p> <p>In a city, there exist houses numbered <code>1</code> to <code>n</code> connected by <code>n</code> streets. There is a street connecting the house numbered <code>i</code> with the house numbered <code>...
Medium
22.6K
40K
22,592
39,966
56.5%
['walls-and-gates']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> countOfPairs(int n, int x, int y) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] countOfPairs(int n, int x, int y) {\n \n }\n}"}, {"value": "python", "tex...
3 1 3
{ "name": "countOfPairs", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "x" }, { "type": "integer", "name": "y" } ], "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...
['Breadth-First Search', 'Graph', 'Prefix Sum']
3,016
Minimum Number of Pushes to Type Word II
minimum-number-of-pushes-to-type-word-ii
<p>You are given a string <code>word</code> containing lowercase English letters.</p> <p>Telephone keypads have keys mapped with <strong>distinct</strong> collections of lowercase English letters, which can be used to form words by pushing them. For example, the key <code>2</code> is mapped with <code>[&quot;a&quot;,&...
Medium
180.3K
225.7K
180,341
225,706
79.9%
['letter-combinations-of-a-phone-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumPushes(string word) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumPushes(String word) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
"abcde"
{ "name": "minimumPushes", "params": [ { "name": "word", "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', 'Greedy', 'Sorting', 'Counting']
3,017
Count the Number of Houses at a Certain Distance II
count-the-number-of-houses-at-a-certain-distance-ii
<p>You are given three <strong>positive</strong> integers <code>n</code>, <code>x</code>, and <code>y</code>.</p> <p>In a city, there exist houses numbered <code>1</code> to <code>n</code> connected by <code>n</code> streets. There is a street connecting the house numbered <code>i</code> with the house numbered <code>...
Hard
3.5K
16.5K
3,526
16,487
21.4%
['walls-and-gates']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<long long> countOfPairs(int n, int x, int y) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long[] countOfPairs(int n, int x, int y) {\n \n }\n}"}, {"value": "python...
3 1 3
{ "name": "countOfPairs", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "x" }, { "type": "integer", "name": "y" } ], "return": { "type": "long[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Prefix Sum']
3,018
Maximum Number of Removal Queries That Can Be Processed I
maximum-number-of-removal-queries-that-can-be-processed-i
null
Hard
559
1.3K
559
1,296
43.1%
[]
[]
Algorithms
null
[1,2,3,4,5] [1,2,3,4,6]
{ "name": "maximumProcessableQueries", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "queries" } ], "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']
3,019
Number of Changing Keys
number-of-changing-keys
<p>You are given a <strong>0-indexed </strong>string <code>s</code> typed by a user. Changing a key is defined as using a key different from the last used key. For example, <code>s = &quot;ab&quot;</code> has a change of a key while <code>s = &quot;bBBb&quot;</code> does not have any.</p> <p>Return <em>the number of t...
Easy
62.8K
78.9K
62,772
78,933
79.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countKeyChanges(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countKeyChanges(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
"aAbBcC"
{ "name": "countKeyChanges", "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']
3,020
Find the Maximum Number of Elements in Subset
find-the-maximum-number-of-elements-in-subset
<p>You are given an array of <strong>positive</strong> integers <code>nums</code>.</p> <p>You need to select a <span data-keyword="subset">subset</span> of <code>nums</code> which satisfies the following condition:</p> <ul> <li>You can place the selected elements in a <strong>0-indexed</strong> array such that it fo...
Medium
25.9K
98.5K
25,876
98,478
26.3%
['longest-consecutive-sequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximumLength(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximumLength(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[5,4,1,2,2]
{ "name": "maximumLength", "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', 'Enumeration']
3,021
Alice and Bob Playing Flower Game
alice-and-bob-playing-flower-game
<p>Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are <code>x</code> flowers in the clockwise direction between Alice and Bob, and <code>y</code> flowers in the anti-clockwise direction between them.</p> <p>The game proceeds as follows:...
Medium
21.5K
45.8K
21,508
45,809
47.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long flowerGame(int n, int m) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long flowerGame(int n, int m) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
3 2
{ "name": "flowerGame", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "m" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
3,022
Minimize OR of Remaining Elements Using Operations
minimize-or-of-remaining-elements-using-operations
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and an integer <code>k</code>.</p> <p>In one operation, you can pick any index <code>i</code> of <code>nums</code> such that <code>0 &lt;= i &lt; nums.length - 1</code> and replace <code>nums[i]</code> and <code>nums[i + 1]</code> with a sin...
Hard
3.6K
12.4K
3,569
12,446
28.7%
['maximum-xor-after-operations', 'apply-operations-on-array-to-maximize-sum-of-squares']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOrAfterOperations(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOrAfterOperations(int[] nums, int k) {\n \n }\n}"}, {"value": "pyth...
[3,5,3,2,7] 2
{ "name": "minOrAfterOperations", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Bit Manipulation']
3,023
Find Pattern in Infinite Stream I
find-pattern-in-infinite-stream-i
null
Medium
1.5K
2.6K
1,464
2,591
56.5%
[]
[]
Algorithms
null
[1,1,1,0,1] [0,1]
{ "name": "foobar", "params": [ { "name": "stream", "type": "integer[]" }, { "type": "integer[]", "name": "pattern" } ], "return": { "type": "integer" }, "manual": true, "languages": [ "cpp", "java", "python", "c", "csharp", "javascript",...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Rolling Hash', 'String Matching', 'Hash Function']
3,024
Type of Triangle
type-of-triangle
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>3</code> which can form the sides of a triangle.</p> <ul> <li>A triangle is called <strong>equilateral</strong> if it has all sides of equal length.</li> <li>A triangle is called <strong>isosceles</strong> if it has exactly t...
Easy
62.5K
164.6K
62,487
164,554
38.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string triangleType(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String triangleType(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[3,3,3]
{ "name": "triangleType", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Sorting']
3,025
Find the Number of Ways to Place People I
find-the-number-of-ways-to-place-people-i
<p>You are given a 2D array <code>points</code> of size <code>n x 2</code> representing integer coordinates of some points on a 2D plane, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>.</p> <p>Count the number of pairs of points <code>(A, B)</code>, where</p> <ul> <li><code>A</code> is on the <strong>...
Medium
15.4K
38K
15,398
37,993
40.5%
['rectangle-area']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numberOfPairs(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numberOfPairs(int[][] points) {\n \n }\n}"}, {"value": "python", "text": "...
[[1,1],[2,2],[3,3]]
{ "name": "numberOfPairs", "params": [ { "name": "points", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Geometry', 'Sorting', 'Enumeration']
3,026
Maximum Good Subarray Sum
maximum-good-subarray-sum
<p>You are given an array <code>nums</code> of length <code>n</code> and a <strong>positive</strong> integer <code>k</code>.</p> <p>A <span data-keyword="subarray-nonempty">subarray</span> of <code>nums</code> is called <strong>good</strong> if the <strong>absolute difference</strong> between its first and last elemen...
Medium
25.5K
127.6K
25,519
127,568
20.0%
['maximum-subarray', 'maximum-sum-of-distinct-subarrays-with-length-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maximumSubarraySum(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maximumSubarraySum(int[] nums, int k) {\n \n }\n}"}, {"value": "p...
[1,2,3,4,5,6] 1
{ "name": "maximumSubarraySum", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Prefix Sum']
3,027
Find the Number of Ways to Place People II
find-the-number-of-ways-to-place-people-ii
<p>You are given a 2D array <code>points</code> of size <code>n x 2</code> representing integer coordinates of some points on a 2D-plane, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>.</p> <p>We define the <strong>right</strong> direction as positive x-axis (<strong>increasing x-coordinate</strong>) an...
Hard
11.3K
24.7K
11,270
24,653
45.7%
['rectangle-area']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numberOfPairs(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numberOfPairs(int[][] points) {\n \n }\n}"}, {"value": "python", "text": "...
[[1,1],[2,2],[3,3]]
{ "name": "numberOfPairs", "params": [ { "name": "points", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Geometry', 'Sorting', 'Enumeration']
3,028
Ant on the Boundary
ant-on-the-boundary
<p>An ant is on a boundary. It sometimes goes <strong>left</strong> and sometimes <strong>right</strong>.</p> <p>You are given an array of <strong>non-zero</strong> integers <code>nums</code>. The ant starts reading <code>nums</code> from the first element of it to its end. At each step, it moves according to the valu...
Easy
60.7K
82.7K
60,740
82,653
73.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int returnToBoundaryCount(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int returnToBoundaryCount(int[] nums) {\n \n }\n}"}, {"value": "python", "text":...
[2,3,-5]
{ "name": "returnToBoundaryCount", "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', 'Simulation', 'Prefix Sum']
3,029
Minimum Time to Revert Word to Initial State I
minimum-time-to-revert-word-to-initial-state-i
<p>You are given a <strong>0-indexed</strong> string <code>word</code> and an integer <code>k</code>.</p> <p>At every second, you must perform the following operations:</p> <ul> <li>Remove the first <code>k</code> characters of <code>word</code>.</li> <li>Add any <code>k</code> characters to the end of <code>word</...
Medium
21.8K
53K
21,762
53,016
41.0%
['longest-happy-prefix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumTimeToInitialState(string word, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumTimeToInitialState(String word, int k) {\n \n }\n}"}, {"value": ...
"abacaba" 3
{ "name": "minimumTimeToInitialState", "params": [ { "name": "word", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Rolling Hash', 'String Matching', 'Hash Function']
3,030
Find the Grid of Region Average
find-the-grid-of-region-average
<p>You are given <code>m x n</code> grid <code>image</code> which represents a grayscale image, where <code>image[i][j]</code> represents a pixel with intensity in the range <code>[0..255]</code>. You are also given a <strong>non-negative</strong> integer <code>threshold</code>.</p> <p>Two pixels are <strong>adjacent<...
Medium
10.8K
25.8K
10,829
25,804
42.0%
['range-sum-query-2d-immutable', 'k-radius-subarray-averages']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> resultGrid(vector<vector<int>>& image, int threshold) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] resultGrid(int[][] image, int threshold) {\n \...
[[5,6,7,10],[8,9,10,10],[11,12,13,10]] 3
{ "name": "resultGrid", "params": [ { "name": "image", "type": "integer[][]" }, { "type": "integer", "name": "threshold" } ], "return": { "type": "integer[][]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix']
3,031
Minimum Time to Revert Word to Initial State II
minimum-time-to-revert-word-to-initial-state-ii
<p>You are given a <strong>0-indexed</strong> string <code>word</code> and an integer <code>k</code>.</p> <p>At every second, you must perform the following operations:</p> <ul> <li>Remove the first <code>k</code> characters of <code>word</code>.</li> <li>Add any <code>k</code> characters to the end of <code>word</...
Hard
12.1K
35.5K
12,142
35,509
34.2%
['longest-happy-prefix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumTimeToInitialState(string word, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumTimeToInitialState(String word, int k) {\n \n }\n}"}, {"value": ...
"abacaba" 3
{ "name": "minimumTimeToInitialState", "params": [ { "name": "word", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Rolling Hash', 'String Matching', 'Hash Function']
3,032
Count Numbers With Unique Digits II
count-numbers-with-unique-digits-ii
null
Easy
6.4K
7.2K
6,369
7,237
88.0%
['count-numbers-with-unique-digits']
[]
Algorithms
null
1 20
{ "name": "numberCount", "params": [ { "name": "a", "type": "integer" }, { "type": "integer", "name": "b" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Math', 'Dynamic Programming']
3,033
Modify the Matrix
modify-the-matrix
<p>Given a <strong>0-indexed</strong> <code>m x n</code> integer matrix <code>matrix</code>, create a new <strong>0-indexed</strong> matrix called <code>answer</code>. Make <code>answer</code> equal to <code>matrix</code>, then replace each element with the value <code>-1</code> with the <strong>maximum</strong> elemen...
Easy
48.5K
71.1K
48,508
71,148
68.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> modifiedMatrix(vector<vector<int>>& matrix) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] modifiedMatrix(int[][] matrix) {\n \n }\n}"}, {"value...
[[1,2,-1],[4,-1,6],[7,8,9]]
{ "name": "modifiedMatrix", "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', 'Matrix']
3,034
Number of Subarrays That Match a Pattern I
number-of-subarrays-that-match-a-pattern-i
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code>, and a <strong>0-indexed</strong> integer array <code>pattern</code> of size <code>m</code> consisting of integers <code>-1</code>, <code>0</code>, and <code>1</code>.</p> <p>A <span data-keyword="subarray">subarray</s...
Medium
29.4K
44.4K
29,441
44,427
66.3%
['count-the-number-of-incremovable-subarrays-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countMatchingSubarrays(vector<int>& nums, vector<int>& pattern) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countMatchingSubarrays(int[] nums, int[] pattern) {\n \n...
[1,2,3,4,5,6] [1,1]
{ "name": "countMatchingSubarrays", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "pattern" } ], "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', 'Rolling Hash', 'String Matching', 'Hash Function']
3,035
Maximum Palindromes After Operations
maximum-palindromes-after-operations
<p>You are given a <strong>0-indexed</strong> string array <code>words</code> having length <code>n</code> and containing <strong>0-indexed</strong> strings.</p> <p>You are allowed to perform the following operation <strong>any</strong> number of times (<strong>including</strong> <strong>zero</strong>):</p> <ul> <li...
Medium
16.7K
39K
16,711
39,027
42.8%
['valid-palindrome']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxPalindromesAfterOperations(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxPalindromesAfterOperations(String[] words) {\n \n }\n}"}, {"v...
["abbb","ba","aa"]
{ "name": "maxPalindromesAfterOperations", "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', 'String', 'Greedy', 'Sorting', 'Counting']
3,036
Number of Subarrays That Match a Pattern II
number-of-subarrays-that-match-a-pattern-ii
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code>, and a <strong>0-indexed</strong> integer array <code>pattern</code> of size <code>m</code> consisting of integers <code>-1</code>, <code>0</code>, and <code>1</code>.</p> <p>A <span data-keyword="subarray">subarray</s...
Hard
12.3K
38.7K
12,301
38,677
31.8%
['match-substring-after-replacement']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countMatchingSubarrays(vector<int>& nums, vector<int>& pattern) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countMatchingSubarrays(int[] nums, int[] pattern) {\n \n...
[1,2,3,4,5,6] [1,1]
{ "name": "countMatchingSubarrays", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "pattern" } ], "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', 'Rolling Hash', 'String Matching', 'Hash Function']
3,037
Find Pattern in Infinite Stream II
find-pattern-in-infinite-stream-ii
null
Hard
1.1K
1.7K
1,134
1,662
68.2%
[]
[]
Algorithms
null
[1,1,1,0,1] [0,1]
{ "name": "findPattern", "params": [ { "name": "stream", "type": "integer[]" }, { "type": "integer[]", "name": "pattern" } ], "return": { "type": "integer" }, "manual": true, "languages": [ "cpp", "java", "python", "c", "csharp", "javascr...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Rolling Hash', 'String Matching', 'Hash Function']
3,038
Maximum Number of Operations With the Same Score I
maximum-number-of-operations-with-the-same-score-i
<p>You are given an array of integers <code>nums</code>. Consider the following operation:</p> <ul> <li>Delete the first two elements <code>nums</code> and define the <em>score</em> of the operation as the sum of these two elements.</li> </ul> <p>You can perform this operation until <code>nums</code> contains fewer ...
Easy
37.6K
72.6K
37,554
72,648
51.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxOperations(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxOperations(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[3,2,1,4,5]
{ "name": "maxOperations", "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', 'Simulation']
3,039
Apply Operations to Make String Empty
apply-operations-to-make-string-empty
<p>You are given a string <code>s</code>.</p> <p>Consider performing the following operation until <code>s</code> becomes <strong>empty</strong>:</p> <ul> <li>For <strong>every</strong> alphabet character from <code>&#39;a&#39;</code> to <code>&#39;z&#39;</code>, remove the <strong>first</strong> occurrence of that ...
Medium
28.9K
51.7K
28,872
51,663
55.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string lastNonEmptyString(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String lastNonEmptyString(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"aabcbbca"
{ "name": "lastNonEmptyString", "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...
['Array', 'Hash Table', 'Sorting', 'Counting']
3,040
Maximum Number of Operations With the Same Score II
maximum-number-of-operations-with-the-same-score-ii
<p>Given an array of integers called <code>nums</code>, you can perform <strong>any</strong> of the following operation while <code>nums</code> contains <strong>at least</strong> <code>2</code> elements:</p> <ul> <li>Choose the first two elements of <code>nums</code> and delete them.</li> <li>Choose the last two ele...
Medium
22.5K
68.3K
22,467
68,295
32.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxOperations(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxOperations(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[3,2,1,2,3,4]
{ "name": "maxOperations", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Memoization']
3,041
Maximize Consecutive Elements in an Array After Modification
maximize-consecutive-elements-in-an-array-after-modification
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of <strong>positive</strong> integers.</p> <p>Initially, you can increase the value of <strong>any</strong> element in the array by <strong>at most</strong> <code>1</code>.</p> <p>After that, you need to select <strong>one or more</stron...
Hard
9.6K
30.1K
9,626
30,071
32.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxSelectedElements(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxSelectedElements(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Py...
[2,1,5,1,1]
{ "name": "maxSelectedElements", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Sorting']
3,042
Count Prefix and Suffix Pairs I
count-prefix-and-suffix-pairs-i
<p>You are given a <strong>0-indexed</strong> string array <code>words</code>.</p> <p>Let&#39;s define a <strong>boolean</strong> function <code>isPrefixAndSuffix</code> that takes two strings, <code>str1</code> and <code>str2</code>:</p> <ul> <li><code>isPrefixAndSuffix(str1, str2)</code> returns <code>true</code> ...
Easy
195.7K
252.1K
195,694
252,080
77.6%
['implement-trie-prefix-tree', 'design-add-and-search-words-data-structure']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countPrefixSuffixPairs(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countPrefixSuffixPairs(String[] words) {\n \n }\n}"}, {"value": "python...
["a","aba","ababa","aa"]
{ "name": "countPrefixSuffixPairs", "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', 'String', 'Trie', 'Rolling Hash', 'String Matching', 'Hash Function']
3,043
Find the Length of the Longest Common Prefix
find-the-length-of-the-longest-common-prefix
<p>You are given two arrays with <strong>positive</strong> integers <code>arr1</code> and <code>arr2</code>.</p> <p>A <strong>prefix</strong> of a positive integer is an integer formed by one or more of its digits, starting from its <strong>leftmost</strong> digit. For example, <code>123</code> is a prefix of the inte...
Medium
152.8K
271.5K
152,793
271,464
56.3%
['longest-common-prefix', 'longest-common-suffix-queries']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestCommonPrefix(vector<int>& arr1, vector<int>& arr2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestCommonPrefix(int[] arr1, int[] arr2) {\n \n }\n}"}, ...
[1,10,100] [1000]
{ "name": "longestCommonPrefix", "params": [ { "name": "arr1", "type": "integer[]" }, { "type": "integer[]", "name": "arr2" } ], "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', 'String', 'Trie']
3,044
Most Frequent Prime
most-frequent-prime
<p>You are given a <code>m x n</code> <strong>0-indexed </strong>2D<strong> </strong>matrix <code>mat</code>. From every cell, you can create numbers in the following way:</p> <ul> <li>There could be at most <code>8</code> paths from the cells namely: east, south-east, south, south-west, west, north-west, north, and ...
Medium
17K
38K
16,990
37,999
44.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int mostFrequentPrime(vector<vector<int>>& mat) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int mostFrequentPrime(int[][] mat) {\n \n }\n}"}, {"value": "python", "text":...
[[1,1],[9,9],[1,1]]
{ "name": "mostFrequentPrime", "params": [ { "name": "mat", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Matrix', 'Counting', 'Enumeration', 'Number Theory']
3,045
Count Prefix and Suffix Pairs II
count-prefix-and-suffix-pairs-ii
<p>You are given a <strong>0-indexed</strong> string array <code>words</code>.</p> <p>Let&#39;s define a <strong>boolean</strong> function <code>isPrefixAndSuffix</code> that takes two strings, <code>str1</code> and <code>str2</code>:</p> <ul> <li><code>isPrefixAndSuffix(str1, str2)</code> returns <code>true</code> ...
Hard
13.1K
48.8K
13,110
48,784
26.9%
['implement-trie-prefix-tree', 'design-add-and-search-words-data-structure']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countPrefixSuffixPairs(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countPrefixSuffixPairs(String[] words) {\n \n }\n}"}, {"value": ...
["a","aba","ababa","aa"]
{ "name": "countPrefixSuffixPairs", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Rolling Hash', 'String Matching', 'Hash Function']
3,046
Split the Array
split-the-array
<p>You are given an integer array <code>nums</code> of <strong>even</strong> length. You have to split the array into two parts <code>nums1</code> and <code>nums2</code> such that:</p> <ul> <li><code>nums1.length == nums2.length == nums.length / 2</code>.</li> <li><code>nums1</code> should contain <strong>distinct <...
Easy
65K
110.4K
64,995
110,414
58.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isPossibleToSplit(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isPossibleToSplit(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "P...
[1,1,2,2,3,4]
{ "name": "isPossibleToSplit", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Counting']
3,047
Find the Largest Area of Square Inside Two Rectangles
find-the-largest-area-of-square-inside-two-rectangles
<p>There exist <code>n</code> rectangles in a 2D plane with edges parallel to the x and y axis. You are given two 2D integer arrays&nbsp;<code>bottomLeft</code> and <code>topRight</code>&nbsp;where <code>bottomLeft[i] = [a_i, b_i]</code> and <code>topRight[i] = [c_i, d_i]</code> represent&nbsp;the <strong>bottom-left</...
Medium
21.2K
47.2K
21,173
47,243
44.8%
['rectangle-area']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long largestSquareArea(vector<vector<int>>& bottomLeft, vector<vector<int>>& topRight) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long largestSquareArea(int[][] bottomLeft, ...
[[1,1],[2,2],[3,1]] [[3,3],[4,4],[6,6]]
{ "name": "largestSquareArea", "params": [ { "name": "bottomLeft", "type": "integer[][]" }, { "type": "integer[][]", "name": "topRight" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
3,048
Earliest Second to Mark Indices I
earliest-second-to-mark-indices-i
<p>You are given two <strong>1-indexed</strong> integer arrays, <code>nums</code> and, <code>changeIndices</code>, having lengths <code>n</code> and <code>m</code>, respectively.</p> <p>Initially, all indices in <code>nums</code> are unmarked. Your task is to mark <strong>all</strong> indices in <code>nums</code>.</p>...
Medium
9.5K
27.9K
9,523
27,889
34.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int earliestSecondToMarkIndices(vector<int>& nums, vector<int>& changeIndices) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int earliestSecondToMarkIndices(int[] nums, int[] change...
[2,2,0] [2,2,2,2,3,2,2,1]
{ "name": "earliestSecondToMarkIndices", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "changeIndices" } ], "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']
3,049
Earliest Second to Mark Indices II
earliest-second-to-mark-indices-ii
<p>You are given two <strong>1-indexed</strong> integer arrays, <code>nums</code> and, <code>changeIndices</code>, having lengths <code>n</code> and <code>m</code>, respectively.</p> <p>Initially, all indices in <code>nums</code> are unmarked. Your task is to mark <strong>all</strong> indices in <code>nums</code>.</p>...
Hard
3K
14.8K
2,967
14,756
20.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int earliestSecondToMarkIndices(vector<int>& nums, vector<int>& changeIndices) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int earliestSecondToMarkIndices(int[] nums, int[] change...
[3,2,3] [1,3,2,2,2,2,3]
{ "name": "earliestSecondToMarkIndices", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "changeIndices" } ], "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', 'Greedy', 'Heap (Priority Queue)']
3,050
Pizza Toppings Cost Analysis
pizza-toppings-cost-analysis
null
Medium
2.4K
3.5K
2,355
3,475
67.8%
[]
['Create table if not exists Toppings(topping_name varchar(100), cost decimal(5,2))', 'Truncate table Toppings', "insert into Toppings (topping_name, cost) values ('Pepperoni', '0.5')", "insert into Toppings (topping_name, cost) values ('Sausage', '0.7')", "insert into Toppings (topping_name, cost) values ('Chicken', '...
Database
null
{"headers":{"Toppings":["topping_name","cost"]},"rows":{"Toppings":[["Pepperoni",0.50],["Sausage",0.70],["Chicken",0.55],["Extra Cheese",0.40]]}}
{"mysql": ["Create table if not exists Toppings(topping_name varchar(100), cost decimal(5,2))"], "mssql": ["Create table Toppings(topping_name varchar(100), cost decimal(5,2))"], "oraclesql": ["Create table Toppings(topping_name varchar(100), cost decimal(5,2))"], "database": true, "name": "cost_analysis", "pythondata"...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
3,051
Find Candidates for Data Scientist Position
find-candidates-for-data-scientist-position
null
Easy
3.9K
5.1K
3,867
5,086
76.0%
[]
['Create table If Not Exists Candidates (candidate_id int, skill varchar(30))', 'Truncate table Candidates', "insert into Candidates (candidate_id, skill) values ('123', 'Python')", "insert into Candidates (candidate_id, skill) values ('234', 'R')", "insert into Candidates (candidate_id, skill) values ('123', 'Tableau'...
Database
null
{"headers":{"Candidates":["candidate_id","skill"]},"rows":{"Candidates":[[123,"Python"],[234,"R"],[123,"Tableau"],[123,"PostgreSQL"],[234,"PowerBI"],[234,"SQL Server"],[147,"Python"],[147,"Tableau"],[147,"Java"],[147,"PostgreSQL"],[256,"Tableau"],[102,"DataAnalysis"]]}}
{"mysql": ["Create table If Not Exists Candidates (candidate_id int, skill varchar(30))"], "mssql": ["Create table Candidates (candidate_id int, skill varchar(30))"], "oraclesql": ["Create table Candidates (candidate_id int, skill varchar(30))"], "database": true, "name": "find_candidates", "pythondata": ["Candidates =...
{"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']
3,052
Maximize Items
maximize-items
null
Hard
1.4K
1.8K
1,363
1,822
74.8%
[]
['Create table If Not Exists Inventory ( item_id int, item_type varchar(50), item_category varchar(50), square_footage decimal(10,2))', 'Truncate table Inventory', "insert into Inventory (item_id, item_type, item_category, square_footage) values ('1374', 'prime_eligible', 'Watches', '68.0')", "insert into Inventory (it...
Database
null
{"headers":{"Inventory":["item_id","item_type","item_category","square_footage"]},"rows":{"Inventory":[[1374,"prime_eligible","Watches",68.00],[4245,"not_prime","Art",26.40],[5743,"prime_eligible","Software",325.00],[8543,"not_prime","Clothing",64.50],[2556,"not_prime","Shoes",15.00],[2452,"prime_eligible","Scientific"...
{"mysql": ["Create table If Not Exists Inventory ( item_id int, item_type varchar(50), item_category varchar(50), square_footage decimal(10,2))"], "mssql": ["Create table Inventory ( item_id int, item_type varchar(50), item_category varchar(50), square_footage decimal(10,2))"], "oraclesql": ["Create table Inventory ( ...
{"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']
3,053
Classifying Triangles by Lengths
classifying-triangles-by-lengths
null
Easy
2.7K
5.3K
2,674
5,291
50.5%
[]
['Create table If Not Exists Triangles (A int, B int, C int)', 'Truncate table Triangles', "insert into Triangles (A, B, C) values ('20', '20', '23')", "insert into Triangles (A, B, C) values ('20', '20', '20')", "insert into Triangles (A, B, C) values ('20', '21', '22')", "insert into Triangles (A, B, C) values ('13',...
Database
null
{"headers":{"Triangles":["A","B","C"]},"rows":{"Triangles":[[20,20,23],[20,20,20],[20,21,22],[13,14,30]]}}
{"mysql": ["Create table If Not Exists Triangles (A int, B int, C int)"], "mssql": ["Create table Triangles (A int, B int, C int)"], "oraclesql": ["Create table Triangles (A int, B int, C int)"], "database": true, "name": "type_of_triangle", "pythondata": ["Triangles = pd.DataFrame([], columns=['A', 'B', 'C']).astype({...
{"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']
3,054
Binary Tree Nodes
binary-tree-nodes
null
Medium
2.8K
3.5K
2,780
3,513
79.1%
[]
['Create table If Not Exists Tree (N int,P int)', 'Truncate table Tree', "insert into Tree (N, P) values ('1', '2')", "insert into Tree (N, P) values ('3', '2')", "insert into Tree (N, P) values ('6', '8')", "insert into Tree (N, P) values ('9', '8')", "insert into Tree (N, P) values ('2', '5')", "insert into Tree (N, ...
Database
null
{"headers":{"Tree":["N","P"]},"rows":{"Tree":[[1,2],[3,2],[6,8],[9,8],[2,5],[8,5],[5,null]]}}
{"mysql": ["Create table If Not Exists Tree (N int,P int)"], "mssql": ["Create table Tree (N int,P int)"], "oraclesql": ["Create table Tree (N int,P int)"], "database": true, "name": "binary_tree_nodes", "pythondata": ["Tree = pd.DataFrame([], columns=['N', 'P']).astype({'N':'Int64', 'P':'Int64'})"], "postgresql": ["Cr...
{"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']
3,055
Top Percentile Fraud
top-percentile-fraud
null
Medium
2.2K
3.9K
2,250
3,851
58.4%
[]
['Create table If Not Exists Fraud (policy_id int, state varchar(50), fraud_score decimal(5,2))', 'Truncate table Fraud', "insert into Fraud (policy_id, state, fraud_score) values ('1', 'California', '0.92')", "insert into Fraud (policy_id, state, fraud_score) values ('2', 'California', '0.68')", "insert into Fraud (po...
Database
null
{"headers":{"Fraud":["policy_id","state","fraud_score"]},"rows":{"Fraud":[[1,"California",0.92],[2,"California",0.68],[3,"California",0.17],[4,"New York",0.94],[5,"New York",0.81],[6,"New York",0.77],[7,"Texas",0.98],[8,"Texas",0.97],[9,"Texas",0.96],[10,"Florida",0.97],[11,"Florida",0.98],[12,"Florida",0.78],[13,"Flor...
{"mysql": ["Create table If Not Exists Fraud (policy_id int, state varchar(50), fraud_score decimal(5,2))"], "mssql": ["Create table Fraud (policy_id int, state varchar(50), fraud_score decimal(5,2))"], "oraclesql": ["Create table Fraud (policy_id int, state varchar(50), fraud_score decimal(10,2))"], "database": true,...
{"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']
3,056
Snaps Analysis
snaps-analysis
null
Medium
2.4K
4.1K
2,381
4,073
58.5%
[]
["Create table if Not Exists Activities(activity_id int, user_id int, activity_type ENUM('send', 'open'), time_spent decimal(5,2))", "Create table if not Exists Age( user_id int, age_bucket ENUM('21-25','26-30','31-35'))", 'Truncate table Activities', "insert into Activities (activity_id, user_id, activity_type, time_s...
Database
null
{"headers":{"Activities":["activity_id","user_id","activity_type","time_spent"],"Age":["user_id","age_bucket"]},"rows":{"Activities":[[7274,123,"open",4.50],[2425,123,"send",3.50],[1413,456,"send",5.67],[2536,456,"open",3.00],[8564,456,"send",8.24],[5235,789,"send",6.24],[4251,123,"open",1.25],[1435,789,"open",5.25]],"...
{"mysql": ["Create table if Not Exists Activities(activity_id int, user_id int, activity_type ENUM('send', 'open'), time_spent decimal(5,2))", "Create table if not Exists Age( user_id int, age_bucket ENUM('21-25','26-30','31-35'))"], "mssql": ["Create table Activities (activity_id int, user_id int, activity_type varcha...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
3,057
Employees Project Allocation
employees-project-allocation
null
Hard
1.7K
2.5K
1,717
2,500
68.7%
[]
['Create table If Not Exists Project (project_id int, employee_id int, workload int)', 'Create table If Not Exists Employees (employee_id int, name varchar(20), team varchar(20))', 'Truncate table Project', "insert into Project (project_id, employee_id, workload) values ('1', '1', '45')", "insert into Project (project_...
Database
null
{"headers":{"Project":["project_id","employee_id","workload"],"Employees":["employee_id","name","team"]},"rows":{"Project":[[1,1,45],[1,2,90],[2,3,12],[2,4,68]],"Employees":[[1,"Khaled","A"],[2,"Ali","B"],[3,"John","B"],[4,"Doe","A"]]}}
{"mysql": ["Create table If Not Exists Project (project_id int, employee_id int, workload int)", "Create table If Not Exists Employees (employee_id int, name varchar(20), team varchar(20))"], "mssql": ["Create table Project (project_id int, employee_id int, workload int)", "Create table Employees (employee_id int, name...
{"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']
3,058
Friends With No Mutual Friends
friends-with-no-mutual-friends
null
Medium
2.1K
4.3K
2,083
4,292
48.5%
[]
['Create Table if Not Exists Friends( user_id1 int, user_id2 int)', 'Truncate table Friends', "insert into Friends (user_id1, user_id2) values ('1', '2')", "insert into Friends (user_id1, user_id2) values ('2', '3')", "insert into Friends (user_id1, user_id2) values ('2', '4')", "insert into Friends (user_id1, user_id2...
Database
null
{"headers":{"Friends":["user_id1","user_id2"]},"rows":{"Friends":[[1,2],[2,3],[2,4],[1,5],[6,7],[3,4],[2,5],[8,9]]}}
{"mysql": ["Create Table if Not Exists Friends( user_id1 int, user_id2 int)"], "mssql": ["Create Table Friends( user_id1 int, user_id2 int)"], "oraclesql": ["Create Table Friends( user_id1 int, user_id2 int)"], "database": true, "name": "friends_with_no_mutual_friends", "pythondata": ["Friends = pd.DataFrame([], column...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
3,059
Find All Unique Email Domains
find-all-unique-email-domains
null
Easy
2.9K
4.2K
2,935
4,178
70.2%
[]
['Create table If Not Exists Emails (id int, email varchar(255))', 'Truncate table Emails', "insert into Emails (id, email) values ('336', 'hwkiy@test.edu')", "insert into Emails (id, email) values ('489', 'adcmaf@outlook.com')", "insert into Emails (id, email) values ('449', 'vrzmwyum@yahoo.com')", "insert into Emails...
Database
null
{"headers":{"Emails":["id","email"]},"rows":{"Emails":[[336,"hwkiy@test.edu"],[489,"adcmaf@outlook.com"],[449,"vrzmwyum@yahoo.com"],[95,"tof@test.edu"],[320,"jxhbagkpm@example.org"],[411,"zxcf@outlook.com"]]}}
{"mysql": ["Create table If Not Exists Emails (id int, email varchar(255))"], "mssql": ["Create table Emails (id int, email varchar(255))"], "oraclesql": ["Create table Emails (id int, email varchar(255))"], "database": true, "name": "find_unique_email_domains", "postgresql": ["CREATE TABLE Emails (\n id INT,\n e...
{"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']
3,060
User Activities within Time Bounds
user-activities-within-time-bounds
null
Hard
1.6K
4.1K
1,611
4,074
39.5%
[]
["Create table If Not Exists Sessions (user_id int, session_start datetime, session_end datetime, session_id int, session_type ENUM('Viewer','Streamer'))", 'Truncate table Sessions', "insert into Sessions (user_id, session_start, session_end, session_id, session_type) values ('101', '2023-11-01 08:00:00', '2023-11-01 0...
Database
null
{"headers":{"Sessions":["user_id","session_start","session_end","session_id","session_type"]},"rows":{"Sessions":[[101,"2023-11-01 08:00:00","2023-11-01 09:00:00",1,"Viewer"],[101,"2023-11-01 10:00:00","2023-11-01 11:00:00",2,"Streamer"],[102,"2023-11-01 13:00:00","2023-11-01 14:00:00",3,"Viewer"],[102,"2023-11-01 15:0...
{"mysql": ["Create table If Not Exists Sessions (user_id int, session_start datetime, session_end datetime, session_id int, session_type ENUM('Viewer','Streamer'))"], "mssql": ["Create table Sessions (user_id int, session_start datetime, session_end datetime, session_id int, session_type varchar(20) NOT NULL CHECK (ses...
{"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']
3,061
Calculate Trapping Rain Water
calculate-trapping-rain-water
null
Hard
1.2K
1.4K
1,183
1,441
82.1%
[]
['Create Table if not Exists Heights(id int, height int)', 'Truncate table Heights', "insert into Heights (id, height) values ('1', '0')", "insert into Heights (id, height) values ('2', '1')", "insert into Heights (id, height) values ('3', '0')", "insert into Heights (id, height) values ('4', '2')", "insert into Height...
Database
null
{"headers":{"Heights":["id","height"]},"rows":{"Heights":[[1,0],[2,1],[3,0],[4,2],[5,1],[6,0],[7,1],[8,3],[9,2],[10,1],[11,2],[12,1]]}}
{"mysql": ["Create Table if not Exists Heights(id int, height int)"], "mssql": ["Create Table Heights(id int,height int)"], "oraclesql": ["Create Table Heights(id int,height int)"], "database": true, "name": "calculate_trapped_rain_water", "postgresql": ["CREATE TABLE Heights(\n id int,\n height int\n);\n"], "pyt...
{"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']
3,062
Winner of the Linked List Game
winner-of-the-linked-list-game
null
Easy
10.4K
13.1K
10,369
13,127
79.0%
[]
[]
Algorithms
null
[2,1]
{ "name": "gameResult", "params": [ { "name": "head", "type": "ListNode" } ], "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...
['Linked List']
3,063
Linked List Frequency
linked-list-frequency
null
Easy
12.5K
14.5K
12,458
14,540
85.7%
['top-k-frequent-elements']
[]
Algorithms
null
[1,1,2,1,2,3]
{ "name": "frequenciesOfElements", "params": [ { "name": "head", "type": "ListNode" } ], "return": { "type": "ListNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Linked List', 'Counting']
3,064
Guess the Number Using Bitwise Questions I
guess-the-number-using-bitwise-questions-i
null
Medium
1.8K
2K
1,787
1,983
90.1%
[]
[]
Algorithms
null
31
{ "name": "guessNumber", "params": [ { "type": "integer", "name": "n" } ], "return": { "type": "integer" }, "manual": true, "manual": true, "typescriptCustomType": "function commonSetBits(num: number): number {\n let x = num & __pick__;\n let count = 0;\n while (x > 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...
['Bit Manipulation', 'Interactive']
3,065
Minimum Operations to Exceed Threshold Value I
minimum-operations-to-exceed-threshold-value-i
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>, and an integer <code>k</code>.</p> <p>In one operation, you can remove one occurrence of the smallest element of <code>nums</code>.</p> <p>Return <em>the <strong>minimum</strong> number of operations needed so that all elements of the arra...
Easy
82.1K
95.6K
82,132
95,648
85.9%
['search-insert-position', 'majority-element', 'number-of-employees-who-met-the-target']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "...
[2,11,10,1,3] 10
{ "name": "minOperations", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array']
3,066
Minimum Operations to Exceed Threshold Value II
minimum-operations-to-exceed-threshold-value-ii
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>, and an integer <code>k</code>.</p> <p>You are allowed to perform some operations on <code>nums</code>, where in a single operation, you can:</p> <ul> <li>Select the two <strong>smallest</strong> integers <code>x</code> and <code>y</code> ...
Medium
183.1K
400.8K
183,148
400,832
45.7%
['minimum-operations-to-halve-array-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "...
[2,11,10,1,3] 10
{ "name": "minOperations", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Heap (Priority Queue)', 'Simulation']
3,067
Count Pairs of Connectable Servers in a Weighted Tree Network
count-pairs-of-connectable-servers-in-a-weighted-tree-network
<p>You are given an unrooted weighted tree with <code>n</code> vertices representing servers numbered from <code>0</code> to <code>n - 1</code>, an array <code>edges</code> where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>, weight<sub>i</sub>]</code> represents a bidirectional edge between vertices <code>a<sub>i</su...
Medium
14.2K
26.3K
14,153
26,307
53.8%
['minimum-height-trees', 'sum-of-distances-in-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> countPairsOfConnectableServers(vector<vector<int>>& edges, int signalSpeed) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] countPairsOfConnectableServers(int[][] ed...
[[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]] 1
{ "name": "countPairsOfConnectableServers", "params": [ { "name": "edges", "type": "integer[][]" }, { "type": "integer", "name": "signalSpeed" } ], "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', 'Tree', 'Depth-First Search']
3,068
Find the Maximum Sum of Node Values
find-the-maximum-sum-of-node-values
<p>There exists an <strong>undirected</strong> tree with <code>n</code> nodes numbered <code>0</code> to <code>n - 1</code>. You are given a <strong>0-indexed</strong> 2D integer array <code>edges</code> of length <code>n - 1</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> indicates that there is a...
Hard
73.3K
112.4K
73,319
112,431
65.2%
['maximum-score-after-applying-operations-on-a-tree', 'find-number-of-coins-to-place-in-tree-nodes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maximumValueSum(vector<int>& nums, int k, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maximumValueSum(int[] nums, int k, int[][] edges) ...
[1,2,1] 3 [[0,1],[0,2]]
{ "name": "maximumValueSum", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" }, { "type": "integer[][]", "name": "edges" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Bit Manipulation', 'Tree', 'Sorting']
3,069
Distribute Elements Into Two Arrays I
distribute-elements-into-two-arrays-i
<p>You are given a <strong>1-indexed</strong> array of <strong>distinct</strong> integers <code>nums</code> of length <code>n</code>.</p> <p>You need to distribute all the elements of <code>nums</code> between two arrays <code>arr1</code> and <code>arr2</code> using <code>n</code> operations. In the first operation, a...
Easy
52K
71.5K
52,027
71,494
72.8%
['split-array-largest-sum', 'divide-array-into-equal-pairs']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] resultArray(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[2,1,3]
{ "name": "resultArray", "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', 'Simulation']
3,070
Count Submatrices with Top-Left Element and Sum Less Than k
count-submatrices-with-top-left-element-and-sum-less-than-k
<p>You are given a <strong>0-indexed</strong> integer matrix <code>grid</code> and an integer <code>k</code>.</p> <p>Return <em>the <strong>number</strong> of <span data-keyword="submatrix">submatrices</span> that contain the top-left element of the</em> <code>grid</code>, <em>and have a sum less than or equal to </em...
Medium
28.1K
49.4K
28,139
49,432
56.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countSubmatrices(vector<vector<int>>& grid, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countSubmatrices(int[][] grid, int k) {\n \n }\n}"}, {"value": "py...
[[7,6,3],[6,6,1]] 18
{ "name": "countSubmatrices", "params": [ { "name": "grid", "type": "integer[][]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix', 'Prefix Sum']
3,071
Minimum Operations to Write the Letter Y on a Grid
minimum-operations-to-write-the-letter-y-on-a-grid
<p>You are given a <strong>0-indexed</strong> <code>n x n</code> grid where <code>n</code> is odd, and <code>grid[r][c]</code> is <code>0</code>, <code>1</code>, or <code>2</code>.</p> <p>We say that a cell belongs to the Letter <strong>Y</strong> if it belongs to one of the following:</p> <ul> <li>The diagonal star...
Medium
22.9K
37.5K
22,916
37,461
61.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumOperationsToWriteY(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumOperationsToWriteY(int[][] grid) {\n \n }\n}"}, {"value":...
[[1,2,2],[1,1,0],[0,1,0]]
{ "name": "minimumOperationsToWriteY", "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', 'Hash Table', 'Matrix', 'Counting']
3,072
Distribute Elements Into Two Arrays II
distribute-elements-into-two-arrays-ii
<p>You are given a <strong>1-indexed</strong> array of integers <code>nums</code> of length <code>n</code>.</p> <p>We define a function <code>greaterCount</code> such that <code>greaterCount(arr, val)</code> returns the number of elements in <code>arr</code> that are <strong>strictly greater</strong> than <code>val</c...
Hard
12.4K
42.6K
12,378
42,646
29.0%
['split-array-largest-sum', 'divide-array-into-equal-pairs']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> resultArray(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] resultArray(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[2,1,3,3]
{ "name": "resultArray", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Indexed Tree', 'Segment Tree', 'Simulation']
3,073
Maximum Increasing Triplet Value
maximum-increasing-triplet-value
null
Medium
1.1K
3K
1,074
3,039
35.3%
[]
[]
Algorithms
null
[5,6,9]
{ "name": "maximumTripletValue", "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', 'Ordered Set']
3,074
Apple Redistribution into Boxes
apple-redistribution-into-boxes
<p>You are given an array <code>apple</code> of size <code>n</code> and an array <code>capacity</code> of size <code>m</code>.</p> <p>There are <code>n</code> packs where the <code>i<sup>th</sup></code> pack contains <code>apple[i]</code> apples. There are <code>m</code> boxes as well, and the <code>i<sup>th</sup></co...
Easy
56.1K
82.6K
56,055
82,623
67.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumBoxes(vector<int>& apple, vector<int>& capacity) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumBoxes(int[] apple, int[] capacity) {\n \n }\n}"}, {"va...
[1,3,2] [4,3,1,5,2]
{ "name": "minimumBoxes", "params": [ { "name": "apple", "type": "integer[]" }, { "type": "integer[]", "name": "capacity" } ], "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']
3,075
Maximize Happiness of Selected Children
maximize-happiness-of-selected-children
<p>You are given an array <code>happiness</code> of length <code>n</code>, and a <strong>positive</strong> integer <code>k</code>.</p> <p>There are <code>n</code> children standing in a queue, where the <code>i<sup>th</sup></code> child has <strong>happiness value</strong> <code>happiness[i]</code>. You want to select...
Medium
179.2K
326.9K
179,153
326,913
54.8%
['maximum-candies-allocated-to-k-children']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maximumHappinessSum(vector<int>& happiness, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maximumHappinessSum(int[] happiness, int k) {\n \n }\n}"}, ...
[1,2,3] 2
{ "name": "maximumHappinessSum", "params": [ { "name": "happiness", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
3,076
Shortest Uncommon Substring in an Array
shortest-uncommon-substring-in-an-array
<p>You are given an array <code>arr</code> of size <code>n</code> consisting of <strong>non-empty</strong> strings.</p> <p>Find a string array <code>answer</code> of size <code>n</code> such that:</p> <ul> <li><code>answer[i]</code> is the <strong>shortest</strong> <span data-keyword="substring">substring</span> of ...
Medium
27.8K
58.7K
27,840
58,720
47.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> shortestSubstrings(vector<string>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String[] shortestSubstrings(String[] arr) {\n \n }\n}"}, {"value": "py...
["cab","ad","bad","c"]
{ "name": "shortestSubstrings", "params": [ { "name": "arr", "type": "string[]" } ], "return": { "type": "string[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Trie']
3,077
Maximum Strength of K Disjoint Subarrays
maximum-strength-of-k-disjoint-subarrays
<p>You are given an array of integers <code>nums</code> with length <code>n</code>, and a positive <strong>odd</strong> integer <code>k</code>.</p> <p>Select exactly <b><code>k</code></b> disjoint <span data-keyword="subarray-nonempty">subarrays</span> <b><code>sub<sub>1</sub>, sub<sub>2</sub>, ..., sub<sub>k</sub></c...
Hard
7.2K
27K
7,162
26,980
26.5%
['partition-array-into-disjoint-intervals', 'maximum-strength-of-a-group']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maximumStrength(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maximumStrength(int[] nums, int k) {\n \n }\n}"}, {"value": "python"...
[1,2,3,-1,2] 3
{ "name": "maximumStrength", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Prefix Sum']
3,078
Match Alphanumerical Pattern in Matrix I
match-alphanumerical-pattern-in-matrix-i
null
Medium
992
1.6K
992
1,559
63.6%
[]
[]
Algorithms
null
[[1,2,2],[2,2,3],[2,3,3]] ["ab","bb"]
{ "name": "findPattern", "params": [ { "name": "board", "type": "integer[][]" }, { "type": "string[]", "name": "pattern" } ], "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', 'String', 'Matrix']
3,079
Find the Sum of Encrypted Integers
find-the-sum-of-encrypted-integers
<p>You are given an integer array <code>nums</code> containing <strong>positive</strong> integers. We define a function <code>encrypt</code> such that <code>encrypt(x)</code> replaces <strong>every</strong> digit in <code>x</code> with the <strong>largest</strong> digit in <code>x</code>. For example, <code>encrypt(523...
Easy
53K
72.3K
53,017
72,315
73.3%
['encrypt-and-decrypt-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumOfEncryptedInt(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumOfEncryptedInt(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,2,3]
{ "name": "sumOfEncryptedInt", "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']
3,080
Mark Elements on Array by Performing Queries
mark-elements-on-array-by-performing-queries
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> of size <code>n</code> consisting of positive integers.</p> <p>You are also given a 2D array <code>queries</code> of size <code>m</code> where <code>queries[i] = [index<sub>i</sub>, k<sub>i</sub>]</code>.</p> <p>Initially all elements of the array ...
Medium
19.9K
42K
19,929
42,036
47.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long[] unmarkedSumArray(int[] nums, int[][] queries...
[1,2,2,1,2,3,1] [[1,2],[3,3],[4,2]]
{ "name": "unmarkedSumArray", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[][]", "name": "queries" } ], "return": { "type": "long[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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)', 'Simulation']
3,081
Replace Question Marks in String to Minimize Its Value
replace-question-marks-in-string-to-minimize-its-value
<p>You are given a string <code>s</code>. <code>s[i]</code> is either a lowercase English letter or <code>&#39;?&#39;</code>.</p> <p>For a string <code>t</code> having length <code>m</code> containing <strong>only</strong> lowercase English letters, we define the function <code>cost(i)</code> for an index <code>i</cod...
Medium
15.3K
55.4K
15,283
55,425
27.6%
['lexicographically-smallest-string-after-substring-operation']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string minimizeStringValue(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String minimizeStringValue(String s) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"???"
{ "name": "minimizeStringValue", "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...
['Hash Table', 'String', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'Counting']
3,082
Find the Sum of the Power of All Subsequences
find-the-sum-of-the-power-of-all-subsequences
<p>You are given an integer array <code>nums</code> of length <code>n</code> and a <strong>positive</strong> integer <code>k</code>.</p> <p>The <strong>power</strong> of an array of integers is defined as the number of <span data-keyword="subsequence-array">subsequences</span> with their sum <strong>equal</strong> to ...
Hard
8.3K
22.9K
8,277
22,882
36.2%
['number-of-subsequences-that-satisfy-the-given-sum-condition']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumOfPower(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumOfPower(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,2,3] 3
{ "name": "sumOfPower", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
3,083
Existence of a Substring in a String and Its Reverse
existence-of-a-substring-in-a-string-and-its-reverse
<p>Given a<strong> </strong>string <code>s</code>, find any <span data-keyword="substring">substring</span> of length <code>2</code> which is also present in the reverse of <code>s</code>.</p> <p>Return <code>true</code><em> if such a substring exists, and </em><code>false</code><em> otherwise.</em></p> <p>&nbsp;</p>...
Easy
50.1K
76.6K
50,117
76,557
65.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isSubstringPresent(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isSubstringPresent(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
"leetcode"
{ "name": "isSubstringPresent", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String']
3,084
Count Substrings Starting and Ending with Given Character
count-substrings-starting-and-ending-with-given-character
<p>You are given a string <code>s</code> and a character <code>c</code>. Return <em>the total number of <span data-keyword="substring-nonempty">substrings</span> of </em><code>s</code><em> that start and end with </em><code>c</code><em>.</em></p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div c...
Medium
40.8K
83.8K
40,838
83,834
48.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countSubstrings(string s, char c) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countSubstrings(String s, char c) {\n \n }\n}"}, {"value": "python", "text":...
"abada" "a"
{ "name": "countSubstrings", "params": [ { "name": "s", "type": "string" }, { "type": "character", "name": "c" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Counting']
3,085
Minimum Deletions to Make String K-Special
minimum-deletions-to-make-string-k-special
<p>You are given a string <code>word</code> and an integer <code>k</code>.</p> <p>We consider <code>word</code> to be <strong>k-special</strong> if <code>|freq(word[i]) - freq(word[j])| &lt;= k</code> for all indices <code>i</code> and <code>j</code> in the string.</p> <p>Here, <code>freq(x)</code> denotes the <span ...
Medium
22.2K
50.1K
22,158
50,140
44.2%
['minimum-deletions-to-make-character-frequencies-unique']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumDeletions(string word, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumDeletions(String word, int k) {\n \n }\n}"}, {"value": "python", "text": ...
"aabcaba" 0
{ "name": "minimumDeletions", "params": [ { "name": "word", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Greedy', 'Sorting', 'Counting']
3,086
Minimum Moves to Pick K Ones
minimum-moves-to-pick-k-ones
<p>You are given a binary array <code>nums</code> of length <code>n</code>, a <strong>positive</strong> integer <code>k</code> and a <strong>non-negative</strong> integer <code>maxChanges</code>.</p> <p>Alice plays a game, where the goal is for Alice to pick up <code>k</code> ones from <code>nums</code> using the <str...
Hard
3.6K
17.5K
3,599
17,452
20.6%
['minimum-swaps-to-group-all-1s-together']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long minimumMoves(vector<int>& nums, int k, int maxChanges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long minimumMoves(int[] nums, int k, int maxChanges) {\n \n ...
[1,1,0,0,0,1,1,0,0,1] 3 1
{ "name": "minimumMoves", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" }, { "type": "integer", "name": "maxChanges" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Sliding Window', 'Prefix Sum']
3,087
Find Trending Hashtags
find-trending-hashtags
null
Medium
1.9K
3K
1,864
3,031
61.5%
[]
['Create table If Not Exists Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))', 'Truncate table Tweets', "insert into Tweets (user_id, tweet_id, tweet, tweet_date) values ('135', '13', 'Enjoying a great start to the day. #HappyDay', '2024-02-01')", "insert into Tweets (user_id, tweet_id, tweet, ...
Database
null
{"headers":{"Tweets":["user_id","tweet_id","tweet","tweet_date"]},"rows":{"Tweets":[[135,13,"Enjoying a great start to the day. #HappyDay","2024-02-01"],[136,14,"Another #HappyDay with good ","2024-02-03"],[137,15,"Productivity peaks! #WorkLife","2024-02-04"],[138,16,"Exploring new tech frontiers. #TechLife","2024-02-0...
{"mysql": ["Create table If Not Exists Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))"], "mssql": ["Create table Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))"], "oraclesql": ["Create table Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))", "A...
{"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']
3,088
Make String Anti-palindrome
make-string-anti-palindrome
null
Hard
623
1.5K
623
1,477
42.2%
[]
[]
Algorithms
null
"abca"
{ "name": "makeAntiPalindrome", "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', 'Greedy', 'Sorting', 'Counting Sort']
3,089
Find Bursty Behavior
find-bursty-behavior
null
Medium
1.6K
4K
1,563
3,991
39.2%
[]
['Create table If Not Exists Posts (post_id int, user_id int, post_date date)', 'Truncate table Posts', "insert into Posts (post_id, user_id, post_date) values ('1', '1', '2024-02-27')", "insert into Posts (post_id, user_id, post_date) values ('2', '5', '2024-02-06')", "insert into Posts (post_id, user_id, post_date) ...
Database
null
{"headers": {"Posts": ["post_id", "user_id", "post_date"]}, "rows": {"Posts": [[1, 1, "2024-02-27"], [2, 5, "2024-02-06"], [3, 3, "2024-02-25"], [4, 3, "2024-02-14"], [5, 3, "2024-02-06"], [6, 2, "2024-02-25"]]}}
{"mysql": ["Create table If Not Exists Posts (post_id int, user_id int, post_date date)"], "mssql": ["Create table Posts (post_id int, user_id int, post_date date)"], "oraclesql": ["Create table Posts (post_id int, user_id int, post_date date)", "ALTER SESSION SET nls_date_format='YYYY-MM-DD'"], "database": true, "n...
{"mysql": ["MySQL", "<p><code>MySQL 8.0</code>.</p>"], "mssql": ["MS SQL Server", "<p><code>mssql server 2019</code>.</p>"], "oraclesql": ["Oracle", "<p><code>Oracle Sql 11.2</code>.</p>"], "pythondata": ["Pandas", "<p>Python 3.10 with Pandas 2.2.2 and NumPy 1.26.4</p>"], "postgresql": ["PostgreSQL", "<p>PostgreSQL 16<...
['Database']
3,090
Maximum Length Substring With Two Occurrences
maximum-length-substring-with-two-occurrences
Given a string <code>s</code>, return the <strong>maximum</strong> length of a <span data-keyword="substring">substring</span>&nbsp;such that it contains <em>at most two occurrences</em> of each character. <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <div class="example-block"> <p><strong>Input:</s...
Easy
49.6K
78.6K
49,599
78,618
63.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximumLengthSubstring(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximumLengthSubstring(String s) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"bcbbbcba"
{ "name": "maximumLengthSubstring", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Sliding Window']
3,091
Apply Operations to Make Sum of Array Greater Than or Equal to k
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k
<p>You are given a <strong>positive</strong> integer <code>k</code>. Initially, you have an array <code>nums = [1]</code>.</p> <p>You can perform <strong>any</strong> of the following operations on the array <strong>any</strong> number of times (<strong>possibly zero</strong>):</p> <ul> <li>Choose any element in the...
Medium
29.7K
68.7K
29,660
68,654
43.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
11
{ "name": "minOperations", "params": [ { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Greedy', 'Enumeration']
3,092
Most Frequent IDs
most-frequent-ids
<p>The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, <code>nums</code> and <code>freq</code>, of equal length <code>n</code>. Each element in <code>nums</code> represents an ID, and the corresponding element in <code>freq</code> indicates how many ti...
Medium
21.9K
52.9K
21,888
52,933
41.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<long long> mostFrequentIDs(vector<int>& nums, vector<int>& freq) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long[] mostFrequentIDs(int[] nums, int[] freq) {\n \n ...
[2,3,2,1] [3,2,-3,1]
{ "name": "mostFrequentIDs", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "freq" } ], "return": { "type": "long[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Heap (Priority Queue)', 'Ordered Set']
3,093
Longest Common Suffix Queries
longest-common-suffix-queries
<p>You are given two arrays of strings <code>wordsContainer</code> and <code>wordsQuery</code>.</p> <p>For each <code>wordsQuery[i]</code>, you need to find a string from <code>wordsContainer</code> that has the <strong>longest common suffix</strong> with <code>wordsQuery[i]</code>. If there are two or more strings in...
Hard
11.8K
32K
11,753
31,995
36.7%
['longest-common-prefix', 'find-the-length-of-the-longest-common-prefix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> stringIndices(vector<string>& wordsContainer, vector<string>& wordsQuery) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] stringIndices(String[] wordsContainer, Stri...
["abcd","bcd","xbcd"] ["cd","bcd","xyz"]
{ "name": "stringIndices", "params": [ { "name": "wordsContainer", "type": "string[]" }, { "type": "string[]", "name": "wordsQuery" } ], "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']
3,094
Guess the Number Using Bitwise Questions II
guess-the-number-using-bitwise-questions-ii
null
Medium
798
961
798
961
83.0%
[]
[]
Algorithms
null
31
{ "name": "foobar", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" }, "manual": true, "typescriptCustomType": "function commonBits(num: number): number {\n let x = num ^ __pick__ ^ 1073741823;\n let count = 0;\n while (x > 0) {\n cou...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Interactive']
3,095
Shortest Subarray With OR at Least K I
shortest-subarray-with-or-at-least-k-i
<p>You are given an array <code>nums</code> of <strong>non-negative</strong> integers and an integer <code>k</code>.</p> <p>An array is called <strong>special</strong> if the bitwise <code>OR</code> of all of its elements is <strong>at least</strong> <code>k</code>.</p> <p>Return <em>the length of the <strong>shortes...
Easy
33.5K
78.9K
33,486
78,896
42.4%
['minimum-size-subarray-sum', 'shortest-subarray-with-sum-at-least-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumSubarrayLength(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumSubarrayLength(int[] nums, int k) {\n \n }\n}"}, {"value": "py...
[1,2,3] 2
{ "name": "minimumSubarrayLength", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Sliding Window']
3,096
Minimum Levels to Gain More Points
minimum-levels-to-gain-more-points
<p>You are given a binary array <code>possible</code> of length <code>n</code>.</p> <p>Alice and Bob are playing a game that consists of <code>n</code> levels. Some of the levels in the game are <strong>impossible</strong> to clear while others can <strong>always</strong> be cleared. In particular, if <code>possible[i...
Medium
24.4K
62.7K
24,364
62,712
38.9%
['minimum-rounds-to-complete-all-tasks']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumLevels(vector<int>& possible) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumLevels(int[] possible) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,0,1,0]
{ "name": "minimumLevels", "params": [ { "name": "possible", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Prefix Sum']
3,097
Shortest Subarray With OR at Least K II
shortest-subarray-with-or-at-least-k-ii
<p>You are given an array <code>nums</code> of <strong>non-negative</strong> integers and an integer <code>k</code>.</p> <p>An array is called <strong>special</strong> if the bitwise <code>OR</code> of all of its elements is <strong>at least</strong> <code>k</code>.</p> <p>Return <em>the length of the <strong>shortes...
Medium
95.8K
190.7K
95,832
190,705
50.3%
['maximum-size-subarray-sum-equals-k', 'shortest-subarray-with-sum-at-least-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumSubarrayLength(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumSubarrayLength(int[] nums, int k) {\n \n }\n}"}, {"value": "py...
[1,2,3] 2
{ "name": "minimumSubarrayLength", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Sliding Window']
3,098
Find the Sum of Subsequence Powers
find-the-sum-of-subsequence-powers
<p>You are given an integer array <code>nums</code> of length <code>n</code>, and a <strong>positive</strong> integer <code>k</code>.</p> <p>The <strong>power</strong> of a <span data-keyword="subsequence-array">subsequence</span> is defined as the <strong>minimum</strong> absolute difference between <strong>any</stro...
Hard
5.7K
24.7K
5,717
24,715
23.1%
['number-of-subsequences-that-satisfy-the-given-sum-condition', 'closest-subsequence-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumOfPowers(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumOfPowers(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,2,3,4] 3
{ "name": "sumOfPowers", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Sorting']
3,099
Harshad Number
harshad-number
<p>An integer divisible by the <strong>sum</strong> of its digits is said to be a <strong>Harshad</strong> number. You are given an integer <code>x</code>. Return<em> the sum of the digits </em>of<em> </em><code>x</code><em> </em>if<em> </em><code>x</code><em> </em>is a <strong>Harshad</strong> number, otherwise, retur...
Easy
79.5K
95.8K
79,544
95,783
83.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumOfTheDigitsOfHarshadNumber(int x) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumOfTheDigitsOfHarshadNumber(int x) {\n \n }\n}"}, {"value": "python", "text": ...
18
{ "name": "sumOfTheDigitsOfHarshadNumber", "params": [ { "name": "x", "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']
3,100
Water Bottles II
water-bottles-ii
<p>You are given two integers <code>numBottles</code> and <code>numExchange</code>.</p> <p><code>numBottles</code> represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations:</p> <ul> <li>Drink any number of full water bottles turning them i...
Medium
37.5K
60.5K
37,539
60,485
62.1%
['water-bottles']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxBottlesDrunk(int numBottles, int numExchange) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxBottlesDrunk(int numBottles, int numExchange) {\n \n }\n}"}, {"va...
13 6
{ "name": "maxBottlesDrunk", "params": [ { "name": "numBottles", "type": "integer" }, { "type": "integer", "name": "numExchange" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Simulation']
3,101
Count Alternating Subarrays
count-alternating-subarrays
<p>You are given a <span data-keyword="binary-array">binary array</span> <code>nums</code>.</p> <p>We call a <span data-keyword="subarray-nonempty">subarray</span> <strong>alternating</strong> if <strong>no</strong> two <strong>adjacent</strong> elements in the subarray have the <strong>same</strong> value.</p> <p>Re...
Medium
39.6K
69.6K
39,553
69,595
56.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countAlternatingSubarrays(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countAlternatingSubarrays(int[] nums) {\n \n }\n}"}, {"value": "p...
[0,1,1,1]
{ "name": "countAlternatingSubarrays", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
3,102
Minimize Manhattan Distances
minimize-manhattan-distances
<p>You are given an array <code>points</code> representing integer coordinates of some points on a 2D plane, where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>.</p> <p>The distance between two points is defined as their <span data-keyword="manhattan-distance">Manhattan distance</span>.</p> <p>Return <em>th...
Hard
9.4K
30.2K
9,446
30,241
31.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumDistance(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumDistance(int[][] points) {\n \n }\n}"}, {"value": "python", "text...
[[3,10],[5,15],[10,2],[4,4]]
{ "name": "minimumDistance", "params": [ { "name": "points", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Geometry', 'Sorting', 'Ordered Set']
3,103
Find Trending Hashtags II
find-trending-hashtags-ii
null
Hard
1.1K
1.6K
1,076
1,638
65.7%
[]
['Create table If Not Exists Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))', 'Truncate table Tweets', "insert into Tweets (user_id, tweet_id, tweet, tweet_date) values ('135', '13', 'Enjoying a great start to the day. #HappyDay #MorningVibes', '2024-02-01')", "insert into Tweets (user_id, twe...
Database
null
{"headers":{"Tweets":["user_id","tweet_id","tweet","tweet_date"]},"rows":{"Tweets":[[135,13,"Enjoying a great start to the day. #HappyDay #MorningVibes","2024-02-01"],[136,14,"Another #HappyDay with good vibes! #FeelGood","2024-02-03"],[137,15,"Productivity peaks! #WorkLife #ProductiveDay","2024-02-04"],[138,16,"Explor...
{"mysql": ["Create table If Not Exists Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))"], "mssql": ["Create table Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))"], "oraclesql": ["Create table Tweets (user_id int, tweet_id int, tweet_date date, tweet varchar(100))", "A...
{"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']
3,104
Find Longest Self-Contained Substring
find-longest-self-contained-substring
null
Hard
2.3K
3.9K
2,329
3,949
59.0%
['select-k-disjoint-special-substrings']
[]
Algorithms
null
"abba"
{ "name": "maxSubstringLength", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Binary Search', 'Prefix Sum']
3,105
Longest Strictly Increasing or Strictly Decreasing Subarray
longest-strictly-increasing-or-strictly-decreasing-subarray
<p>You are given an array of integers <code>nums</code>. Return <em>the length of the <strong>longest</strong> <span data-keyword="subarray-nonempty">subarray</span> of </em><code>nums</code><em> which is either <strong><span data-keyword="strictly-increasing-array">strictly increasing</span></strong> or <strong><span ...
Easy
202K
310.4K
202,045
310,384
65.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestMonotonicSubarray(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestMonotonicSubarray(int[] nums) {\n \n }\n}"}, {"value": "python", "...
[1,4,3,3,2]
{ "name": "longestMonotonicSubarray", "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']
3,106
Lexicographically Smallest String After Operations With Constraint
lexicographically-smallest-string-after-operations-with-constraint
<p>You are given a string <code>s</code> and an integer <code>k</code>.</p> <p>Define a function <code>distance(s<sub>1</sub>, s<sub>2</sub>)</code> between two strings <code>s<sub>1</sub></code> and <code>s<sub>2</sub></code> of the same length <code>n</code> as:</p> <ul> <li>The<strong> sum</strong> of the <strong...
Medium
27.2K
43.8K
27,183
43,795
62.1%
['lexicographically-smallest-string-after-substring-operation']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string getSmallestString(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String getSmallestString(String s, int k) {\n \n }\n}"}, {"value": "python", "text"...
"zbbz" 3
{ "name": "getSmallestString", "params": [ { "name": "s", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Greedy']
3,107
Minimum Operations to Make Median of Array Equal to K
minimum-operations-to-make-median-of-array-equal-to-k
<p>You are given an integer array <code>nums</code> and a <strong>non-negative</strong> integer <code>k</code>. In one operation, you can increase or decrease any element by 1.</p> <p>Return the <strong>minimum</strong> number of operations needed to make the <strong>median</strong> of <code>nums</code> <em>equal</em>...
Medium
27.3K
58.8K
27,343
58,815
46.5%
['find-median-from-data-stream', 'sliding-window-median']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long minOperationsToMakeMedianK(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long minOperationsToMakeMedianK(int[] nums, int k) {\n \n }\n}...
[2,5,6,8,5] 4
{ "name": "minOperationsToMakeMedianK", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "long" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
3,108
Minimum Cost Walk in Weighted Graph
minimum-cost-walk-in-weighted-graph
<p>There is an undirected weighted graph with <code>n</code> vertices labeled from <code>0</code> to <code>n - 1</code>.</p> <p>You are given the integer <code>n</code> and an array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>, w<sub>i</sub>]</code> indicates that there is an edge between v...
Hard
100.1K
145.9K
100,072
145,874
68.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> minimumCost(int n, vector<vector<int>>& edges, vector<vector<int>>& query) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] minimumCost(int n, int[][] edges, int[][] ...
5 [[0,1,7],[1,3,7],[1,2,1]] [[0,3],[3,4]]
{ "name": "minimumCost", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "edges" }, { "type": "integer[][]", "name": "query" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Union Find', 'Graph']
3,109
Find the Index of Permutation
find-the-index-of-permutation
null
Medium
614
1.7K
614
1,669
36.8%
[]
[]
Algorithms
null
[1,2]
{ "name": "getPermutationIndex", "params": [ { "name": "perm", "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', 'Divide and Conquer', 'Binary Indexed Tree', 'Segment Tree', 'Merge Sort', 'Ordered Set']