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
701
Insert into a Binary Search Tree
insert-into-a-binary-search-tree
<p>You are given the <code>root</code> node of a binary search tree (BST) and a <code>value</code> to insert into the tree. Return <em>the root node of the BST after the insertion</em>. It is <strong>guaranteed</strong> that the new value does not exist in the original BST.</p> <p><strong>Notice</strong>&nbsp;that the...
Medium
671.6K
914.1K
671,564
914,080
73.5%
['search-in-a-binary-search-tree']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[4,2,7,1,3] 5
{ "name": "insertIntoBST", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "val", "type": "integer" } ], "return": { "type": "TreeNode" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Binary Search Tree', 'Binary Tree']
702
Search in a Sorted Array of Unknown Size
search-in-a-sorted-array-of-unknown-size
null
Medium
106K
145.9K
106,030
145,870
72.7%
['binary-search', 'find-the-index-of-the-large-integer']
[]
Algorithms
null
[-1,0,3,5,9,12] 9
{ "name": "search", "params": [ { "name": "secret", "type": "integer[]" }, { "name": "target", "type": "integer" } ], "return": { "type": "integer" }, "languages": [ "cpp", "java", "python", "c", "javascript", "golang", "python3", "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Interactive']
703
Kth Largest Element in a Stream
kth-largest-element-in-a-stream
<p>You are part of a university admissions office and need to keep track of the <code>kth</code> highest test score from applicants in real-time. This helps to determine cut-off marks for interviews and admissions dynamically as new applicants submit their scores.</p> <p>You are tasked to implement a class which, for ...
Easy
795.7K
1.3M
795,739
1,331,132
59.8%
['kth-largest-element-in-an-array', 'finding-mk-average', 'sequentially-ordinal-rank-tracker']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class KthLargest {\npublic:\n KthLargest(int k, vector<int>& nums) {\n \n }\n \n int add(int val) {\n \n }\n};\n\n/**\n * Your KthLargest object will be instantiated and called as such:\n * KthLargest* obj = new KthLargest(k, nums);\n * int p...
["KthLargest","add","add","add","add","add"] [[3,[4,5,8,2]],[3],[5],[10],[9],[4]]
{ "classname": "KthLargest", "constructor": { "params": [ { "type": "integer", "name": "k" }, { "type": "integer[]", "name": "nums" }, { "type": "integer", "name": "numsSize", "lang": "c", "value": "size_2" } ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Design', 'Binary Search Tree', 'Heap (Priority Queue)', 'Binary Tree', 'Data Stream']
704
Binary Search
binary-search
<p>Given an array of integers <code>nums</code> which is sorted in ascending order, and an integer <code>target</code>, write a function to search <code>target</code> in <code>nums</code>. If <code>target</code> exists, then return its index. Otherwise, return <code>-1</code>.</p> <p>You must write an algorithm with <...
Easy
3.1M
5.2M
3,071,620
5,180,016
59.3%
['search-in-a-sorted-array-of-unknown-size', 'maximum-count-of-positive-integer-and-negative-integer']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int search(vector<int>& nums, int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int search(int[] nums, int target) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
[-1,0,3,5,9,12] 9
{ "name": "search", "params": [ { "name": "nums", "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', 'Binary Search']
705
Design HashSet
design-hashset
<p>Design a HashSet without using any built-in hash table libraries.</p> <p>Implement <code>MyHashSet</code> class:</p> <ul> <li><code>void add(key)</code> Inserts the value <code>key</code> into the HashSet.</li> <li><code>bool contains(key)</code> Returns whether the value <code>key</code> exists in the HashSet o...
Easy
483.4K
718.1K
483,386
718,074
67.3%
['design-hashmap', 'design-skiplist']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyHashSet {\npublic:\n MyHashSet() {\n \n }\n \n void add(int key) {\n \n }\n \n void remove(int key) {\n \n }\n \n bool contains(int key) {\n \n }\n};\n\n/**\n * Your MyHashSet object will be instantiate...
["MyHashSet","add","add","contains","contains","add","contains","remove","contains"] [[],[1],[2],[1],[3],[2],[2],[2],[2]]
{ "classname": "MyHashSet", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "key" } ], "name": "add", "return": { "type": "void" } }, { "params": [ { "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', 'Linked List', 'Design', 'Hash Function']
706
Design HashMap
design-hashmap
<p>Design a HashMap without using any built-in hash table libraries.</p> <p>Implement the <code>MyHashMap</code> class:</p> <ul> <li><code>MyHashMap()</code> initializes the object with an empty map.</li> <li><code>void put(int key, int value)</code> inserts a <code>(key, value)</code> pair into the HashMap. If the...
Easy
657K
1000K
656,998
999,960
65.7%
['design-hashset', 'design-skiplist']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyHashMap {\npublic:\n MyHashMap() {\n \n }\n \n void put(int key, int value) {\n \n }\n \n int get(int key) {\n \n }\n \n void remove(int key) {\n \n }\n};\n\n/**\n * Your MyHashMap object will be instan...
["MyHashMap","put","put","get","get","put","get","remove","get"] [[],[1,1],[2,2],[1],[3],[2,1],[2],[2],[2]]
{ "classname": "MyHashMap", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "key" }, { "type": "integer", "name": "value" } ], "return": { "type": "void" }, ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>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', 'Design', 'Hash Function']
707
Design Linked List
design-linked-list
<p>Design your implementation of the linked list. You can choose to use a singly or doubly linked list.<br /> A node in a singly linked list should have two attributes: <code>val</code> and <code>next</code>. <code>val</code> is the value of the current node, and <code>next</code> is a pointer/reference to the next nod...
Medium
398.7K
1.4M
398,724
1,376,477
29.0%
['design-skiplist']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyLinkedList {\npublic:\n MyLinkedList() {\n \n }\n \n int get(int index) {\n \n }\n \n void addAtHead(int val) {\n \n }\n \n void addAtTail(int val) {\n \n }\n \n void addAtIndex(int index, int val...
["MyLinkedList","addAtHead","addAtTail","addAtIndex","get","deleteAtIndex","get"] [[],[1],[3],[1,2],[1],[1],[1]]
{ "classname": "MyLinkedList", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "index" } ], "return": { "type": "integer" }, "name": "get" }, { "params": [ { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Design']
708
Insert into a Sorted Circular Linked List
insert-into-a-sorted-circular-linked-list
null
Medium
219.7K
580.5K
219,718
580,543
37.8%
['insertion-sort-list']
[]
Algorithms
null
[3,4,1] 2
{ "name": "insert", "params": [ { "name": "head", "type": "ListNode" }, { "name": "insertVal", "type": "integer" } ], "return": { "type": "ListNode" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "kotlin",...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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']
709
To Lower Case
to-lower-case
<p>Given a string <code>s</code>, return <em>the string after replacing every uppercase letter with the same lowercase letter</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> s = &quot;Hello&quot; <strong>Output:</strong> &quot;hello&quot; </pre> <p><strong cla...
Easy
607.8K
723K
607,781
723,027
84.1%
['capitalize-the-title']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string toLowerCase(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String toLowerCase(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
"Hello"
{ "name": "toLowerCase", "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']
710
Random Pick with Blacklist
random-pick-with-blacklist
<p>You are given an integer <code>n</code> and an array of <strong>unique</strong> integers <code>blacklist</code>. Design an algorithm to pick a random integer in the range <code>[0, n - 1]</code> that is <strong>not</strong> in <code>blacklist</code>. Any integer that is in the mentioned range and not in <code>blackl...
Hard
46.9K
139.1K
46,937
139,094
33.7%
['random-pick-index', 'random-pick-with-weight', 'find-unique-binary-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n Solution(int n, vector<int>& blacklist) {\n \n }\n \n int pick() {\n \n }\n};\n\n/**\n * Your Solution object will be instantiated and called as such:\n * Solution* obj = new Solution(n, blacklist);\n * int param_1...
["Solution","pick","pick","pick","pick","pick","pick","pick"] [[7,[2,3,5]],[],[],[],[],[],[],[]]
{ "classname": "Solution", "maxbytesperline": 200000, "constructor": { "params": [ { "name": "n", "type": "integer" }, { "name": "blacklist", "type": "integer[]" }, { "type": "integer", "name": "blacklistSize", "lang": "c", ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>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', 'Binary Search', 'Sorting', 'Randomized']
711
Number of Distinct Islands II
number-of-distinct-islands-ii
null
Hard
13K
23.9K
13,022
23,900
54.5%
['number-of-distinct-islands']
[]
Algorithms
null
[[1,1,0,0,0],[1,0,0,0,0],[0,0,0,0,1],[0,0,0,1,1]]
{ "name": "numDistinctIslands2", "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...
['Hash Table', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Hash Function']
712
Minimum ASCII Delete Sum for Two Strings
minimum-ascii-delete-sum-for-two-strings
<p>Given two strings <code>s1</code> and&nbsp;<code>s2</code>, return <em>the lowest <strong>ASCII</strong> sum of deleted characters to make two strings equal</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> s1 = &quot;sea&quot;, s2 = &quot;eat&quot; <strong>Ou...
Medium
161K
245.5K
161,040
245,540
65.6%
['edit-distance', 'longest-increasing-subsequence', 'delete-operation-for-two-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minimumDeleteSum(string s1, string s2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minimumDeleteSum(String s1, String s2) {\n \n }\n}"}, {"value": "python", "tex...
"sea" "eat"
{ "name": "minimumDeleteSum", "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', 'Dynamic Programming']
713
Subarray Product Less Than K
subarray-product-less-than-k
<p>Given an array of integers <code>nums</code> and an integer <code>k</code>, return <em>the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than </em><code>k</code>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</stron...
Medium
481.8K
916.8K
481,819
916,753
52.6%
['maximum-product-subarray', 'maximum-size-subarray-sum-equals-k', 'subarray-sum-equals-k', 'two-sum-less-than-k', 'number-of-smooth-descent-periods-of-a-stock', 'count-subarrays-with-score-less-than-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSubarrayProductLessThanK(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSubarrayProductLessThanK(int[] nums, int k) {\n \n }\n}"}, {...
[10,5,2,6] 100
{ "name": "numSubarrayProductLessThanK", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Sliding Window', 'Prefix Sum']
714
Best Time to Buy and Sell Stock with Transaction Fee
best-time-to-buy-and-sell-stock-with-transaction-fee
<p>You are given an array <code>prices</code> where <code>prices[i]</code> is the price of a given stock on the <code>i<sup>th</sup></code> day, and an integer <code>fee</code> representing a transaction fee.</p> <p>Find the maximum profit you can achieve. You may complete as many transactions as you like, but you nee...
Medium
461.5K
658.5K
461,549
658,495
70.1%
['best-time-to-buy-and-sell-stock-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxProfit(vector<int>& prices, int fee) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxProfit(int[] prices, int fee) {\n \n }\n}"}, {"value": "python", "text": "...
[1,3,2,8,4,9] 2
{ "name": "maxProfit", "params": [ { "name": "prices", "type": "integer[]" }, { "name": "fee", "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']
715
Range Module
range-module
<p>A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as <strong>half-open intervals</strong> and query about them.</p> <p>A <strong>half-open interval</strong> <code>[left, right)</code> denotes all the real numbers <code>x</code> where <code>left &lt;= x...
Hard
82.6K
187.2K
82,616
187,221
44.1%
['merge-intervals', 'insert-interval', 'data-stream-as-disjoint-intervals']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class RangeModule {\npublic:\n RangeModule() {\n \n }\n \n void addRange(int left, int right) {\n \n }\n \n bool queryRange(int left, int right) {\n \n }\n \n void removeRange(int left, int right) {\n \n }\n};\...
["RangeModule","addRange","removeRange","queryRange","queryRange","queryRange"] [[],[10,20],[14,16],[10,14],[13,15],[16,17]]
{ "classname": "RangeModule", "constructor": { "params": [] }, "methods": [ { "name" : "addRange", "params": [ { "type": "integer", "name": "left" }, { "typ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Segment Tree', 'Ordered Set']
716
Max Stack
max-stack
null
Hard
167.9K
369.8K
167,871
369,808
45.4%
['min-stack']
[]
Algorithms
null
["MaxStack","push","push","push","top","popMax","top","peekMax","pop","top"] [[],[5],[1],[5],[],[],[],[],[],[]]
{ "classname": "MaxStack", "constructor": { "params": [] }, "methods": [ { "params": [ { "type": "integer", "name": "x" } ], "return": { "type": "void" }, "name": "push" }, { "params": [], "return": { "...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Linked List', 'Stack', 'Design', 'Doubly-Linked List', 'Ordered Set']
717
1-bit and 2-bit Characters
1-bit-and-2-bit-characters
<p>We have two special characters:</p> <ul> <li>The first character can be represented by one bit <code>0</code>.</li> <li>The second character can be represented by two bits (<code>10</code> or <code>11</code>).</li> </ul> <p>Given a binary array <code>bits</code> that ends with <code>0</code>, return <code>true</...
Easy
149.6K
331.7K
149,608
331,670
45.1%
['gray-code']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isOneBitCharacter(vector<int>& bits) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isOneBitCharacter(int[] bits) {\n \n }\n}"}, {"value": "python", "text": "P...
[1,0,0]
{ "name": "isOneBitCharacter", "params": [ { "name": "bits", "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']
718
Maximum Length of Repeated Subarray
maximum-length-of-repeated-subarray
<p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, return <em>the maximum length of a subarray that appears in <strong>both</strong> arrays</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <pre> <strong>Input:</strong> nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] <strong>Outp...
Medium
331.4K
649.9K
331,352
649,908
51.0%
['minimum-size-subarray-sum', 'longest-common-subpath', 'find-the-maximum-length-of-a-good-subsequence-ii', 'find-the-maximum-length-of-a-good-subsequence-i']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findLength(vector<int>& nums1, vector<int>& nums2) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findLength(int[] nums1, int[] nums2) {\n \n }\n}"}, {"value": "pyt...
[1,2,3,2,1] [3,2,1,4,7]
{ "name": "findLength", "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', 'Binary Search', 'Dynamic Programming', 'Sliding Window', 'Rolling Hash', 'Hash Function']
719
Find K-th Smallest Pair Distance
find-k-th-smallest-pair-distance
<p>The <strong>distance of a pair</strong> of integers <code>a</code> and <code>b</code> is defined as the absolute difference between <code>a</code> and <code>b</code>.</p> <p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the</em> <code>k<sup>th</sup></code> <em>smallest <strong>d...
Hard
194.7K
426.4K
194,681
426,434
45.7%
['find-k-pairs-with-smallest-sums', 'kth-smallest-element-in-a-sorted-matrix', 'find-k-closest-elements', 'kth-smallest-number-in-multiplication-table', 'k-th-smallest-prime-fraction', 'find-the-median-of-the-uniqueness-array', 'maximize-score-of-numbers-in-ranges']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int smallestDistancePair(vector<int>& nums, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int smallestDistancePair(int[] nums, int k) {\n \n }\n}"}, {"value": "pyth...
[1,3,1] 1
{ "name": "smallestDistancePair", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting']
720
Longest Word in Dictionary
longest-word-in-dictionary
<p>Given an array of strings <code>words</code> representing an English Dictionary, return <em>the longest word in</em> <code>words</code> <em>that can be built one character at a time by other words in</em> <code>words</code>.</p> <p>If there is more than one possible answer, return the longest word with the smallest...
Medium
169.3K
317.9K
169,292
317,881
53.3%
['longest-word-in-dictionary-through-deleting', 'implement-magic-dictionary', 'longest-word-with-all-prefixes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string longestWord(vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String longestWord(String[] words) {\n \n }\n}"}, {"value": "python", "text": "Pyth...
["w","wo","wor","worl","world"]
{ "name": "longestWord", "params": [ { "name": "words", "type": "string[]" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Trie', 'Sorting']
721
Accounts Merge
accounts-merge
<p>Given a list of <code>accounts</code> where each element <code>accounts[i]</code> is a list of strings, where the first element <code>accounts[i][0]</code> is a name, and the rest of the elements are <strong>emails</strong> representing emails of the account.</p> <p>Now, we would like to merge these accounts. Two a...
Medium
499.6K
845.4K
499,566
845,405
59.1%
['redundant-connection', 'sentence-similarity', 'sentence-similarity-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<string>> accountsMerge(vector<vector<string>>& accounts) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<List<String>> accountsMerge(List<List<String>> accounts) {\...
[["John","johnsmith@mail.com","john_newyork@mail.com"],["John","johnsmith@mail.com","john00@mail.com"],["Mary","mary@mail.com"],["John","johnnybravo@mail.com"]]
{ "name": "accountsMerge", "params": [ { "name": "accounts", "type": "list<list<string>>" } ], "return": { "type": "list<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', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Sorting']
722
Remove Comments
remove-comments
<p>Given a C++ program, remove comments from it. The program source is an array of strings <code>source</code> where <code>source[i]</code> is the <code>i<sup>th</sup></code> line of the source code. This represents the result of splitting the original source code string by the newline character <code>&#39;\n&#39;</cod...
Medium
78.9K
200.8K
78,888
200,774
39.3%
['mini-parser', 'ternary-expression-parser']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> removeComments(vector<string>& source) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> removeComments(String[] source) {\n \n }\n}"}, {"value": "...
["/*Test program */", "int main()", "{ ", " // variable declaration ", "int a, b, c;", "/* This is a test", " multiline ", " comment for ", " testing */", "a = b + c;", "}"]
{ "name": "removeComments", "params": [ { "name": "source", "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', 'String']
723
Candy Crush
candy-crush
null
Medium
78.4K
101.6K
78,443
101,561
77.2%
[]
[]
Algorithms
null
[[110,5,112,113,114],[210,211,5,213,214],[310,311,3,313,314],[410,411,412,5,414],[5,1,512,3,3],[610,4,1,613,614],[710,1,2,713,714],[810,1,2,1,1],[1,1,2,2,2],[4,1,4,4,1014]]
{ "name": "candyCrush", "params": [ { "name": "board", "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', 'Matrix', 'Simulation']
724
Find Pivot Index
find-pivot-index
<p>Given an array of integers <code>nums</code>, calculate the <strong>pivot index</strong> of this array.</p> <p>The <strong>pivot index</strong> is the index where the sum of all the numbers <strong>strictly</strong> to the left of the index is equal to the sum of all the numbers <strong>strictly</strong> to the ind...
Easy
1.4M
2.3M
1,358,248
2,258,206
60.1%
['subarray-sum-equals-k', 'find-the-middle-index-in-array', 'number-of-ways-to-split-array', 'maximum-sum-score-of-array', 'left-and-right-sum-differences']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int pivotIndex(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int pivotIndex(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCod...
[1,7,3,6,5,6]
{ "name": "pivotIndex", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Prefix Sum']
725
Split Linked List in Parts
split-linked-list-in-parts
<p>Given the <code>head</code> of a singly linked list and an integer <code>k</code>, split the linked list into <code>k</code> consecutive linked list parts.</p> <p>The length of each part should be as equal as possible: no two parts should have a size differing by more than one. This may lead to some parts being nul...
Medium
328.8K
468.9K
328,795
468,874
70.1%
['rotate-list', 'odd-even-linked-list', 'split-a-circular-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] 5
{ "name": "splitListToParts", "params": [ { "name": "head", "type": "ListNode" }, { "name": "k", "type": "integer" } ], "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']
726
Number of Atoms
number-of-atoms
<p>Given a string <code>formula</code> representing a chemical formula, return <em>the count of each atom</em>.</p> <p>The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.</p> <p>One or more digits representing that element&#39;s count may follow if...
Hard
153.7K
236.5K
153,737
236,484
65.0%
['decode-string', 'encode-string-with-shortest-length', 'parse-lisp-expression']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string countOfAtoms(string formula) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String countOfAtoms(String formula) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"H2O"
{ "name": "countOfAtoms", "params": [ { "name": "formula", "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', 'Stack', 'Sorting']
727
Minimum Window Subsequence
minimum-window-subsequence
null
Hard
95.9K
220K
95,877
219,953
43.6%
['minimum-window-substring', 'longest-continuous-increasing-subsequence']
[]
Algorithms
null
"abcdebdde" "bde"
{ "name": "minWindow", "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...
['String', 'Dynamic Programming', 'Sliding Window']
728
Self Dividing Numbers
self-dividing-numbers
<p>A <strong>self-dividing number</strong> is a number that is divisible by every digit it contains.</p> <ul> <li>For example, <code>128</code> is <strong>a self-dividing number</strong> because <code>128 % 1 == 0</code>, <code>128 % 2 == 0</code>, and <code>128 % 8 == 0</code>.</li> </ul> <p>A <strong>self-dividing...
Easy
276.2K
347.5K
276,162
347,488
79.5%
['perfect-number', 'check-if-number-has-equal-digit-count-and-digit-value', 'count-the-digits-that-divide-a-number']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> selfDividingNumbers(int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> selfDividingNumbers(int left, int right) {\n \n }\n}"}, {"...
1 22
{ "name": "selfDividingNumbers", "params": [ { "name": "left", "type": "integer" }, { "name": "right", "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...
['Math']
729
My Calendar I
my-calendar-i
<p>You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a <strong>double booking</strong>.</p> <p>A <strong>double booking</strong> happens when two events have some non-empty intersection (i.e., some moment is common to both events.).</p> <p>The event can ...
Medium
420.2K
720K
420,152
720,020
58.4%
['my-calendar-ii', 'my-calendar-iii', 'determine-if-two-events-have-conflict']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyCalendar {\npublic:\n MyCalendar() {\n \n }\n \n bool book(int startTime, int endTime) {\n \n }\n};\n\n/**\n * Your MyCalendar object will be instantiated and called as such:\n * MyCalendar* obj = new MyCalendar();\n * bool param_1 = ...
["MyCalendar","book","book","book"] [[],[10,20],[15,25],[20,30]]
{ "classname": "MyCalendar", "constructor": { "params": [] }, "methods": [ { "name": "book", "params": [ { "type": "integer", "name": "startTime" }, { "type": "integer", "name": "endTime" } ], "return": { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Design', 'Segment Tree', 'Ordered Set']
730
Count Different Palindromic Subsequences
count-different-palindromic-subsequences
<p>Given a string s, return <em>the number of different non-empty palindromic subsequences in</em> <code>s</code>. Since the answer may be very large, return it <strong>modulo</strong> <code>10<sup>9</sup> + 7</code>.</p> <p>A subsequence of a string is obtained by deleting zero or more characters from the string.</p>...
Hard
40.9K
88.5K
40,911
88,518
46.2%
['longest-palindromic-subsequence', 'count-palindromic-subsequences']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countPalindromicSubsequences(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countPalindromicSubsequences(String s) {\n \n }\n}"}, {"value": "python", "tex...
"bccb"
{ "name": "countPalindromicSubsequences", "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', 'Dynamic Programming']
731
My Calendar II
my-calendar-ii
<p>You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a <strong>triple booking</strong>.</p> <p>A <strong>triple booking</strong> happens when three events have some non-empty intersection (i.e., some moment is common to all the three events.).</p> <p>The...
Medium
192.8K
306.9K
192,809
306,854
62.8%
['my-calendar-i', 'my-calendar-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyCalendarTwo {\npublic:\n MyCalendarTwo() {\n \n }\n \n bool book(int startTime, int endTime) {\n \n }\n};\n\n/**\n * Your MyCalendarTwo object will be instantiated and called as such:\n * MyCalendarTwo* obj = new MyCalendarTwo();\n * ...
["MyCalendarTwo","book","book","book","book","book","book"] [[],[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]
{ "classname": "MyCalendarTwo", "constructor": { "params": [] }, "methods": [ { "name": "book", "params": [ { "type": "integer", "name": "startTime" }, { "type": "integer", "name": "endTime" } ], "return": { ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search', 'Design', 'Segment Tree', 'Prefix Sum', 'Ordered Set']
732
My Calendar III
my-calendar-iii
<p>A <code>k</code>-booking happens when <code>k</code> events have some non-empty intersection (i.e., there is some time that is common to all <code>k</code> events.)</p> <p>You are given some events <code>[startTime, endTime)</code>, after each given event, return an integer <code>k</code> representing the maximum <...
Hard
100K
138.8K
100,012
138,813
72.0%
['my-calendar-i', 'my-calendar-ii', 'count-integers-in-intervals']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class MyCalendarThree {\npublic:\n MyCalendarThree() {\n \n }\n \n int book(int startTime, int endTime) {\n \n }\n};\n\n/**\n * Your MyCalendarThree object will be instantiated and called as such:\n * MyCalendarThree* obj = new MyCalendarThre...
["MyCalendarThree","book","book","book","book","book","book"] [[],[10,20],[50,60],[10,40],[5,15],[5,10],[25,55]]
{ "classname": "MyCalendarThree", "constructor": { "params": [] }, "methods": [ { "name": "book", "params": [ { "type": "integer", "name": "startTime" }, { "type": "integer", "name": "endTime" } ], "return": ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Binary Search', 'Design', 'Segment Tree', 'Prefix Sum', 'Ordered Set']
733
Flood Fill
flood-fill
<p>You are given an image represented by an <code>m x n</code> grid of integers <code>image</code>, where <code>image[i][j]</code> represents the pixel value of the image. You are also given three integers <code>sr</code>, <code>sc</code>, and <code>color</code>. Your task is to perform a <strong>flood fill</strong> on...
Easy
1.1M
1.7M
1,116,874
1,691,582
66.0%
['island-perimeter']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int color) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[][] floodFill(int[][] image, int sr, int sc, i...
[[1,1,1],[1,1,0],[1,0,1]] 1 1 2
{ "name": "floodFill", "params": [ { "name": "image", "type": "integer[][]" }, { "name": "sr", "type": "integer" }, { "name": "sc", "type": "integer" }, { "name": "color", "type": "integer" } ], "return": { "type": "integer[][]"...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix']
734
Sentence Similarity
sentence-similarity
null
Easy
71.5K
160.5K
71,520
160,532
44.6%
['number-of-provinces', 'accounts-merge', 'sentence-similarity-ii']
[]
Algorithms
null
["great","acting","skills"] ["fine","drama","talent"] [["great","fine"],["drama","acting"],["skills","talent"]]
{ "name": "areSentencesSimilar", "params": [ { "name": "sentence1", "type": "string[]" }, { "name": "sentence2", "type": "string[]" }, { "name": "similarPairs", "type": "list<list<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...
['Array', 'Hash Table', 'String']
735
Asteroid Collision
asteroid-collision
<p>We are given an array <code>asteroids</code> of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space.</p> <p>For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative mea...
Medium
745.1K
1.6M
745,134
1,648,264
45.2%
['can-place-flowers', 'destroying-asteroids', 'count-collisions-on-a-road', 'robot-collisions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> asteroidCollision(vector<int>& asteroids) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] asteroidCollision(int[] asteroids) {\n \n }\n}"}, {"value": "pyth...
[5,10,-5]
{ "name": "asteroidCollision", "params": [ { "name": "asteroids", "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', 'Simulation']
736
Parse Lisp Expression
parse-lisp-expression
<p>You are given a string expression representing a Lisp-like expression to return the integer value of.</p> <p>The syntax for these expressions is given as follows.</p> <ul> <li>An expression is either an integer, let expression, add expression, mult expression, or an assigned variable. Expressions always evaluate ...
Hard
24.5K
46.7K
24,457
46,679
52.4%
['ternary-expression-parser', 'number-of-atoms', 'basic-calculator-iv']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int evaluate(string expression) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int evaluate(String expression) {\n \n }\n}"}, {"value": "python", "text": "Python", "default...
"(let x 2 (mult x (let x 3 y 4 (add x y))))"
{ "name": "evaluate", "params": [ { "name": "expression", "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', 'Stack', 'Recursion']
737
Sentence Similarity II
sentence-similarity-ii
null
Medium
75K
148.4K
74,995
148,361
50.5%
['number-of-provinces', 'accounts-merge', 'sentence-similarity']
[]
Algorithms
null
["great","acting","skills"] ["fine","drama","talent"] [["great","good"],["fine","good"],["drama","acting"],["skills","talent"]]
{ "name": "areSentencesSimilarTwo", "params": [ { "name": "sentence1", "type": "string[]" }, { "name": "sentence2", "type": "string[]" }, { "name": "similarPairs", "type": "list<list<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...
['Array', 'Hash Table', 'String', 'Depth-First Search', 'Breadth-First Search', 'Union Find']
738
Monotone Increasing Digits
monotone-increasing-digits
<p>An integer has <strong>monotone increasing digits</strong> if and only if each pair of adjacent digits <code>x</code> and <code>y</code> satisfy <code>x &lt;= y</code>.</p> <p>Given an integer <code>n</code>, return <em>the largest number that is less than or equal to </em><code>n</code><em> with <strong>monotone i...
Medium
60.7K
125K
60,705
125,050
48.5%
['remove-k-digits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int monotoneIncreasingDigits(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int monotoneIncreasingDigits(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
10
{ "name": "monotoneIncreasingDigits", "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', 'Greedy']
739
Daily Temperatures
daily-temperatures
<p>Given an array of integers <code>temperatures</code> represents the daily temperatures, return <em>an array</em> <code>answer</code> <em>such that</em> <code>answer[i]</code> <em>is the number of days you have to wait after the</em> <code>i<sup>th</sup></code> <em>day to get a warmer temperature</em>. If there is no...
Medium
1.3M
1.9M
1,263,977
1,883,609
67.1%
['next-greater-element-i', 'online-stock-span']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> dailyTemperatures(vector<int>& temperatures) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] dailyTemperatures(int[] temperatures) {\n \n }\n}"}, {"value":...
[73,74,75,71,69,72,76,73]
{ "name": "dailyTemperatures", "params": [ { "name": "temperatures", "type": "integer[]" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Stack', 'Monotonic Stack']
740
Delete and Earn
delete-and-earn
<p>You are given an integer array <code>nums</code>. You want to maximize the number of points you get by performing the following operation any number of times:</p> <ul> <li>Pick any <code>nums[i]</code> and delete it to earn <code>nums[i]</code> points. Afterwards, you must delete <b>every</b> element equal to <cod...
Medium
391.3K
690.5K
391,288
690,498
56.7%
['house-robber']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int deleteAndEarn(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int deleteAndEarn(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[3,4,2]
{ "name": "deleteAndEarn", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'Dynamic Programming']
741
Cherry Pickup
cherry-pickup
<p>You are given an <code>n x n</code> <code>grid</code> representing a field of cherries, each cell is one of three possible integers.</p> <ul> <li><code>0</code> means the cell is empty, so you can pass through,</li> <li><code>1</code> means the cell contains a cherry that you can pick up and pass through, or</li>...
Hard
92.3K
245.1K
92,302
245,052
37.7%
['minimum-path-sum', 'dungeon-game', 'maximum-path-quality-of-a-graph', 'paths-in-matrix-whose-sum-is-divisible-by-k']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int cherryPickup(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int cherryPickup(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python...
[[0,1,-1],[1,0,-1],[1,1,1]]
{ "name": "cherryPickup", "params": [ { "name": "grid", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Matrix']
742
Closest Leaf in a Binary Tree
closest-leaf-in-a-binary-tree
null
Medium
51.3K
109.1K
51,273
109,087
47.0%
[]
[]
Algorithms
null
[1,3,2] 1
{ "name": "findClosestLeaf", "params": [ { "name": "root", "type": "TreeNode" }, { "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...
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Tree']
743
Network Delay Time
network-delay-time
<p>You are given a network of <code>n</code> nodes, labeled from <code>1</code> to <code>n</code>. You are also given <code>times</code>, a list of travel times as directed edges <code>times[i] = (u<sub>i</sub>, v<sub>i</sub>, w<sub>i</sub>)</code>, where <code>u<sub>i</sub></code> is the source node, <code>v<sub>i</su...
Medium
639.8K
1.1M
639,835
1,128,060
56.7%
['the-time-when-the-network-becomes-idle', 'second-minimum-time-to-reach-destination']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int networkDelayTime(vector<vector<int>>& times, int n, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int networkDelayTime(int[][] times, int n, int k) {\n \n }\n}"...
[[2,1,1],[2,3,1],[3,4,1]] 4 2
{ "name": "networkDelayTime", "params": [ { "name": "times", "type": "integer[][]" }, { "name": "n", "type": "integer" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer" }, "manual": false }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Depth-First Search', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Shortest Path']
744
Find Smallest Letter Greater Than Target
find-smallest-letter-greater-than-target
<p>You are given an array of characters <code>letters</code> that is sorted in <strong>non-decreasing order</strong>, and a character <code>target</code>. There are <strong>at least two different</strong> characters in <code>letters</code>.</p> <p>Return <em>the smallest character in </em><code>letters</code><em> that...
Easy
582K
1.1M
581,953
1,082,145
53.8%
['count-elements-with-strictly-smaller-and-greater-elements']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n char nextGreatestLetter(vector<char>& letters, char target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public char nextGreatestLetter(char[] letters, char target) {\n \n }\n}"...
["c","f","j"] "a"
{ "name": "nextGreatestLetter", "params": [ { "name": "letters", "type": "character[]" }, { "name": "target", "type": "character" } ], "return": { "type": "character" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Binary Search']
745
Prefix and Suffix Search
prefix-and-suffix-search
<p>Design a special dictionary that searches the words in it by a prefix and a suffix.</p> <p>Implement the <code>WordFilter</code> class:</p> <ul> <li><code>WordFilter(string[] words)</code> Initializes the object with the <code>words</code> in the dictionary.</li> <li><code>f(string pref, string suff)</code> Retu...
Hard
103.1K
250K
103,069
249,973
41.2%
['design-add-and-search-words-data-structure']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class WordFilter {\npublic:\n WordFilter(vector<string>& words) {\n \n }\n \n int f(string pref, string suff) {\n \n }\n};\n\n/**\n * Your WordFilter object will be instantiated and called as such:\n * WordFilter* obj = new WordFilter(words);...
["WordFilter","f"] [[["apple"]],["a","e"]]
{ "classname": "WordFilter", "constructor": { "params": [ { "type": "string[]", "name": "words" } ] }, "methods": [ { "name": "f", "params": [ { "type": "string", "name": "pref" }, { "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', 'Design', 'Trie']
746
Min Cost Climbing Stairs
min-cost-climbing-stairs
<p>You are given an integer array <code>cost</code> where <code>cost[i]</code> is the cost of <code>i<sup>th</sup></code> step on a staircase. Once you pay the cost, you can either climb one or two steps.</p> <p>You can either start from the step with index <code>0</code>, or the step with index <code>1</code>.</p> <...
Easy
1.4M
2.2M
1,441,694
2,153,636
66.9%
['climbing-stairs', 'find-number-of-ways-to-reach-the-k-th-stair']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minCostClimbingStairs(vector<int>& cost) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minCostClimbingStairs(int[] cost) {\n \n }\n}"}, {"value": "python", "text":...
[10,15,20]
{ "name": "minCostClimbingStairs", "params": [ { "name": "cost", "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']
747
Largest Number At Least Twice of Others
largest-number-at-least-twice-of-others
<p>You are given an integer array <code>nums</code> where the largest integer is <strong>unique</strong>.</p> <p>Determine whether the largest element in the array is <strong>at least twice</strong> as much as every other number in the array. If it is, return <em>the <strong>index</strong> of the largest element, or r...
Easy
289.1K
572.4K
289,073
572,446
50.5%
['keep-multiplying-found-values-by-two', 'largest-number-after-digit-swaps-by-parity']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int dominantIndex(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int dominantIndex(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[3,6,1,0]
{ "name": "dominantIndex", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting']
748
Shortest Completing Word
shortest-completing-word
<p>Given a string <code>licensePlate</code> and an array of strings <code>words</code>, find the <strong>shortest completing</strong> word in <code>words</code>.</p> <p>A <strong>completing</strong> word is a word that <strong>contains all the letters</strong> in <code>licensePlate</code>. <strong>Ignore numbers and s...
Easy
91.2K
149.2K
91,189
149,241
61.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string shortestCompletingWord(string licensePlate, vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String shortestCompletingWord(String licensePlate, String[] w...
"1s3 PSt" ["step","steps","stripe","stepple"]
{ "name": "shortestCompletingWord", "params": [ { "name": "licensePlate", "type": "string" }, { "name": "words", "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']
749
Contain Virus
contain-virus
<p>A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.</p> <p>The world is modeled as an <code>m x n</code> binary grid <code>isInfected</code>, where <code>isInfected[i][j] == 0</code> represents uninfected cells, and <code>isInfected[i][j] == 1</code> represents cells ...
Hard
15K
28.7K
15,008
28,694
52.3%
['count-the-number-of-infection-sequences']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int containVirus(vector<vector<int>>& isInfected) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int containVirus(int[][] isInfected) {\n \n }\n}"}, {"value": "python", "te...
[[0,1,0,0,0,0,0,1],[0,1,0,0,0,0,0,1],[0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0]]
{ "name": "containVirus", "params": [ { "name": "isInfected", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Depth-First Search', 'Breadth-First Search', 'Matrix', 'Simulation']
750
Number Of Corner Rectangles
number-of-corner-rectangles
null
Medium
39.7K
58.6K
39,710
58,573
67.8%
[]
[]
Algorithms
null
[[1,0,0,1,0],[0,0,1,0,1],[0,0,0,1,0],[1,0,1,0,1]]
{ "name": "countCornerRectangles", "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', 'Dynamic Programming', 'Matrix']
751
IP to CIDR
ip-to-cidr
null
Medium
28.3K
51.1K
28,300
51,139
55.3%
['restore-ip-addresses', 'validate-ip-address']
[]
Algorithms
null
"255.0.0.7" 10
{ "name": "ipToCIDR", "params": [ { "name": "ip", "type": "string" }, { "name": "n", "type": "integer" } ], "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', 'Bit Manipulation']
752
Open the Lock
open-the-lock
<p>You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: <code>&#39;0&#39;, &#39;1&#39;, &#39;2&#39;, &#39;3&#39;, &#39;4&#39;, &#39;5&#39;, &#39;6&#39;, &#39;7&#39;, &#39;8&#39;, &#39;9&#39;</code>. The wheels can rotate freely and wrap around: for example we can turn <code>&#39;9&#39;</code...
Medium
353K
582.2K
353,022
582,205
60.6%
['reachable-nodes-with-restrictions']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int openLock(vector<string>& deadends, string target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int openLock(String[] deadends, String target) {\n \n }\n}"}, {"value":...
["0201","0101","0102","1212","2002"] "0202"
{ "name": "openLock", "params": [ { "name": "deadends", "type": "string[]" }, { "name": "target", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Breadth-First Search']
753
Cracking the Safe
cracking-the-safe
<p>There is a safe protected by a password. The password is a sequence of <code>n</code> digits where each digit can be in the range <code>[0, k - 1]</code>.</p> <p>The safe has a peculiar way of checking the password. When you enter in a sequence, it checks the <strong>most recent </strong><code>n</code><strong> digi...
Hard
64.5K
111.9K
64,496
111,901
57.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string crackSafe(int n, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String crackSafe(int n, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCo...
1 2
{ "name": "crackSafe", "params": [ { "name": "n", "type": "integer" }, { "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...
['Depth-First Search', 'Graph', 'Eulerian Circuit']
754
Reach a Number
reach-a-number
<p>You are standing at position <code>0</code> on an infinite number line. There is a destination at position <code>target</code>.</p> <p>You can make some number of moves <code>numMoves</code> so that:</p> <ul> <li>On each move, you can either go left or right.</li> <li>During the <code>i<sup>th</sup></code> move ...
Medium
61.7K
141K
61,675
140,963
43.8%
['number-of-ways-to-reach-a-position-after-exactly-k-steps']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int reachNumber(int target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int reachNumber(int target) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "...
2
{ "name": "reachNumber", "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...
['Math', 'Binary Search']
755
Pour Water
pour-water
null
Medium
41.9K
87.8K
41,876
87,800
47.7%
['trapping-rain-water']
[]
Algorithms
null
[2,1,1,2,1,2,2] 4 3
{ "name": "pourWater", "params": [ { "name": "heights", "type": "integer[]" }, { "name": "volume", "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', 'Simulation']
756
Pyramid Transition Matrix
pyramid-transition-matrix
<p>You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains <strong>one less block</strong> than the row beneath it and is centered on top.</p> <p>To make the pyramid aesthetically pleasing, there are only specific <strong>triangular patter...
Medium
36.9K
69.8K
36,859
69,775
52.8%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool pyramidTransition(string bottom, vector<string>& allowed) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean pyramidTransition(String bottom, List<String> allowed) {\n ...
"BCD" ["BCC","CDE","CEA","FFF"]
{ "name": "pyramidTransition", "params": [ { "name": "bottom", "type": "string" }, { "name": "allowed", "type": "list<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...
['Bit Manipulation', 'Depth-First Search', 'Breadth-First Search']
757
Set Intersection Size At Least Two
set-intersection-size-at-least-two
<p>You are given a 2D integer array <code>intervals</code> where <code>intervals[i] = [start<sub>i</sub>, end<sub>i</sub>]</code> represents all the integers from <code>start<sub>i</sub></code> to <code>end<sub>i</sub></code> inclusively.</p> <p>A <strong>containing set</strong> is an array <code>nums</code> where eac...
Hard
26.3K
58.5K
26,311
58,462
45.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int intersectionSizeTwo(vector<vector<int>>& intervals) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int intersectionSizeTwo(int[][] intervals) {\n \n }\n}"}, {"value": "...
[[1,3],[3,7],[8,9]]
{ "name": "intersectionSizeTwo", "params": [ { "name": "intervals", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Greedy', 'Sorting']
758
Bold Words in String
bold-words-in-string
null
Medium
19.9K
38.3K
19,912
38,274
52.0%
[]
[]
Algorithms
null
["ab","bc"] "aabcd"
{ "name": "boldWords", "params": [ { "name": "words", "type": "string[]" }, { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Hash Table', 'String', 'Trie', 'String Matching']
759
Employee Free Time
employee-free-time
null
Hard
163.4K
225.3K
163,423
225,262
72.5%
['merge-intervals', 'interval-list-intersections']
[]
Algorithms
null
[[[1,2],[5,6]],[[1,3]],[[4,10]]]
{ "name": "employeeFreeTime", "params": [ { "name": "schedule", "type": "integer" } ], "return": { "type": "integer" }, "languages": [ "cpp", "java", "python", "csharp", "javascript", "python3", "golang", "ruby", "kotlin", "scala", "swift",...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Sorting', 'Heap (Priority Queue)']
760
Find Anagram Mappings
find-anagram-mappings
null
Easy
107.2K
127.9K
107,188
127,852
83.8%
[]
[]
Algorithms
null
[12,28,46,32,50] [50,12,32,46,28]
{ "name": "anagramMappings", "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', 'Hash Table']
761
Special Binary String
special-binary-string
<p><strong>Special binary strings</strong> are binary strings with the following two properties:</p> <ul> <li>The number of <code>0</code>&#39;s is equal to the number of <code>1</code>&#39;s.</li> <li>Every prefix of the binary string has at least as many <code>1</code>&#39;s as <code>0</code>&#39;s.</li> </ul> <p...
Hard
22.6K
35.8K
22,608
35,776
63.2%
['valid-parenthesis-string', 'number-of-good-binary-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string makeLargestSpecial(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String makeLargestSpecial(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", ...
"11011000"
{ "name": "makeLargestSpecial", "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', 'Recursion']
762
Prime Number of Set Bits in Binary Representation
prime-number-of-set-bits-in-binary-representation
<p>Given two integers <code>left</code> and <code>right</code>, return <em>the <strong>count</strong> of numbers in the <strong>inclusive</strong> range </em><code>[left, right]</code><em> having a <strong>prime number of set bits</strong> in their binary representation</em>.</p> <p>Recall that the <strong>number of s...
Easy
113.9K
161.1K
113,861
161,121
70.7%
['number-of-1-bits']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int countPrimeSetBits(int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int countPrimeSetBits(int left, int right) {\n \n }\n}"}, {"value": "python", "tex...
6 10
{ "name": "countPrimeSetBits", "params": [ { "name": "left", "type": "integer" }, { "name": "right", "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', 'Bit Manipulation']
763
Partition Labels
partition-labels
<p>You are given a string <code>s</code>. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string <code>&quot;ababcc&quot;</code> can be partitioned into <code>[&quot;abab&quot;, &quot;cc&quot;]</code>, but partitions such as <code>[&quot;a...
Medium
703K
863.2K
702,957
863,221
81.4%
['merge-intervals', 'optimal-partition-of-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> partitionLabels(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<Integer> partitionLabels(String s) {\n \n }\n}"}, {"value": "python", "text": "Pyt...
"ababcbacadefegdehijhklij"
{ "name": "partitionLabels", "params": [ { "name": "s", "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...
['Hash Table', 'Two Pointers', 'String', 'Greedy']
764
Largest Plus Sign
largest-plus-sign
<p>You are given an integer <code>n</code>. You have an <code>n x n</code> binary grid <code>grid</code> with all values initially <code>1</code>&#39;s except for some indices given in the array <code>mines</code>. The <code>i<sup>th</sup></code> element of the array <code>mines</code> is defined as <code>mines[i] = [x...
Medium
63.5K
130.9K
63,460
130,920
48.5%
['maximal-square']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int orderOfLargestPlusSign(int n, vector<vector<int>>& mines) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int orderOfLargestPlusSign(int n, int[][] mines) {\n \n }\n}"},...
5 [[4,2]]
{ "name": "orderOfLargestPlusSign", "params": [ { "name": "n", "type": "integer" }, { "name": "mines", "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']
765
Couples Holding Hands
couples-holding-hands
<p>There are <code>n</code> couples sitting in <code>2n</code> seats arranged in a row and want to hold hands.</p> <p>The people and seats are represented by an integer array <code>row</code> where <code>row[i]</code> is the ID of the person sitting in the <code>i<sup>th</sup></code> seat. The couples are numbered in ...
Hard
71.3K
122.5K
71,315
122,548
58.2%
['first-missing-positive', 'missing-number', 'k-similar-strings']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int minSwapsCouples(vector<int>& row) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int minSwapsCouples(int[] row) {\n \n }\n}"}, {"value": "python", "text": "Python", "de...
[0,2,1,3]
{ "name": "minSwapsCouples", "params": [ { "name": "row", "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...
['Greedy', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Graph']
766
Toeplitz Matrix
toeplitz-matrix
<p>Given an <code>m x n</code> <code>matrix</code>, return&nbsp;<em><code>true</code>&nbsp;if the matrix is Toeplitz. Otherwise, return <code>false</code>.</em></p> <p>A matrix is <strong>Toeplitz</strong> if every diagonal from top-left to bottom-right has the same elements.</p> <p>&nbsp;</p> <p><strong class="examp...
Easy
396.3K
570.1K
396,295
570,063
69.5%
['valid-word-square']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isToeplitzMatrix(vector<vector<int>>& matrix) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isToeplitzMatrix(int[][] matrix) {\n \n }\n}"}, {"value": "python"...
[[1,2,3,4],[5,1,2,3],[9,5,1,2]]
{ "name": "isToeplitzMatrix", "params": [ { "name": "matrix", "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', 'Matrix']
767
Reorganize String
reorganize-string
<p>Given a string <code>s</code>, rearrange the characters of <code>s</code> so that any two adjacent characters are not the same.</p> <p>Return <em>any possible rearrangement of</em> <code>s</code> <em>or return</em> <code>&quot;&quot;</code> <em>if not possible</em>.</p> <p>&nbsp;</p> <p><strong class="example">Exa...
Medium
495.1K
885K
495,061
884,984
55.9%
['rearrange-string-k-distance-apart', 'task-scheduler', 'longest-happy-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string reorganizeString(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String reorganizeString(String s) {\n \n }\n}"}, {"value": "python", "text": "Python", "def...
"aab"
{ "name": "reorganizeString", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Greedy', 'Sorting', 'Heap (Priority Queue)', 'Counting']
768
Max Chunks To Make Sorted II
max-chunks-to-make-sorted-ii
<p>You are given an integer array <code>arr</code>.</p> <p>We split <code>arr</code> into some number of <strong>chunks</strong> (i.e., partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.</p> <p>Return <em>the largest number of chunks we can make to sort ...
Hard
76.5K
141.7K
76,527
141,671
54.0%
['max-chunks-to-make-sorted']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxChunksToSorted(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxChunksToSorted(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[5,4,3,2,1]
{ "name": "maxChunksToSorted", "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', 'Stack', 'Greedy', 'Sorting', 'Monotonic Stack']
769
Max Chunks To Make Sorted
max-chunks-to-make-sorted
<p>You are given an integer array <code>arr</code> of length <code>n</code> that represents a permutation of the integers in the range <code>[0, n - 1]</code>.</p> <p>We split <code>arr</code> into some number of <strong>chunks</strong> (i.e., partitions), and individually sort each chunk. After concatenating them, th...
Medium
218.1K
341K
218,135
340,956
64.0%
['max-chunks-to-make-sorted-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int maxChunksToSorted(vector<int>& arr) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int maxChunksToSorted(int[] arr) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[4,3,2,1,0]
{ "name": "maxChunksToSorted", "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', 'Stack', 'Greedy', 'Sorting', 'Monotonic Stack']
770
Basic Calculator IV
basic-calculator-iv
<p>Given an expression such as <code>expression = &quot;e + 8 - a + 5&quot;</code> and an evaluation map such as <code>{&quot;e&quot;: 1}</code> (given in terms of <code>evalvars = [&quot;e&quot;]</code> and <code>evalints = [1]</code>), return a list of tokens representing the simplified expression, such as <code>[&qu...
Hard
12.1K
22.2K
12,142
22,229
54.6%
['parse-lisp-expression', 'basic-calculator-iii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> basicCalculatorIV(string expression, vector<string>& evalvars, vector<int>& evalints) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> basicCalculatorIV(Str...
"e + 8 - a + 5" ["e"] [1]
{ "name": "basicCalculatorIV", "params": [ { "name": "expression", "type": "string" }, { "name": "evalvars", "type": "string[]" }, { "name": "evalints", "type": "integer[]" } ], "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...
['Hash Table', 'Math', 'String', 'Stack', 'Recursion']
771
Jewels and Stones
jewels-and-stones
<p>You&#39;re given strings <code>jewels</code> representing the types of stones that are jewels, and <code>stones</code> representing the stones you have. Each character in <code>stones</code> is a type of stone you have. You want to know how many of the stones you have are also jewels.</p> <p>Letters are case sensit...
Easy
1.2M
1.3M
1,201,968
1,348,420
89.1%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numJewelsInStones(string jewels, string stones) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numJewelsInStones(String jewels, String stones) {\n \n }\n}"}, {"valu...
"aA" "aAAbbbb"
{ "name": "numJewelsInStones", "params": [ { "name": "jewels", "type": "string" }, { "name": "stones", "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']
772
Basic Calculator III
basic-calculator-iii
null
Hard
142.9K
274.2K
142,949
274,179
52.1%
['basic-calculator', 'basic-calculator-ii', 'basic-calculator-iv', 'build-binary-expression-tree-from-infix-expression']
[]
Algorithms
null
"1+1"
{ "name": "calculate", "params": [ { "name": "s", "type": "string" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Stack', 'Recursion']
773
Sliding Puzzle
sliding-puzzle
<p>On an <code>2 x 3</code> board, there are five tiles labeled from <code>1</code> to <code>5</code>, and an empty square represented by <code>0</code>. A <strong>move</strong> consists of choosing <code>0</code> and a 4-directionally adjacent number and swapping it.</p> <p>The state of the board is solved if and onl...
Hard
176.4K
241.5K
176,368
241,489
73.0%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int slidingPuzzle(vector<vector<int>>& board) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int slidingPuzzle(int[][] board) {\n \n }\n}"}, {"value": "python", "text": "Py...
[[1,2,3],[4,0,5]]
{ "name": "slidingPuzzle", "params": [ { "name": "board", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Dynamic Programming', 'Backtracking', 'Breadth-First Search', 'Memoization', 'Matrix']
774
Minimize Max Distance to Gas Station
minimize-max-distance-to-gas-station
null
Hard
32.9K
62.1K
32,851
62,140
52.9%
['koko-eating-bananas']
[]
Algorithms
null
[1,2,3,4,5,6,7,8,9,10] 9
{ "name": "minmaxGasDist", "params": [ { "name": "stations", "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', 'Binary Search']
775
Global and Local Inversions
global-and-local-inversions
<p>You are given an integer array <code>nums</code> of length <code>n</code> which represents a permutation of all the integers in the range <code>[0, n - 1]</code>.</p> <p>The number of <strong>global inversions</strong> is the number of the different pairs <code>(i, j)</code> where:</p> <ul> <li><code>0 &lt;= i &l...
Medium
80.7K
190.9K
80,720
190,865
42.3%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isIdealPermutation(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isIdealPermutation(int[] nums) {\n \n }\n}"}, {"value": "python", "text": ...
[1,0,2]
{ "name": "isIdealPermutation", "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']
776
Split BST
split-bst
null
Medium
110.6K
134.2K
110,643
134,193
82.5%
['delete-node-in-a-bst']
[]
Algorithms
null
[4,2,6,1,3,5,7] 2
{ "name": "splitBST", "params": [ { "name": "root", "type": "TreeNode" }, { "name": "target", "type": "integer" } ], "return": { "type": "TreeNode[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Binary Search Tree', 'Recursion', 'Binary Tree']
777
Swap Adjacent in LR String
swap-adjacent-in-lr-string
<p>In a string composed of <code>&#39;L&#39;</code>, <code>&#39;R&#39;</code>, and <code>&#39;X&#39;</code> characters, like <code>&quot;RXXLRXRXL&quot;</code>, a move consists of either replacing one occurrence of <code>&quot;XL&quot;</code> with <code>&quot;LX&quot;</code>, or replacing one occurrence of <code>&quot;...
Medium
85.3K
228.1K
85,350
228,056
37.4%
['move-pieces-to-obtain-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool canTransform(string start, string result) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean canTransform(String start, String result) {\n \n }\n}"}, {"value": "py...
"RXXLRXRXL" "XRLXXRRLX"
{ "name": "canTransform", "params": [ { "name": "start", "type": "string" }, { "name": "result", "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']
778
Swim in Rising Water
swim-in-rising-water
<p>You are given an <code>n x n</code> integer matrix <code>grid</code> where each value <code>grid[i][j]</code> represents the elevation at that point <code>(i, j)</code>.</p> <p>The rain starts to fall. At time <code>t</code>, the depth of the water everywhere is <code>t</code>. You can swim from a square to another...
Hard
211.2K
338.5K
211,233
338,539
62.4%
['path-with-minimum-effort']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int swimInWater(vector<vector<int>>& grid) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int swimInWater(int[][] grid) {\n \n }\n}"}, {"value": "python", "text": "Python",...
[[0,2],[1,3]]
{ "name": "swimInWater", "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', 'Binary Search', 'Depth-First Search', 'Breadth-First Search', 'Union Find', 'Heap (Priority Queue)', 'Matrix']
779
K-th Symbol in Grammar
k-th-symbol-in-grammar
<p>We build a table of <code>n</code> rows (<strong>1-indexed</strong>). We start by writing <code>0</code> in the <code>1<sup>st</sup></code> row. Now in every subsequent row, we look at the previous row and replace each occurrence of <code>0</code> with <code>01</code>, and each occurrence of <code>1</code> with <cod...
Medium
228.3K
483.3K
228,305
483,296
47.2%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int kthGrammar(int n, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int kthGrammar(int n, int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode":...
1 1
{ "name": "kthGrammar", "params": [ { "name": "n", "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...
['Math', 'Bit Manipulation', 'Recursion']
780
Reaching Points
reaching-points
<p>Given four integers <code>sx</code>, <code>sy</code>, <code>tx</code>, and <code>ty</code>, return <code>true</code><em> if it is possible to convert the point </em><code>(sx, sy)</code><em> to the point </em><code>(tx, ty)</code> <em>through some operations</em><em>, or </em><code>false</code><em> otherwise</em>.</...
Hard
74.1K
221K
74,120
220,967
33.5%
['number-of-ways-to-reach-a-position-after-exactly-k-steps', 'check-if-point-is-reachable', 'determine-if-a-cell-is-reachable-at-a-given-time']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool reachingPoints(int sx, int sy, int tx, int ty) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean reachingPoints(int sx, int sy, int tx, int ty) {\n \n }\n}"}, {"v...
1 1 3 5
{ "name": "reachingPoints", "params": [ { "name": "sx", "type": "integer" }, { "name": "sy", "type": "integer" }, { "name": "tx", "type": "integer" }, { "name": "ty", "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']
781
Rabbits in Forest
rabbits-in-forest
<p>There is a forest with an unknown number of rabbits. We asked n rabbits <strong>&quot;How many rabbits have the same color as you?&quot;</strong> and collected the answers in an integer array <code>answers</code> where <code>answers[i]</code> is the answer of the <code>i<sup>th</sup></code> rabbit.</p> <p>Given the...
Medium
69.3K
131.6K
69,301
131,634
52.6%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numRabbits(vector<int>& answers) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numRabbits(int[] answers) {\n \n }\n}"}, {"value": "python", "text": "Python", "defa...
[1,1,2]
{ "name": "numRabbits", "params": [ { "name": "answers", "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', 'Greedy']
782
Transform to Chessboard
transform-to-chessboard
<p>You are given an <code>n x n</code> binary grid <code>board</code>. In each move, you can swap any two rows with each other, or any two columns with each other.</p> <p>Return <em>the minimum number of moves to transform the board into a <strong>chessboard board</strong></em>. If the task is impossible, return <code...
Hard
19.4K
38.5K
19,407
38,486
50.4%
['minimum-moves-to-get-a-peaceful-board']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int movesToChessboard(vector<vector<int>>& board) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int movesToChessboard(int[][] board) {\n \n }\n}"}, {"value": "python", "te...
[[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]]
{ "name": "movesToChessboard", "params": [ { "name": "board", "type": "integer[][]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math', 'Bit Manipulation', 'Matrix']
783
Minimum Distance Between BST Nodes
minimum-distance-between-bst-nodes
<p>Given the <code>root</code> of a Binary Search Tree (BST), return <em>the minimum difference between the values of any two different nodes in the tree</em>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</strong></p> <img alt="" src="https://assets.leetcode.com/uploads/2021/02/05/bst1.jpg" style="width: 29...
Easy
282.9K
470.2K
282,895
470,236
60.2%
['binary-tree-inorder-traversal']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * Tre...
[4,2,6,1,3]
{ "name": "minDiffInBST", "params": [ { "name": "root", "type": "TreeNode" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Tree', 'Depth-First Search', 'Breadth-First Search', 'Binary Search Tree', 'Binary Tree']
784
Letter Case Permutation
letter-case-permutation
<p>Given a string <code>s</code>, you&nbsp;can transform every letter individually to be lowercase or uppercase to create another string.</p> <p>Return <em>a list of all possible strings we could create</em>. Return the output in <strong>any order</strong>.</p> <p>&nbsp;</p> <p><strong class="example">Example 1:</str...
Medium
331.8K
442.8K
331,753
442,829
74.9%
['subsets', 'brace-expansion']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<string> letterCasePermutation(string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<String> letterCasePermutation(String s) {\n \n }\n}"}, {"value": "python"...
"a1b2"
{ "name": "letterCasePermutation", "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', 'Bit Manipulation']
785
Is Graph Bipartite?
is-graph-bipartite
<p>There is an <strong>undirected</strong> graph with <code>n</code> nodes, where each node is numbered between <code>0</code> and <code>n - 1</code>. You are given a 2D array <code>graph</code>, where <code>graph[u]</code> is an array of nodes that node <code>u</code> is adjacent to. More formally, for each <code>v</c...
Medium
694.2K
1.2M
694,193
1,210,373
57.4%
['divide-nodes-into-the-maximum-number-of-groups']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool isBipartite(vector<vector<int>>& graph) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean isBipartite(int[][] graph) {\n \n }\n}"}, {"value": "python", "text": "P...
[[1,2,3],[0,2],[0,1,3],[0,2]]
{ "name": "isBipartite", "params": [ { "name": "graph", "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']
786
K-th Smallest Prime Fraction
k-th-smallest-prime-fraction
<p>You are given a sorted integer array <code>arr</code> containing <code>1</code> and <strong>prime</strong> numbers, where all the integers of <code>arr</code> are unique. You are also given an integer <code>k</code>.</p> <p>For every <code>i</code> and <code>j</code> where <code>0 &lt;= i &lt; j &lt; arr.length</co...
Medium
158.7K
231.9K
158,735
231,946
68.4%
['kth-smallest-element-in-a-sorted-matrix', 'kth-smallest-number-in-multiplication-table', 'find-k-th-smallest-pair-distance']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<int> kthSmallestPrimeFraction(vector<int>& arr, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int[] kthSmallestPrimeFraction(int[] arr, int k) {\n \n }\n}"},...
[1,2,3,5] 3
{ "name": "kthSmallestPrimeFraction", "params": [ { "name": "arr", "type": "integer[]" }, { "name": "k", "type": "integer" } ], "return": { "type": "integer[]" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Two Pointers', 'Binary Search', 'Sorting', 'Heap (Priority Queue)']
787
Cheapest Flights Within K Stops
cheapest-flights-within-k-stops
<p>There are <code>n</code> cities connected by some number of flights. You are given an array <code>flights</code> where <code>flights[i] = [from<sub>i</sub>, to<sub>i</sub>, price<sub>i</sub>]</code> indicates that there is a flight from city <code>from<sub>i</sub></code> to city <code>to<sub>i</sub></code> with cost...
Medium
704.5K
1.8M
704,496
1,753,919
40.2%
['maximum-vacation-days', 'minimum-cost-to-reach-city-with-discounts']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int findCheapestPrice(int n, vector<vector<int>>& flights, int src, int dst, int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int findCheapestPrice(int n, int[][] flights, int s...
4 [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]] 0 3 1
{ "name": "findCheapestPrice", "params": [ { "name": "n", "type": "integer" }, { "name": "flights", "type": "integer[][]" }, { "name": "src", "type": "integer" }, { "name": "dst", "type": "integer" }, { "name": "k", "typ...
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<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', 'Depth-First Search', 'Breadth-First Search', 'Graph', 'Heap (Priority Queue)', 'Shortest Path']
788
Rotated Digits
rotated-digits
<p>An integer <code>x</code> is a <strong>good</strong> if after rotating each digit individually by 180 degrees, we get a valid number that is different from <code>x</code>. Each digit must be rotated - we cannot choose to leave it alone.</p> <p>A number is valid if each digit remains a digit after rotation. For exam...
Medium
117K
207.5K
117,047
207,507
56.4%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int rotatedDigits(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int rotatedDigits(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class ...
10
{ "name": "rotatedDigits", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Dynamic Programming']
789
Escape The Ghosts
escape-the-ghosts
<p>You are playing a simplified PAC-MAN game on an infinite 2-D grid. You start at the point <code>[0, 0]</code>, and you are given a destination point <code>target = [x<sub>target</sub>, y<sub>target</sub>]</code> that you are trying to get to. There are several ghosts on the map with their starting positions given as...
Medium
33.6K
53.8K
33,625
53,837
62.5%
['cat-and-mouse-ii']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool escapeGhosts(vector<vector<int>>& ghosts, vector<int>& target) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean escapeGhosts(int[][] ghosts, int[] target) {\n \n ...
[[1,0],[0,3]] [0,1]
{ "name": "escapeGhosts", "params": [ { "name": "ghosts", "type": "integer[][]" }, { "name": "target", "type": "integer[]" } ], "return": { "type": "boolean" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Math']
790
Domino and Tromino Tiling
domino-and-tromino-tiling
<p>You have two types of tiles: a <code>2 x 1</code> domino shape and a tromino shape. You may rotate these shapes.</p> <img alt="" src="https://assets.leetcode.com/uploads/2021/07/15/lc-domino.jpg" style="width: 362px; height: 195px;" /> <p>Given an integer n, return <em>the number of ways to tile an</em> <code>2 x n<...
Medium
171K
352.6K
170,995
352,650
48.5%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numTilings(int n) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numTilings(int n) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "class Soluti...
3
{ "name": "numTilings", "params": [ { "name": "n", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Dynamic Programming']
791
Custom Sort String
custom-sort-string
<p>You are given two strings <code>order</code> and <code>s</code>. All the characters of <code>order</code> are <strong>unique</strong> and were sorted in some custom order previously.</p> <p>Permute the characters of <code>s</code> so that they match the order that <code>order</code> was sorted. More specifically, i...
Medium
518.3K
721.5K
518,343
721,526
71.8%
['sort-the-students-by-their-kth-score']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n string customSortString(string order, string s) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public String customSortString(String order, String s) {\n \n }\n}"}, {"value": "pyt...
"cba" "abcd"
{ "name": "customSortString", "params": [ { "name": "order", "type": "string" }, { "name": "s", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Hash Table', 'String', 'Sorting']
792
Number of Matching Subsequences
number-of-matching-subsequences
<p>Given a string <code>s</code> and an array of strings <code>words</code>, return <em>the number of</em> <code>words[i]</code> <em>that is a subsequence of</em> <code>s</code>.</p> <p>A <strong>subsequence</strong> of a string is a new string generated from the original string with some characters (can be none) dele...
Medium
246.8K
486.8K
246,755
486,825
50.7%
['is-subsequence', 'shortest-way-to-form-string', 'count-vowel-substrings-of-a-string']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numMatchingSubseq(string s, vector<string>& words) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numMatchingSubseq(String s, String[] words) {\n \n }\n}"}, {"value...
"abcde" ["a","bb","acd","ace"]
{ "name": "numMatchingSubseq", "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', 'Hash Table', 'String', 'Binary Search', 'Dynamic Programming', 'Trie', 'Sorting']
793
Preimage Size of Factorial Zeroes Function
preimage-size-of-factorial-zeroes-function
<p>Let <code>f(x)</code> be the number of zeroes at the end of <code>x!</code>. Recall that <code>x! = 1 * 2 * 3 * ... * x</code> and by convention, <code>0! = 1</code>.</p> <ul> <li>For example, <code>f(3) = 0</code> because <code>3! = 6</code> has no zeroes at the end, while <code>f(11) = 2</code> because <code>11!...
Hard
21.2K
46.5K
21,169
46,510
45.5%
['factorial-trailing-zeroes']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int preimageSizeFZF(int k) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int preimageSizeFZF(int k) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaultCode": "cl...
0
{ "name": "preimageSizeFZF", "params": [ { "name": "k", "type": "integer" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'Binary Search']
794
Valid Tic-Tac-Toe State
valid-tic-tac-toe-state
<p>Given a Tic-Tac-Toe board as a string array <code>board</code>, return <code>true</code> if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.</p> <p>The board is a <code>3 x 3</code> array that consists of characters <code>&#39; &#39;</code>, <code>&#39;X&#39;</c...
Medium
62.7K
181K
62,651
181,027
34.6%
['design-tic-tac-toe']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool validTicTacToe(vector<string>& board) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean validTicTacToe(String[] board) {\n \n }\n}"}, {"value": "python", "text": ...
["O "," "," "]
{ "name": "validTicTacToe", "params": [ { "name": "board", "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...
['Array', 'Matrix']
795
Number of Subarrays with Bounded Maximum
number-of-subarrays-with-bounded-maximum
<p>Given an integer array <code>nums</code> and two integers <code>left</code> and <code>right</code>, return <em>the number of contiguous non-empty <strong>subarrays</strong> such that the value of the maximum array element in that subarray is in the range </em><code>[left, right]</code>.</p> <p>The test cases are ge...
Medium
78K
145.4K
77,957
145,364
53.6%
['count-subarrays-with-median-k', 'find-the-number-of-subarrays-where-boundary-elements-are-maximum']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int numSubarrayBoundedMax(vector<int>& nums, int left, int right) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int numSubarrayBoundedMax(int[] nums, int left, int right) {\n ...
[2,1,4,3] 2 3
{ "name": "numSubarrayBoundedMax", "params": [ { "name": "nums", "type": "integer[]" }, { "name": "left", "type": "integer" }, { "name": "right", "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']
796
Rotate String
rotate-string
<p>Given two strings <code>s</code> and <code>goal</code>, return <code>true</code> <em>if and only if</em> <code>s</code> <em>can become</em> <code>goal</code> <em>after some number of <strong>shifts</strong> on</em> <code>s</code>.</p> <p>A <strong>shift</strong> on <code>s</code> consists of moving the leftmost cha...
Easy
590.2K
926.7K
590,190
926,670
63.7%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n bool rotateString(string s, string goal) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public boolean rotateString(String s, String goal) {\n \n }\n}"}, {"value": "python", "text...
"abcde" "cdeab"
{ "name": "rotateString", "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...
['String', 'String Matching']
797
All Paths From Source to Target
all-paths-from-source-to-target
<p>Given a directed acyclic graph (<strong>DAG</strong>) of <code>n</code> nodes labeled from <code>0</code> to <code>n - 1</code>, find all possible paths from node <code>0</code> to node <code>n - 1</code> and return them in <strong>any order</strong>.</p> <p>The graph is given as follows: <code>graph[i]</code> is a...
Medium
596.2K
718.4K
596,235
718,404
83.0%
['number-of-ways-to-arrive-at-destination', 'number-of-increasing-paths-in-a-grid']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n vector<vector<int>> allPathsSourceTarget(vector<vector<int>>& graph) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public List<List<Integer>> allPathsSourceTarget(int[][] graph) {\n ...
[[1,2],[3],[3],[]]
{ "name": "allPathsSourceTarget", "params": [ { "name": "graph", "type": "integer[][]" } ], "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...
['Backtracking', 'Depth-First Search', 'Breadth-First Search', 'Graph']
798
Smallest Rotation with Highest Score
smallest-rotation-with-highest-score
<p>You are given an array <code>nums</code>. You can rotate it by a non-negative integer <code>k</code> so that the array becomes <code>[nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]]</code>. Afterward, any entries that are less than or equal to their index are worth one point.</p> ...
Hard
15.7K
30.3K
15,708
30,278
51.9%
[]
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n int bestRotation(vector<int>& nums) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public int bestRotation(int[] nums) {\n \n }\n}"}, {"value": "python", "text": "Python", "defaul...
[2,3,1,4,0]
{ "name": "bestRotation", "params": [ { "name": "nums", "type": "integer[]" } ], "return": { "type": "integer" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Array', 'Prefix Sum']
799
Champagne Tower
champagne-tower
<p>We stack glasses in a pyramid, where the <strong>first</strong> row has <code>1</code> glass, the <strong>second</strong> row has <code>2</code> glasses, and so on until the 100<sup>th</sup> row.&nbsp; Each glass holds one cup&nbsp;of champagne.</p> <p>Then, some champagne is poured into the first glass at the top....
Medium
161.4K
277.2K
161,427
277,249
58.2%
['number-of-ways-to-build-house-of-cards']
[]
Algorithms
[{"value": "cpp", "text": "C++", "defaultCode": "class Solution {\npublic:\n double champagneTower(int poured, int query_row, int query_glass) {\n \n }\n};"}, {"value": "java", "text": "Java", "defaultCode": "class Solution {\n public double champagneTower(int poured, int query_row, int query_glass) {\n...
1 1 1
{ "name": "champagneTower", "params": [ { "name": "poured", "type": "integer" }, { "name": "query_row", "type": "integer" }, { "name": "query_glass", "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...
['Dynamic Programming']
800
Similar RGB Color
similar-rgb-color
null
Easy
18K
26.5K
17,956
26,504
67.7%
[]
[]
Algorithms
null
"#09f166"
{ "name": "similarRGB", "params": [ { "name": "color", "type": "string" } ], "return": { "type": "string" } }
{"cpp": ["C++", "<p>Compiled with <code> clang 19 </code> using the latest C++ 23 standard, and <code>libstdc++</code> provided by GCC 14.</p>\r\n\r\n<p>Your code is compiled with level two optimization (<code>-O2</code>). <a href=\"https://github.com/google/sanitizers/wiki/AddressSanitizer\" target=\"_blank\">AddressS...
['Math', 'String', 'Enumeration']