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
801
Minimum Swaps To Make Sequences Increasing
minimum-swaps-to-make-sequences-increasing
<p>You are given two integer arrays of the same length <code>nums1</code> and <code>nums2</code>. In one operation, you are allowed to swap <code>nums1[i]</code> with <code>nums2[i]</code>.</p> <ul> <li>For example, if <code>nums1 = [1,2,3,<u>8</u>]</code>, and <code>nums2 = [5,6,7,<u>4</u>]</code>, you can swap the ...
Hard
88.1K
216.9K
88,121
216,923
40.6%
['minimum-operations-to-make-the-array-k-increasing', 'minimum-operations-to-maximize-last-elements-in-arrays']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minSwap(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minSwap(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "python", ...
[1,3,5,4] [1,2,3,7]
{ "name": "minSwap", "params": [ { "name": "nums1", "type": "integer[]" }, { "name": "nums2", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
802
Find Eventual Safe States
find-eventual-safe-states
<p>There is a directed graph of <code>n</code> nodes with each node labeled from <code>0</code> to <code>n - 1</code>. The graph is represented by a <strong>0-indexed</strong> 2D integer array <code>graph</code> where <code>graph[i]</code> is an integer array of nodes adjacent to node <code>i</code>, meaning there is a...
Medium
434.5K
637.7K
434,490
637,656
68.1%
['build-a-matrix-with-conditions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> eventualSafeNodes(vector<vector<int>>& graph) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> eventualSafeNodes(int[][] graph) {\n \n }\n}"}, {"val...
[[1,2],[2,3],[5],[0],[5],[],[]]
{ "name": "eventualSafeNodes", "params": [ { "name": "graph", "type": "integer[][]" } ], "return": { "type": "list<integer>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Topological Sort']
803
Bricks Falling When Hit
bricks-falling-when-hit
<p>You are given an <code>m x n</code> binary <code>grid</code>, where each <code>1</code> represents a brick and <code>0</code> represents an empty space. A brick is <strong>stable</strong> if:</p> <ul> <li>It is directly connected to the top of the grid, or</li> <li>At least one other brick in its four adjacent ce...
Hard
32.9K
92.9K
32,858
92,890
35.4%
['last-day-where-you-can-still-cross', 'number-of-ways-to-build-sturdy-brick-wall']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> hitBricks(vector<vector<int>>& grid, vector<vector<int>>& hits) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] hitBricks(int[][] grid, int[][] hits) {\n \n ...
[[1,0,0,0],[1,1,1,0]] [[1,0]]
{ "name": "hitBricks", "params": [ { "name": "grid", "type": "integer[][]" }, { "name": "hits", "type": "integer[][]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Union Find', 'Matrix']
804
Unique Morse Code Words
unique-morse-code-words
<p>International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:</p> <ul> <li><code>&#39;a&#39;</code> maps to <code>&quot;.-&quot;</code>,</li> <li><code>&#39;b&#39;</code> maps to <code>&quot;-...&quot;</code>,</li> <li><code>&#39;c&#39;</code> maps t...
Easy
378.6K
455.2K
378,631
455,240
83.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int uniqueMorseRepresentations(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int uniqueMorseRepresentations(String[] words) {\n \n }\n}"}, {"value":...
["gin","zen","gig","msg"]
{ "name": "uniqueMorseRepresentations", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String']
805
Split Array With Same Average
split-array-with-same-average
<p>You are given an integer array <code>nums</code>.</p> <p>You should move each element of <code>nums</code> into one of the two arrays <code>A</code> and <code>B</code> such that <code>A</code> and <code>B</code> are non-empty, and <code>average(A) == average(B)</code>.</p> <p>Return <code>true</code> if it is poss...
Hard
40.6K
157K
40,633
156,974
25.9%
['partition-array-into-two-arrays-to-minimize-sum-difference', 'minimum-average-difference']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool splitArraySameAverage(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean splitArraySameAverage(int[] nums) {\n \n }\n}"}, {"value": "python", "t...
[1,2,3,4,5,6,7,8]
{ "name": "splitArraySameAverage", "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', 'Dynamic Programming', 'Bit Manipulation', 'Bitmask']
806
Number of Lines To Write String
number-of-lines-to-write-string
<p>You are given a string <code>s</code> of lowercase English letters and an array <code>widths</code> denoting <strong>how many pixels wide</strong> each lowercase English letter is. Specifically, <code>widths[0]</code> is the width of <code>&#39;a&#39;</code>, <code>widths[1]</code> is the width of <code>&#39;b&#39;<...
Easy
95.6K
135.9K
95,608
135,869
70.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> numberOfLines(vector<int>& widths, string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] numberOfLines(int[] widths, String s) {\n \n }\n}"}, {"value":...
[10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10] "abcdefghijklmnopqrstuvwxyz"
{ "name": "numberOfLines", "params": [ { "name": "widths", "type": "integer[]" }, { "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...
['Array', 'String']
807
Max Increase to Keep City Skyline
max-increase-to-keep-city-skyline
<p>There is a city composed of <code>n x n</code> blocks, where each block contains a single building shaped like a vertical square prism. You are given a <strong>0-indexed</strong> <code>n x n</code> integer matrix <code>grid</code> where <code>grid[r][c]</code> represents the <strong>height</strong> of the building l...
Medium
175.4K
203.6K
175,416
203,561
86.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxIncreaseKeepingSkyline(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxIncreaseKeepingSkyline(int[][] grid) {\n \n }\n}"}, {"value":...
[[3,0,8,4],[2,4,5,7],[9,2,6,3],[0,3,1,0]]
{ "name": "maxIncreaseKeepingSkyline", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Matrix']
808
Soup Servings
soup-servings
<p>There are two types of soup: <strong>type A</strong> and <strong>type B</strong>. Initially, we have <code>n</code> ml of each type of soup. There are four kinds of operations:</p> <ol> <li>Serve <code>100</code> ml of <strong>soup A</strong> and <code>0</code> ml of <strong>soup B</strong>,</li> <li>Serve <code>...
Medium
71.2K
133.6K
71,237
133,616
53.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double soupServings(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double soupServings(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "cl...
50
{ "name": "soupServings", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Probability and Statistics']
809
Expressive Words
expressive-words
<p>Sometimes people repeat letters to represent extra feeling. For example:</p> <ul> <li><code>&quot;hello&quot; -&gt; &quot;heeellooo&quot;</code></li> <li><code>&quot;hi&quot; -&gt; &quot;hiiii&quot;</code></li> </ul> <p>In these strings like <code>&quot;heeellooo&quot;</code>, we have groups of adjacent letters ...
Medium
126K
272K
126,003
272,020
46.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int expressiveWords(string s, vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int expressiveWords(String s, String[] words) {\n \n }\n}"}, {"value": "...
"heeellooo" ["hello", "hi", "helo"]
{ "name": "expressiveWords", "params": [ { "name": "s", "type": "string" }, { "name": "words", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'String']
810
Chalkboard XOR Game
chalkboard-xor-game
<p>You are given an array of integers <code>nums</code> represents the numbers written on a chalkboard.</p> <p>Alice and Bob take turns erasing exactly one number from the chalkboard, with Alice starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become <code>0</code>, t...
Hard
14.4K
23.1K
14,432
23,138
62.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool xorGame(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean xorGame(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode...
[1,1,2]
{ "name": "xorGame", "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', 'Bit Manipulation', 'Brainteaser', 'Game Theory']
811
Subdomain Visit Count
subdomain-visit-count
<p>A website domain <code>&quot;discuss.leetcode.com&quot;</code> consists of various subdomains. At the top level, we have <code>&quot;com&quot;</code>, at the next level, we have <code>&quot;leetcode.com&quot;</code>&nbsp;and at the lowest level, <code>&quot;discuss.leetcode.com&quot;</code>. When we visit a domain l...
Medium
245.9K
320.4K
245,948
320,413
76.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> subdomainVisits(vector<string>& cpdomains) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> subdomainVisits(String[] cpdomains) {\n \n }\n}"}, {"v...
["9001 discuss.leetcode.com"]
{ "name": "subdomainVisits", "params": [ { "name": "cpdomains", "type": "string[]" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Counting']
812
Largest Triangle Area
largest-triangle-area
<p>Given an array of points on the <strong>X-Y</strong> plane <code>points</code> where <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>, return <em>the area of the largest triangle that can be formed by any three different points</em>. Answers within <code>10<sup>-5</sup></code> of the actual answer will be acc...
Easy
61.9K
100.3K
61,922
100,262
61.8%
['largest-perimeter-triangle']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double largestTriangleArea(vector<vector<int>>& points) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double largestTriangleArea(int[][] points) {\n \n }\n}"}, {"value": "...
[[0,0],[0,1],[1,0],[0,2],[2,0]]
{ "name": "largestTriangleArea", "params": [ { "name": "points", "type": "integer[][]" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Geometry']
813
Largest Sum of Averages
largest-sum-of-averages
<p>You are given an integer array <code>nums</code> and an integer <code>k</code>. You can partition the array into <strong>at most</strong> <code>k</code> non-empty adjacent subarrays. The <strong>score</strong> of a partition is the sum of the averages of each subarray.</p> <p>Note that the partition must use every ...
Medium
59.3K
109.9K
59,278
109,922
53.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double largestSumOfAverages(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double largestSumOfAverages(int[] nums, int k) {\n \n }\n}"}, {"value":...
[9,1,2,3,9] 3
{ "name": "largestSumOfAverages", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Prefix Sum']
814
Binary Tree Pruning
binary-tree-pruning
<p>Given the <code>root</code> of a binary tree, return <em>the same tree where every subtree (of the given tree) not containing a </em><code>1</code><em> has been removed</em>.</p> <p>A subtree of a node <code>node</code> is <code>node</code> plus every node that is a descendant of <code>node</code>.</p> <p>&nbsp;</...
Medium
265.9K
367.7K
265,942
367,735
72.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,null,0,0,1]
{ "name": "pruneTree", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
815
Bus Routes
bus-routes
<p>You are given an array <code>routes</code> representing bus routes where <code>routes[i]</code> is a bus route that the <code>i<sup>th</sup></code> bus repeats forever.</p> <ul> <li>For example, if <code>routes[0] = [1, 5, 7]</code>, this means that the <code>0<sup>th</sup></code> bus travels in the sequence <code...
Hard
236.7K
503.9K
236,749
503,932
47.0%
['minimum-costs-using-the-train-line']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numBusesToDestination(vector<vector<int>>& routes, int source, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numBusesToDestination(int[][] routes, int source, in...
[[1,2,7],[3,6,7]] 1 6
{ "name": "numBusesToDestination", "params": [ { "name": "routes", "type": "integer[][]" }, { "name": "source", "type": "integer" }, { "name": "target", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Breadth-First Search']
816
Ambiguous Coordinates
ambiguous-coordinates
<p>We had some 2-dimensional coordinates, like <code>&quot;(1, 3)&quot;</code> or <code>&quot;(2, 0.5)&quot;</code>. Then, we removed all commas, decimal points, and spaces and ended up with the string s.</p> <ul> <li>For example, <code>&quot;(1, 3)&quot;</code> becomes <code>s = &quot;(13)&quot;</code> and <code>&qu...
Medium
32.1K
57.6K
32,140
57,617
55.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> ambiguousCoordinates(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> ambiguousCoordinates(String s) {\n \n }\n}"}, {"value": "python", ...
"(123)"
{ "name": "ambiguousCoordinates", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Backtracking', 'Enumeration']
817
Linked List Components
linked-list-components
<p>You are given the <code>head</code> of a linked list containing unique integer values and an integer array <code>nums</code> that is a subset of the linked list values.</p> <p>Return <em>the number of connected components in </em><code>nums</code><em> where two values are connected if they appear <strong>consecutiv...
Medium
108.5K
189.8K
108,465
189,837
57.1%
['merge-nodes-in-between-zeros']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[0,1,2,3] [0,1,3]
{ "name": "numComponents", "params": [ { "name": "head", "type": "ListNode" }, { "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', 'Linked List']
818
Race Car
race-car
<p>Your car starts at position <code>0</code> and speed <code>+1</code> on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions <code>&#39;A&#39;</code> (accelerate) and <code>&#39;R&#39;</code> (reverse):</p> <ul> <li>When you get an ...
Hard
96K
218.3K
96,050
218,258
44.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int racecar(int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int racecar(int target) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class So...
3
{ "name": "racecar", "params": [ { "name": "target", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming']
819
Most Common Word
most-common-word
<p>Given a string <code>paragraph</code> and a string array of the banned words <code>banned</code>, return <em>the most frequent word that is not banned</em>. It is <strong>guaranteed</strong> there is <strong>at least one word</strong> that is not banned, and that the answer is <strong>unique</strong>.</p> <p>The wo...
Easy
403K
905.4K
402,984
905,355
44.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string mostCommonWord(string paragraph, vector<string>& banned) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String mostCommonWord(String paragraph, String[] banned) {\n \n ...
"Bob hit a ball, the hit BALL flew far after it was hit." ["hit"]
{ "name": "mostCommonWord", "params": [ { "name": "paragraph", "type": "string" }, { "name": "banned", "type": "string[]" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Counting']
820
Short Encoding of Words
short-encoding-of-words
<p>A <strong>valid encoding</strong> of an array of <code>words</code> is any reference string <code>s</code> and array of indices <code>indices</code> such that:</p> <ul> <li><code>words.length == indices.length</code></li> <li>The reference string <code>s</code> ends with the <code>&#39;#&#39;</code> character.</l...
Medium
100.3K
165.7K
100,278
165,698
60.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumLengthEncoding(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumLengthEncoding(String[] words) {\n \n }\n}"}, {"value": "python",...
["time","me","bell"]
{ "name": "minimumLengthEncoding", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Trie']
821
Shortest Distance to a Character
shortest-distance-to-a-character
<p>Given a string <code>s</code> and a character <code>c</code> that occurs in <code>s</code>, return <em>an array of integers </em><code>answer</code><em> where </em><code>answer.length == s.length</code><em> and </em><code>answer[i]</code><em> is the <strong>distance</strong> from index </em><code>i</code><em> to the...
Easy
209.4K
290.5K
209,376
290,526
72.1%
['check-distances-between-same-letters']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> shortestToChar(string s, char c) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] shortestToChar(String s, char c) {\n \n }\n}"}, {"value": "python", "text"...
"loveleetcode" "e"
{ "name": "shortestToChar", "params": [ { "name": "s", "type": "string" }, { "name": "c", "type": "character" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'String']
822
Card Flipping Game
card-flipping-game
<p>You are given two <strong>0-indexed</strong> integer arrays <code>fronts</code> and <code>backs</code> of length <code>n</code>, where the <code>i<sup>th</sup></code> card has the positive integer <code>fronts[i]</code> printed on the front and <code>backs[i]</code> printed on the back. Initially, each card is place...
Medium
22K
45.8K
22,027
45,848
48.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int flipgame(vector<int>& fronts, vector<int>& backs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int flipgame(int[] fronts, int[] backs) {\n \n }\n}"}, {"value": "pytho...
[1,2,4,4,7] [1,3,4,1,3]
{ "name": "flipgame", "params": [ { "name": "fronts", "type": "integer[]" }, { "name": "backs", "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']
823
Binary Trees With Factors
binary-trees-with-factors
<p>Given an array of unique integers, <code>arr</code>, where each integer <code>arr[i]</code> is strictly greater than <code>1</code>.</p> <p>We make a binary tree using these integers, and each number may be used for any number of times. Each non-leaf node&#39;s value should be equal to the product of the values of ...
Medium
153.8K
290.7K
153,809
290,703
52.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numFactoredBinaryTrees(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numFactoredBinaryTrees(int[] arr) {\n \n }\n}"}, {"value": "python", "text":...
[2,4]
{ "name": "numFactoredBinaryTrees", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Dynamic Programming', 'Sorting']
824
Goat Latin
goat-latin
<p>You are given a string <code>sentence</code> that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.</p> <p>We would like to convert the sentence to &quot;Goat Latin&quot; (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:</p> <ul> <li...
Easy
212.6K
307.2K
212,591
307,158
69.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string toGoatLatin(string sentence) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String toGoatLatin(String sentence) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"I speak Goat Latin"
{ "name": "toGoatLatin", "params": [ { "name": "sentence", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String']
825
Friends Of Appropriate Ages
friends-of-appropriate-ages
<p>There are <code>n</code> persons on a social media website. You are given an integer array <code>ages</code> where <code>ages[i]</code> is the age of the <code>i<sup>th</sup></code> person.</p> <p>A Person <code>x</code> will not send a friend request to a person <code>y</code> (<code>x != y</code>) if any of the f...
Medium
110.7K
226.4K
110,660
226,429
48.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numFriendRequests(vector<int>& ages) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numFriendRequests(int[] ages) {\n \n }\n}"}, {"value": "python", "text": "Python...
[16,16]
{ "name": "numFriendRequests", "params": [ { "name": "ages", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting']
826
Most Profit Assigning Work
most-profit-assigning-work
<p>You have <code>n</code> jobs and <code>m</code> workers. You are given three arrays: <code>difficulty</code>, <code>profit</code>, and <code>worker</code> where:</p> <ul> <li><code>difficulty[i]</code> and <code>profit[i]</code> are the difficulty and the profit of the <code>i<sup>th</sup></code> job, and</li> <l...
Medium
224.3K
401.5K
224,276
401,522
55.9%
['maximum-number-of-tasks-you-can-assign', 'successful-pairs-of-spells-and-potions', 'maximum-matching-of-players-with-trainers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxProfitAssignment(vector<int>& difficulty, vector<int>& profit, vector<int>& worker) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxProfitAssignment(int[] difficulty, in...
[2,4,6,8,10] [10,20,30,40,50] [4,5,6,7]
{ "name": "maxProfitAssignment", "params": [ { "name": "difficulty", "type": "integer[]" }, { "name": "profit", "type": "integer[]" }, { "name": "worker", "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']
827
Making A Large Island
making-a-large-island
<p>You are given an <code>n x n</code> binary matrix <code>grid</code>. You are allowed to change <strong>at most one</strong> <code>0</code> to be <code>1</code>.</p> <p>Return <em>the size of the largest <strong>island</strong> in</em> <code>grid</code> <em>after applying this operation</em>.</p> <p>An <strong>isla...
Hard
328.5K
604.1K
328,499
604,145
54.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int largestIsland(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int largestIsland(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[[1,0],[0,1]]
{ "name": "largestIsland", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Matrix']
828
Count Unique Characters of All Substrings of a Given String
count-unique-characters-of-all-substrings-of-a-given-string
<p>Let&#39;s define a function <code>countUniqueChars(s)</code> that returns the number of unique characters in&nbsp;<code>s</code>.</p> <ul> <li>For example, calling <code>countUniqueChars(s)</code> if <code>s = &quot;LEETCODE&quot;</code> then <code>&quot;L&quot;</code>, <code>&quot;T&quot;</code>, <code>&quot;C&qu...
Hard
77.7K
147.3K
77,680
147,318
52.7%
['total-appeal-of-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int uniqueLetterString(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int uniqueLetterString(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
"ABC"
{ "name": "uniqueLetterString", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Dynamic Programming']
829
Consecutive Numbers Sum
consecutive-numbers-sum
<p>Given an integer <code>n</code>, return <em>the number of ways you can write </em><code>n</code><em> as the sum of consecutive positive integers.</em></p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> n = 5 <strong>Output:</strong> 2 <strong>Explanation:</strong> 5 ...
Hard
93.3K
222.5K
93,317
222,539
41.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int consecutiveNumbersSum(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int consecutiveNumbersSum(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
5
{ "name": "consecutiveNumbersSum", "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', 'Enumeration']
830
Positions of Large Groups
positions-of-large-groups
<p>In a string <code><font face="monospace">s</font></code>&nbsp;of lowercase letters, these letters form consecutive groups of the same character.</p> <p>For example, a string like <code>s = &quot;abbxxxxzyy&quot;</code> has the groups <code>&quot;a&quot;</code>, <code>&quot;bb&quot;</code>, <code>&quot;xxxx&quot;</c...
Easy
106.5K
201.7K
106,483
201,685
52.8%
['divide-a-string-into-groups-of-size-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> largeGroupPositions(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<List<Integer>> largeGroupPositions(String s) {\n \n }\n}"}, {"value": ...
"abbxxxxzzy"
{ "name": "largeGroupPositions", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "list<list<integer>>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String']
831
Masking Personal Information
masking-personal-information
<p>You are given a personal information string <code>s</code>, representing either an <strong>email address</strong> or a <strong>phone number</strong>. Return <em>the <strong>masked</strong> personal information using the below rules</em>.</p> <p><u><strong>Email address:</strong></u></p> <p>An email address is:</p>...
Medium
22.9K
45.6K
22,940
45,634
50.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string maskPII(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String maskPII(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
"LeetCode@LeetCode.com"
{ "name": "maskPII", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String']
832
Flipping an Image
flipping-an-image
<p>Given an <code>n x n</code> binary matrix <code>image</code>, flip the image <strong>horizontally</strong>, then invert it, and return <em>the resulting image</em>.</p> <p>To flip an image horizontally means that each row of the image is reversed.</p> <ul> <li>For example, flipping <code>[1,1,0]</code> horizontal...
Easy
487.5K
588.6K
487,528
588,609
82.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> flipAndInvertImage(vector<vector<int>>& image) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] flipAndInvertImage(int[][] image) {\n \n }\n}"}, {...
[[1,1,0],[1,0,1],[0,0,0]]
{ "name": "flipAndInvertImage", "params": [ { "name": "image", "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', 'Bit Manipulation', 'Matrix', 'Simulation']
833
Find And Replace in String
find-and-replace-in-string
<p>You are given a <strong>0-indexed</strong> string <code>s</code> that you must perform <code>k</code> replacement operations on. The replacement operations are given as three <strong>0-indexed</strong> parallel arrays, <code>indices</code>, <code>sources</code>, and <code>targets</code>, all of length <code>k</code>...
Medium
158.5K
308.2K
158,468
308,151
51.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string findReplaceString(string s, vector<int>& indices, vector<string>& sources, vector<string>& targets) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String findReplaceString(Str...
"abcd" [0, 2] ["a", "cd"] ["eee", "ffff"]
{ "name": "findReplaceString", "params": [ { "name": "s", "type": "string" }, { "name": "indices", "type": "integer[]" }, { "name": "sources", "type": "string[]" }, { "name": "targets", "type": "string[]" } ], "return": { "type"...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Sorting']
834
Sum of Distances in Tree
sum-of-distances-in-tree
<p>There is an undirected connected tree with <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code> and <code>n - 1</code> edges.</p> <p>You are given the integer <code>n</code> and the array <code>edges</code> where <code>edges[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that there is an edg...
Hard
167.1K
256.1K
167,124
256,059
65.3%
['distribute-coins-in-binary-tree', 'count-nodes-with-the-highest-score', 'collect-coins-in-a-tree', 'maximum-score-after-applying-operations-on-a-tree', 'count-pairs-of-connectable-servers-in-a-weighted-tree-network', 'time-taken-to-mark-all-nodes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> sumOfDistancesInTree(int n, vector<vector<int>>& edges) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] sumOfDistancesInTree(int n, int[][] edges) {\n \n }...
6 [[0,1],[0,2],[2,3],[2,4],[2,5]]
{ "name": "sumOfDistancesInTree", "params": [ { "name": "n", "type": "integer" }, { "name": "edges", "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', 'Tree', 'Depth-First Search', 'Graph']
835
Image Overlap
image-overlap
<p>You are given two images, <code>img1</code> and <code>img2</code>, represented as binary, square matrices of size <code>n x n</code>. A binary matrix has only <code>0</code>s and <code>1</code>s as values.</p> <p>We <strong>translate</strong> one image however we choose by sliding all the <code>1</code> bits left, ...
Medium
99.2K
155.7K
99,155
155,658
63.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int largestOverlap(vector<vector<int>>& img1, vector<vector<int>>& img2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int largestOverlap(int[][] img1, int[][] img2) {\n \n ...
[[1,1,0],[0,1,0],[0,1,0]] [[0,0,0],[0,1,1],[0,0,1]]
{ "name": "largestOverlap", "params": [ { "name": "img1", "type": "integer[][]" }, { "name": "img2", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix']
836
Rectangle Overlap
rectangle-overlap
<p>An axis-aligned rectangle is represented as a list <code>[x1, y1, x2, y2]</code>, where <code>(x1, y1)</code> is the coordinate of its bottom-left corner, and <code>(x2, y2)</code> is the coordinate of its top-right corner. Its top and bottom edges are parallel to the X-axis, and its left and right edges are paralle...
Easy
162.9K
357.3K
162,884
357,322
45.6%
['rectangle-area']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isRectangleOverlap(int[] rec1, int[] rec2) {\n \n }\n}"...
[0,0,2,2] [1,1,3,3]
{ "name": "isRectangleOverlap", "params": [ { "name": "rec1", "type": "integer[]" }, { "name": "rec2", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Geometry']
837
New 21 Game
new-21-game
<p>Alice plays the following game, loosely based on the card game <strong>&quot;21&quot;</strong>.</p> <p>Alice starts with <code>0</code> points and draws numbers while she has less than <code>k</code> points. During each draw, she gains an integer number of points randomly from the range <code>[1, maxPts]</code>, wh...
Medium
80.5K
179.7K
80,483
179,652
44.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double new21Game(int n, int k, int maxPts) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double new21Game(int n, int k, int maxPts) {\n \n }\n}"}, {"value": "python", "tex...
10 1 10
{ "name": "new21Game", "params": [ { "name": "n", "type": "integer" }, { "name": "k", "type": "integer" }, { "name": "maxPts", "type": "integer" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming', 'Sliding Window', 'Probability and Statistics']
838
Push Dominoes
push-dominoes
<p>There are <code>n</code> dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to the left or to the right.</p> <p>After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoe...
Medium
130.7K
227.9K
130,724
227,936
57.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string pushDominoes(string dominoes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String pushDominoes(String dominoes) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"RR.L"
{ "name": "pushDominoes", "params": [ { "name": "dominoes", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'String', 'Dynamic Programming']
839
Similar String Groups
similar-string-groups
<p>Two strings, <code>X</code> and <code>Y</code>, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string <code>X</code>.</p> <p>For example, <code>&quot;tars&quot;</code>&nbsp;and <code>&quot;rats&quot;</code>&nbsp;a...
Hard
129.7K
234.7K
129,661
234,737
55.2%
['groups-of-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSimilarGroups(vector<string>& strs) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSimilarGroups(String[] strs) {\n \n }\n}"}, {"value": "python", "text": "Py...
["tars","rats","arts","star"]
{ "name": "numSimilarGroups", "params": [ { "name": "strs", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Depth-First Search', 'Breadth-First Search', 'Union Find']
840
Magic Squares In Grid
magic-squares-in-grid
<p>A <code>3 x 3</code> <strong>magic square</strong> is a <code>3 x 3</code> grid filled with distinct numbers <strong>from </strong>1<strong> to </strong>9 such that each row, column, and both diagonals all have the same sum.</p> <p>Given a <code>row x col</code> <code>grid</code> of integers, how many <code>3 x 3</...
Medium
147K
285.3K
146,985
285,265
51.5%
['largest-magic-square']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numMagicSquaresInside(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numMagicSquaresInside(int[][] grid) {\n \n }\n}"}, {"value": "python...
[[4,3,8,4],[9,5,1,9],[2,7,6,2]]
{ "name": "numMagicSquaresInside", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Math', 'Matrix']
841
Keys and Rooms
keys-and-rooms
<p>There are <code>n</code> rooms labeled from <code>0</code> to <code>n - 1</code>&nbsp;and all the rooms are locked except for room <code>0</code>. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key.</p> <p>When you visit a room, you may find a set of <strong>distinct...
Medium
562.5K
756.1K
562,467
756,056
74.4%
['graph-valid-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canVisitAllRooms(vector<vector<int>>& rooms) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canVisitAllRooms(List<List<Integer>> rooms) {\n \n }\n}"}, {"value"...
[[1],[2],[3],[]]
{ "name": "canVisitAllRooms", "params": [ { "name": "rooms", "type": "list<list<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...
['Depth-First Search', 'Breadth-First Search', 'Graph']
842
Split Array into Fibonacci Sequence
split-array-into-fibonacci-sequence
<p>You are given a string of digits <code>num</code>, such as <code>&quot;123456579&quot;</code>. We can split it into a Fibonacci-like sequence <code>[123, 456, 579]</code>.</p> <p>Formally, a <strong>Fibonacci-like</strong> sequence is a list <code>f</code> of non-negative integers such that:</p> <ul> <li><code>0 ...
Medium
43K
108.8K
43,048
108,774
39.6%
['additive-number', 'fibonacci-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> splitIntoFibonacci(string num) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> splitIntoFibonacci(String num) {\n \n }\n}"}, {"value": "python", "t...
"1101111"
{ "name": "splitIntoFibonacci", "params": [ { "name": "num", "type": "string" } ], "return": { "type": "list<integer>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Backtracking']
843
Guess the Word
guess-the-word
<p>You are given an array of unique strings <code>words</code> where <code>words[i]</code> is six letters long. One word of <code>words</code> was chosen as a secret word.</p> <p>You are also given the helper object <code>Master</code>. You may call <code>Master.guess(word)</code> where <code>word</code> is a six-lett...
Hard
157.2K
414.7K
157,171
414,734
37.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * // This is the Master's API interface.\n * // You should not implement it, or speculate about its implementation\n * class Master {\n * public:\n * int guess(string word);\n * };\n */\nclass Solution {\npublic:\n void findSecretWord(vector<string>& words...
"acckzz" ["acckzz","ccbazz","eiowzz","abcczz"] 10
{ "name": "findSecretWord", "params": [ { "name": "secret", "type": "string" }, { "name": "words", "type": "string[]" }, { "name": "allowedGuesses", "type": "integer" } ], "return": { "type": "void" }, "manual": true, "languages": [ "cpp"...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>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', 'Interactive', 'Game Theory']
844
Backspace String Compare
backspace-string-compare
<p>Given two strings <code>s</code> and <code>t</code>, return <code>true</code> <em>if they are equal when both are typed into empty text editors</em>. <code>&#39;#&#39;</code> means a backspace character.</p> <p>Note that after backspacing an empty text, the text will continue empty.</p> <p>&nbsp;</p> <p><strong cl...
Easy
924.6K
1.9M
924,555
1,870,349
49.4%
['crawler-log-folder', 'removing-stars-from-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool backspaceCompare(string s, string t) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean backspaceCompare(String s, String t) {\n \n }\n}"}, {"value": "python", "te...
"ab#c" "ad#c"
{ "name": "backspaceCompare", "params": [ { "name": "s", "type": "string" }, { "name": "t", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Two Pointers', 'String', 'Stack', 'Simulation']
845
Longest Mountain in Array
longest-mountain-in-array
<p>You may recall that an array <code>arr</code> is a <strong>mountain array</strong> if and only if:</p> <ul> <li><code>arr.length &gt;= 3</code></li> <li>There exists some index <code>i</code> (<strong>0-indexed</strong>) with <code>0 &lt; i &lt; arr.length - 1</code> such that: <ul> <li><code>arr[0] &lt; arr[1...
Medium
155.7K
380K
155,664
380,020
41.0%
['minimum-number-of-removals-to-make-mountain-array', 'find-good-days-to-rob-the-bank']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int longestMountain(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int longestMountain(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[2,1,4,7,3,2,5]
{ "name": "longestMountain", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Dynamic Programming', 'Enumeration']
846
Hand of Straights
hand-of-straights
<p>Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size <code>groupSize</code>, and consists of <code>groupSize</code> consecutive cards.</p> <p>Given an integer array <code>hand</code> where <code>hand[i]</code> is the value written on the <code>i<sup>th</sup><...
Medium
360.3K
633.1K
360,329
633,131
56.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isNStraightHand(vector<int>& hand, int groupSize) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isNStraightHand(int[] hand, int groupSize) {\n \n }\n}"}, {"va...
[1,2,3,6,2,3,4,7,8] 3
{ "name": "isNStraightHand", "params": [ { "name": "hand", "type": "integer[]" }, { "name": "groupSize", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Greedy', 'Sorting']
847
Shortest Path Visiting All Nodes
shortest-path-visiting-all-nodes
<p>You have an undirected, connected graph of <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. You are given an array <code>graph</code> where <code>graph[i]</code> is a list of all the nodes connected with node <code>i</code> by an edge.</p> <p>Return <em>the length of the shortest path that vi...
Hard
133.3K
204K
133,299
203,966
65.4%
['find-the-minimum-cost-array-permutation']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int shortestPathLength(vector<vector<int>>& graph) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int shortestPathLength(int[][] graph) {\n \n }\n}"}, {"value": "python", "...
[[1,2,3],[0],[0],[0]]
{ "name": "shortestPathLength", "params": [ { "name": "graph", "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', 'Bit Manipulation', 'Breadth-First Search', 'Graph', 'Bitmask']
848
Shifting Letters
shifting-letters
<p>You are given a string <code>s</code> of lowercase English letters and an integer array <code>shifts</code> of the same length.</p> <p>Call the <code>shift()</code> of a letter, the next letter in the alphabet, (wrapping around so that <code>&#39;z&#39;</code> becomes <code>&#39;a&#39;</code>).</p> <ul> <li>For e...
Medium
116.2K
256K
116,166
256,002
45.4%
['replace-all-digits-with-characters', 'shifting-letters-ii', 'lexicographically-smallest-string-after-substring-operation', 'shift-distance-between-two-strings', 'find-the-k-th-character-in-string-game-i', 'find-the-k-th-character-in-string-game-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string shiftingLetters(string s, vector<int>& shifts) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String shiftingLetters(String s, int[] shifts) {\n \n }\n}"}, {"value":...
"abc" [3,5,9]
{ "name": "shiftingLetters", "params": [ { "name": "s", "type": "string" }, { "name": "shifts", "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', 'Prefix Sum']
849
Maximize Distance to Closest Person
maximize-distance-to-closest-person
<p>You are given an array representing a row of <code>seats</code> where <code>seats[i] = 1</code> represents a person sitting in the <code>i<sup>th</sup></code> seat, and <code>seats[i] = 0</code> represents that the <code>i<sup>th</sup></code> seat is empty <strong>(0-indexed)</strong>.</p> <p>There is at least one ...
Medium
251.7K
515.8K
251,662
515,791
48.8%
['exam-room', 'task-scheduler-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxDistToClosest(vector<int>& seats) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxDistToClosest(int[] seats) {\n \n }\n}"}, {"value": "python", "text": "Python...
[1,0,0,0,1,0,1]
{ "name": "maxDistToClosest", "params": [ { "name": "seats", "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']
850
Rectangle Area II
rectangle-area-ii
<p>You are given a 2D array of axis-aligned <code>rectangles</code>. Each <code>rectangle[i] = [x<sub>i1</sub>, y<sub>i1</sub>, x<sub>i2</sub>, y<sub>i2</sub>]</code> denotes the <code>i<sup>th</sup></code> rectangle where <code>(x<sub>i1</sub>, y<sub>i1</sub>)</code> are the coordinates of the <strong>bottom-left corn...
Hard
38K
69.8K
38,031
69,841
54.5%
['separate-squares-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rectangleArea(vector<vector<int>>& rectangles) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rectangleArea(int[][] rectangles) {\n \n }\n}"}, {"value": "python", "...
[[0,0,2,2],[1,0,2,3],[1,0,3,1]]
{ "name": "rectangleArea", "params": [ { "name": "rectangles", "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', 'Segment Tree', 'Line Sweep', 'Ordered Set']
851
Loud and Rich
loud-and-rich
<p>There is a group of <code>n</code> people labeled from <code>0</code> to <code>n - 1</code> where each person has a different amount of money and a different level of quietness.</p> <p>You are given an array <code>richer</code> where <code>richer[i] = [a<sub>i</sub>, b<sub>i</sub>]</code> indicates that <code>a<sub...
Medium
59.4K
97.3K
59,421
97,332
61.0%
['build-a-matrix-with-conditions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> loudAndRich(vector<vector<int>>& richer, vector<int>& quiet) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] loudAndRich(int[][] richer, int[] quiet) {\n \n ...
[[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]] [3,2,5,4,6,1,7,0]
{ "name": "loudAndRich", "params": [ { "name": "richer", "type": "integer[][]" }, { "name": "quiet", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Depth-First Search', 'Graph', 'Topological Sort']
852
Peak Index in a Mountain Array
peak-index-in-a-mountain-array
<p>You are given an integer <strong>mountain</strong> array <code>arr</code> of length <code>n</code> where the values increase to a <strong>peak element</strong> and then decrease.</p> <p>Return the index of the peak element.</p> <p>Your task is to solve it in <code>O(log(n))</code> time complexity.</p> <p>&nbsp;</...
Medium
976.6K
1.4M
976,630
1,442,518
67.7%
['find-peak-element', 'find-in-mountain-array', 'minimum-number-of-removals-to-make-mountain-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int peakIndexInMountainArray(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int peakIndexInMountainArray(int[] arr) {\n \n }\n}"}, {"value": "python", "te...
[0,1,0]
{ "name": "peakIndexInMountainArray", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
853
Car Fleet
car-fleet
<p>There are <code>n</code> cars at given miles away from the starting mile 0, traveling to reach the mile <code>target</code>.</p> <p>You are given two integer array <code>position</code> and <code>speed</code>, both of length <code>n</code>, where <code>position[i]</code> is the starting mile of the <code>i<sup>th</...
Medium
359.1K
675.8K
359,066
675,791
53.1%
['car-fleet-ii', 'count-collisions-on-a-road']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int carFleet(int target, vector<int>& position, vector<int>& speed) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int carFleet(int target, int[] position, int[] speed) {\n \n...
12 [10,8,0,5,3] [2,4,1,1,3]
{ "name": "carFleet", "params": [ { "name": "target", "type": "integer" }, { "name": "position", "type": "integer[]" }, { "name": "speed", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Stack', 'Sorting', 'Monotonic Stack']
854
K-Similar Strings
k-similar-strings
<p>Strings <code>s1</code> and <code>s2</code> are <code>k</code><strong>-similar</strong> (for some non-negative integer <code>k</code>) if we can swap the positions of two letters in <code>s1</code> exactly <code>k</code> times so that the resulting string equals <code>s2</code>.</p> <p>Given two anagrams <code>s1</...
Hard
49.7K
124.2K
49,733
124,249
40.0%
['couples-holding-hands']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int kSimilarity(string s1, string s2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int kSimilarity(String s1, String s2) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
"ab" "ba"
{ "name": "kSimilarity", "params": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Breadth-First Search']
855
Exam Room
exam-room
<p>There is an exam room with <code>n</code> seats in a single row labeled from <code>0</code> to <code>n - 1</code>.</p> <p>When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there are multiple such seats, they sit in the seat with the lowest number. If no ...
Medium
66.6K
152.6K
66,578
152,609
43.6%
['maximize-distance-to-closest-person']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class ExamRoom {\npublic:\n ExamRoom(int n) {\n \n }\n \n int seat() {\n \n }\n \n void leave(int p) {\n \n }\n};\n\n/**\n * Your ExamRoom object will be instantiated and called as such:\n * ExamRoom* obj = new ExamRoom(n);\n ...
["ExamRoom","seat","seat","seat","seat","leave","seat"] [[10],[],[],[],[],[4],[]]
{ "classname": "ExamRoom", "maxbytesperline": 200000, "constructor": { "params": [ { "type": "integer", "name": "n" } ] }, "methods": [ { "name": "seat", "params": [], "return": { "type": "integer" } }, { "name": "leave", ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Design', 'Heap (Priority Queue)', 'Ordered Set']
856
Score of Parentheses
score-of-parentheses
<p>Given a balanced parentheses string <code>s</code>, return <em>the <strong>score</strong> of the string</em>.</p> <p>The <strong>score</strong> of a balanced parentheses string is based on the following rule:</p> <ul> <li><code>&quot;()&quot;</code> has score <code>1</code>.</li> <li><code>AB</code> has score <c...
Medium
203.8K
319.6K
203,763
319,612
63.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int scoreOfParentheses(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int scoreOfParentheses(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
"()"
{ "name": "scoreOfParentheses", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Stack']
857
Minimum Cost to Hire K Workers
minimum-cost-to-hire-k-workers
<p>There are <code>n</code> workers. You are given two integer arrays <code>quality</code> and <code>wage</code> where <code>quality[i]</code> is the quality of the <code>i<sup>th</sup></code> worker and <code>wage[i]</code> is the minimum wage expectation for the <code>i<sup>th</sup></code> worker.</p> <p>We want to ...
Hard
148.5K
234.2K
148,531
234,212
63.4%
['maximum-subsequence-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double mincostToHireWorkers(vector<int>& quality, vector<int>& wage, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double mincostToHireWorkers(int[] quality, int[] wage, int ...
[10,20,5] [70,50,30] 2
{ "name": "mincostToHireWorkers", "params": [ { "name": "quality", "type": "integer[]" }, { "name": "wage", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "double" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting', 'Heap (Priority Queue)']
858
Mirror Reflection
mirror-reflection
<p>There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining corners, numbered <code>0</code>, <code>1</code>, and <code>2</code>.</p> <p>The square room has walls of length <code>p</code>&nbsp;and a laser ray from the southwest...
Medium
83K
133.8K
82,964
133,766
62.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int mirrorReflection(int p, int q) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int mirrorReflection(int p, int q) {\n \n }\n}"}, {"value": "python", "text": "Python", "d...
2 1
{ "name": "mirrorReflection", "params": [ { "name": "p", "type": "integer" }, { "name": "q", "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', 'Geometry', 'Number Theory']
859
Buddy Strings
buddy-strings
<p>Given two strings <code>s</code> and <code>goal</code>, return <code>true</code><em> if you can swap two letters in </em><code>s</code><em> so the result is equal to </em><code>goal</code><em>, otherwise, return </em><code>false</code><em>.</em></p> <p>Swapping letters is defined as taking two indices <code>i</code...
Easy
270.1K
804.4K
270,120
804,424
33.6%
['determine-if-two-strings-are-close', 'check-if-one-string-swap-can-make-strings-equal', 'make-number-of-distinct-characters-equal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool buddyStrings(string s, string goal) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean buddyStrings(String s, String goal) {\n \n }\n}"}, {"value": "python", "text...
"ab" "ba"
{ "name": "buddyStrings", "params": [ { "name": "s", "type": "string" }, { "name": "goal", "type": "string" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String']
860
Lemonade Change
lemonade-change
<p>At a lemonade stand, each lemonade costs <code>$5</code>. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a <code>$5</code>, <code>$10</code>, or <code>$20</code> bill. You must provide the corre...
Easy
433.4K
743K
433,423
742,964
58.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool lemonadeChange(vector<int>& bills) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean lemonadeChange(int[] bills) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
[5,5,5,10,20]
{ "name": "lemonadeChange", "params": [ { "name": "bills", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy']
861
Score After Flipping Matrix
score-after-flipping-matrix
<p>You are given an <code>m x n</code> binary matrix <code>grid</code>.</p> <p>A <strong>move</strong> consists of choosing any row or column and toggling each value in that row or column (i.e., changing all <code>0</code>&#39;s to <code>1</code>&#39;s, and all <code>1</code>&#39;s to <code>0</code>&#39;s).</p> <p>Ev...
Medium
155.6K
194K
155,600
193,957
80.2%
['remove-all-ones-with-row-and-column-flips']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int matrixScore(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int matrixScore(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[0,0,1,1],[1,0,1,0],[1,1,0,0]]
{ "name": "matrixScore", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Bit Manipulation', 'Matrix']
862
Shortest Subarray with Sum at Least K
shortest-subarray-with-sum-at-least-k
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the length of the shortest non-empty <strong>subarray</strong> of </em><code>nums</code><em> with a sum of at least </em><code>k</code>. If there is no such <strong>subarray</strong>, return <code>-1</code>.</p> <p>A <strong>subarray...
Hard
186.1K
578.3K
186,145
578,296
32.2%
['shortest-subarray-with-or-at-least-k-ii', 'shortest-subarray-with-or-at-least-k-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int shortestSubarray(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int shortestSubarray(int[] nums, int k) {\n \n }\n}"}, {"value": "python", "te...
[1] 1
{ "name": "shortestSubarray", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Queue', 'Sliding Window', 'Heap (Priority Queue)', 'Prefix Sum', 'Monotonic Queue']
863
All Nodes Distance K in Binary Tree
all-nodes-distance-k-in-binary-tree
<p>Given the <code>root</code> of a binary tree, the value of a target node <code>target</code>, and an integer <code>k</code>, return <em>an array of the values of all nodes that have a distance </em><code>k</code><em> from the target node.</em></p> <p>You can return the answer in <strong>any order</strong>.</p> <p>...
Medium
556.9K
843.3K
556,879
843,292
66.0%
['amount-of-time-for-binary-tree-to-be-infected']
[]
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(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n vector<int> distanceK(TreeNode* roo...
[3,5,1,6,2,0,8,null,null,7,4] 5 2
{ "name": "distanceK", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "target", "type": "integer" }, { "name": "k", "type": "integer" } ], "return": { "type": "list<integer>" }, "manual": true, "languages": [ "cpp", "ja...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree']
864
Shortest Path to Get All Keys
shortest-path-to-get-all-keys
<p>You are given an <code>m x n</code> grid <code>grid</code> where:</p> <ul> <li><code>&#39;.&#39;</code> is an empty cell.</li> <li><code>&#39;#&#39;</code> is a wall.</li> <li><code>&#39;@&#39;</code> is the starting point.</li> <li>Lowercase letters represent keys.</li> <li>Uppercase letters represent locks.<...
Hard
83.6K
155.9K
83,585
155,876
53.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int shortestPathAllKeys(vector<string>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int shortestPathAllKeys(String[] grid) {\n \n }\n}"}, {"value": "python", "text...
["@.a..","###.#","b.A.B"]
{ "name": "shortestPathAllKeys", "params": [ { "name": "grid", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Bit Manipulation', 'Breadth-First Search', 'Matrix']
865
Smallest Subtree with all the Deepest Nodes
smallest-subtree-with-all-the-deepest-nodes
<p>Given the <code>root</code> of a binary tree, the depth of each node is <strong>the shortest distance to the root</strong>.</p> <p>Return <em>the smallest subtree</em> such that it contains <strong>all the deepest nodes</strong> in the original tree.</p> <p>A node is called <strong>the deepest</strong> if it has t...
Medium
161.8K
223.8K
161,824
223,762
72.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[3,5,1,6,2,0,8,null,null,7,4]
{ "name": "subtreeWithAllDeepest", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree']
866
Prime Palindrome
prime-palindrome
<p>Given an integer n, return <em>the smallest <strong>prime palindrome</strong> greater than or equal to </em><code>n</code>.</p> <p>An integer is <strong>prime</strong> if it has exactly two divisors: <code>1</code> and itself. Note that <code>1</code> is not a prime number.</p> <ul> <li>For example, <code>2</code...
Medium
39.7K
149.1K
39,732
149,122
26.6%
['sum-of-k-mirror-numbers']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int primePalindrome(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int primePalindrome(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "cl...
6
{ "name": "primePalindrome", "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', 'Number Theory']
867
Transpose Matrix
transpose-matrix
<p>Given a 2D integer array <code>matrix</code>, return <em>the <strong>transpose</strong> of</em> <code>matrix</code>.</p> <p>The <strong>transpose</strong> of a matrix is the matrix flipped over its main diagonal, switching the matrix&#39;s row and column indices.</p> <p><img alt="" src="https://assets.leetcode.com...
Easy
478.1K
646.8K
478,078
646,804
73.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> transpose(vector<vector<int>>& matrix) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] transpose(int[][] matrix) {\n \n }\n}"}, {"value": "python...
[[1,2,3],[4,5,6],[7,8,9]]
{ "name": "transpose", "params": [ { "name": "matrix", "type": "integer[][]" } ], "return": { "type": "integer[][]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix', 'Simulation']
868
Binary Gap
binary-gap
<p>Given a positive integer <code>n</code>, find and return <em>the <strong>longest distance</strong> between any two <strong>adjacent</strong> </em><code>1</code><em>&#39;s in the binary representation of </em><code>n</code><em>. If there are no two adjacent </em><code>1</code><em>&#39;s, return </em><code>0</code><em...
Easy
93.6K
145.7K
93,588
145,699
64.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int binaryGap(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int binaryGap(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Solution...
22
{ "name": "binaryGap", "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']
869
Reordered Power of 2
reordered-power-of-2
<p>You are given an integer <code>n</code>. We reorder the digits in any order (including the original order) such that the leading digit is not zero.</p> <p>Return <code>true</code> <em>if and only if we can do this so that the resulting number is a power of two</em>.</p> <p>&nbsp;</p> <p><strong class="example">Exa...
Medium
117.9K
189.6K
117,874
189,637
62.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool reorderedPowerOf2(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean reorderedPowerOf2(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultC...
1
{ "name": "reorderedPowerOf2", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'Math', 'Sorting', 'Counting', 'Enumeration']
870
Advantage Shuffle
advantage-shuffle
<p>You are given two integer arrays <code>nums1</code> and <code>nums2</code> both of the same length. The <strong>advantage</strong> of <code>nums1</code> with respect to <code>nums2</code> is the number of indices <code>i</code> for which <code>nums1[i] &gt; nums2[i]</code>.</p> <p>Return <em>any permutation of </em...
Medium
73.4K
137.9K
73,369
137,912
53.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> advantageCount(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] advantageCount(int[] nums1, int[] nums2) {\n \n }\n}...
[2,7,11,15] [1,10,4,11]
{ "name": "advantageCount", "params": [ { "name": "nums1", "type": "integer[]" }, { "name": "nums2", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Greedy', 'Sorting']
871
Minimum Number of Refueling Stops
minimum-number-of-refueling-stops
<p>A car travels from a starting position to a destination which is <code>target</code> miles east of the starting position.</p> <p>There are gas stations along the way. The gas stations are represented as an array <code>stations</code> where <code>stations[i] = [position<sub>i</sub>, fuel<sub>i</sub>]</code> indicate...
Hard
149.6K
369.8K
149,567
369,786
40.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minRefuelStops(int target, int startFuel, vector<vector<int>>& stations) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minRefuelStops(int target, int startFuel, int[][] stat...
1 1 []
{ "name": "minRefuelStops", "params": [ { "name": "target", "type": "integer" }, { "name": "startFuel", "type": "integer" }, { "name": "stations", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Greedy', 'Heap (Priority Queue)']
872
Leaf-Similar Trees
leaf-similar-trees
<p>Consider all the leaves of a binary tree, from&nbsp;left to right order, the values of those&nbsp;leaves form a <strong>leaf value sequence</strong><em>.</em></p> <p><img alt="" src="https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/16/tree.png" style="width: 400px; height: 336px;" /></p> <p>For example, in th...
Easy
589.2K
841K
589,218
841,004
70.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[3,5,1,6,2,9,8,null,null,7,4] [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8]
{ "name": "leafSimilar", "params": [ { "name": "root1", "type": "TreeNode" }, { "name": "root2", "type": "TreeNode" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Binary Tree']
873
Length of Longest Fibonacci Subsequence
length-of-longest-fibonacci-subsequence
<p>A sequence <code>x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>n</sub></code> is <em>Fibonacci-like</em> if:</p> <ul> <li><code>n &gt;= 3</code></li> <li><code>x<sub>i</sub> + x<sub>i+1</sub> == x<sub>i+2</sub></code> for all <code>i + 2 &lt;= n</code></li> </ul> <p>Given a <b>strictly increasing</b> array <code>arr<...
Medium
180.8K
313.6K
180,771
313,585
57.6%
['fibonacci-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int lenLongestFibSubseq(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int lenLongestFibSubseq(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[1,2,3,4,5,6,7,8]
{ "name": "lenLongestFibSubseq", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Dynamic Programming']
874
Walking Robot Simulation
walking-robot-simulation
<p>A robot on an infinite XY-plane starts at point <code>(0, 0)</code> facing north. The robot receives an array of integers <code>commands</code>, which represents a sequence of moves that it needs to execute. There are only three possible types of instructions the robot can receive:</p> <ul> <li><code>-2</code>: Tu...
Medium
161.1K
277.1K
161,108
277,061
58.1%
['walking-robot-simulation-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int robotSim(vector<int>& commands, vector<vector<int>>& obstacles) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int robotSim(int[] commands, int[][] obstacles) {\n \n }\...
[4,-1,3] []
{ "name": "robotSim", "params": [ { "name": "commands", "type": "integer[]" }, { "name": "obstacles", "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', 'Simulation']
875
Koko Eating Bananas
koko-eating-bananas
<p>Koko loves to eat bananas. There are <code>n</code> piles of bananas, the <code>i<sup>th</sup></code> pile has <code>piles[i]</code> bananas. The guards have gone and will come back in <code>h</code> hours.</p> <p>Koko can decide her bananas-per-hour eating speed of <code>k</code>. Each hour, she chooses some pile ...
Medium
1M
2.1M
1,040,797
2,125,961
49.0%
['minimize-max-distance-to-gas-station', 'maximum-candies-allocated-to-k-children', 'minimized-maximum-of-products-distributed-to-any-store', 'frog-jump-ii', 'minimum-time-to-repair-cars']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minEatingSpeed(vector<int>& piles, int h) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minEatingSpeed(int[] piles, int h) {\n \n }\n}"}, {"value": "python", "text...
[3,6,7,11] 8
{ "name": "minEatingSpeed", "params": [ { "name": "piles", "type": "integer[]" }, { "name": "h", "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']
876
Middle of the Linked List
middle-of-the-linked-list
<p>Given the <code>head</code> of a singly linked list, return <em>the middle node of the linked list</em>.</p> <p>If there are two middle nodes, return <strong>the second middle</strong> node.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/20...
Easy
2.4M
3M
2,395,152
2,983,571
80.3%
['delete-the-middle-node-of-a-linked-list', 'maximum-twin-sum-of-a-linked-list']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for singly-linked list.\n * struct ListNode {\n * int val;\n * ListNode *next;\n * ListNode() : val(0), next(nullptr) {}\n * ListNode(int x) : val(x), next(nullptr) {}\n * ListNode(int x, ListNode *next) : val(x), next(next) {}\n * ...
[1,2,3,4,5]
{ "name": "middleNode", "params": [ { "name": "head", "type": "ListNode" } ], "return": { "type": "ListNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Two Pointers']
877
Stone Game
stone-game
<p>Alice and Bob play a game with piles of stones. There are an <strong>even</strong> number of piles arranged in a row, and each pile has a <strong>positive</strong> integer number of stones <code>piles[i]</code>.</p> <p>The objective of the game is to end with the most stones. The <strong>total</strong> number of st...
Medium
279.3K
390.8K
279,322
390,784
71.5%
['stone-game-v', 'stone-game-vi', 'stone-game-vii', 'stone-game-viii', 'stone-game-ix', 'strictly-palindromic-number', 'visit-array-positions-to-maximize-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool stoneGame(vector<int>& piles) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean stoneGame(int[] piles) {\n \n }\n}"}, {"value": "python", "text": "Python", "defau...
[5,3,4,5]
{ "name": "stoneGame", "params": [ { "name": "piles", "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', 'Dynamic Programming', 'Game Theory']
878
Nth Magical Number
nth-magical-number
<p>A positive integer is <em>magical</em> if it is divisible by either <code>a</code> or <code>b</code>.</p> <p>Given the three integers <code>n</code>, <code>a</code>, and <code>b</code>, return the <code>n<sup>th</sup></code> magical number. Since the answer may be very large, <strong>return it modulo </strong><code...
Hard
44K
123.3K
44,028
123,342
35.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int nthMagicalNumber(int n, int a, int b) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int nthMagicalNumber(int n, int a, int b) {\n \n }\n}"}, {"value": "python", "text"...
1 2 3
{ "name": "nthMagicalNumber", "params": [ { "name": "n", "type": "integer" }, { "name": "a", "type": "integer" }, { "name": "b", "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', 'Binary Search']
879
Profitable Schemes
profitable-schemes
<p>There is a group of <code>n</code> members, and a list of various crimes they could commit. The <code>i<sup>th</sup></code> crime generates a <code>profit[i]</code> and requires <code>group[i]</code> members to participate in it. If a member participates in one crime, that member can&#39;t participate in another cri...
Hard
69.4K
144.6K
69,426
144,557
48.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int profitableSchemes(int n, int minProfit, vector<int>& group, vector<int>& profit) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int profitableSchemes(int n, int minProfit, int[] ...
5 3 [2,2] [2,3]
{ "name": "profitableSchemes", "params": [ { "name": "n", "type": "integer" }, { "name": "minProfit", "type": "integer" }, { "name": "group", "type": "integer[]" }, { "name": "profit", "type": "integer[]" } ], "return": { "type"...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming']
880
Decoded String at Index
decoded-string-at-index
<p>You are given an encoded string <code>s</code>. To decode the string to a tape, the encoded string is read one character at a time and the following steps are taken:</p> <ul> <li>If the character read is a letter, that letter is written onto the tape.</li> <li>If the character read is a digit <code>d</code>, the ...
Medium
101.6K
277.5K
101,591
277,548
36.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string decodeAtIndex(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String decodeAtIndex(String s, int k) {\n \n }\n}"}, {"value": "python", "text": "Pytho...
"leet2code3" 10
{ "name": "decodeAtIndex", "params": [ { "name": "s", "type": "string" }, { "name": "k", "type": "integer" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['String', 'Stack']
881
Boats to Save People
boats-to-save-people
<p>You are given an array <code>people</code> where <code>people[i]</code> is the weight of the <code>i<sup>th</sup></code> person, and an <strong>infinite number of boats</strong> where each boat can carry a maximum weight of <code>limit</code>. Each boat carries at most two people at the same time, provided the sum o...
Medium
466.2K
776.6K
466,242
776,589
60.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numRescueBoats(vector<int>& people, int limit) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numRescueBoats(int[] people, int limit) {\n \n }\n}"}, {"value": "pyth...
[1,2] 3
{ "name": "numRescueBoats", "params": [ { "name": "people", "type": "integer[]" }, { "name": "limit", "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']
882
Reachable Nodes In Subdivided Graph
reachable-nodes-in-subdivided-graph
<p>You are given an undirected graph (the <strong>&quot;original graph&quot;</strong>) with <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>. You decide to <strong>subdivide</strong> each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.</p> <p>The g...
Hard
31.9K
63K
31,936
62,974
50.7%
['find-all-people-with-secret', 'paths-in-maze-that-lead-to-same-room']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int reachableNodes(vector<vector<int>>& edges, int maxMoves, int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int reachableNodes(int[][] edges, int maxMoves, int n) {\n \...
[[0,1,10],[0,2,1],[1,2,2]] 6 3
{ "name": "reachableNodes", "params": [ { "name": "edges", "type": "integer[][]" }, { "name": "maxMoves", "type": "integer" }, { "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...
['Graph', 'Heap (Priority Queue)', 'Shortest Path']
883
Projection Area of 3D Shapes
projection-area-of-3d-shapes
<p>You are given an <code>n x n</code> <code>grid</code> where we place some <code>1 x 1 x 1</code> cubes that are axis-aligned with the <code>x</code>, <code>y</code>, and <code>z</code> axes.</p> <p>Each value <code>v = grid[i][j]</code> represents a tower of <code>v</code> cubes placed on top of the cell <code>(i, ...
Easy
64K
86.7K
64,024
86,662
73.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int projectionArea(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int projectionArea(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Py...
[[1,2],[3,4]]
{ "name": "projectionArea", "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', 'Math', 'Geometry', 'Matrix']
884
Uncommon Words from Two Sentences
uncommon-words-from-two-sentences
<p>A <strong>sentence</strong> is a string of single-space separated words where each word consists only of lowercase letters.</p> <p>A word is <strong>uncommon</strong> if it appears exactly once in one of the sentences, and <strong>does not appear</strong> in the other sentence.</p> <p>Given two <strong>sentences</...
Easy
311.5K
413.8K
311,541
413,757
75.3%
['count-common-words-with-one-occurrence']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> uncommonFromSentences(string s1, string s2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String[] uncommonFromSentences(String s1, String s2) {\n \n }\n}"}...
"this apple is sweet" "this apple is sour"
{ "name": "uncommonFromSentences", "params": [ { "name": "s1", "type": "string" }, { "name": "s2", "type": "string" } ], "return": { "type": "string[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Counting']
885
Spiral Matrix III
spiral-matrix-iii
<p>You start at the cell <code>(rStart, cStart)</code> of an <code>rows x cols</code> grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.</p> <p>You will walk in a clockwise spiral shape to visit every position in this grid. Wheneve...
Medium
165.2K
195.5K
165,170
195,549
84.5%
['spiral-matrix', 'spiral-matrix-ii', 'spiral-matrix-iv']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] spiralMatrixIII(int rows, int cols, int rStart,...
1 4 0 0
{ "name": "spiralMatrixIII", "params": [ { "name": "rows", "type": "integer" }, { "name": "cols", "type": "integer" }, { "name": "rStart", "type": "integer" }, { "name": "cStart", "type": "integer" } ], "return": { "type": "inte...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Matrix', 'Simulation']
886
Possible Bipartition
possible-bipartition
<p>We want to split a group of <code>n</code> people (labeled from <code>1</code> to <code>n</code>) into two groups of <strong>any size</strong>. Each person may dislike some other people, and they should not go into the same group.</p> <p>Given the integer <code>n</code> and the array <code>dislikes</code> where <co...
Medium
233.5K
455.2K
233,452
455,236
51.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool possibleBipartition(int n, vector<vector<int>>& dislikes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean possibleBipartition(int n, int[][] dislikes) {\n \n }\...
4 [[1,2],[1,3],[2,4]]
{ "name": "possibleBipartition", "params": [ { "name": "n", "type": "integer" }, { "name": "dislikes", "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...
['Depth-First Search', 'Breadth-First Search', 'Union Find', 'Graph']
887
Super Egg Drop
super-egg-drop
<p>You are given <code>k</code> identical eggs and you have access to a building with <code>n</code> floors labeled from <code>1</code> to <code>n</code>.</p> <p>You know that there exists a floor <code>f</code> where <code>0 &lt;= f &lt;= n</code> such that any egg dropped at a floor <strong>higher</strong> than <cod...
Hard
83.4K
292.6K
83,390
292,637
28.5%
['egg-drop-with-2-eggs-and-n-floors']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int superEggDrop(int k, int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int superEggDrop(int k, int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
1 2
{ "name": "superEggDrop", "params": [ { "name": "k", "type": "integer" }, { "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', 'Binary Search', 'Dynamic Programming']
888
Fair Candy Swap
fair-candy-swap
<p>Alice and Bob have a different total number of candies. You are given two integer arrays <code>aliceSizes</code> and <code>bobSizes</code> where <code>aliceSizes[i]</code> is the number of candies of the <code>i<sup>th</sup></code> box of candy that Alice has and <code>bobSizes[j]</code> is the number of candies of ...
Easy
143.6K
227.8K
143,556
227,800
63.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> fairCandySwap(vector<int>& aliceSizes, vector<int>& bobSizes) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] fairCandySwap(int[] aliceSizes, int[] bobSizes) {\n ...
[1,1] [2,2]
{ "name": "fairCandySwap", "params": [ { "name": "aliceSizes", "type": "integer[]" }, { "name": "bobSizes", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Binary Search', 'Sorting']
889
Construct Binary Tree from Preorder and Postorder Traversal
construct-binary-tree-from-preorder-and-postorder-traversal
<p>Given two integer arrays, <code>preorder</code> and <code>postorder</code> where <code>preorder</code> is the preorder traversal of a binary tree of <strong>distinct</strong> values and <code>postorder</code> is the postorder traversal of the same tree, reconstruct and return <em>the binary tree</em>.</p> <p>If the...
Medium
202.2K
259.5K
202,241
259,454
77.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[1,2,4,5,3,6,7] [4,5,2,6,7,3,1]
{ "name": "constructFromPrePost", "params": [ { "name": "preorder", "type": "integer[]" }, { "name": "postorder", "type": "integer[]" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Divide and Conquer', 'Tree', 'Binary Tree']
890
Find and Replace Pattern
find-and-replace-pattern
<p>Given a list of strings <code>words</code> and a string <code>pattern</code>, return <em>a list of</em> <code>words[i]</code> <em>that match</em> <code>pattern</code>. You may return the answer in <strong>any order</strong>.</p> <p>A word matches the pattern if there exists a permutation of letters <code>p</code> s...
Medium
200.2K
260.7K
200,229
260,691
76.8%
['isomorphic-strings', 'word-pattern']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> findAndReplacePattern(vector<string>& words, string pattern) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> findAndReplacePattern(String[] words, String p...
["abc","deq","mee","aqq","dkd","ccc"] "abb"
{ "name": "findAndReplacePattern", "params": [ { "name": "words", "type": "string[]" }, { "name": "pattern", "type": "string" } ], "return": { "type": "list<string>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String']
891
Sum of Subsequence Widths
sum-of-subsequence-widths
<p>The <strong>width</strong> of a sequence is the difference between the maximum and minimum elements in the sequence.</p> <p>Given an array of integers <code>nums</code>, return <em>the sum of the <strong>widths</strong> of all the non-empty <strong>subsequences</strong> of </em><code>nums</code>. Since the answer m...
Hard
23.8K
61.4K
23,772
61,385
38.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int sumSubseqWidths(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int sumSubseqWidths(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "...
[2,1,3]
{ "name": "sumSubseqWidths", "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', 'Sorting']
892
Surface Area of 3D Shapes
surface-area-of-3d-shapes
<p>You are given an <code>n x n</code> <code>grid</code> where you have placed some <code>1 x 1 x 1</code> cubes. Each value <code>v = grid[i][j]</code> represents a tower of <code>v</code> cubes placed on top of cell <code>(i, j)</code>.</p> <p>After placing these cubes, you have decided to glue any directly adjacent...
Easy
46.2K
68.3K
46,241
68,299
67.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int surfaceArea(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int surfaceArea(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[1,2],[3,4]]
{ "name": "surfaceArea", "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', 'Math', 'Geometry', 'Matrix']
893
Groups of Special-Equivalent Strings
groups-of-special-equivalent-strings
<p>You are given an array of strings of the same length <code>words</code>.</p> <p>In one <strong>move</strong>, you can swap any two even indexed characters or any two odd indexed characters of a string <code>words[i]</code>.</p> <p>Two strings <code>words[i]</code> and <code>words[j]</code> are <strong>special-equi...
Medium
54.2K
74.6K
54,158
74,566
72.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSpecialEquivGroups(String[] words) {\n \n }\n}"}, {"value": "python",...
["abcd","cdab","cbad","xyzz","zzxy","zzyx"]
{ "name": "numSpecialEquivGroups", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Sorting']
894
All Possible Full Binary Trees
all-possible-full-binary-trees
<p>Given an integer <code>n</code>, return <em>a list of all possible <strong>full binary trees</strong> with</em> <code>n</code> <em>nodes</em>. Each node of each tree in the answer must have <code>Node.val == 0</code>.</p> <p>Each element of the answer is the root node of one possible tree. You may return the final ...
Medium
198.4K
239.8K
198,353
239,843
82.7%
[]
[]
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...
7
{ "name": "allPossibleFBT", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "list<TreeNode>" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming', 'Tree', 'Recursion', 'Memoization', 'Binary Tree']
895
Maximum Frequency Stack
maximum-frequency-stack
<p>Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.</p> <p>Implement the <code>FreqStack</code> class:</p> <ul> <li><code>FreqStack()</code> constructs an empty frequency stack.</li> <li><code>void push(int val)</code> pushes an integer <code>val</co...
Hard
194.8K
291.9K
194,823
291,898
66.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class FreqStack {\npublic:\n FreqStack() {\n \n }\n \n void push(int val) {\n \n }\n \n int pop() {\n \n }\n};\n\n/**\n * Your FreqStack object will be instantiated and called as such:\n * FreqStack* obj = new FreqStack();\n *...
["FreqStack","push","push","push","push","push","push","pop","pop","pop","pop"] [[],[5],[7],[5],[7],[4],[5],[],[],[],[]]
{ "classname": "FreqStack", "maxbytesperline": 200000, "constructor": { "params": [] }, "methods": [ { "name": "push", "params": [ { "type": "integer", "name": "val" } ], "return": { "type": "void" } }, { "name": "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Stack', 'Design', 'Ordered Set']
896
Monotonic Array
monotonic-array
<p>An array is <strong>monotonic</strong> if it is either monotone increasing or monotone decreasing.</p> <p>An array <code>nums</code> is monotone increasing if for all <code>i &lt;= j</code>, <code>nums[i] &lt;= nums[j]</code>. An array <code>nums</code> is monotone decreasing if for all <code>i &lt;= j</code>, <cod...
Easy
499.6K
811.4K
499,589
811,390
61.6%
['count-hills-and-valleys-in-an-array', 'find-the-count-of-monotonic-pairs-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isMonotonic(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isMonotonic(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "def...
[1,2,2,3]
{ "name": "isMonotonic", "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']
897
Increasing Order Search Tree
increasing-order-search-tree
<p>Given the <code>root</code> of a binary search tree, rearrange the tree in <strong>in-order</strong> so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only one right child.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="htt...
Easy
309.5K
393.8K
309,459
393,816
78.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[5,3,6,2,4,null,8,1,null,null,null,7,9]
{ "name": "increasingBST", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Stack', 'Tree', 'Depth-First Search', 'Binary Search Tree', 'Binary Tree']
898
Bitwise ORs of Subarrays
bitwise-ors-of-subarrays
<p>Given an integer array <code>arr</code>, return <em>the number of distinct bitwise ORs of all the non-empty subarrays of</em> <code>arr</code>.</p> <p>The bitwise OR of a subarray is the bitwise OR of each integer in the subarray. The bitwise OR of a subarray of one integer is that integer.</p> <p>A <strong>subarr...
Medium
42.1K
104.1K
42,087
104,073
40.4%
['longest-nice-subarray', 'smallest-subarrays-with-maximum-bitwise-or', 'bitwise-or-of-all-subsequence-sums', 'find-the-maximum-sequence-value-of-array']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int subarrayBitwiseORs(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int subarrayBitwiseORs(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python...
[0]
{ "name": "subarrayBitwiseORs", "params": [ { "name": "arr", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Bit Manipulation']
899
Orderly Queue
orderly-queue
<p>You are given a string <code>s</code> and an integer <code>k</code>. You can choose one of the first <code>k</code> letters of <code>s</code> and append it at the end of the string.</p> <p>Return <em>the lexicographically smallest string you could have after applying the mentioned step any number of moves</em>.</p>...
Hard
75.7K
114.5K
75,733
114,526
66.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string orderlyQueue(string s, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String orderlyQueue(String s, int k) {\n \n }\n}"}, {"value": "python", "text": "Python"...
"cba" 1
{ "name": "orderlyQueue", "params": [ { "name": "s", "type": "string" }, { "name": "k", "type": "integer" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Sorting']
900
RLE Iterator
rle-iterator
<p>We can use run-length encoding (i.e., <strong>RLE</strong>) to encode a sequence of integers. In a run-length encoded array of even length <code>encoding</code> (<strong>0-indexed</strong>), for all even <code>i</code>, <code>encoding[i]</code> tells us the number of times that the non-negative integer value <code>e...
Medium
79.7K
133.3K
79,652
133,278
59.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class RLEIterator {\npublic:\n RLEIterator(vector<int>& encoding) {\n \n }\n \n int next(int n) {\n \n }\n};\n\n/**\n * Your RLEIterator object will be instantiated and called as such:\n * RLEIterator* obj = new RLEIterator(encoding);\n * int...
["RLEIterator","next","next","next","next"] [[[3,8,0,9,2,5]],[2],[1],[1],[2]]
{ "classname": "RLEIterator", "maxbytesperline": 200000, "constructor": { "params": [ { "type": "integer[]", "name": "encoding" } ] }, "methods": [ { "name": "next", "params": [ { "type": "integer", "name": "n" } ], ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Design', 'Counting', 'Iterator']