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
2,509
Cycle Length Queries in a Tree
cycle-length-queries-in-a-tree
<p>You are given an integer <code>n</code>. There is a <strong>complete binary tree</strong> with <code>2<sup>n</sup> - 1</code> nodes. The root of that tree is the node with the value <code>1</code>, and every node with a value <code>val</code> in the range <code>[1, 2<sup>n - 1</sup> - 1]</code> has two children wher...
Hard
15.7K
27.1K
15,700
27,142
57.8%
['populating-next-right-pointers-in-each-node', 'lowest-common-ancestor-of-a-binary-tree', 'path-in-zigzag-labelled-binary-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> cycleLengthQueries(int n, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] cycleLengthQueries(int n, int[][] queries) {\n \n }...
3 [[5,3],[4,7],[2,3]]
{ "name": "cycleLengthQueries", "params": [ { "type": "integer", "name": "n" }, { "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', 'Tree', 'Binary Tree']
2,510
Check if There is a Path With Equal Number of 0's And 1's
check-if-there-is-a-path-with-equal-number-of-0s-and-1s
null
Medium
6.6K
12.9K
6,624
12,915
51.3%
['minimum-path-sum', 'dungeon-game', 'minimum-cost-homecoming-of-a-robot-in-a-grid', 'paths-in-matrix-whose-sum-is-divisible-by-k']
[]
Algorithms
null
[[0,1,0,0],[0,1,0,0],[1,0,1,0]]
{ "name": "isThereAPath", "params": [ { "name": "grid", "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', 'Dynamic Programming', 'Matrix']
2,511
Maximum Enemy Forts That Can Be Captured
maximum-enemy-forts-that-can-be-captured
<p>You are given a <strong>0-indexed</strong> integer array <code>forts</code> of length <code>n</code> representing the positions of several forts. <code>forts[i]</code> can be <code>-1</code>, <code>0</code>, or <code>1</code> where:</p> <ul> <li><code>-1</code> represents there is <strong>no fort</strong> at the <...
Easy
28.9K
72.5K
28,852
72,498
39.8%
['max-consecutive-ones', 'max-consecutive-ones-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int captureForts(vector<int>& forts) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int captureForts(int[] forts) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[1,0,0,-1,0,0,0,0,1]
{ "name": "captureForts", "params": [ { "name": "forts", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers']
2,512
Reward Top K Students
reward-top-k-students
<p>You are given two string arrays <code>positive_feedback</code> and <code>negative_feedback</code>, containing the words denoting positive and negative feedback, respectively. Note that <strong>no</strong> word is both positive and negative.</p> <p>Initially every student has <code>0</code> points. Each positive wor...
Medium
24.8K
54.2K
24,801
54,233
45.7%
['queue-reconstruction-by-height', 'k-highest-ranked-items-within-a-price-range']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> topStudents(vector<string>& positive_feedback, vector<string>& negative_feedback, vector<string>& report, vector<int>& student_id, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution...
["smart","brilliant","studious"] ["not"] ["this student is studious","the student is smart"] [1,2] 2
{ "name": "topStudents", "params": [ { "name": "positive_feedback", "type": "string[]" }, { "type": "string[]", "name": "negative_feedback" }, { "type": "string[]", "name": "report" }, { "type": "integer[]", "name": "student_id" }, ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Sorting', 'Heap (Priority Queue)']
2,513
Minimize the Maximum of Two Arrays
minimize-the-maximum-of-two-arrays
<p>We have two arrays <code>arr1</code> and <code>arr2</code> which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:</p> <ul> <li><code>arr1</code> contains <code>uniqueCnt1</code> <strong>distinct</strong> positive integers, each of which is <strong>...
Medium
14.9K
47.8K
14,876
47,823
31.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimizeSet(int divisor1, int divisor2, int uniqueCnt1, int uniqueCnt2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimizeSet(int divisor1, int divisor2, int uniqueCnt1,...
2 7 1 3
{ "name": "minimizeSet", "params": [ { "name": "divisor1", "type": "integer" }, { "type": "integer", "name": "divisor2" }, { "type": "integer", "name": "uniqueCnt1" }, { "type": "integer", "name": "uniqueCnt2" } ], "return": { "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Binary Search', 'Number Theory']
2,514
Count Anagrams
count-anagrams
<p>You are given a string <code>s</code> containing one or more words. Every consecutive pair of words is separated by a single space <code>&#39; &#39;</code>.</p> <p>A string <code>t</code> is an <strong>anagram</strong> of string <code>s</code> if the <code>i<sup>th</sup></code> word of <code>t</code> is a <strong>p...
Hard
15.1K
43.5K
15,139
43,482
34.8%
['group-anagrams', 'count-ways-to-build-rooms-in-an-ant-colony']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countAnagrams(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countAnagrams(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
"too hot"
{ "name": "countAnagrams", "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', 'Math', 'String', 'Combinatorics', 'Counting']
2,515
Shortest Distance to Target String in a Circular Array
shortest-distance-to-target-string-in-a-circular-array
<p>You are given a <strong>0-indexed</strong> <strong>circular</strong> string array <code>words</code> and a string <code>target</code>. A <strong>circular array</strong> means that the array&#39;s end connects to the array&#39;s beginning.</p> <ul> <li>Formally, the next element of <code>words[i]</code> is <code>wo...
Easy
35.5K
70.7K
35,525
70,688
50.3%
['defuse-the-bomb']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int closestTarget(vector<string>& words, string target, int startIndex) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int closestTarget(String[] words, String target, int startIndex...
["hello","i","am","leetcode","hello"] "hello" 1
{ "name": "closestTarget", "params": [ { "name": "words", "type": "string[]" }, { "type": "string", "name": "target" }, { "type": "integer", "name": "startIndex" } ], "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']
2,516
Take K of Each Character From Left and Right
take-k-of-each-character-from-left-and-right
<p>You are given a string <code>s</code> consisting of the characters <code>&#39;a&#39;</code>, <code>&#39;b&#39;</code>, and <code>&#39;c&#39;</code> and a non-negative integer <code>k</code>. Each minute, you may take either the <strong>leftmost</strong> character of <code>s</code>, or the <strong>rightmost</strong> ...
Medium
107.3K
207.6K
107,335
207,559
51.7%
['merge-sorted-array', 'reorder-list', 'defuse-the-bomb']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int takeCharacters(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int takeCharacters(String s, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"aabaaaacaabc" 2
{ "name": "takeCharacters", "params": [ { "name": "s", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Sliding Window']
2,517
Maximum Tastiness of Candy Basket
maximum-tastiness-of-candy-basket
<p>You are given an array of positive integers <code>price</code> where <code>price[i]</code> denotes the price of the <code>i<sup>th</sup></code> candy and a positive integer <code>k</code>.</p> <p>The store sells baskets of <code>k</code> <strong>distinct</strong> candies. The <strong>tastiness</strong> of a candy b...
Medium
28.3K
43.1K
28,342
43,135
65.7%
['container-with-most-water', 'sliding-window-maximum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximumTastiness(vector<int>& price, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximumTastiness(int[] price, int k) {\n \n }\n}"}, {"value": "python", "...
[13,5,1,8,21,2] 3
{ "name": "maximumTastiness", "params": [ { "type": "integer[]", "name": "price" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Greedy', 'Sorting']
2,518
Number of Great Partitions
number-of-great-partitions
<p>You are given an array <code>nums</code> consisting of <strong>positive</strong> integers and an integer <code>k</code>.</p> <p><strong>Partition</strong> the array into two ordered <strong>groups</strong> such that each element is in exactly <strong>one</strong> group. A partition is called great if the <strong>su...
Hard
11.1K
34.5K
11,136
34,533
32.2%
['palindrome-partitioning-ii', 'partition-equal-subset-sum', 'find-the-punishment-number-of-an-integer']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countPartitions(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countPartitions(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text...
[1,2,3,4] 4
{ "name": "countPartitions", "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']
2,519
Count the Number of K-Big Indices
count-the-number-of-k-big-indices
null
Hard
9.1K
17.1K
9,098
17,129
53.1%
['count-of-smaller-numbers-after-self', 'find-all-good-indices']
[]
Algorithms
null
[2,3,6,5,2,3] 2
{ "name": "kBigIndices", "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', 'Binary Search', 'Divide and Conquer', 'Binary Indexed Tree', 'Segment Tree', 'Merge Sort', 'Ordered Set']
2,520
Count the Digits That Divide a Number
count-the-digits-that-divide-a-number
<p>Given an integer <code>num</code>, return <em>the number of digits in <code>num</code> that divide </em><code>num</code>.</p> <p>An integer <code>val</code> divides <code>nums</code> if <code>nums % val == 0</code>.</p> <p>&nbsp;</p> <p><strong>Example 1:</strong></p> <pre> <strong>Input:</strong> num = 7 <strong...
Easy
113K
132K
112,959
131,952
85.6%
['happy-number', 'self-dividing-numbers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countDigits(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countDigits(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
7
{ "name": "countDigits", "params": [ { "name": "num", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math']
2,521
Distinct Prime Factors of Product of Array
distinct-prime-factors-of-product-of-array
<p>Given an array of positive integers <code>nums</code>, return <em>the number of <strong>distinct prime factors</strong> in the product of the elements of</em> <code>nums</code>.</p> <p><strong>Note</strong> that:</p> <ul> <li>A number greater than <code>1</code> is called <strong>prime</strong> if it is divisible...
Medium
37.7K
71.6K
37,669
71,607
52.6%
['2-keys-keyboard', 'largest-component-size-by-common-factor', 'closest-divisors', 'smallest-value-after-replacing-with-sum-of-prime-factors', 'count-the-number-of-square-free-subsets']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int distinctPrimeFactors(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int distinctPrimeFactors(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "...
[2,4,3,7,10,6]
{ "name": "distinctPrimeFactors", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Number Theory']
2,522
Partition String Into Substrings With Values at Most K
partition-string-into-substrings-with-values-at-most-k
<p>You are given a string <code>s</code> consisting of digits from <code>1</code> to <code>9</code> and an integer <code>k</code>.</p> <p>A partition of a string <code>s</code> is called <strong>good</strong> if:</p> <ul> <li>Each digit of <code>s</code> is part of <strong>exactly</strong> one substring.</li> <li>T...
Medium
23.9K
51.5K
23,897
51,546
46.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumPartition(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumPartition(String s, int k) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
"165462" 60
{ "name": "minimumPartition", "params": [ { "name": "s", "type": "string" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Dynamic Programming', 'Greedy']
2,523
Closest Prime Numbers in Range
closest-prime-numbers-in-range
<p>Given two positive integers <code>left</code> and <code>right</code>, find the two integers <code>num1</code> and <code>num2</code> such that:</p> <ul> <li><code>left &lt;= num1 &lt; num2 &lt;= right </code>.</li> <li>Both <code>num1</code> and <code>num2</code> are <span data-keyword="prime-number">prime numbers...
Medium
176.3K
342K
176,294
342,033
51.5%
['count-ways-to-make-array-with-product']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> closestPrimes(int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] closestPrimes(int left, int right) {\n \n }\n}"}, {"value": "python", "t...
10 19
{ "name": "closestPrimes", "params": [ { "name": "left", "type": "integer" }, { "type": "integer", "name": "right" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Number Theory']
2,524
Maximum Frequency Score of a Subarray
maximum-frequency-score-of-a-subarray
null
Hard
1.3K
3.9K
1,336
3,876
34.5%
[]
[]
Algorithms
null
[1,1,1,2,1,2] 3
{ "name": "maxFrequencyScore", "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', 'Hash Table', 'Math', 'Stack', 'Sliding Window']
2,525
Categorize Box According to Criteria
categorize-box-according-to-criteria
<p>Given four integers <code>length</code>, <code>width</code>, <code>height</code>, and <code>mass</code>, representing the dimensions and mass of a box, respectively, return <em>a string representing the <strong>category</strong> of the box</em>.</p> <ul> <li>The box is <code>&quot;Bulky&quot;</code> if: <ul> <...
Easy
40K
107.8K
40,042
107,782
37.2%
['fizz-buzz', 'find-winner-on-a-tic-tac-toe-game', 'best-poker-hand']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string categorizeBox(int length, int width, int height, int mass) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String categorizeBox(int length, int width, int height, int mass) {\n...
1000 35 700 300
{ "name": "categorizeBox", "params": [ { "name": "length", "type": "integer" }, { "type": "integer", "name": "width" }, { "type": "integer", "name": "height" }, { "type": "integer", "name": "mass" } ], "return": { "type": "strin...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
2,526
Find Consecutive Integers from a Data Stream
find-consecutive-integers-from-a-data-stream
<p>For a stream of integers, implement a data structure that checks if the last <code>k</code> integers parsed in the stream are <strong>equal</strong> to <code>value</code>.</p> <p>Implement the <strong>DataStream</strong> class:</p> <ul> <li><code>DataStream(int value, int k)</code> Initializes the object with an ...
Medium
30.9K
61.2K
30,915
61,191
50.5%
['number-of-zero-filled-subarrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class DataStream {\npublic:\n DataStream(int value, int k) {\n \n }\n \n bool consec(int num) {\n \n }\n};\n\n/**\n * Your DataStream object will be instantiated and called as such:\n * DataStream* obj = new DataStream(value, k);\n * bool par...
["DataStream","consec","consec","consec","consec"] [[4,3],[4],[4],[4],[3]]
{ "classname": "DataStream", "constructor": { "params": [ { "type": "integer", "name": "value" }, { "name": "k", "type": "integer" } ] }, "methods": [ { "params": [ { "type": "integer", "name": "num" } ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Design', 'Queue', 'Counting', 'Data Stream']
2,527
Find Xor-Beauty of Array
find-xor-beauty-of-array
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p> <p>The <strong>effective value</strong> of three indices <code>i</code>, <code>j</code>, and <code>k</code> is defined as <code>((nums[i] | nums[j]) &amp; nums[k])</code>.</p> <p>The <strong>xor-beauty</strong> of the array is the XORi...
Medium
22.3K
32.4K
22,322
32,374
69.0%
['decode-xored-permutation']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int xorBeauty(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int xorBeauty(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode"...
[1,4]
{ "name": "xorBeauty", "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', 'Bit Manipulation']
2,528
Maximize the Minimum Powered City
maximize-the-minimum-powered-city
<p>You are given a <strong>0-indexed</strong> integer array <code>stations</code> of length <code>n</code>, where <code>stations[i]</code> represents the number of power stations in the <code>i<sup>th</sup></code> city.</p> <p>Each power station can provide power to every city in a fixed <strong>range</strong>. In oth...
Hard
8.3K
25.3K
8,316
25,284
32.9%
['maximum-number-of-tasks-you-can-assign']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maxPower(vector<int>& stations, int r, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maxPower(int[] stations, int r, int k) {\n \n }\n}"}, {"value": ...
[1,2,4,5,0] 1 2
{ "name": "maxPower", "params": [ { "name": "stations", "type": "integer[]" }, { "type": "integer", "name": "r" }, { "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', 'Binary Search', 'Greedy', 'Queue', 'Sliding Window', 'Prefix Sum']
2,529
Maximum Count of Positive Integer and Negative Integer
maximum-count-of-positive-integer-and-negative-integer
<p>Given an array <code>nums</code> sorted in <strong>non-decreasing</strong> order, return <em>the maximum between the number of positive integers and the number of negative integers.</em></p> <ul> <li>In other words, if the number of positive integers in <code>nums</code> is <code>pos</code> and the number of negat...
Easy
306.4K
411K
306,413
411,018
74.5%
['binary-search', 'count-negative-numbers-in-a-sorted-matrix']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximumCount(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximumCount(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[-2,-1,-1,1,2,3]
{ "name": "maximumCount", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Counting']
2,530
Maximal Score After Applying K Operations
maximal-score-after-applying-k-operations
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and an integer <code>k</code>. You have a <strong>starting score</strong> of <code>0</code>.</p> <p>In one <strong>operation</strong>:</p> <ol> <li>choose an index <code>i</code> such that <code>0 &lt;= i &lt; nums.length</code>,</li> <li...
Medium
155.6K
244.1K
155,648
244,101
63.8%
['sliding-window-maximum', 'remove-stones-to-minimize-the-total']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maxKelements(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maxKelements(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "tex...
[10,10,10,10,10] 5
{ "name": "maxKelements", "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', 'Heap (Priority Queue)']
2,531
Make Number of Distinct Characters Equal
make-number-of-distinct-characters-equal
<p>You are given two <strong>0-indexed</strong> strings <code>word1</code> and <code>word2</code>.</p> <p>A <strong>move</strong> consists of choosing two indices <code>i</code> and <code>j</code> such that <code>0 &lt;= i &lt; word1.length</code> and <code>0 &lt;= j &lt; word2.length</code> and swapping <code>word1[i...
Medium
21.7K
80.8K
21,662
80,752
26.8%
['bulls-and-cows', 'buddy-strings', 'minimum-swaps-to-make-strings-equal', 'check-if-one-string-swap-can-make-strings-equal', 'check-if-all-characters-have-equal-number-of-occurrences']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isItPossible(string word1, string word2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isItPossible(String word1, String word2) {\n \n }\n}"}, {"value": "pyth...
"ac" "b"
{ "name": "isItPossible", "params": [ { "name": "word1", "type": "string" }, { "type": "string", "name": "word2" } ], "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', 'Counting']
2,532
Time to Cross a Bridge
time-to-cross-a-bridge
<p>There are <code>k</code> workers who want to move <code>n</code> boxes from the right (old) warehouse to the left (new) warehouse. You are given the two integers <code>n</code> and <code>k</code>, and a 2D integer array <code>time</code> of size <code>k x 4</code> where <code>time[i] = [right<sub>i</sub>, pick<sub>i...
Hard
5K
11.5K
4,991
11,497
43.4%
['the-latest-time-to-catch-a-bus', 'total-cost-to-hire-k-workers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findCrossingTime(int n, int k, vector<vector<int>>& time) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findCrossingTime(int n, int k, int[][] time) {\n \n }\n}"},...
1 3 [[1,1,2,1],[1,1,3,1],[1,1,4,1]]
{ "name": "findCrossingTime", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "k" }, { "type": "integer[][]", "name": "time" } ], "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']
2,533
Number of Good Binary Strings
number-of-good-binary-strings
null
Medium
6.9K
13.2K
6,901
13,176
52.4%
['special-binary-string']
[]
Algorithms
null
2 3 1 2
{ "name": "goodBinaryStrings", "params": [ { "name": "minLength", "type": "integer" }, { "type": "integer", "name": "maxLength" }, { "type": "integer", "name": "oneGroup" }, { "type": "integer", "name": "zeroGroup" } ], "return": { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming']
2,534
Time Taken to Cross the Door
time-taken-to-cross-the-door
null
Hard
11.8K
24.1K
11,827
24,145
49.0%
['the-latest-time-to-catch-a-bus']
[]
Algorithms
null
[0,1,1,2,4] [0,1,0,0,1]
{ "name": "timeTaken", "params": [ { "name": "arrival", "type": "integer[]" }, { "type": "integer[]", "name": "state" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Queue', 'Simulation']
2,535
Difference Between Element Sum and Digit Sum of an Array
difference-between-element-sum-and-digit-sum-of-an-array
<p>You are given a positive integer array <code>nums</code>.</p> <ul> <li>The <strong>element sum</strong> is the sum of all the elements in <code>nums</code>.</li> <li>The <strong>digit sum</strong> is the sum of all the digits (not necessarily distinct) that appear in <code>nums</code>.</li> </ul> <p>Return <em>t...
Easy
157K
185.3K
157,019
185,327
84.7%
['add-digits', 'minimum-sum-of-four-digit-number-after-splitting-digits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int differenceOfSum(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int differenceOfSum(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[1,15,6,3]
{ "name": "differenceOfSum", "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']
2,536
Increment Submatrices by One
increment-submatrices-by-one
<p>You are given a positive integer <code>n</code>, indicating that we initially have an <code>n x n</code>&nbsp;<strong>0-indexed</strong> integer matrix <code>mat</code> filled with zeroes.</p> <p>You are also given a 2D integer array <code>query</code>. For each <code>query[i] = [row1<sub>i</sub>, col1<sub>i</sub>,...
Medium
23.5K
45.8K
23,484
45,806
51.3%
['range-sum-query-2d-mutable', 'count-positions-on-street-with-required-brightness']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> rangeAddQueries(int n, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] rangeAddQueries(int n, int[][] queries) {\n \n ...
3 [[1,1,2,2],[0,0,1,1]]
{ "name": "rangeAddQueries", "params": [ { "name": "n", "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', 'Matrix', 'Prefix Sum']
2,537
Count the Number of Good Subarrays
count-the-number-of-good-subarrays
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the number of <strong>good</strong> subarrays of</em> <code>nums</code>.</p> <p>A subarray <code>arr</code> is <strong>good</strong> if there are <strong>at least </strong><code>k</code> pairs of indices <code>(i, j)</code> such that...
Medium
26.4K
49.9K
26,435
49,926
52.9%
['count-number-of-homogenous-substrings', 'maximum-sum-of-distinct-subarrays-with-length-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countGood(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countGood(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "P...
[1,1,1,1,1] 10
{ "name": "countGood", "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', 'Sliding Window']
2,538
Difference Between Maximum and Minimum Price Sum
difference-between-maximum-and-minimum-price-sum
<p>There exists an undirected and initially unrooted tree with <code>n</code> nodes indexed from <code>0</code> to <code>n - 1</code>. You are given the integer <code>n</code> and a 2D integer array <code>edges</code> of length <code>n - 1</code>, where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates t...
Hard
8.9K
28.3K
8,938
28,285
31.6%
['binary-tree-maximum-path-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maxOutput(int n, vector<vector<int>>& edges, vector<int>& price) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maxOutput(int n, int[][] edges, int[] price) {\n ...
6 [[0,1],[1,2],[1,3],[3,4],[3,5]] [9,8,7,6,10,5]
{ "name": "maxOutput", "params": [ { "name": "n", "type": "integer" }, { "type": "integer[][]", "name": "edges" }, { "type": "integer[]", "name": "price" } ], "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', 'Tree', 'Depth-First Search']
2,539
Count the Number of Good Subsequences
count-the-number-of-good-subsequences
null
Medium
3.2K
6.2K
3,190
6,211
51.4%
['number-of-music-playlists', 'count-ways-to-build-rooms-in-an-ant-colony']
[]
Algorithms
null
"aabb"
{ "name": "countGoodSubsequences", "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', 'Math', 'String', 'Combinatorics', 'Counting']
2,540
Minimum Common Value
minimum-common-value
<p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, sorted in non-decreasing order, return <em>the <strong>minimum integer common</strong> to both arrays</em>. If there is no common integer amongst <code>nums1</code> and <code>nums2</code>, return <code>-1</code>.</p> <p>Note that an integer is said...
Easy
273.2K
468.9K
273,198
468,906
58.3%
['intersection-of-two-arrays', 'intersection-of-two-arrays-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int getCommon(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int getCommon(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "pytho...
[1,2,3] [2,4]
{ "name": "getCommon", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Two Pointers', 'Binary Search']
2,541
Minimum Operations to Make Array Equal II
minimum-operations-to-make-array-equal-ii
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> of equal length <code>n</code> and an integer <code>k</code>. You can perform the following operation on <code>nums1</code>:</p> <ul> <li>Choose two indexes <code>i</code> and <code>j</code> and increment <code>nums1[i]</code> by <code>k</c...
Medium
25.1K
78K
25,130
78,005
32.2%
['minimum-operations-to-make-array-equal', 'minimum-number-of-operations-to-make-arrays-similar']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long minOperations(vector<int>& nums1, vector<int>& nums2, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long minOperations(int[] nums1, int[] nums2, int k) {\n \...
[4,3,1,4] [1,3,7,1] 3
{ "name": "minOperations", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" }, { "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', 'Math', 'Greedy']
2,542
Maximum Subsequence Score
maximum-subsequence-score
<p>You are given two <strong>0-indexed</strong> integer arrays <code>nums1</code> and <code>nums2</code> of equal length <code>n</code> and a positive integer <code>k</code>. You must choose a <strong>subsequence</strong> of indices from <code>nums1</code> of length <code>k</code>.</p> <p>For chosen indices <code>i<su...
Medium
122.9K
226.8K
122,852
226,835
54.2%
['ipo', 'minimum-cost-to-hire-k-workers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long maxScore(vector<int>& nums1, vector<int>& nums2, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long maxScore(int[] nums1, int[] nums2, int k) {\n \n }\n}"...
[1,3,3,2] [2,1,3,4] 3
{ "name": "maxScore", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" }, { "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', 'Heap (Priority Queue)']
2,543
Check if Point Is Reachable
check-if-point-is-reachable
<p>There exists an infinitely large grid. You are currently at point <code>(1, 1)</code>, and you need to reach the point <code>(targetX, targetY)</code> using a finite number of steps.</p> <p>In one <strong>step</strong>, you can move from point <code>(x, y)</code> to any one of the following points:</p> <ul> <li><...
Hard
9.2K
21.3K
9,194
21,309
43.1%
['reaching-points', 'check-if-the-rectangle-corner-is-reachable']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isReachable(int targetX, int targetY) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isReachable(int targetX, int targetY) {\n \n }\n}"}, {"value": "python", "...
6 9
{ "name": "isReachable", "params": [ { "name": "targetX", "type": "integer" }, { "type": "integer", "name": "targetY" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Number Theory']
2,544
Alternating Digit Sum
alternating-digit-sum
<p>You are given a positive integer <code>n</code>. Each digit of <code>n</code> has a sign according to the following rules:</p> <ul> <li>The <strong>most significant digit</strong> is assigned a <strong>positive</strong> sign.</li> <li>Each other digit has an opposite sign to its adjacent digits.</li> </ul> <p>Re...
Easy
77.2K
112.9K
77,168
112,869
68.4%
['add-digits', 'minimum-sum-of-four-digit-number-after-splitting-digits', 'separate-the-digits-in-an-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int alternateDigitSum(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int alternateDigitSum(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
521
{ "name": "alternateDigitSum", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math']
2,545
Sort the Students by Their Kth Score
sort-the-students-by-their-kth-score
<p>There is a class with <code>m</code> students and <code>n</code> exams. You are given a <strong>0-indexed</strong> <code>m x n</code> integer matrix <code>score</code>, where each row represents one student and <code>score[i][j]</code> denotes the score the <code>i<sup>th</sup></code> student got in the <code>j<sup>...
Medium
75.4K
88.2K
75,447
88,193
85.5%
['erect-the-fence', 'custom-sort-string', 'sort-the-people']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> sortTheStudents(vector<vector<int>>& score, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] sortTheStudents(int[][] score, int k) {\n \n }...
[[10,6,9,1],[7,5,11,2],[4,8,3,15]] 2
{ "name": "sortTheStudents", "params": [ { "name": "score", "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', 'Sorting', 'Matrix']
2,546
Apply Bitwise Operations to Make Strings Equal
apply-bitwise-operations-to-make-strings-equal
<p>You are given two <strong>0-indexed binary</strong> strings <code>s</code> and <code>target</code> of the same length <code>n</code>. You can do the following operation on <code>s</code> <strong>any</strong> number of times:</p> <ul> <li>Choose two <strong>different</strong> indices <code>i</code> and <code>j</cod...
Medium
20.7K
49.9K
20,708
49,877
41.5%
['minimum-one-bit-operations-to-make-integers-zero']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool makeStringsEqual(string s, string target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean makeStringsEqual(String s, String target) {\n \n }\n}"}, {"value": "py...
"1010" "0110"
{ "name": "makeStringsEqual", "params": [ { "name": "s", "type": "string" }, { "type": "string", "name": "target" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Bit Manipulation']
2,547
Minimum Cost to Split an Array
minimum-cost-to-split-an-array
<p>You are given an integer array <code>nums</code> and an integer <code>k</code>.</p> <p>Split the array into some number of non-empty subarrays. The <strong>cost</strong> of a split is the sum of the <strong>importance value</strong> of each subarray in the split.</p> <p>Let <code>trimmed(subarray)</code> be the ve...
Hard
14.1K
33.7K
14,100
33,720
41.8%
['coin-change', 'split-array-largest-sum', 'divide-an-array-into-subarrays-with-minimum-cost-ii', 'minimum-sum-of-values-by-dividing-array', 'minimum-cost-to-divide-array-into-subarrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCost(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCost(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[1,2,1,2,1,3,3] 2
{ "name": "minCost", "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', 'Hash Table', 'Dynamic Programming', 'Counting']
2,548
Maximum Price to Fill a Bag
maximum-price-to-fill-a-bag
null
Medium
1.7K
2.6K
1,674
2,637
63.5%
[]
[]
Algorithms
null
[[50,1],[10,8]] 5
{ "name": "maxPrice", "params": [ { "name": "items", "type": "integer[][]" }, { "type": "integer", "name": "capacity" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
2,549
Count Distinct Numbers on Board
count-distinct-numbers-on-board
<p>You are given a positive integer <code>n</code>, that is initially placed on a board. Every day, for <code>10<sup>9</sup></code> days, you perform the following procedure:</p> <ul> <li>For each number <code>x</code> present on the board, find all numbers <code>1 &lt;= i &lt;= n</code> such that <code>x % i == 1</c...
Easy
50.7K
82.9K
50,739
82,909
61.2%
['count-of-matches-in-tournament']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int distinctIntegers(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int distinctIntegers(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
5
{ "name": "distinctIntegers", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Simulation']
2,550
Count Collisions of Monkeys on a Polygon
count-collisions-of-monkeys-on-a-polygon
<p>There is a regular convex polygon with <code>n</code> vertices. The vertices are labeled from <code>0</code> to <code>n - 1</code> in a clockwise direction, and each vertex has <strong>exactly one monkey</strong>. The following figure shows a convex polygon of <code>6</code> vertices.</p> <img alt="" src="https://as...
Medium
23.4K
81.5K
23,350
81,541
28.6%
['powx-n']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int monkeyMove(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int monkeyMove(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Soluti...
3
{ "name": "monkeyMove", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Recursion']
2,551
Put Marbles in Bags
put-marbles-in-bags
<p>You have <code>k</code> bags. You are given a <strong>0-indexed</strong> integer array <code>weights</code> where <code>weights[i]</code> is the weight of the <code>i<sup>th</sup></code> marble. You are also given the integer <code>k.</code></p> <p>Divide the marbles into the <code>k</code> bags according to the fo...
Hard
143K
196.9K
142,954
196,945
72.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long putMarbles(vector<int>& weights, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long putMarbles(int[] weights, int k) {\n \n }\n}"}, {"value": "python", "t...
[1,3,5,1] 2
{ "name": "putMarbles", "params": [ { "name": "weights", "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', 'Heap (Priority Queue)']
2,552
Count Increasing Quadruplets
count-increasing-quadruplets
<p>Given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code> containing all numbers from <code>1</code> to <code>n</code>, return <em>the number of increasing quadruplets</em>.</p> <p>A quadruplet <code>(i, j, k, l)</code> is increasing if:</p> <ul> <li><code>0 &lt;= i &lt; j &lt; k &...
Hard
10.8K
31.9K
10,815
31,858
33.9%
['increasing-triplet-subsequence', 'count-special-quadruplets', 'count-good-triplets-in-an-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countQuadruplets(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countQuadruplets(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "P...
[1,3,2,4,5]
{ "name": "countQuadruplets", "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', 'Dynamic Programming', 'Binary Indexed Tree', 'Enumeration', 'Prefix Sum']
2,553
Separate the Digits in an Array
separate-the-digits-in-an-array
<p>Given an array of positive integers <code>nums</code>, return <em>an array </em><code>answer</code><em> that consists of the digits of each integer in </em><code>nums</code><em> after separating them in <strong>the same order</strong> they appear in </em><code>nums</code>.</p> <p>To separate the digits of an intege...
Easy
87.6K
109.4K
87,624
109,390
80.1%
['count-integers-with-even-digit-sum', 'alternating-digit-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> separateDigits(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] separateDigits(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Py...
[13,25,83,77]
{ "name": "separateDigits", "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']
2,554
Maximum Number of Integers to Choose From a Range I
maximum-number-of-integers-to-choose-from-a-range-i
<p>You are given an integer array <code>banned</code> and two integers <code>n</code> and <code>maxSum</code>. You are choosing some number of integers following the below rules:</p> <ul> <li>The chosen integers have to be in the range <code>[1, n]</code>.</li> <li>Each integer can be chosen <strong>at most once</st...
Medium
160.2K
236.1K
160,223
236,113
67.9%
['first-missing-positive', 'find-all-numbers-disappeared-in-an-array', 'append-k-integers-with-minimal-sum', 'replace-elements-in-an-array', 'maximum-number-of-integers-to-choose-from-a-range-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxCount(vector<int>& banned, int n, int maxSum) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxCount(int[] banned, int n, int maxSum) {\n \n }\n}"}, {"value": "...
[1,6,5] 5 6
{ "name": "maxCount", "params": [ { "name": "banned", "type": "integer[]" }, { "type": "integer", "name": "n" }, { "type": "integer", "name": "maxSum" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Binary Search', 'Greedy', 'Sorting']
2,555
Maximize Win From Two Segments
maximize-win-from-two-segments
<p>There are some prizes on the <strong>X-axis</strong>. You are given an integer array <code>prizePositions</code> that is <strong>sorted in non-decreasing order</strong>, where <code>prizePositions[i]</code> is the position of the <code>i<sup>th</sup></code> prize. There could be different prizes at the same position...
Medium
12.6K
36.1K
12,557
36,086
34.8%
['best-time-to-buy-and-sell-stock-iii', 'two-best-non-overlapping-events']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximizeWin(vector<int>& prizePositions, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximizeWin(int[] prizePositions, int k) {\n \n }\n}"}, {"value": "py...
[1,1,2,2,3,3,5] 2
{ "name": "maximizeWin", "params": [ { "name": "prizePositions", "type": "integer[]" }, { "type": "integer", "name": "k" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Sliding Window']
2,556
Disconnect Path in a Binary Matrix by at Most One Flip
disconnect-path-in-a-binary-matrix-by-at-most-one-flip
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> <strong>binary</strong> matrix <code>grid</code>. You can move from a cell <code>(row, col)</code> to any of the cells <code>(row + 1, col)</code> or <code>(row, col + 1)</code> that has the value <code>1</code>.&nbsp;The matrix is <strong>disconnected</s...
Medium
16.4K
60.1K
16,378
60,137
27.2%
['number-of-submatrices-that-sum-to-target', 'minimum-cost-to-make-at-least-one-valid-path-in-a-grid', 'minimum-number-of-days-to-disconnect-island', 'minimum-weighted-subgraph-with-the-required-paths']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isPossibleToCutPath(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isPossibleToCutPath(int[][] grid) {\n \n }\n}"}, {"value": "pytho...
[[1,1,1],[1,0,0],[1,1,1]]
{ "name": "isPossibleToCutPath", "params": [ { "name": "grid", "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', 'Dynamic Programming', 'Depth-First Search', 'Breadth-First Search', 'Matrix']
2,557
Maximum Number of Integers to Choose From a Range II
maximum-number-of-integers-to-choose-from-a-range-ii
null
Medium
2.5K
7K
2,491
7,048
35.3%
['first-missing-positive', 'find-all-numbers-disappeared-in-an-array', 'append-k-integers-with-minimal-sum', 'replace-elements-in-an-array', 'maximum-number-of-integers-to-choose-from-a-range-i', 'maximize-the-distance-between-points-on-a-square']
[]
Algorithms
null
[1,4,6] 6 4
{ "name": "maxCount", "params": [ { "name": "banned", "type": "integer[]" }, { "type": "integer", "name": "n" }, { "type": "long", "name": "maxSum" } ], "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', 'Sorting']
2,558
Take Gifts From the Richest Pile
take-gifts-from-the-richest-pile
<p>You are given an integer array <code>gifts</code> denoting the number of gifts in various piles. Every second, you do the following:</p> <ul> <li>Choose the pile with the maximum number of gifts.</li> <li>If there is more than one pile with the maximum number of gifts, choose any.</li> <li>Reduce the number of g...
Easy
178.1K
235.3K
178,109
235,284
75.7%
['remove-stones-to-minimize-the-total']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long pickGifts(vector<int>& gifts, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long pickGifts(int[] gifts, int k) {\n \n }\n}"}, {"value": "python", "text": ...
[25,64,9,4,100] 4
{ "name": "pickGifts", "params": [ { "name": "gifts", "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', 'Heap (Priority Queue)', 'Simulation']
2,559
Count Vowel Strings in Ranges
count-vowel-strings-in-ranges
<p>You are given a <strong>0-indexed</strong> array of strings <code>words</code> and a 2D array of integers <code>queries</code>.</p> <p>Each query <code>queries[i] = [l<sub>i</sub>, r<sub>i</sub>]</code> asks us to find the number of strings present at the indices ranging from <code>l<sub>i</sub></code> to <code>r<s...
Medium
185.1K
272.6K
185,127
272,593
67.9%
['jump-game-vii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> vowelStrings(vector<string>& words, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] vowelStrings(String[] words, int[][] queries) {\n ...
["aba","bcb","ece","aa","e"] [[0,2],[1,4],[1,1]]
{ "name": "vowelStrings", "params": [ { "name": "words", "type": "string[]" }, { "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', 'String', 'Prefix Sum']
2,560
House Robber IV
house-robber-iv
<p>There are several consecutive houses along a street, each of which has some money inside. There is also a robber, who wants to steal money from the homes, but he <strong>refuses to steal from adjacent homes</strong>.</p> <p>The <strong>capability</strong> of the robber is the maximum amount of money he steals from ...
Medium
124.5K
191.1K
124,541
191,072
65.2%
['container-with-most-water', 'house-robber']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCapability(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCapability(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "text": "...
[2,3,5,9] 2
{ "name": "minCapability", "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', 'Binary Search']
2,561
Rearranging Fruits
rearranging-fruits
<p>You have two fruit baskets containing <code>n</code> fruits each. You are given two <strong>0-indexed</strong> integer arrays <code>basket1</code> and <code>basket2</code> representing the cost of fruit in each basket. You want to make both baskets <strong>equal</strong>. To do so, you can use the following operatio...
Hard
11.8K
33.6K
11,754
33,650
34.9%
['the-latest-time-to-catch-a-bus', 'minimum-number-of-operations-to-make-arrays-similar']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long minCost(vector<int>& basket1, vector<int>& basket2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long minCost(int[] basket1, int[] basket2) {\n \n }\n}"}, {"val...
[4,2,2,2] [1,4,1,2]
{ "name": "minCost", "params": [ { "name": "basket1", "type": "integer[]" }, { "type": "integer[]", "name": "basket2" } ], "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', 'Greedy']
2,562
Find the Array Concatenation Value
find-the-array-concatenation-value
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p> <p>The <strong>concatenation</strong> of two numbers is the number formed by concatenating their numerals.</p> <ul> <li>For example, the concatenation of <code>15</code>, <code>49</code> is <code>1549</code>.</li> </ul> <p>The <stron...
Easy
58.5K
82.6K
58,473
82,631
70.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long findTheArrayConcVal(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long findTheArrayConcVal(int[] nums) {\n \n }\n}"}, {"value": "python", "tex...
[7,52,2,4]
{ "name": "findTheArrayConcVal", "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', 'Two Pointers', 'Simulation']
2,563
Count the Number of Fair Pairs
count-the-number-of-fair-pairs
<p>Given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code> and two integers <code>lower</code> and <code>upper</code>, return <em>the number of fair pairs</em>.</p> <p>A pair <code>(i, j)</code> is <b>fair </b>if:</p> <ul> <li><code>0 &lt;= i &lt; j &lt; n</code>, and</li> <li><cod...
Medium
130K
266.5K
129,958
266,506
48.8%
['count-of-range-sum', 'finding-pairs-with-a-certain-sum', 'count-number-of-pairs-with-absolute-difference-k', 'count-pairs-whose-sum-is-less-than-target']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long countFairPairs(vector<int>& nums, int lower, int upper) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long countFairPairs(int[] nums, int lower, int upper) {\n \n ...
[0,1,7,4,4,5] 3 6
{ "name": "countFairPairs", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "lower" }, { "type": "integer", "name": "upper" } ], "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', 'Two Pointers', 'Binary Search', 'Sorting']
2,564
Substring XOR Queries
substring-xor-queries
<p>You are given a <strong>binary string</strong> <code>s</code>, and a <strong>2D</strong> integer array <code>queries</code> where <code>queries[i] = [first<sub>i</sub>, second<sub>i</sub>]</code>.</p> <p>For the <code>i<sup>th</sup></code> query, find the <strong>shortest substring</strong> of <code>s</code> whose ...
Medium
14.6K
42.6K
14,619
42,633
34.3%
['string-matching-in-an-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> substringXorQueries(string s, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] substringXorQueries(String s, int[][] queries) ...
"101101" [[0,5],[1,2]]
{ "name": "substringXorQueries", "params": [ { "name": "s", "type": "string" }, { "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', 'Hash Table', 'String', 'Bit Manipulation']
2,565
Subsequence With the Minimum Score
subsequence-with-the-minimum-score
<p>You are given two strings <code>s</code> and <code>t</code>.</p> <p>You are allowed to remove any number of characters from the string <code>t</code>.</p> <p>The score of the string is <code>0</code> if no characters are removed from the string <code>t</code>, otherwise:</p> <ul> <li>Let <code>left</code> be the...
Hard
8.8K
27.3K
8,850
27,251
32.5%
['longest-common-subsequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumScore(string s, string t) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumScore(String s, String t) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"abacaba" "bzaa"
{ "name": "minimumScore", "params": [ { "name": "s", "type": "string" }, { "type": "string", "name": "t" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'String', 'Binary Search']
2,566
Maximum Difference by Remapping a Digit
maximum-difference-by-remapping-a-digit
<p>You are given an integer <code>num</code>. You know that Bob will sneakily <strong>remap</strong> one of the <code>10</code> possible digits (<code>0</code> to <code>9</code>) to another digit.</p> <p>Return <em>the difference between the maximum and minimum&nbsp;values Bob can make by remapping&nbsp;<strong>exactl...
Easy
28.5K
47.2K
28,453
47,183
60.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minMaxDifference(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minMaxDifference(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
11891
{ "name": "minMaxDifference", "params": [ { "name": "num", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Greedy']
2,567
Minimum Score by Changing Two Elements
minimum-score-by-changing-two-elements
<p>You are given an integer array <code>nums</code>.</p> <ul> <li>The <strong>low</strong> score of <code>nums</code> is the <strong>minimum</strong> absolute difference between any two integers.</li> <li>The <strong>high</strong> score of <code>nums</code> is the <strong>maximum</strong> absolute difference between...
Medium
19.5K
40.1K
19,509
40,066
48.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimizeSum(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
[1,4,7,8,5]
{ "name": "minimizeSum", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
2,568
Minimum Impossible OR
minimum-impossible-or
<p>You are given a <strong>0-indexed</strong>&nbsp;integer array <code>nums</code>.</p> <p>We say that an integer x is <strong>expressible</strong> from <code>nums</code> if there exist some integers <code>0 &lt;= index<sub>1</sub> &lt; index<sub>2</sub> &lt; ... &lt; index<sub>k</sub> &lt; nums.length</code> for whic...
Medium
17.6K
30.6K
17,613
30,602
57.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minImpossibleOR(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minImpossibleOR(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[2,1]
{ "name": "minImpossibleOR", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Brainteaser']
2,569
Handling Sum Queries After Update
handling-sum-queries-after-update
<p>You are given two <strong>0-indexed</strong> arrays <code>nums1</code> and <code>nums2</code> and a 2D array <code>queries</code> of queries. There are three types of queries:</p> <ol> <li>For a query of type 1, <code>queries[i]&nbsp;= [1, l, r]</code>. Flip the values from <code>0</code> to <code>1</code> and fro...
Hard
6.6K
22.6K
6,556
22,561
29.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<long long> handleQuery(vector<int>& nums1, vector<int>& nums2, vector<vector<int>>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long[] handleQuery(int[] nums1, int...
[1,0,1] [0,0,0] [[1,1,1],[2,1,0],[3,0,0]]
{ "name": "handleQuery", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" }, { "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', 'Segment Tree']
2,570
Merge Two 2D Arrays by Summing Values
merge-two-2d-arrays-by-summing-values
<p>You are given two <strong>2D</strong> integer arrays <code>nums1</code> and <code>nums2.</code></p> <ul> <li><code>nums1[i] = [id<sub>i</sub>, val<sub>i</sub>]</code>&nbsp;indicate that the number with the id <code>id<sub>i</sub></code> has a value equal to <code>val<sub>i</sub></code>.</li> <li><code>nums2[i] = ...
Easy
190.6K
232.1K
190,566
232,123
82.1%
['merge-two-sorted-lists', 'meeting-scheduler', 'merge-similar-items']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> mergeArrays(vector<vector<int>>& nums1, vector<vector<int>>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] mergeArrays(int[][] nums1, int[][] nums...
[[1,2],[2,3],[4,5]] [[1,4],[3,2],[4,1]]
{ "name": "mergeArrays", "params": [ { "name": "nums1", "type": "integer[][]" }, { "type": "integer[][]", "name": "nums2" } ], "return": { "type": "integer[][]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Two Pointers']
2,571
Minimum Operations to Reduce an Integer to 0
minimum-operations-to-reduce-an-integer-to-0
<p>You are given a positive integer <code>n</code>, you can do the following operation <strong>any</strong> number of times:</p> <ul> <li>Add or subtract a <strong>power</strong> of <code>2</code> from <code>n</code>.</li> </ul> <p>Return <em>the <strong>minimum</strong> number of operations to make </em><code>n</co...
Medium
34.6K
60.9K
34,620
60,882
56.9%
['plus-one']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minOperations(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minOperations(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
39
{ "name": "minOperations", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming', 'Greedy', 'Bit Manipulation']
2,572
Count the Number of Square-Free Subsets
count-the-number-of-square-free-subsets
<p>You are given a positive integer <strong>0-indexed</strong>&nbsp;array <code>nums</code>.</p> <p>A subset of the array <code>nums</code> is <strong>square-free</strong> if the product of its elements is a <strong>square-free integer</strong>.</p> <p>A <strong>square-free integer</strong> is an integer that is divi...
Medium
11.5K
46.8K
11,545
46,813
24.7%
['distinct-prime-factors-of-product-of-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int squareFreeSubsets(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int squareFreeSubsets(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python...
[3,4,4,5]
{ "name": "squareFreeSubsets", "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', 'Dynamic Programming', 'Bit Manipulation', 'Bitmask']
2,573
Find the String with LCP
find-the-string-with-lcp
<p>We define the <code>lcp</code> matrix of any <strong>0-indexed</strong> string <code>word</code> of <code>n</code> lowercase English letters as an <code>n x n</code> grid such that:</p> <ul> <li><code>lcp[i][j]</code> is equal to the length of the <strong>longest common prefix</strong> between the substrings <code...
Hard
6K
18.9K
5,954
18,921
31.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string findTheString(vector<vector<int>>& lcp) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String findTheString(int[][] lcp) {\n \n }\n}"}, {"value": "python", "text": "...
[[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]]
{ "name": "findTheString", "params": [ { "name": "lcp", "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', 'String', 'Dynamic Programming', 'Greedy', 'Union Find', 'Matrix']
2,574
Left and Right Sum Differences
left-and-right-sum-differences
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code>.</p> <p>Define two arrays <code>leftSum</code> and <code>rightSum</code> where:</p> <ul> <li><code>leftSum[i]</code> is the sum of elements to the left of the index <code>i</code> in the array <code>nums</code>. If t...
Easy
174.1K
199.3K
174,092
199,340
87.3%
['find-pivot-index', 'find-the-middle-index-in-array', 'find-the-distinct-difference-array', 'find-the-n-th-value-after-k-seconds']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> leftRightDifference(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] leftRightDifference(int[] nums) {\n \n }\n}"}, {"value": "python", "...
[10,4,8,3]
{ "name": "leftRightDifference", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Prefix Sum']
2,575
Find the Divisibility Array of a String
find-the-divisibility-array-of-a-string
<p>You are given a <strong>0-indexed</strong> string <code>word</code> of length <code>n</code>&nbsp;consisting of digits, and a positive integer&nbsp;<code>m</code>.</p> <p>The <strong>divisibility array</strong> <code>div</code> of <code>word</code> is an integer array of length <code>n</code> such that:</p> <ul> ...
Medium
33.3K
97.1K
33,322
97,124
34.3%
['subarray-sums-divisible-by-k', 'make-sum-divisible-by-p']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> divisibilityArray(string word, int m) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] divisibilityArray(String word, int m) {\n \n }\n}"}, {"value": "pytho...
"998244353" 3
{ "name": "divisibilityArray", "params": [ { "name": "word", "type": "string" }, { "type": "integer", "name": "m" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'String']
2,576
Find the Maximum Number of Marked Indices
find-the-maximum-number-of-marked-indices
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p> <p>Initially, all of the indices are unmarked. You are allowed to make this operation any number of times:</p> <ul> <li>Pick two <strong>different unmarked</strong> indices <code>i</code> and <code>j</code> such that <code>2 * nums[i]...
Medium
23K
57.9K
22,979
57,933
39.7%
['minimum-array-length-after-pair-removals']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxNumOfMarkedIndices(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxNumOfMarkedIndices(int[] nums) {\n \n }\n}"}, {"value": "python", "text":...
[3,5,2,4]
{ "name": "maxNumOfMarkedIndices", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Greedy', 'Sorting']
2,577
Minimum Time to Visit a Cell In a Grid
minimum-time-to-visit-a-cell-in-a-grid
<p>You are given a <code>m x n</code> matrix <code>grid</code> consisting of <b>non-negative</b> integers where <code>grid[row][col]</code> represents the <strong>minimum</strong> time required to be able to visit the cell <code>(row, col)</code>, which means you can visit the cell <code>(row, col)</code> only when the...
Hard
81.8K
143.4K
81,755
143,372
57.0%
['find-minimum-time-to-reach-last-room-i', 'find-minimum-time-to-reach-last-room-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumTime(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumTime(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[0,1,3,2],[5,1,2,5],[4,3,8,6]]
{ "name": "minimumTime", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Matrix', 'Shortest Path']
2,578
Split With Minimum Sum
split-with-minimum-sum
<p>Given a positive integer <code>num</code>, split it into two non-negative integers <code>num1</code> and <code>num2</code> such that:</p> <ul> <li>The concatenation of <code>num1</code> and <code>num2</code> is a permutation of <code>num</code>. <ul> <li>In other words, the sum of the number of occurrences of ...
Easy
43.4K
60.3K
43,360
60,333
71.9%
['partition-equal-subset-sum', 'minimum-cost-to-move-chips-to-the-same-position', 'partition-array-into-two-arrays-to-minimize-sum-difference', 'minimum-sum-of-values-by-dividing-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int splitNum(int num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int splitNum(int num) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Soluti...
4325
{ "name": "splitNum", "params": [ { "name": "num", "type": "integer" } ], "return": { "type": "integer" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Greedy', 'Sorting']
2,579
Count Total Number of Colored Cells
count-total-number-of-colored-cells
<p>There exists an infinitely large two-dimensional grid of uncolored unit cells. You are given a positive integer <code>n</code>, indicating that you must do the following routine for <code>n</code> minutes:</p> <ul> <li>At the first minute, color <strong>any</strong> arbitrary unit cell blue.</li> <li>Every minute...
Medium
194.6K
294K
194,638
294,012
66.2%
['minimum-cuts-to-divide-a-circle']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long coloredCells(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long coloredCells(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "c...
1
{ "name": "coloredCells", "params": [ { "name": "n", "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...
['Math']
2,580
Count Ways to Group Overlapping Ranges
count-ways-to-group-overlapping-ranges
<p>You are given a 2D integer array <code>ranges</code> where <code>ranges[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> denotes that all integers between <code>start<sub>i</sub></code> and <code>end<sub>i</sub></code> (both <strong>inclusive</strong>) are contained in the <code>i<sup>th</sup></code> range.</p> <p>...
Medium
19.9K
52.6K
19,871
52,629
37.8%
['merge-intervals']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countWays(vector<vector<int>>& ranges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countWays(int[][] ranges) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[6,10],[5,15]]
{ "name": "countWays", "params": [ { "name": "ranges", "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']
2,581
Count Number of Possible Root Nodes
count-number-of-possible-root-nodes
<p>Alice has an undirected tree with <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. The tree is represented as a 2D integer array <code>edges</code> of length <code>n - 1</code> where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge between nodes <code>a<su...
Hard
7.5K
16.3K
7,504
16,313
46.0%
['closest-node-to-path-in-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rootCount(vector<vector<int>>& edges, vector<vector<int>>& guesses, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rootCount(int[][] edges, int[][] guesses, int k) {\n...
[[0,1],[1,2],[1,3],[4,2]] [[1,3],[0,1],[1,0],[2,4]] 3
{ "name": "rootCount", "params": [ { "name": "edges", "type": "integer[][]" }, { "type": "integer[][]", "name": "guesses" }, { "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', 'Hash Table', 'Dynamic Programming', 'Tree', 'Depth-First Search']
2,582
Pass the Pillow
pass-the-pillow
<p>There are <code>n</code> people standing in a line labeled from <code>1</code> to <code>n</code>. The first person in the line is holding a pillow initially. Every second, the person holding the pillow passes it to the next person standing in the line. Once the pillow reaches the end of the line, the direction chang...
Easy
202.9K
358.7K
202,926
358,732
56.6%
['find-the-student-that-will-replace-the-chalk']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int passThePillow(int n, int time) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int passThePillow(int n, int time) {\n \n }\n}"}, {"value": "python", "text": "Python", "d...
4 5
{ "name": "passThePillow", "params": [ { "name": "n", "type": "integer" }, { "type": "integer", "name": "time" } ], "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']
2,583
Kth Largest Sum in a Binary Tree
kth-largest-sum-in-a-binary-tree
<p>You are given the <code>root</code> of a binary tree and a positive integer <code>k</code>.</p> <p>The <strong>level sum</strong> in the tree is the sum of the values of the nodes that are on the <strong>same</strong> level.</p> <p>Return<em> the </em><code>k<sup>th</sup></code><em> <strong>largest</strong> level ...
Medium
163.8K
276.3K
163,839
276,295
59.3%
['binary-tree-preorder-traversal', 'maximum-level-sum-of-a-binary-tree', 'find-the-level-of-tree-with-minimum-sum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[5,8,9,2,1,3,7,4,6] 2
{ "name": "kthLargestLevelSum", "params": [ { "name": "root", "type": "TreeNode" }, { "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...
['Tree', 'Breadth-First Search', 'Sorting', 'Binary Tree']
2,584
Split the Array to Make Coprime Products
split-the-array-to-make-coprime-products
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of length <code>n</code>.</p> <p>A <strong>split</strong> at an index <code>i</code> where <code>0 &lt;= i &lt;= n - 2</code> is called <strong>valid</strong> if the product of the first <code>i + 1</code> elements and the product of the rem...
Hard
12.9K
55.7K
12,937
55,691
23.2%
['replace-non-coprime-numbers-in-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findValidSplit(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findValidSplit(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[4,7,8,15,3,5]
{ "name": "findValidSplit", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Number Theory']
2,585
Number of Ways to Earn Points
number-of-ways-to-earn-points
<p>There is a test that has <code>n</code> types of questions. You are given an integer <code>target</code> and a <strong>0-indexed</strong> 2D integer array <code>types</code> where <code>types[i] = [count<sub>i</sub>, marks<sub>i</sub>]</code> indicates that there are <code>count<sub>i</sub></code> questions of the <...
Hard
20.1K
34.5K
20,144
34,526
58.3%
['coin-change-ii', 'minimum-total-distance-traveled']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int waysToReachTarget(int target, vector<vector<int>>& types) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int waysToReachTarget(int target, int[][] types) {\n \n }\n}"},...
6 [[6,1],[3,2],[2,3]]
{ "name": "waysToReachTarget", "params": [ { "name": "target", "type": "integer" }, { "type": "integer[][]", "name": "types" } ], "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']
2,586
Count the Number of Vowel Strings in Range
count-the-number-of-vowel-strings-in-range
<p>You are given a <strong>0-indexed</strong> array of string <code>words</code> and two integers <code>left</code> and <code>right</code>.</p> <p>A string is called a <strong>vowel string</strong> if it starts with a vowel character and ends with a vowel character where vowel characters are <code>&#39;a&#39;</code>, ...
Easy
75.4K
102.8K
75,440
102,821
73.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int vowelStrings(String[] words, int left, int right) {\n \n }\n...
["are","amy","u"] 0 2
{ "name": "vowelStrings", "params": [ { "name": "words", "type": "string[]" }, { "type": "integer", "name": "left" }, { "type": "integer", "name": "right" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'String', 'Counting']
2,587
Rearrange Array to Maximize Prefix Score
rearrange-array-to-maximize-prefix-score
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. You can rearrange the elements of <code>nums</code> to <strong>any order</strong> (including the given order).</p> <p>Let <code>prefix</code> be the array containing the prefix sums of <code>nums</code> after rearranging it. In other words,...
Medium
33.6K
81.5K
33,567
81,509
41.2%
['two-city-scheduling']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxScore(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxScore(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": ...
[2,-1,0,1,-3,3,-3]
{ "name": "maxScore", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting', 'Prefix Sum']
2,588
Count the Number of Beautiful Subarrays
count-the-number-of-beautiful-subarrays
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. In one operation, you can:</p> <ul> <li>Choose two different indices <code>i</code> and <code>j</code> such that <code>0 &lt;= i, j &lt; nums.length</code>.</li> <li>Choose a non-negative integer <code>k</code> such that the <code>k<sup>t...
Medium
21.2K
41.2K
21,180
41,205
51.4%
['maximum-xor-for-each-query', 'count-the-number-of-ideal-arrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long beautifulSubarrays(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long beautifulSubarrays(int[] nums) {\n \n }\n}"}, {"value": "python", "text"...
[4,3,1,2,4]
{ "name": "beautifulSubarrays", "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', 'Hash Table', 'Bit Manipulation', 'Prefix Sum']
2,589
Minimum Time to Complete All Tasks
minimum-time-to-complete-all-tasks
<p>There is a computer that can run an unlimited number of tasks <strong>at the same time</strong>. You are given a 2D integer array <code>tasks</code> where <code>tasks[i] = [start<sub>i</sub>, end<sub>i</sub>, duration<sub>i</sub>]</code> indicates that the <code>i<sup>th</sup></code> task should run for a total of <...
Hard
11.8K
31.9K
11,784
31,888
37.0%
['single-threaded-cpu']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findMinimumTime(vector<vector<int>>& tasks) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findMinimumTime(int[][] tasks) {\n \n }\n}"}, {"value": "python", "text":...
[[2,3,1],[4,5,1],[1,5,2]]
{ "name": "findMinimumTime", "params": [ { "name": "tasks", "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', 'Stack', 'Greedy', 'Sorting']
2,590
Design a Todo List
design-a-todo-list
null
Medium
3.1K
5.3K
3,131
5,326
58.8%
[]
[]
Algorithms
null
["TodoList","addTask","addTask","getAllTasks","getAllTasks","addTask","getTasksForTag","completeTask","completeTask","getTasksForTag","getAllTasks"] [[],[1,"Task1",50,[]],[1,"Task2",100,["P1"]],[1],[5],[1,"Task3",30,["P1"]],[1,"P1"],[5,1],[1,2],[1,"P1"],[1]]
{ "classname": "TodoList", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "userId" }, { "type": "string", "name": "taskDescription" }, { "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', 'Design', 'Sorting']
2,591
Distribute Money to Maximum Children
distribute-money-to-maximum-children
<p>You are given an integer <code>money</code> denoting the amount of money (in dollars) that you have and another integer <code>children</code> denoting the number of children that you must distribute the money to.</p> <p>You have to distribute the money according to the following rules:</p> <ul> <li>All money must...
Easy
38.3K
197.9K
38,266
197,928
19.3%
['distribute-candies-to-people', 'fair-distribution-of-cookies', 'calculate-money-in-leetcode-bank']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int distMoney(int money, int children) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int distMoney(int money, int children) {\n \n }\n}"}, {"value": "python", "text": "Pyt...
20 3
{ "name": "distMoney", "params": [ { "name": "money", "type": "integer" }, { "type": "integer", "name": "children" } ], "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']
2,592
Maximize Greatness of an Array
maximize-greatness-of-an-array
<p>You are given a 0-indexed integer array <code>nums</code>. You are allowed to permute <code>nums</code> into a new array <code>perm</code> of your choosing.</p> <p>We define the <strong>greatness</strong> of <code>nums</code> be the number of indices <code>0 &lt;= i &lt; nums.length</code> for which <code>perm[i] &...
Medium
30.6K
52.7K
30,569
52,699
58.0%
['3sum-smaller', 'maximum-matching-of-players-with-trainers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximizeGreatness(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximizeGreatness(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,3,5,2,1,3,1]
{ "name": "maximizeGreatness", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Greedy', 'Sorting']
2,593
Find Score of an Array After Marking All Elements
find-score-of-an-array-after-marking-all-elements
<p>You are given an array <code>nums</code> consisting of positive integers.</p> <p>Starting with <code>score = 0</code>, apply the following algorithm:</p> <ul> <li>Choose the smallest integer of the array that is not marked. If there is a tie, choose the one with the smallest index.</li> <li>Add the value of the ...
Medium
128.4K
198.5K
128,407
198,529
64.7%
['sort-integers-by-the-power-value']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long findScore(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long findScore(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
[2,1,3,4,5,2]
{ "name": "findScore", "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', 'Hash Table', 'Sorting', 'Heap (Priority Queue)', 'Simulation']
2,594
Minimum Time to Repair Cars
minimum-time-to-repair-cars
<p>You are given an integer array <code>ranks</code> representing the <strong>ranks</strong> of some mechanics. <font face="monospace">ranks<sub>i</sub></font> is the rank of the <font face="monospace">i<sup>th</sup></font> mechanic<font face="monospace">.</font> A mechanic with a rank <code>r</code> can repair <font f...
Medium
140.9K
234.9K
140,911
234,941
60.0%
['sort-transformed-array', 'koko-eating-bananas']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long repairCars(vector<int>& ranks, int cars) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long repairCars(int[] ranks, int cars) {\n \n }\n}"}, {"value": "python", ...
[4,2,3,1] 10
{ "name": "repairCars", "params": [ { "name": "ranks", "type": "integer[]" }, { "type": "integer", "name": "cars" } ], "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', 'Binary Search']
2,595
Number of Even and Odd Bits
number-of-even-and-odd-bits
<p>You are given a <strong>positive</strong> integer <code>n</code>.</p> <p>Let <code>even</code> denote the number of even indices in the binary representation of <code>n</code> with value 1.</p> <p>Let <code>odd</code> denote the number of odd indices in the binary representation of <code>n</code> with value 1.</p>...
Easy
56.3K
77.8K
56,252
77,805
72.3%
['find-numbers-with-even-number-of-digits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> evenOddBit(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] evenOddBit(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "cl...
50
{ "name": "evenOddBit", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Bit Manipulation']
2,596
Check Knight Tour Configuration
check-knight-tour-configuration
<p>There is a knight on an <code>n x n</code> chessboard. In a valid configuration, the knight starts <strong>at the top-left cell</strong> of the board and visits every cell on the board <strong>exactly once</strong>.</p> <p>You are given an <code>n x n</code> integer matrix <code>grid</code> consisting of distinct i...
Medium
37.2K
64.9K
37,154
64,920
57.2%
['minimum-knight-moves', 'maximum-number-of-moves-to-kill-all-pawns']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool checkValidGrid(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean checkValidGrid(int[][] grid) {\n \n }\n}"}, {"value": "python", "text"...
[[0,11,16,5,20],[17,4,19,10,15],[12,1,8,21,6],[3,18,23,14,9],[24,13,2,7,22]]
{ "name": "checkValidGrid", "params": [ { "name": "grid", "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', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Simulation']
2,597
The Number of Beautiful Subsets
the-number-of-beautiful-subsets
<p>You are given an array <code>nums</code> of positive integers and a <strong>positive</strong> integer <code>k</code>.</p> <p>A subset of <code>nums</code> is <strong>beautiful</strong> if it does not contain two integers with an absolute difference equal to <code>k</code>.</p> <p>Return <em>the number of <strong>n...
Medium
122.9K
242.4K
122,902
242,387
50.7%
['construct-the-lexicographically-largest-valid-sequence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int beautifulSubsets(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int beautifulSubsets(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "te...
[2,4,6] 2
{ "name": "beautifulSubsets", "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', 'Hash Table', 'Math', 'Dynamic Programming', 'Backtracking', 'Sorting', 'Combinatorics']
2,598
Smallest Missing Non-negative Integer After Operations
smallest-missing-non-negative-integer-after-operations
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> and an integer <code>value</code>.</p> <p>In one operation, you can add or subtract <code>value</code> from any element of <code>nums</code>.</p> <ul> <li>For example, if <code>nums = [1,2,3]</code> and <code>value = 2</code>, you can choo...
Medium
18.7K
47.2K
18,668
47,173
39.6%
['first-missing-positive']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findSmallestInteger(vector<int>& nums, int value) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findSmallestInteger(int[] nums, int value) {\n \n }\n}"}, {"value":...
[1,-10,7,13,6,8] 5
{ "name": "findSmallestInteger", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer", "name": "value" } ], "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', 'Greedy']
2,599
Make the Prefix Sum Non-negative
make-the-prefix-sum-non-negative
null
Medium
7.8K
15.2K
7,840
15,180
51.6%
['furthest-building-you-can-reach']
[]
Algorithms
null
[2,3,-5,4]
{ "name": "makePrefSumNonNegative", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Heap (Priority Queue)']
2,600
K Items With the Maximum Sum
k-items-with-the-maximum-sum
<p>There is a bag that consists of items, each item&nbsp;has a number <code>1</code>, <code>0</code>, or <code>-1</code> written on it.</p> <p>You are given four <strong>non-negative </strong>integers <code>numOnes</code>, <code>numZeros</code>, <code>numNegOnes</code>, and <code>k</code>.</p> <p>The bag initially co...
Easy
50.1K
82.4K
50,079
82,446
60.7%
['maximum-subarray']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int kItemsWithMaximumSum(int numOnes, int numZeros, int numN...
3 2 0 2
{ "name": "kItemsWithMaximumSum", "params": [ { "name": "numOnes", "type": "integer" }, { "type": "integer", "name": "numZeros" }, { "type": "integer", "name": "numNegOnes" }, { "type": "integer", "name": "k" } ], "return": { "t...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Greedy']
2,601
Prime Subtraction Operation
prime-subtraction-operation
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of length <code>n</code>.</p> <p>You can perform the following operation as many times as you want:</p> <ul> <li>Pick an index <code>i</code> that you haven&rsquo;t picked before, and pick a prime <code>p</code> <strong>strictly less than<...
Medium
116.3K
209.3K
116,329
209,320
55.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool primeSubOperation(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean primeSubOperation(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "P...
[4,9,6,10]
{ "name": "primeSubOperation", "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', 'Math', 'Binary Search', 'Greedy', 'Number Theory']
2,602
Minimum Operations to Make All Array Elements Equal
minimum-operations-to-make-all-array-elements-equal
<p>You are given an array <code>nums</code> consisting of positive integers.</p> <p>You are also given an integer array <code>queries</code> of size <code>m</code>. For the <code>i<sup>th</sup></code> query, you want to make all of the elements of <code>nums</code> equal to<code> queries[i]</code>. You can perform the...
Medium
24.3K
66.5K
24,310
66,486
36.6%
['minimum-moves-to-equal-array-elements-ii', 'minimum-cost-to-make-array-equal', 'sum-of-distances']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<long long> minOperations(vector<int>& nums, vector<int>& queries) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Long> minOperations(int[] nums, int[] queries) {\n ...
[3,1,6,8] [1,5]
{ "name": "minOperations", "params": [ { "name": "nums", "type": "integer[]" }, { "type": "integer[]", "name": "queries" } ], "return": { "type": "list<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', 'Binary Search', 'Sorting', 'Prefix Sum']
2,603
Collect Coins in a Tree
collect-coins-in-a-tree
<p>There exists an undirected and unrooted tree with <code>n</code> nodes indexed from <code>0</code> to <code>n - 1</code>. You are given an integer <code>n</code> and a 2D integer array edges of length <code>n - 1</code>, where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edge bet...
Hard
9.1K
25.5K
9,074
25,544
35.5%
['minimum-height-trees', 'sum-of-distances-in-tree', '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 int collectTheCoins(vector<int>& coins, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int collectTheCoins(int[] coins, int[][] edges) {\n \n }\...
[1,0,0,0,0,1] [[0,1],[1,2],[2,3],[3,4],[4,5]]
{ "name": "collectTheCoins", "params": [ { "name": "coins", "type": "integer[]" }, { "type": "integer[][]", "name": "edges" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Tree', 'Graph', 'Topological Sort']
2,604
Minimum Time to Eat All Grains
minimum-time-to-eat-all-grains
null
Hard
1.7K
4.2K
1,657
4,214
39.3%
['kth-smallest-number-in-multiplication-table']
[]
Algorithms
null
[3,6,7] [2,4,7,9]
{ "name": "minimumTime", "params": [ { "name": "hens", "type": "integer[]" }, { "type": "integer[]", "name": "grains" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting']
2,605
Form Smallest Number From Two Digit Arrays
form-smallest-number-from-two-digit-arrays
Given two arrays of <strong>unique</strong> digits <code>nums1</code> and <code>nums2</code>, return <em>the <strong>smallest</strong> number that contains <strong>at least</strong> one digit from each array</em>. <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> nums1 = [4...
Easy
44.1K
81.4K
44,072
81,402
54.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minNumber(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minNumber(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "pytho...
[4,1,3] [5,7]
{ "name": "minNumber", "params": [ { "name": "nums1", "type": "integer[]" }, { "type": "integer[]", "name": "nums2" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Enumeration']
2,606
Find the Substring With Maximum Cost
find-the-substring-with-maximum-cost
<p>You are given a string <code>s</code>, a string <code>chars</code> of <strong>distinct</strong> characters and an integer array <code>vals</code> of the same length as <code>chars</code>.</p> <p>The <strong>cost of the substring </strong>is the sum of the values of each character in the substring. The cost of an em...
Medium
28.1K
49.7K
28,082
49,685
56.5%
['maximum-subarray']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maximumCostSubstring(string s, string chars, vector<int>& vals) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maximumCostSubstring(String s, String chars, int[] vals) {\n ...
"adaa" "d" [-1000]
{ "name": "maximumCostSubstring", "params": [ { "name": "s", "type": "string" }, { "type": "string", "name": "chars" }, { "type": "integer[]", "name": "vals" } ], "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', 'Dynamic Programming']
2,607
Make K-Subarray Sums Equal
make-k-subarray-sums-equal
<p>You are given a <strong>0-indexed</strong> integer array <code>arr</code> and an integer <code>k</code>. The array <code>arr</code> is circular. In other words, the first element of the array is the next element of the last element, and the last element of the array is the previous element of the first element.</p> ...
Medium
12K
33.2K
11,996
33,156
36.2%
['rotate-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n long long makeSubKSumEqual(vector<int>& arr, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public long makeSubKSumEqual(int[] arr, int k) {\n \n }\n}"}, {"value": "python"...
[1,4,1,3] 2
{ "name": "makeSubKSumEqual", "params": [ { "name": "arr", "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', 'Math', 'Greedy', 'Sorting', 'Number Theory']
2,608
Shortest Cycle in a Graph
shortest-cycle-in-a-graph
<p>There is a <strong>bi-directional </strong>graph with <code>n</code> vertices, where each vertex is labeled from <code>0</code> to <code>n - 1</code>. The edges in the graph are represented by a given 2D integer array <code>edges</code>, where <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> denotes an edge be...
Hard
22.9K
61.9K
22,950
61,871
37.1%
['redundant-connection', 'longest-cycle-in-a-graph', 'divide-nodes-into-the-maximum-number-of-groups']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findShortestCycle(int n, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findShortestCycle(int n, int[][] edges) {\n \n }\n}"}, {"value":...
7 [[0,1],[1,2],[2,0],[3,4],[4,5],[5,6],[6,3]]
{ "name": "findShortestCycle", "params": [ { "type": "integer", "name": "n" }, { "type": "integer[][]", "name": "edges" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Breadth-First Search', 'Graph']