diff --git a/books/All.md b/books/All.md index d188f27..6104f46 100644 --- a/books/All.md +++ b/books/All.md @@ -4236,6 +4236,90 @@ def __init__(self): # param_4 = obj.getMin() ``` +## 156. Binary Tree Upside Down [Medium] +https://leetcode.com/problems/binary-tree-upside-down/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to flip a binary tree upside down, where the original leftmost node becomes the new root, and the original root becomes the rightmost leaf. The transformation follows a specific pattern where left children become parents and right children become left children. + +**1.1 Constraints & Complexity:** +- Input size: The tree can have up to O(n) nodes where n is the number of nodes +- **Time Complexity:** O(n) where n is the number of nodes - we visit each node exactly once +- **Space Complexity:** O(h) where h is the height of the tree - the recursion stack depth equals the tree height +- **Edge Case:** If the tree is empty or has no left child, return the root as-is + +**1.2 High-level approach:** +We use recursion to traverse to the leftmost node, which becomes the new root. During the backtracking phase, we reassign pointers to transform the tree structure according to the upside-down pattern. + +![Binary tree upside down transformation](https://assets.leetcode.com/static_assets/others/binary-tree-upside-down.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Create a new tree by copying nodes and reassigning pointers iteratively. This requires O(n) extra space. +- **Optimized Strategy:** Use recursion to transform the tree in-place by reassigning pointers during backtracking. This uses O(h) space for recursion. +- **Why it's better:** We modify the tree in-place without creating new nodes, making it more memory efficient. + +**1.4 Decomposition:** +1. Recursively traverse to the leftmost node, which will become the new root +2. During backtracking, reassign the current node's left child's left pointer to the current node's right child +3. Reassign the current node's left child's right pointer to the current node itself +4. Set the current node's left and right pointers to None to break old connections +5. Return the new root (leftmost node) from the deepest recursion + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example tree with nodes [1,2,3,4,5]: +- Root: 1, left: 2, right: 3 +- Node 2: left: 4, right: 5 +- After transformation, node 4 becomes the new root + +**2.2 Start Processing:** +We begin recursive traversal starting from the root, always going left first. + +**2.3 Trace Walkthrough:** + +| Node | Has Left? | Action | New Root | Transformations | +|------|-----------|--------|----------|------------------| +| 1 | Yes | Go left to 2 | - | - | +| 2 | Yes | Go left to 4 | - | - | +| 4 | No | Return 4 | 4 | - | +| 2 | - | Backtrack | 4 | 4.left = 5, 4.right = 2, 2.left = None, 2.right = None | +| 1 | - | Backtrack | 4 | 2.left = 3, 2.right = 1, 1.left = None, 1.right = None | + +**2.4 Increment and Loop:** +The recursion naturally handles the traversal. We continue until we reach a node with no left child. + +**2.5 Return Result:** +Return the new root (node 4), which is the leftmost node from the original tree. The tree is now upside down with all pointers correctly reassigned. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def upsideDownBinaryTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + if not root or not root.left: + return root + + new_root = self.upsideDownBinaryTree(root.left) + + root.left.left = root.right + root.left.right = root + root.left = None + root.right = None + + return new_root +``` + ## 160. Intersection of Two Linked Lists [Easy] https://leetcode.com/problems/intersection-of-two-linked-lists/ @@ -4330,6 +4414,92 @@ class Solution: return p1 ``` +## 170. Two Sum III - Data structure design [Easy] +https://leetcode.com/problems/two-sum-iii-data-structure-design/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to design a data structure that supports adding numbers and checking if any two numbers in the structure sum to a target value. This is similar to the classic Two Sum problem, but we need to handle dynamic additions and queries. + +**1.1 Constraints & Complexity:** +- Input size: Number of add operations and find operations can be large +- **Time Complexity:** O(1) for add, O(n) for find where n is the number of distinct numbers added +- **Space Complexity:** O(n) where n is the number of distinct numbers stored +- **Edge Case:** If we add the same number twice and look for 2*number, we need at least 2 occurrences. If we look for a sum that requires two different numbers, we need both to exist. + +**1.2 High-level approach:** +We use a hash map to store the frequency of each number added. For the find operation, we iterate through all numbers and check if their complement (target - number) exists in the map. We handle the special case where the complement equals the number itself. + +![Hash map storing number frequencies](https://assets.leetcode.com/static_assets/others/two-sum-hashmap.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Store numbers in a list, and for each find, check all pairs O(n²) time. +- **Optimized Strategy:** Use a hash map for O(1) lookups. For find, iterate through keys and check complements in O(1) time each. +- **Why it's better:** Hash map lookups are O(1) average case, making find operations much faster than checking all pairs. + +**1.4 Decomposition:** +1. Initialize a hash map to store number frequencies in the constructor +2. For add operation, increment the count of the number in the hash map +3. For find operation, iterate through all numbers in the hash map +4. For each number, calculate its complement (target - number) +5. Check if complement exists, handling the case where complement equals the number (need count >= 2) + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `add(1)`, `add(3)`, `add(5)`, `find(4)`, `find(7)` +- Initialize `num_counts = {}` (empty hash map) + +**2.2 Start Adding:** +We add numbers to the data structure. + +**2.3 Trace Walkthrough:** + +| Operation | number | num_counts after | - | +|-----------|--------|-------------------|---| +| add(1) | 1 | {1: 1} | - | +| add(3) | 3 | {1: 1, 3: 1} | - | +| add(5) | 5 | {1: 1, 3: 1, 5: 1} | - | +| find(4) | - | {1: 1, 3: 1, 5: 1} | Check: 1→complement=3 (exists), return True | +| find(7) | - | {1: 1, 3: 1, 5: 1} | Check: 1→complement=6 (not exists), 3→complement=4 (not exists), 5→complement=2 (not exists), return False | + +**Detailed find(4) check:** +- num=1: complement = 4-1 = 3, exists in map → return True + +**Detailed find(7) check:** +- num=1: complement = 7-1 = 6, not in map +- num=3: complement = 7-3 = 4, not in map +- num=5: complement = 7-5 = 2, not in map +- return False + +**2.4 Increment and Loop:** +For find operations, we iterate through all keys in the hash map. We stop early if we find a valid pair. + +**2.5 Return Result:** +Return True if any pair sums to the target value, False otherwise. For find(4), we return True because 1 + 3 = 4. For find(7), we return False because no pair sums to 7. + +### Solution + +```python +def __init__(self): + self.num_counts = defaultdict(int) + + def add(self, number: int) -> None: + self.num_counts[number] += 1 + + def find(self, value: int) -> bool: + for num in self.num_counts: + complement = value - num + if complement in self.num_counts: + if complement != num or self.num_counts[num] > 1: + return True + return False +``` + ## 173. Binary Search Tree Iterator [Medium] https://leetcode.com/problems/binary-search-tree-iterator/ @@ -6650,6 +6820,99 @@ class Codec: return root ``` +## 328. Odd Even Linked List [Medium] +https://leetcode.com/problems/odd-even-linked-list/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The linked list can have up to 10^4 nodes. +* **Time Complexity:** O(n) - We traverse the list once, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 0 or 1 node, return it as-is since there's nothing to reorder. + +**1.2 High-level approach:** + +The goal is to group all nodes at odd positions together, followed by all nodes at even positions, while maintaining their relative order within each group. + +![Linked list showing odd nodes (1,3,5) followed by even nodes (2,4)] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Create two separate lists for odd and even nodes, then concatenate them. This requires O(n) extra space. +* **Optimized (In-place):** Use two pointers to separate odd and even nodes in-place by rewiring the next pointers. This uses O(1) extra space. +* **Why it's better:** The in-place approach meets the O(1) space requirement and is more memory efficient. + +**1.4 Decomposition:** + +1. Use two pointers: `odd` for odd-positioned nodes and `even` for even-positioned nodes. +2. Keep track of the head of the even list. +3. Rewire connections: odd.next = even.next, even.next = odd.next.next. +4. Move both pointers forward. +5. Connect the end of the odd list to the head of the even list. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: head = [1,2,3,4,5] + +We initialize: +* `odd = head` (points to node 1) +* `even = head.next` (points to node 2) +* `even_head = even` (save the head of even list) + +**2.2 Start Checking/Processing:** + +We enter a loop while `even` and `even.next` exist. + +**2.3 Trace Walkthrough:** + +| Step | odd.val | even.val | odd.next.val | even.next.val | Action | +|------|---------|----------|--------------|---------------|--------| +| Initial | 1 | 2 | 3 | 3 | Setup | +| 1 | 1 | 2 | 3 | 4 | odd.next = 3, even.next = 4 | +| 2 | 3 | 4 | 5 | 5 | odd.next = 5, even.next = None | +| Final | 5 | 4 | 2 | - | Connect odd.next = even_head | + +**2.4 Increment and Loop:** + +After each iteration, we move `odd = odd.next` and `even = even.next` to process the next pair. + +**2.5 Return Result:** + +The final list is [1,3,5,2,4], which is returned. + +### Solution + +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]: + if not head or not head.next: + return head + + odd = head + even = head.next + even_head = even + + while even and even.next: + odd.next = even.next + odd = odd.next + even.next = odd.next + even = even.next + + odd.next = even_head + return head +``` + ## 337. House Robber III [Medium] https://leetcode.com/problems/house-robber-iii/ @@ -6918,6 +7181,110 @@ class Solution: return res ``` +## 437. Path Sum III [Medium] +https://leetcode.com/problems/path-sum-iii/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The tree can have up to 1000 nodes. +* **Time Complexity:** O(n) - We visit each node once during DFS, where n is the number of nodes. +* **Space Complexity:** O(h) for recursion stack where h is the height, plus O(n) in worst case for the prefix sum map. +* **Edge Case:** If the tree is empty, return 0. If targetSum is 0 and there are nodes with value 0, we need to count paths correctly. + +**1.2 High-level approach:** + +The goal is to count all paths in a binary tree where the sum of node values equals targetSum. A path can start and end anywhere, but must go downward. We use prefix sums to efficiently count paths ending at each node. + +![Tree showing paths with prefix sum tracking] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** For each node, explore all downward paths starting from it. This is O(n^2) in the worst case. +* **Optimized (Prefix Sum with Hash Map):** Use a hash map to store prefix sums along the current path. For each node, check if (current_sum - targetSum) exists in the map. This is O(n) time. +* **Why it's better:** The prefix sum approach avoids redundant calculations and reduces time complexity from O(n^2) to O(n). + +**1.4 Decomposition:** + +1. Use DFS to traverse the tree. +2. Maintain a prefix sum map that tracks sums along the current path. +3. At each node, add the node's value to current sum. +4. Check if (current_sum - targetSum) exists in the map to count paths ending here. +5. Recursively process left and right children. +6. Backtrack by decrementing the prefix sum count before returning. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = [10,5,-3,3,2,null,11,3,-2,null,1], targetSum = 8 + +We initialize: +* `res = 0` (count of paths) +* `prefix_sums = {}` (map of prefix sum -> count) +* `current_sum = 0` + +**2.2 Start Checking/Processing:** + +We call `dfs(root, 0)` to start traversal. + +**2.3 Trace Walkthrough:** + +| Node | current_sum | prefix_sums | current_sum - 8 | Paths Found | +|------|-------------|-------------|-----------------|-------------| +| 10 | 10 | {10:1} | 2 | 0 | +| 5 | 15 | {10:1, 15:1} | 7 | 0 | +| 3 | 18 | {10:1, 15:1, 18:1} | 10 | 1 (18-8=10 exists) | +| -2 | 16 | {10:1, 15:1, 18:1, 16:1} | 8 | 1 (16-8=8, but 8 not in map, but current_sum=16, check if 16==8: no) | +| 2 | 17 | {10:1, 15:1, 18:1, 16:1, 17:1} | 9 | 0 | +| 1 | 18 | {10:1, 15:1, 18:2, 16:1, 17:1} | 10 | 1 (18-8=10 exists) | + +**2.4 Increment and Loop:** + +After processing each node and its children, we backtrack by decrementing the prefix sum count. + +**2.5 Return Result:** + +After processing all nodes, `res = 3` is returned (paths: 5->3, 5->2->1, -3->11). + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def pathSum(self, root: Optional[TreeNode], targetSum: int) -> int: + res = 0 + prefix_sums = {} + + def dfs(node, current_sum): + nonlocal res, prefix_sums + if not node: + return + + current_sum += node.val + if current_sum == targetSum: + res += 1 + + res += prefix_sums.get(current_sum - targetSum, 0) + prefix_sums[current_sum] = prefix_sums.get(current_sum, 0) + 1 + + dfs(node.left, current_sum) + dfs(node.right, current_sum) + + prefix_sums[current_sum] -= 1 + + dfs(root, 0) + return res +``` + ## 443. String Compression [Medium] https://leetcode.com/problems/string-compression/ @@ -7384,6 +7751,113 @@ class Solution: return res ``` +## 617. Merge Two Binary Trees [Easy] +https://leetcode.com/problems/merge-two-binary-trees/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +- **Input Size:** The number of nodes in both trees is in the range `[0, 2000]`. +- **Value Range:** `-10^4 <= Node.val <= 10^4`. +- **Time Complexity:** O(min(m, n)) where m and n are the number of nodes in the two trees. We visit each node at most once. +- **Space Complexity:** O(min(m, n)) for the recursion stack in the worst case (skewed tree). +- **Edge Case:** If one tree is null, return the other tree. If both are null, return null. + +**1.2 High-level approach:** + +The goal is to merge two binary trees by summing overlapping nodes and using non-null nodes when one tree has a node and the other doesn't. We use recursion to traverse both trees simultaneously, creating new nodes for the merged tree. + +![Visualization showing how two binary trees are merged node by node, with overlapping nodes summed and non-overlapping nodes preserved] + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** There isn't really a brute force approach - we must traverse both trees to merge them. +- **Optimized Strategy:** Use recursive depth-first search to traverse both trees simultaneously, creating merged nodes as we go. +- **Why it's better:** Recursion naturally handles the tree structure and allows us to process each node exactly once. + +**1.4 Decomposition:** + +1. If both nodes are null, return null. +2. If one node is null, return the other node (no merging needed). +3. If both nodes exist, create a new node with the sum of their values. +4. Recursively merge the left subtrees. +5. Recursively merge the right subtrees. +6. Return the merged node. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: +- `root1 = [1, 3, 2, 5]` (tree structure: 1 has left=3, right=2; 3 has left=5) +- `root2 = [2, 1, 3, null, 4, null, 7]` (tree structure: 2 has left=1, right=3; 1 has right=4; 3 has right=7) + +**2.2 Start Checking:** + +We start from the root nodes of both trees. + +**2.3 Trace Walkthrough:** + +| Step | root1 node | root2 node | Action | Merged value | Left child | Right child | +|------|------------|------------|--------|--------------|------------|-------------| +| 1 | 1 | 2 | Both exist | 1 + 2 = 3 | Merge(3, 1) | Merge(2, 3) | +| 2 | 3 | 1 | Both exist | 3 + 1 = 4 | Merge(5, null) | Merge(null, 4) | +| 3 | 5 | null | root2 is null | 5 | null | null | +| 4 | null | 4 | root1 is null | 4 | null | null | +| 5 | 2 | 3 | Both exist | 2 + 3 = 5 | Merge(null, null) | Merge(null, 7) | +| 6 | null | null | Both null | null | - | - | +| 7 | null | 7 | root1 is null | 7 | null | null | + +The merged tree structure: +- Root: 3 (1 + 2) + - Left: 4 (3 + 1) + - Left: 5 (5 + null) + - Right: 4 (null + 4) + - Right: 5 (2 + 3) + - Left: null + - Right: 7 (null + 7) + +**2.4 Increment and Loop:** + +Recursion handles the traversal automatically. + +**2.5 Return Result:** + +Return the merged tree root: `[3, 4, 5, 5, 4, null, 7]`. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def mergeTrees(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> Optional[TreeNode]: + if not root1 and not root2: + return None + + if not root1: + return root2 + + if not root2: + return root1 + + # Merge values + merged = TreeNode(root1.val + root2.val) + + # Recursively merge left and right subtrees + merged.left = self.mergeTrees(root1.left, root2.left) + merged.right = self.mergeTrees(root1.right, root2.right) + + return merged +``` + ## 637. Average of Levels in Binary Tree [Easy] https://leetcode.com/problems/average-of-levels-in-binary-tree/ @@ -7533,8 +8007,90 @@ def longestSubarray(nums): return max_len ``` -## 701. Insert into a Binary Search Tree [Medium] -https://leetcode.com/problems/insert-into-a-binary-search-tree/ +## 700. Search in a Binary Search Tree [Easy] +https://leetcode.com/problems/search-in-a-binary-search-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The tree can have up to 5000 nodes. +* **Time Complexity:** O(h) where h is the height of the tree. In the worst case (skewed tree), h = n, giving O(n). In a balanced tree, h = log n. +* **Space Complexity:** O(h) for the recursion stack. In worst case O(n), in balanced tree O(log n). +* **Edge Case:** If the tree is empty or the value doesn't exist, return None. + +**1.2 High-level approach:** + +The goal is to find a node in a BST with a given value. We use the BST property: left subtree contains smaller values, right subtree contains larger values. + +![BST search showing how we navigate left or right based on comparison] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Traverse the entire tree (inorder/preorder/postorder) to find the value. This takes O(n) time. +* **Optimized (BST Property):** Use the BST property to eliminate half of the remaining nodes at each step. This takes O(h) time where h is height. +* **Why it's better:** The BST property allows us to skip entire subtrees, making search much faster than linear traversal. + +**1.4 Decomposition:** + +1. If the current node is None, return None (value not found). +2. If current node's value equals target, return the current node. +3. If current node's value is greater than target, search in the left subtree. +4. If current node's value is less than target, search in the right subtree. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = [4,2,7,1,3], val = 2 + +We start at the root node with value 4. + +**2.2 Start Checking/Processing:** + +We call `searchBST(root, 2)`. + +**2.3 Trace Walkthrough:** + +| Step | Current Node | Current Val | Comparison | Action | +|------|--------------|-------------|------------|--------| +| 1 | 4 | 4 | 4 > 2 | Go left to node 2 | +| 2 | 2 | 2 | 2 == 2 | Found! Return node 2 | + +**2.4 Increment and Loop:** + +After each comparison, we recursively search the appropriate subtree. + +**2.5 Return Result:** + +We return the node with value 2, which is the root of the subtree [2,1,3]. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def searchBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]: + if not root: + return None + + if root.val == val: + return root + elif root.val > val: + return self.searchBST(root.left, val) + else: + return self.searchBST(root.right, val) +``` + +## 701. Insert into a Binary Search Tree [Medium] +https://leetcode.com/problems/insert-into-a-binary-search-tree/ ### Explanation @@ -7642,6 +8198,96 @@ class Solution: return root ``` +## 872. Leaf-Similar Trees [Easy] +https://leetcode.com/problems/leaf-similar-trees/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** Each tree can have up to 200 nodes. +* **Time Complexity:** O(n + m) - We traverse both trees once to collect leaves, where n and m are the number of nodes in each tree. +* **Space Complexity:** O(n + m) - We store leaf sequences for both trees, plus O(h) for recursion stack. +* **Edge Case:** If both trees are empty, they are leaf-similar (both have empty leaf sequences). + +**1.2 High-level approach:** + +The goal is to check if two binary trees have the same leaf value sequence. We collect leaves from left to right for both trees and compare the sequences. + +![Tree traversal showing leaf collection from left to right] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Convert both trees to arrays using any traversal, then extract and compare leaves. This is inefficient. +* **Optimized (DFS with Leaf Collection):** Use DFS to collect leaves in order (left to right) for both trees, then compare the sequences. This is O(n + m) time. +* **Why it's better:** We only collect leaves, avoiding unnecessary processing of internal nodes, and compare sequences directly. + +**1.4 Decomposition:** + +1. Define a helper function to collect leaves from a tree using DFS. +2. For each node: if it's a leaf, add its value; otherwise, recursively collect from left and right subtrees. +3. Collect leaves from both trees. +4. Compare the two leaf sequences. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root1 = [3,5,1,6,2,9,8,null,null,7,4], root2 = [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8] + +We call `get_leaves(root1)` and `get_leaves(root2)`. + +**2.2 Start Checking/Processing:** + +We traverse each tree using DFS to collect leaves. + +**2.3 Trace Walkthrough:** + +For root1: +* Traverse left: 6 (leaf) → [6] +* Traverse right from 5: 7 (leaf) → [6,7] +* Continue: 4 (leaf) → [6,7,4] +* Continue: 9 (leaf) → [6,7,4,9] +* Continue: 8 (leaf) → [6,7,4,9,8] + +For root2: +* Traverse left: 6 (leaf) → [6] +* Traverse right from 5: 7 (leaf) → [6,7] +* Continue: 4 (leaf) → [6,7,4] +* Continue: 9 (leaf) → [6,7,4,9] +* Continue: 8 (leaf) → [6,7,4,9,8] + +**2.4 Increment and Loop:** + +After collecting all leaves from both trees, we compare the sequences. + +**2.5 Return Result:** + +Both sequences are [6,7,4,9,8], so we return `True`. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def leafSimilar(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool: + def get_leaves(node): + if not node: + return [] + if not node.left and not node.right: + return [node.val] + return get_leaves(node.left) + get_leaves(node.right) + + return get_leaves(root1) == get_leaves(root2) +``` + ## 876. Middle of the Linked List [Easy] https://leetcode.com/problems/middle-of-the-linked-list/ @@ -7892,6 +8538,230 @@ def __init__(self): return len(self.queue) ``` +## 981. Time Based Key-Value Store [Medium] +https://leetcode.com/problems/time-based-key-value-store/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +- **Input Size:** `1 <= key.length, value.length <= 100`, `1 <= timestamp <= 10^7`, at most `2 * 10^5` calls to set and get. +- **Time Complexity:** + - `set`: O(1) - append to list. + - `get`: O(log m) where m is the number of timestamps for the key (binary search). +- **Space Complexity:** O(n) where n is the total number of set operations. +- **Edge Case:** If a key doesn't exist or no timestamp <= given timestamp exists, return empty string. + +**1.2 High-level approach:** + +The goal is to design a time-based key-value store that can store multiple values for the same key at different timestamps and retrieve the value associated with the largest timestamp that is <= the given timestamp. We use a dictionary to map keys to lists of (timestamp, value) pairs, and use binary search to efficiently find the correct value. + +![Visualization showing how timestamps are stored and retrieved using binary search to find the largest timestamp <= target] + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** For `get`, iterate through all timestamps for a key to find the largest one <= target. This takes O(m) time where m is the number of timestamps. +- **Optimized Strategy:** Since timestamps are strictly increasing, we can use binary search to find the answer in O(log m) time. +- **Why it's better:** Binary search reduces the time complexity from O(m) to O(log m), which is crucial when there are many timestamps for a key. + +**1.4 Decomposition:** + +1. Initialize a dictionary to store key -> list of (timestamp, value) pairs. +2. For `set`: Append (timestamp, value) to the list for the key. +3. For `get`: Use binary search to find the largest timestamp <= target timestamp. +4. Return the corresponding value, or empty string if not found. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's trace through the example operations: +- `set("foo", "bar", 1)` +- `get("foo", 1)` -> should return "bar" +- `get("foo", 3)` -> should return "bar" (largest timestamp <= 3 is 1) +- `set("foo", "bar2", 4)` +- `get("foo", 4)` -> should return "bar2" +- `get("foo", 5)` -> should return "bar2" (largest timestamp <= 5 is 4) + +**2.2 Start Checking:** + +Initialize: `store = {}` + +**2.3 Trace Walkthrough:** + +| Operation | Key | Timestamp/Value | Store state | Action | +|-----------|-----|-----------------|-------------|--------| +| set | "foo" | ("bar", 1) | {"foo": [(1, "bar")]} | Append to list | +| get | "foo" | 1 | - | Binary search: find timestamp <= 1 | +| - | - | - | - | Found (1, "bar"), return "bar" | +| get | "foo" | 3 | - | Binary search: find timestamp <= 3 | +| - | - | - | - | Found (1, "bar"), return "bar" | +| set | "foo" | ("bar2", 4) | {"foo": [(1, "bar"), (4, "bar2")]} | Append to list | +| get | "foo" | 4 | - | Binary search: find timestamp <= 4 | +| - | - | - | - | Found (4, "bar2"), return "bar2" | +| get | "foo" | 5 | - | Binary search: find timestamp <= 5 | +| - | - | - | - | Found (4, "bar2"), return "bar2" | + +Binary search details for `get("foo", 3)`: +- List: `[(1, "bar"), (4, "bar2")]` +- left = 0, right = 1 +- mid = 0, values[0][0] = 1 <= 3, so res = "bar", left = 1 +- left = 1, right = 1, mid = 1, values[1][0] = 4 > 3, so right = 0 +- left = 1 > right = 0, exit loop +- Return "bar" + +**2.4 Increment and Loop:** + +Binary search continues until left > right. + +**2.5 Return Result:** + +Return the value associated with the largest timestamp <= target, or "" if not found. + +### Solution + +```python +def __init__(self): + self.store = {} # key -> list of (timestamp, value) pairs + + def set(self, key: str, value: str, timestamp: int) -> None: + if key not in self.store: + self.store[key] = [] + self.store[key].append((timestamp, value)) + + def get(self, key: str, timestamp: int) -> str: + if key not in self.store: + return "" + + # Binary search for the largest timestamp <= given timestamp + values = self.store[key] + left, right = 0, len(values) - 1 + res = "" + + while left <= right: + mid = (left + right) // 2 + if values[mid][0] <= timestamp: + res = values[mid][1] + left = mid + 1 + else: + right = mid - 1 + + return res +``` + +## 1161. Maximum Level Sum of a Binary Tree [Medium] +https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The tree can have up to 10^4 nodes. +* **Time Complexity:** O(n) - We visit each node once using BFS, where n is the number of nodes. +* **Space Complexity:** O(w) where w is the maximum width of the tree. In worst case O(n). +* **Edge Case:** If the tree is empty, return 0. If all level sums are equal, return the smallest level (1). + +**1.2 High-level approach:** + +The goal is to find the level with the maximum sum of node values. We use BFS (level-order traversal) to process nodes level by level and track the sum for each level. + +![BFS traversal showing level-by-level processing and sum calculation] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Use DFS to collect all nodes by level, then calculate sums. This requires extra space to store level information. +* **Optimized (BFS):** Use BFS to process one level at a time, calculating the sum as we go. This is O(n) time and naturally processes levels in order. +* **Why it's better:** BFS naturally processes levels sequentially, making it straightforward to track level sums without extra data structures. + +**1.4 Decomposition:** + +1. Use a queue for BFS traversal. +2. For each level: + - Process all nodes at the current level. + - Sum their values. + - Track the maximum sum and corresponding level. +3. Return the smallest level with maximum sum. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = [1,7,0,7,-8,null,null] + +We initialize: +* `queue = deque([root])` +* `max_sum = -inf` +* `res = 1` +* `level = 1` + +**2.2 Start Checking/Processing:** + +We enter a while loop while the queue is not empty. + +**2.3 Trace Walkthrough:** + +| Level | Nodes | Level Sum | max_sum | res | +|-------|-------|-----------|---------|-----| +| 1 | [1] | 1 | 1 | 1 | +| 2 | [7, 0] | 7 | 7 | 2 | +| 3 | [7, -8] | -1 | 7 | 2 | + +**2.4 Increment and Loop:** + +After processing each level, we increment the level counter and continue to the next level. + +**2.5 Return Result:** + +After processing all levels, `res = 2` is returned (level 2 has maximum sum of 7). + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def maxLevelSum(self, root: Optional[TreeNode]) -> int: + if not root: + return 0 + + from collections import deque + queue = deque([root]) + max_sum = float('-inf') + res = 1 + level = 1 + + while queue: + level_sum = 0 + size = len(queue) + + for _ in range(size): + node = queue.popleft() + level_sum += node.val + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + if level_sum > max_sum: + max_sum = level_sum + res = level + + level += 1 + + return res +``` + ## 1207. Unique Number of Occurrences [Easy] https://leetcode.com/problems/unique-number-of-occurrences/ @@ -8114,6 +8984,102 @@ def kidsWithCandies(candies, extraCandies): return [(c + extraCandies) >= max_candies for c in candies] ``` +## 1448. Count Good Nodes in Binary Tree [Medium] +https://leetcode.com/problems/count-good-nodes-in-binary-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The tree can have up to 10^5 nodes. +* **Time Complexity:** O(n) - We visit each node once using DFS, where n is the number of nodes. +* **Space Complexity:** O(h) for the recursion stack where h is the height. In worst case O(n). +* **Edge Case:** The root is always a good node since there are no nodes above it. + +**1.2 High-level approach:** + +The goal is to count nodes where the path from root to that node has no node with value greater than the current node. We use DFS to traverse the tree, tracking the maximum value seen so far. + +![Tree traversal showing how we track maximum values along paths] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** For each node, check all nodes on the path from root to it. This is O(n^2) in worst case. +* **Optimized (DFS with Max Tracking):** During DFS, pass the maximum value seen so far. If current node's value >= max, it's good. This is O(n) time. +* **Why it's better:** We check the condition during traversal without storing paths, making it O(n) instead of O(n^2). + +**1.4 Decomposition:** + +1. Use DFS to traverse the tree. +2. For each node, check if its value >= max_value_seen. +3. If yes, increment the count and update max_value_seen. +4. Recursively process left and right children with updated max_value. +5. Return the total count. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = [3,1,4,3,null,1,5] + +We initialize: +* `res = 0` +* Start DFS from root with `max_val = 3` (root value) + +**2.2 Start Checking/Processing:** + +We call `dfs(root, root.val)`. + +**2.3 Trace Walkthrough:** + +| Node | Value | max_val | Value >= max? | Action | res | +|------|-------|---------|---------------|--------|-----| +| 3 | 3 | 3 | Yes | Count++, max=3 | 1 | +| 1 | 1 | 3 | No | Skip | 1 | +| 3 | 3 | 3 | Yes | Count++, max=3 | 2 | +| 4 | 4 | 3 | Yes | Count++, max=4 | 3 | +| 1 | 1 | 4 | No | Skip | 3 | +| 5 | 5 | 4 | Yes | Count++, max=5 | 4 | + +**2.4 Increment and Loop:** + +After processing each node, we recursively process its children. + +**2.5 Return Result:** + +After processing all nodes, `res = 4` is returned (nodes 3, 3, 4, and 5 are good). + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def goodNodes(self, root: TreeNode) -> int: + res = 0 + + def dfs(node, max_val): + nonlocal res + if not node: + return + + if node.val >= max_val: + res += 1 + max_val = node.val + + dfs(node.left, max_val) + dfs(node.right, max_val) + + dfs(root, root.val) + return res +``` + ## 1515. Best Position for a Service Centre [Hard] https://leetcode.com/problems/best-position-for-a-service-centre/ @@ -8598,6 +9564,101 @@ def getXORSum(arr1, arr2): return result ``` +## 2095. Delete the Middle Node of a Linked List [Medium] +https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The linked list can have up to 10^5 nodes. +* **Time Complexity:** O(n) - We traverse the list once to find the middle, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 0 or 1 node, return None (no middle node to delete). + +**1.2 High-level approach:** + +The goal is to delete the middle node of a linked list. The middle node is at index floor(n/2) using 0-based indexing. We use the two-pointer technique to find the middle node. + +![Two-pointer technique showing fast and slow pointers finding the middle] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Traverse the list to count nodes, then traverse again to find and delete the middle node. This requires two passes. +* **Optimized (Two Pointers):** Use fast and slow pointers. When fast reaches the end, slow is at the middle. This is one pass. +* **Why it's better:** The two-pointer approach finds the middle in one pass, making it more efficient. + +**1.4 Decomposition:** + +1. Handle edge cases: if list has 0 or 1 node, return None. +2. Use two pointers: slow and fast, both starting at head. +3. Also track prev to point to the node before slow. +4. Move fast two steps and slow one step until fast reaches the end. +5. Delete the middle node by setting prev.next = slow.next. +6. Return head. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: head = [1,3,4,7,1,2,6] + +We initialize: +* `slow = head` (node 1) +* `fast = head` (node 1) +* `prev = None` + +**2.2 Start Checking/Processing:** + +We enter a while loop while `fast` and `fast.next` exist. + +**2.3 Trace Walkthrough:** + +| Step | slow.val | fast.val | prev.val | Action | +|------|----------|----------|----------|--------| +| Initial | 1 | 1 | None | Setup | +| 1 | 3 | 4 | 1 | Move pointers | +| 2 | 4 | 1 | 3 | Move pointers | +| 3 | 7 | 2 | 4 | Move pointers | +| 4 | 1 | 6 | 7 | fast.next is None, stop | +| Final | 7 | - | 4 | Delete: prev.next = slow.next | + +**2.4 Increment and Loop:** + +After each iteration, we update prev = slow, then move slow and fast. + +**2.5 Return Result:** + +After deletion, the list is [1,3,4,1,2,6], and head is returned. + +### Solution + +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def deleteMiddle(self, head: Optional[ListNode]) -> Optional[ListNode]: + if not head or not head.next: + return None + + slow = head + fast = head + prev = None + + while fast and fast.next: + prev = slow + slow = slow.next + fast = fast.next.next + + prev.next = slow.next + return head +``` + ## 2119. A Number After a Double Reversal [Easy] https://leetcode.com/problems/a-number-after-a-double-reversal/ @@ -8787,6 +9848,101 @@ def minOperations(nums): return min_operations ``` +## 2130. Maximum Twin Sum of a Linked List [Medium] +https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The linked list has an even number of nodes, up to 10^5. +* **Time Complexity:** O(n) - We traverse the list to find the middle, reverse the second half, and compare pairs, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 2 nodes, return the sum of their values. + +**1.2 High-level approach:** + +The goal is to find the maximum sum of twin pairs. Twins are nodes at positions i and n-1-i. We split the list at the middle, reverse the second half, then compare pairs. + +![Linked list showing twin pairs and their sums] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Store all node values in an array, then calculate all twin sums. This uses O(n) extra space. +* **Optimized (In-place Reversal):** Find the middle, reverse the second half in-place, then traverse both halves simultaneously to find max sum. This uses O(1) extra space. +* **Why it's better:** The in-place approach meets the O(1) space requirement and is more memory efficient. + +**1.4 Decomposition:** + +1. Use two pointers to find the middle of the list. +2. Reverse the second half of the list. +3. Traverse both halves simultaneously, calculating twin sums. +4. Track and return the maximum sum. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: head = [5,4,2,1] + +We initialize: +* Find middle: after two-pointer, slow points to node 2 (middle). + +**2.2 Start Checking/Processing:** + +We reverse the second half starting from slow. + +**2.3 Trace Walkthrough:** + +| Step | First Half | Second Half (reversed) | Twin Sum | Max | +|------|------------|------------------------|----------|-----| +| Initial | [5,4] | [2,1] → reverse → [1,2] | - | 0 | +| 1 | 5 | 1 | 5+1=6 | 6 | +| 2 | 4 | 2 | 4+2=6 | 6 | + +**2.4 Increment and Loop:** + +After calculating each twin sum, we move both pointers forward and update the maximum. + +**2.5 Return Result:** + +After processing all pairs, `res = 6` is returned (both pairs sum to 6). + +### Solution + +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def pairSum(self, head: Optional[ListNode]) -> int: + slow = fast = head + while fast and fast.next: + slow = slow.next + fast = fast.next.next + + prev = None + while slow: + next_node = slow.next + slow.next = prev + prev = slow + slow = next_node + + res = 0 + first = head + second = prev + while second: + res = max(res, first.val + second.val) + first = first.next + second = second.next + + return res +``` + ## 2215. Find the Difference of Two Arrays [Easy] https://leetcode.com/problems/find-the-difference-of-two-arrays/ @@ -8828,6 +9984,99 @@ def findDifference(nums1, nums2): return [list(set1 - set2), list(set2 - set1)] ``` +## 2336. Smallest Number in Infinite Set [Medium] +https://leetcode.com/problems/smallest-number-in-infinite-set/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** At most 1000 calls to popSmallest and addBack. Numbers are between 1 and 1000. +* **Time Complexity:** O(log k) for popSmallest and addBack where k is the number of added-back numbers. O(1) for the infinite set part. +* **Space Complexity:** O(k) where k is the number of distinct numbers that have been popped and added back. +* **Edge Case:** If we pop all numbers 1-1000 and add some back, those added-back numbers should be returned before continuing with 1001+. + +**1.2 High-level approach:** + +The goal is to implement a set that contains all positive integers, with operations to pop the smallest and add numbers back. We use a min-heap for added-back numbers and track the next number in the infinite sequence. + +![Data structure showing heap for added-back numbers and counter for infinite sequence] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** Store all popped numbers in a set, then for popSmallest, iterate from 1 to find the first not in the set. This is O(n) per pop. +* **Optimized (Heap + Counter):** Use a min-heap for added-back numbers and a counter for the infinite sequence. popSmallest returns min(heap.pop(), counter++). This is O(log k) per pop. +* **Why it's better:** The heap allows O(log k) access to the minimum added-back number, and the counter handles the infinite sequence in O(1). + +**1.4 Decomposition:** + +1. Maintain a min-heap for numbers that were popped and added back. +2. Maintain a counter (next_num) for the infinite sequence starting from 1. +3. Maintain a set to track which numbers are currently removed. +4. For popSmallest: if heap is not empty, pop from heap; otherwise, return and increment counter. +5. For addBack: if number is in removed set, add it to heap and remove from set. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +We initialize: +* `removed = set()` (track removed numbers) +* `added_back = []` (min-heap) +* `next_num = 1` (next number in infinite sequence) + +**2.2 Start Checking/Processing:** + +Operations are called: addBack(2), popSmallest(), popSmallest(), popSmallest(), addBack(1), popSmallest() + +**2.3 Trace Walkthrough:** + +| Operation | added_back | next_num | removed | Return | +|-----------|------------|----------|---------|--------| +| addBack(2) | [] | 1 | {} | None (2 already in set) | +| popSmallest() | [] | 1 | {1} | 1, next_num=2 | +| popSmallest() | [] | 2 | {1,2} | 2, next_num=3 | +| popSmallest() | [] | 3 | {1,2,3} | 3, next_num=4 | +| addBack(1) | [1] | 4 | {2,3} | None | +| popSmallest() | [] | 4 | {2,3,1} | 1 (from heap), next_num=4 | + +**2.4 Increment and Loop:** + +After each operation, we update the data structures accordingly. + +**2.5 Return Result:** + +The operations return [null, 1, 2, 3, null, 1] as expected. + +### Solution + +```python +def __init__(self): + self.removed = set() + self.added_back = [] + self.next_num = 1 + + def popSmallest(self) -> int: + if self.added_back: + res = heapq.heappop(self.added_back) + self.removed.add(res) + return res + else: + res = self.next_num + self.next_num += 1 + self.removed.add(res) + return res + + def addBack(self, num: int) -> None: + if num in self.removed: + self.removed.remove(num) + heapq.heappush(self.added_back, num) +``` + ## 2352. Equal Row and Column Pairs [Medium] https://leetcode.com/problems/equal-row-and-column-pairs/ diff --git a/books/LeetCode_75.md b/books/LeetCode_75.md index 3b76482..855013e 100644 --- a/books/LeetCode_75.md +++ b/books/LeetCode_75.md @@ -2,122 +2,8 @@ Problem list from official https://leetcode.com/studyplan/leetcode-75/ -## 142. Linked List Cycle II [Medium] -https://leetcode.com/problems/linked-list-cycle-ii/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -Given the head of a linked list, we need to return the node where the cycle begins. If there is no cycle, return `null`. - -**1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes can be up to $10^4$. -- **Value Range:** Node values can be any integer. -- **Time Complexity:** $O(n)$ - We traverse the list at most twice with Floyd's algorithm. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If the list has no cycle, return `null`. If the list has only one node pointing to itself, that node is the cycle start. - -**1.2 High-level approach:** - -The goal is to find the starting node of a cycle in a linked list. - -We use Floyd's cycle detection algorithm (tortoise and hare). First, we detect if there's a cycle by having two pointers move at different speeds. If they meet, there's a cycle. Then, we find the cycle start by moving one pointer back to the head and moving both at the same speed until they meet again. - -**1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** Use a hash set to store visited nodes. The first node we encounter that's already in the set is the cycle start. This takes $O(n)$ time and $O(n)$ space. -- **Optimized Strategy (Floyd's Algorithm):** Use two pointers moving at different speeds to detect the cycle, then use mathematical properties to find the start. This takes $O(n)$ time and $O(1)$ space. -- **Why it's better:** Floyd's algorithm uses $O(1)$ extra space instead of $O(n)$ for a hash set, while maintaining the same time complexity. - -**1.4 Decomposition:** - -1. Use two pointers (slow and fast) starting at the head. -2. Move slow one step and fast two steps at a time. -3. If they meet, there's a cycle. If fast reaches the end, there's no cycle. -4. If a cycle is detected, move slow back to the head. -5. Move both pointers one step at a time until they meet. The meeting point is the cycle start. - -### Steps (The "How") - -**2.1 Initialization & Example Setup:** - -Let's use the example: head = $[3,2,0,-4]$ with cycle at node with value 2 - -We initialize: -- `slow = head` -- `fast = head` - -**2.2 Start Detection:** - -We begin moving the pointers. - -**2.3 Trace Walkthrough:** - -**Phase 1: Detect Cycle** - -| Step | slow position | fast position | Action | -|------|---------------|---------------|--------| -| 0 | 3 | 3 | Start | -| 1 | 2 | 0 | Move | -| 2 | 0 | 2 | Move | -| 3 | -4 | -4 | **Meet!** Cycle detected | - -**Phase 2: Find Cycle Start** - -| Step | slow position | fast position | Action | -|------|---------------|---------------|--------| -| 0 | 3 (head) | -4 | Reset slow to head | -| 1 | 2 | 3 | Move both one step | -| 2 | 0 | 2 | Move both one step | -| 3 | -4 | 0 | Move both one step | -| 4 | 3 | -4 | Move both one step | -| 5 | 2 | 2 | **Meet!** Cycle start found | - -**2.4 Explanation:** - -- When slow and fast meet in phase 1, the distance from head to cycle start equals the distance from meeting point to cycle start. -- Moving both pointers one step at a time from head and meeting point will make them meet at the cycle start. - -**2.5 Return Result:** - -We return the node with value 2, which is where the cycle begins. - -> **Note:** Floyd's algorithm uses the mathematical property that when the slow and fast pointers meet, the distance from the head to the cycle start equals the distance from the meeting point to the cycle start (moving in the cycle direction). - -### Solution - -```python -def __init__(self, x): -# self.val = x -# self.next = None - -class Solution: - def detectCycle(self, head): - # Floyd's cycle detection algorithm - slow = head - fast = head - - # Find meeting point - while fast and fast.next: - slow = slow.next - fast = fast.next.next - if slow == fast: - # Cycle detected, find the start of cycle - slow = head - while slow != fast: - slow = slow.next - fast = fast.next - return slow - - return None -``` - -## 21. Merge Two Sorted Lists [Easy] -https://leetcode.com/problems/merge-two-sorted-lists/ +## 104. Maximum Depth of Binary Tree [Easy] +https://leetcode.com/problems/maximum-depth-of-binary-tree/ ### Explanation @@ -125,99 +11,99 @@ https://leetcode.com/problems/merge-two-sorted-lists/ ### Strategy (The "Why") -Given two sorted linked lists `list1` and `list2`, we need to merge them into one sorted list and return the head of the merged list. +Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. **1.1 Constraints & Complexity:** -- **Input Size:** The total number of nodes can be up to $50$. +- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. - **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n + m)$ where $n$ and $m$ are the lengths of the two lists. We visit each node exactly once. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for the dummy node and pointers. -- **Edge Case:** If one list is empty, return the other list. If both are empty, return `null`. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Edge Case:** If the tree is empty (root is null), return 0. **1.2 High-level approach:** -The goal is to merge two sorted linked lists into one sorted list. +The goal is to find the maximum depth of a binary tree. + +![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) -We use a dummy node to simplify edge cases and a current pointer to build the merged list. We compare nodes from both lists and attach the smaller one to the result, then move the pointer of the list we took from. +We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Convert both lists to arrays, merge the arrays, then convert back to a linked list. This takes $O(n + m)$ time and $O(n + m)$ space. -- **Optimized Strategy (Two Pointers):** Use two pointers to traverse both lists simultaneously, building the merged list in-place. This takes $O(n + m)$ time and $O(1)$ space. -- **Why it's better:** The two-pointer approach uses $O(1)$ extra space instead of $O(n + m)$ for arrays, while maintaining the same time complexity. +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. +- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. +- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. **1.4 Decomposition:** -1. Create a dummy node to simplify edge cases. -2. Initialize a current pointer at the dummy node. -3. While both lists have nodes, compare the values and attach the smaller node to the result. -4. Move the pointer of the list we took from. -5. Attach the remaining nodes from the non-empty list. -6. Return the head of the merged list (dummy.next). +1. Base case: if the root is null, return 0. +2. Recursively find the maximum depth of the left subtree. +3. Recursively find the maximum depth of the right subtree. +4. Return 1 (for current node) plus the maximum of the two subtree depths. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: $list1 = [1,2,4]$, $list2 = [1,3,4]$ +Let's use the example: root = $[3,9,20,null,null,15,7]$ -We initialize: -- `dummy = ListNode(0)` -- `current = dummy` +The tree structure: +``` + 3 + / \ + 9 20 + / \ + 15 7 +``` -**2.2 Start Merging:** +**2.2 Start Recursion:** -We begin comparing nodes from both lists. +We begin from the root node (value 3). **2.3 Trace Walkthrough:** -| Step | list1.val | list2.val | Compare | Attach | current.next | list1/list2 After | -|------|-----------|-----------|---------|--------|--------------|-------------------| -| 1 | 1 | 1 | Equal | list1 | 1 | list1 = 2 | -| 2 | 2 | 1 | 2 > 1 | list2 | 1 | list2 = 3 | -| 3 | 2 | 3 | 2 < 3 | list1 | 2 | list1 = 4 | -| 4 | 4 | 3 | 4 > 3 | list2 | 3 | list2 = 4 | -| 5 | 4 | 4 | Equal | list1 | 4 | list1 = null | -| 6 | null | 4 | - | list2 | 4 | list2 = null | +| Node | Left Depth | Right Depth | Max Depth | Return Value | +|------|------------|--------------|-----------|--------------| +| 3 | ? | ? | - | Compute... | +| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | ? | ? | - | Compute... | +| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | +| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | -**2.4 Final Result:** +**2.4 Recursion Flow:** -After merging: $[1,1,2,3,4,4]$ +- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ +- Node 9: both children null, return $0 + 1 = 1$ +- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ **2.5 Return Result:** -We return the head of the merged list: $[1,1,2,3,4,4]$ +We return 3, which is the maximum depth of the tree. -> **Note:** The dummy node simplifies the code by providing a starting point. Without it, we'd need special handling for the first node. The key is to always attach the smaller node and move the corresponding pointer forward. +> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. ### Solution ```python -def __init__(self, val=0, next=None): +def __init__(self, val=0, left=None, right=None): # self.val = val -# self.next = next +# self.left = left +# self.right = right class Solution: - def mergeTwoLists(self, list1, list2): - # Create a dummy node to simplify edge cases - dummy = ListNode(0) - current = dummy - - # Merge while both lists have nodes - while list1 and list2: - if list1.val <= list2.val: - current.next = list1 - list1 = list1.next - else: - current.next = list2 - list2 = list2.next - current = current.next + def maxDepth(self, root) -> int: + if not root: + return 0 - # Append remaining nodes - current.next = list1 if list1 else list2 + # Recursively find max depth of left and right subtrees + left_depth = self.maxDepth(root.left) + right_depth = self.maxDepth(root.right) - return dummy.next + # Return max depth plus 1 for current node + return max(left_depth, right_depth) + 1 ``` ## 206. Reverse Linked List [Easy] @@ -320,8 +206,8 @@ class Solution: return prev ``` -## 876. Middle of the Linked List [Easy] -https://leetcode.com/problems/middle-of-the-linked-list/ +## 700. Search in a Binary Search Tree [Easy] +https://leetcode.com/problems/search-in-a-binary-search-tree/ ### Explanation @@ -329,91 +215,81 @@ https://leetcode.com/problems/middle-of-the-linked-list/ ### Strategy (The "Why") -Given the head of a singly linked list, we need to return the middle node of the linked list. If there are two middle nodes, return the second one. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be between $1$ and $100$. -- **Value Range:** Node values are between $1$ and $100$. -- **Time Complexity:** $O(n)$ - We traverse the list once with two pointers. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If the list has only one node, return that node. If the list has two nodes, return the second one. +* **Input Size:** The tree can have up to 5000 nodes. +* **Time Complexity:** O(h) where h is the height of the tree. In the worst case (skewed tree), h = n, giving O(n). In a balanced tree, h = log n. +* **Space Complexity:** O(h) for the recursion stack. In worst case O(n), in balanced tree O(log n). +* **Edge Case:** If the tree is empty or the value doesn't exist, return None. **1.2 High-level approach:** -The goal is to find the middle node of a linked list. +The goal is to find a node in a BST with a given value. We use the BST property: left subtree contains smaller values, right subtree contains larger values. -We use the "tortoise and hare" approach: one pointer moves one step at a time (slow), and another moves two steps at a time (fast). When the fast pointer reaches the end, the slow pointer is at the middle. +![BST search showing how we navigate left or right based on comparison] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** First pass to count nodes, second pass to find the middle node. This takes $O(n)$ time but requires two passes. -- **Optimized Strategy (Two Pointers):** Use two pointers moving at different speeds. This takes $O(n)$ time in a single pass. -- **Why it's better:** The two-pointer approach finds the middle in one pass instead of two, making it more efficient and elegant. +* **Brute Force:** Traverse the entire tree (inorder/preorder/postorder) to find the value. This takes O(n) time. +* **Optimized (BST Property):** Use the BST property to eliminate half of the remaining nodes at each step. This takes O(h) time where h is height. +* **Why it's better:** The BST property allows us to skip entire subtrees, making search much faster than linear traversal. **1.4 Decomposition:** -1. Initialize two pointers (slow and fast) at the head. -2. Move slow one step and fast two steps at a time. -3. When fast reaches the end (null or last node), slow is at the middle. -4. Return the slow pointer. +1. If the current node is None, return None (value not found). +2. If current node's value equals target, return the current node. +3. If current node's value is greater than target, search in the left subtree. +4. If current node's value is less than target, search in the right subtree. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: $head = [1,2,3,4,5]$ +Let's use the example: root = [4,2,7,1,3], val = 2 -We initialize: -- `slow = 1` -- `fast = 1` +We start at the root node with value 4. -**2.2 Start Processing:** +**2.2 Start Checking/Processing:** -We begin moving the pointers. +We call `searchBST(root, 2)`. **2.3 Trace Walkthrough:** -| Step | slow position | fast position | Action | -|------|---------------|---------------|--------| -| 0 | 1 | 1 | Start | -| 1 | 2 | 3 | Move slow 1, fast 2 | -| 2 | 3 | 5 | Move slow 1, fast 2 | -| 3 | 3 | null | fast.next is null, stop | +| Step | Current Node | Current Val | Comparison | Action | +|------|--------------|-------------|------------|--------| +| 1 | 4 | 4 | 4 > 2 | Go left to node 2 | +| 2 | 2 | 2 | 2 == 2 | Found! Return node 2 | -**2.4 Explanation:** +**2.4 Increment and Loop:** -- When fast reaches the end (node 5, where fast.next is null), slow is at node 3, which is the middle node. +After each comparison, we recursively search the appropriate subtree. **2.5 Return Result:** -We return the node with value 3, which is the middle node. - -> **Note:** The key insight is that when the fast pointer moves twice as fast, it covers twice the distance. When it reaches the end, the slow pointer has covered half the distance, which is exactly the middle. +We return the node with value 2, which is the root of the subtree [2,1,3]. ### Solution ```python -def __init__(self, val=0, next=None): +def __init__(self, val=0, left=None, right=None): # self.val = val -# self.next = next - +# self.left = left +# self.right = right class Solution: - def middleNode(self, head): - slow = head - fast = head - - # Move fast pointer twice as fast as slow pointer - while fast and fast.next: - slow = slow.next - fast = fast.next.next + def searchBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]: + if not root: + return None - # When fast reaches the end, slow is at the middle - return slow + if root.val == val: + return root + elif root.val > val: + return self.searchBST(root.left, val) + else: + return self.searchBST(root.right, val) ``` -## 230. Kth Smallest Element in a BST [Medium] -https://leetcode.com/problems/kth-smallest-element-in-a-bst/ +## 872. Leaf-Similar Trees [Easy] +https://leetcode.com/problems/leaf-similar-trees/ ### Explanation @@ -421,93 +297,67 @@ https://leetcode.com/problems/kth-smallest-element-in-a-bst/ ### Strategy (The "Why") -Given the root of a binary search tree (BST) and an integer $k$, we need to find the $k$-th smallest element in the BST. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ in the BST can be up to $10^4$. -- **Value Range:** Node values are between $1$ and $10^4$. -- **Time Complexity:** $O(n)$ - We traverse all nodes in the BST using in-order traversal, which visits each node exactly once. -- **Space Complexity:** $O(n)$ - In the worst case (a skewed tree), the recursion stack can be $O(n)$ deep. Additionally, we store all node values in a list, which requires $O(n)$ space. -- **Edge Case:** If $k$ is 1, we return the smallest element. If $k$ equals the number of nodes, we return the largest element. +* **Input Size:** Each tree can have up to 200 nodes. +* **Time Complexity:** O(n + m) - We traverse both trees once to collect leaves, where n and m are the number of nodes in each tree. +* **Space Complexity:** O(n + m) - We store leaf sequences for both trees, plus O(h) for recursion stack. +* **Edge Case:** If both trees are empty, they are leaf-similar (both have empty leaf sequences). **1.2 High-level approach:** -The goal is to find the $k$-th smallest element in a BST. - -![BST In-order Traversal](https://assets.leetcode.com/uploads/2021/01/28/kthtree1.jpg) +The goal is to check if two binary trees have the same leaf value sequence. We collect leaves from left to right for both trees and compare the sequences. -A key property of a BST is that an in-order traversal (left → root → right) visits nodes in ascending order. Therefore, the $k$-th element visited during an in-order traversal is the $k$-th smallest element. +![Tree traversal showing leaf collection from left to right] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Perform an in-order traversal to collect all node values in a list, then return the element at index $k-1$. This approach is straightforward and works correctly. -- **Optimized Strategy:** We can optimize by stopping the traversal once we've found the $k$-th element, using an iterative approach or early termination in recursion. However, for clarity and beginner-friendliness, we'll use the complete traversal approach. -- **Why it's better:** The brute force approach is actually quite efficient for this problem. A more optimized version would use iterative in-order traversal with early termination, but the complete traversal approach is easier to understand. +* **Brute Force:** Convert both trees to arrays using any traversal, then extract and compare leaves. This is inefficient. +* **Optimized (DFS with Leaf Collection):** Use DFS to collect leaves in order (left to right) for both trees, then compare the sequences. This is O(n + m) time. +* **Why it's better:** We only collect leaves, avoiding unnecessary processing of internal nodes, and compare sequences directly. **1.4 Decomposition:** -1. Perform an in-order traversal of the BST (visit left subtree, then root, then right subtree). -2. Collect all node values in a list during the traversal. -3. Since in-order traversal of a BST produces values in sorted order, the list will be sorted. -4. Return the element at index $k-1$ (since $k$ is 1-indexed). +1. Define a helper function to collect leaves from a tree using DFS. +2. For each node: if it's a leaf, add its value; otherwise, recursively collect from left and right subtrees. +3. Collect leaves from both trees. +4. Compare the two leaf sequences. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3, 1, 4, null, 2]$, $k = 1$ - -The BST structure: -``` - 3 - / \ - 1 4 - \ - 2 -``` +Let's use the example: root1 = [3,5,1,6,2,9,8,null,null,7,4], root2 = [3,5,1,6,7,4,2,null,null,null,null,null,null,9,8] -We initialize: -- An empty list `res = []` to store node values -- We'll perform in-order traversal starting from the root +We call `get_leaves(root1)` and `get_leaves(root2)`. -**2.2 Start Traversing:** +**2.2 Start Checking/Processing:** -We begin the in-order traversal from the root node (value 3). +We traverse each tree using DFS to collect leaves. **2.3 Trace Walkthrough:** -The in-order traversal visits nodes in this order: +For root1: +* Traverse left: 6 (leaf) → [6] +* Traverse right from 5: 7 (leaf) → [6,7] +* Continue: 4 (leaf) → [6,7,4] +* Continue: 9 (leaf) → [6,7,4,9] +* Continue: 8 (leaf) → [6,7,4,9,8] -| Step | Current Node | Action | List State | -|------|--------------|--------|------------| -| 1 | 3 (root) | Go to left child (1) | [] | -| 2 | 1 | Go to left child (null) | [] | -| 3 | null | Return (base case) | [] | -| 4 | 1 | Add 1 to list | [1] | -| 5 | 1 | Go to right child (2) | [1] | -| 6 | 2 | Go to left child (null) | [1] | -| 7 | null | Return (base case) | [1] | -| 8 | 2 | Add 2 to list | [1, 2] | -| 9 | 2 | Go to right child (null) | [1, 2] | -| 10 | null | Return (base case) | [1, 2] | -| 11 | 3 | Add 3 to list | [1, 2, 3] | -| 12 | 3 | Go to right child (4) | [1, 2, 3] | -| 13 | 4 | Go to left child (null) | [1, 2, 3] | -| 14 | null | Return (base case) | [1, 2, 3] | -| 15 | 4 | Add 4 to list | [1, 2, 3, 4] | -| 16 | 4 | Go to right child (null) | [1, 2, 3, 4] | -| 17 | null | Return (base case) | [1, 2, 3, 4] | +For root2: +* Traverse left: 6 (leaf) → [6] +* Traverse right from 5: 7 (leaf) → [6,7] +* Continue: 4 (leaf) → [6,7,4] +* Continue: 9 (leaf) → [6,7,4,9] +* Continue: 8 (leaf) → [6,7,4,9,8] -After traversal: `res = [1, 2, 3, 4]` +**2.4 Increment and Loop:** -**2.4 Return Result:** +After collecting all leaves from both trees, we compare the sequences. -Since $k = 1$ (1-indexed), we return `res[0] = 1`, which is the 1st smallest element. - -For $k = 3$, we would return `res[2] = 3`, which is the 3rd smallest element. +**2.5 Return Result:** -> **Note:** In-order traversal of a BST always produces values in ascending order because of the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. +Both sequences are [6,7,4,9,8], so we return `True`. ### Solution @@ -516,27 +366,20 @@ def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right - class Solution: - def kthSmallest(self, root, k: int) -> int: - # In-order traversal to get elements in sorted order - res = [] - - def inorder(node): + def leafSimilar(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> bool: + def get_leaves(node): if not node: - return - inorder(node.left) - res.append(node.val) - inorder(node.right) + return [] + if not node.left and not node.right: + return [node.val] + return get_leaves(node.left) + get_leaves(node.right) - inorder(root) - - # Return the k-th smallest element (1-indexed) - return res[k - 1] + return get_leaves(root1) == get_leaves(root2) ``` -## 98. Validate Binary Search Tree [Medium] -https://leetcode.com/problems/validate-binary-search-tree/ +## 933. Number of Recent Calls [Easy] +https://leetcode.com/problems/number-of-recent-calls/ ### Explanation @@ -544,216 +387,241 @@ https://leetcode.com/problems/validate-binary-search-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to determine if it is a valid binary search tree (BST). A BST is valid if for every node, all nodes in its left subtree are less than it, and all nodes in its right subtree are greater than it. +We need to implement a `RecentCounter` class that counts the number of recent requests within the past 3000 milliseconds. Each call to `ping(t)` adds a new request at time $t$ and returns the number of requests in the range $[t-3000, t]$. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-2^{31}$ and $2^{31} - 1$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** An empty tree is a valid BST. A tree with only one node is a valid BST. +- **Input Size:** The number of calls to `ping` can be up to $10^4$. +- **Value Range:** Time values $t$ are strictly increasing and between $1$ and $10^9$. +- **Time Complexity:** $O(1)$ amortized - Each `ping` operation is $O(1)$ amortized because each request is added once and removed at most once. +- **Space Complexity:** $O(n)$ where $n$ is the number of requests in the current 3000ms window. In the worst case, if all requests are within 3000ms, this is $O(n)$. +- **Edge Case:** If `ping` is called with times that are more than 3000ms apart, old requests are removed from the queue. **1.2 High-level approach:** -The goal is to validate that a binary tree satisfies the BST property. +The goal is to maintain a sliding window of requests within the past 3000ms. + +![Recent Counter](https://assets.leetcode.com/uploads/2021/09/03/chrome_2021-09-03_10-30-58.png) -We use recursion with range validation. For each node, we check if its value is within the valid range (min_val, max_val). The range is updated as we traverse: left children must be less than the parent, right children must be greater than the parent. +We use a queue (deque) to store request times. When a new request arrives, we remove all requests outside the 3000ms window, then add the new request and return the queue size. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** For each node, check if all nodes in its left subtree are less and all nodes in its right subtree are greater. This would be $O(n^2)$ time. -- **Optimized Strategy (Range Validation):** Use recursion with min and max bounds. Each node must be within its allowed range. This takes $O(n)$ time. -- **Why it's better:** The range validation approach reduces time complexity from $O(n^2)$ to $O(n)$ by passing down constraints instead of checking all descendants for each node. +- **Brute Force:** Store all requests in a list and filter out old ones each time. This could be inefficient if we check all requests. +- **Optimized Strategy (Queue):** Use a deque to store requests. Since times are strictly increasing, we only need to remove from the front. This is efficient. +- **Why it's better:** The queue approach allows us to efficiently remove old requests from the front while adding new ones at the back. Since times are increasing, we never need to check the middle of the queue. **1.4 Decomposition:** -1. Define a recursive function that takes a node and its allowed range (min_val, max_val). -2. If the node is null, return true (base case). -3. Check if the node's value is within the range (strictly greater than min_val and strictly less than max_val). -4. Recursively validate left subtree with range (min_val, node.val). -5. Recursively validate right subtree with range (node.val, max_val). -6. Return true only if all checks pass. +1. Initialize an empty deque in the constructor. +2. In `ping(t)`: + - Add the current time $t$ to the queue. + - Remove all requests from the front that are older than $t - 3000$. + - Return the size of the queue (number of requests in the window). ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[5,1,4,null,null,3,6]$ - -The tree structure: -``` - 5 - / \ - 1 4 - / \ - 3 6 -``` +Let's use the example: `ping(1)`, `ping(100)`, `ping(3001)`, `ping(3002)` We initialize: -- Call `validate(root, -∞, +∞)` +- `queue = deque()` -**2.2 Start Validation:** +**2.2 Start Processing:** -We begin validating from the root. +We process each ping call. **2.3 Trace Walkthrough:** -| Node | min_val | max_val | node.val | Check | Result | -|------|---------|---------|----------|-------|--------| -| 5 | -∞ | +∞ | 5 | $-∞ < 5 < +∞$ | ✓ | -| 1 | -∞ | 5 | 1 | $-∞ < 1 < 5$ | ✓ | -| 4 | 5 | +∞ | 4 | $5 < 4 < +∞$ | ✗ | +| Call | Time | Queue Before | Remove Old | Queue After | Return | +|------|------|--------------|------------|-------------|--------| +| `ping(1)` | 1 | [] | None | [1] | 1 | +| `ping(100)` | 100 | [1] | None ($1 \geq 100-3000$) | [1, 100] | 2 | +| `ping(3001)` | 3001 | [1, 100] | Remove 1 ($1 < 3001-3000$) | [100, 3001] | 2 | +| `ping(3002)` | 3002 | [100, 3001] | Remove 100 ($100 < 3002-3000$) | [3001, 3002] | 2 | **2.4 Explanation:** -- Root (5): Valid, within range (-∞, +∞) -- Left child (1): Valid, within range (-∞, 5) -- Right child (4): Invalid! It should be greater than 5, but 4 < 5 +- `ping(1)`: Window $[1-3000, 1] = [-2999, 1]$, contains [1] → return 1 +- `ping(100)`: Window $[100-3000, 100] = [-2900, 100]$, contains [1, 100] → return 2 +- `ping(3001)`: Window $[3001-3000, 3001] = [1, 3001]$, contains [100, 3001] (1 is removed) → return 2 +- `ping(3002)`: Window $[3002-3000, 3002] = [2, 3002]$, contains [3001, 3002] (100 is removed) → return 2 **2.5 Return Result:** -We return `False` because node 4 violates the BST property (it's in the right subtree of 5 but is less than 5). +Each `ping` call returns the number of requests in the current 3000ms window. -> **Note:** The key insight is to pass down the allowed range for each node. A node's value must be strictly within its range, and we update the range for children: left children get (min_val, node.val) and right children get (node.val, max_val). +> **Note:** Since times are strictly increasing, we only need to check and remove from the front of the queue. All requests in the queue are already in order, so we never need to check the middle or back. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self): + self.queue = deque() -class Solution: - def isValidBST(self, root) -> bool: - def validate(node, min_val, max_val): - # Empty tree is valid - if not node: - return True - - # Check if current node value is within valid range - if node.val <= min_val or node.val >= max_val: - return False - - # Recursively validate left and right subtrees - return (validate(node.left, min_val, node.val) and - validate(node.right, node.val, max_val)) + def ping(self, t: int) -> int: + # Add current request time + self.queue.append(t) + + # Remove requests outside the 3000ms window + while self.queue[0] < t - 3000: + self.queue.popleft() - return validate(root, float('-inf'), float('inf')) + # Return number of requests in the window + return len(self.queue) ``` -## 701. Insert into a Binary Search Tree [Medium] -https://leetcode.com/problems/insert-into-a-binary-search-tree/ +## 1207. Unique Number of Occurrences [Easy] +https://leetcode.com/problems/unique-number-of-occurrences/ ### Explanation -## Explanation +## 1207. Unique Number of Occurrences [Easy] -### Strategy (The "Why") +https://leetcode.com/problems/unique-number-of-occurrences -Given the root node of a binary search tree (BST) and a value to insert, we need to insert the value into the BST and return the root node of the BST after insertion. +## Description +Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise. -**1.1 Constraints & Complexity:** +**Examples** +Input: arr = [1,2,2,1,1,3] +Output: true +Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. -- **Input Size:** The number of nodes $N$ in the BST can be up to $10^4$. -- **Value Range:** Values are between $-10^8$ and $10^8$. -- **Time Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Space Complexity:** $O(h)$ - The recursion stack can be as deep as the height of the tree. In the worst case, this is $O(n)$, and in the average case, this is $O(\log n)$. -- **Edge Case:** If the tree is empty (root is null), we create a new node with the given value and return it. +Input: arr = [1,2] +Output: false -**1.2 High-level approach:** +Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] +Output: true -The goal is to insert a new value into a BST while maintaining the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. +**Constraints** +- 1 <= arr.length <= 1000 +- -1000 <= arr[i] <= 1000 -![BST Insertion](https://assets.leetcode.com/uploads/2020/10/05/insertbst.jpg) +## Hint +Use a dictionary to count occurrences, then check if the counts are unique using a set. -We use the BST property to navigate to the correct insertion point: if the value is less than the current node, go left; if greater, go right. When we reach a null position, that's where we insert the new node. +## Explanation +We want to know if every number in the array appears a unique number of times. First, we count how many times each number appears using a dictionary. Then, we check if all those counts are different by putting them in a set. -**1.3 Brute force vs. optimized strategy:** +We do this because using a dictionary makes counting fast and easy, and a set lets us quickly check for duplicates among the counts. This approach is efficient and avoids unnecessary loops. -- **Brute Force:** There isn't really a brute force approach for BST insertion. We must use the BST property to find the correct position. -- **Optimized Strategy (Recursive):** Recursively traverse the tree using the BST property. When we find a null position, create and return a new node. This naturally maintains the BST structure. -- **Why it's better:** The recursive approach is clean and intuitive. It leverages the BST property efficiently, ensuring we only traverse one path from root to leaf. +### Solution -**1.4 Decomposition:** +```python +def uniqueOccurrences(arr): + from collections import Counter -1. Check if the current node is null. If so, create a new node with the value and return it. -2. Compare the value to insert with the current node's value. -3. If the value is less than the current node's value, recursively insert into the left subtree. -4. If the value is greater than or equal to the current node's value, recursively insert into the right subtree. -5. Return the current node (which may have been modified with a new child). + count = Counter(arr) + return len(set(count.values())) == len(count) +``` -### Steps (The "How") +## 1431. Kids With the Greatest Number of Candies [Easy] +https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/ -**2.1 Initialization & Example Setup:** +### Explanation -Let's use the example: root = $[4,2,7,1,3]$, $val = 5$ +## 1431. Kids With the Greatest Number of Candies [Easy] -The BST structure: -``` - 4 - / \ - 2 7 - / \ - 1 3 -``` +https://leetcode.com/problems/kids-with-the-greatest-number-of-candies -We need to insert value 5. +## Description +There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `i`th kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. -**2.2 Start Traversing:** +Return a boolean array `result` of length `n`, where `result[i]` is `true` if, after giving the `i`th kid all the `extraCandies`, they will have the greatest number of candies among all the kids, or false otherwise. -We begin at the root node (value 4). +Note that multiple kids can have the greatest number of candies. -**2.3 Trace Walkthrough:** +**Examples** + +```text +Input: candies = [2,3,5,1,3], extraCandies = 3 +Output: [true,true,true,false,true] +Explanation: If you give all extraCandies to: +- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids. +- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids. +- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids. +- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids. +- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids. -| Step | Current Node | Value to Insert | Comparison | Action | -|------|--------------|-----------------|------------|--------| -| 1 | 4 | 5 | $5 > 4$ | Go to right child (7) | -| 2 | 7 | 5 | $5 < 7$ | Go to left child (null) | -| 3 | null | 5 | - | Create new node with value 5 | +Input: candies = [4,2,1,1,2], extraCandies = 1 +Output: [true,false,false,false,false] -After insertion: +Input: candies = [12,1,12], extraCandies = 10 +Output: [true,false,true] ``` - 4 - / \ - 2 7 - / \ / - 1 3 5 + +**Constraints** + +```text +- n == candies.length +- 2 <= n <= 100 +- 1 <= candies[i] <= 100 +- 1 <= extraCandies <= 50 ``` -**2.4 Return Result:** +## Hint +For each kid, check if their candies plus `extraCandies` is at least as much as the current maximum. + +## Explanation +First, you want to know the highest number of candies any kid currently has. This is important because you need a reference point to see if giving extra candies to a kid will make them "the greatest." -The new node is created and linked as the left child of node 7. The root node (4) is returned. +For each kid, you add the `extraCandies` to their current amount. You do this because you want to see if, after the bonus, they can reach or beat the current maximum. If they do, you mark them as `True` in our answer list; otherwise, False. -> **Note:** The BST property ensures that we always know which direction to go. We never need to backtrack or check multiple paths. +You only need to find the maximum once, and then just compare each kid's total to it. Don't need to recalculate the maximum for every kid. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def kidsWithCandies(candies, extraCandies): + max_candies = max(candies) # Find the current maximum + return [(c + extraCandies) >= max_candies for c in candies] +``` -class Solution: - def insertIntoBST(self, root, val: int): - # If tree is empty, create new node - if not root: - return TreeNode(val) - - # If val is less than root, insert into left subtree - if val < root.val: - root.left = self.insertIntoBST(root.left, val) - # If val is greater than root, insert into right subtree - else: - root.right = self.insertIntoBST(root.right, val) - - return root +## 2215. Find the Difference of Two Arrays [Easy] +https://leetcode.com/problems/find-the-difference-of-two-arrays/ + +### Explanation + +## 2215. Find the Difference of Two Arrays [Easy] + +https://leetcode.com/problems/find-the-difference-of-two-arrays + +## Description +Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: +- answer[0] is a list of all distinct integers in nums1 which are not present in nums2. +- answer[1] is a list of all distinct integers in nums2 which are not present in nums1. + +**Examples** +Input: nums1 = [1,2,3], nums2 = [2,4,6] +Output: [[1,3],[4,6]] + +Input: nums1 = [1,2,3,3], nums2 = [1,1,2,2] +Output: [[3],[]] + +**Constraints** +- 1 <= nums1.length, nums2.length <= 1000 +- -1000 <= nums1[i], nums2[i] <= 1000 + +## Hint +Use sets to efficiently find unique elements in each array. + +## Explanation +Let's imagine you have two boxes of colored marbles (numbers). You want to find out which colors are only in the first box and which are only in the second. We use sets to quickly check for unique marbles in each box. + +We do this because sets make it easy and fast to find differences—checking if something is in a set is much quicker than searching through a list. By converting the lists to sets, we can use set operations to get the answer efficiently. + +### Solution + +```python +def findDifference(nums1, nums2): + set1, set2 = set(nums1), set(nums2) + return [list(set1 - set2), list(set2 - set1)] ``` -## 235. Lowest Common Ancestor of a Binary Search Tree [Medium] -https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ +## 199. Binary Tree Right Side View [Medium] +https://leetcode.com/problems/binary-tree-right-side-view/ ### Explanation @@ -761,77 +629,83 @@ https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ ### Strategy (The "Why") -Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. The LCA is the lowest node that has both nodes as descendants. +Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ in the BST can be between $2$ and $10^5$. -- **Value Range:** All node values are unique and between $-10^9$ and $10^9$. -- **Time Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Space Complexity:** $O(h)$ - The recursion stack can be as deep as the height of the tree. In the worst case, this is $O(n)$, and in the average case, this is $O(\log n)$. -- **Edge Case:** Both nodes are guaranteed to exist in the BST. The LCA could be one of the nodes itself (if one is an ancestor of the other). +- **Input Size:** The number of nodes $N$ can be up to $100$. +- **Value Range:** Node values are between $0$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. +- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. **1.2 High-level approach:** -The goal is to find the lowest common ancestor of two nodes in a BST. +The goal is to find the rightmost node at each level of the tree. -![BST LCA](https://assets.leetcode.com/uploads/2018/12/14/binarysearchtree_improved.png) +![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) -We leverage the BST property: if both nodes are less than the current root, the LCA is in the left subtree. If both are greater, the LCA is in the right subtree. Otherwise, the current root is the LCA. +We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Find paths from root to both nodes, then find the last common node in both paths. This requires storing paths and comparing them. -- **Optimized Strategy (BST Property):** Use the BST property to navigate directly. If both nodes are on the same side of the root, recurse on that side. Otherwise, the root is the LCA. -- **Why it's better:** The BST property allows us to eliminate half of the tree at each step, making this much more efficient than a general binary tree LCA algorithm. +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. +- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. +- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. **1.4 Decomposition:** -1. Compare the values of both nodes with the current root. -2. If both nodes are less than the root, the LCA is in the left subtree - recurse left. -3. If both nodes are greater than the root, the LCA is in the right subtree - recurse right. -4. Otherwise (one is less and one is greater, or one equals the root), the current root is the LCA. +1. If the tree is empty, return an empty list. +2. Initialize a queue with the root node. +3. While the queue is not empty: + - Get the number of nodes at the current level. + - Process all nodes at this level. + - For the last node at each level (rightmost), add its value to the result. + - Add all children to the queue for the next level. +4. Return the result. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[6,2,8,0,4,7,9,null,null,3,5]$, $p = 2$, $q = 8$ +Let's use the example: root = $[1,2,3,null,5,null,4]$ -The BST structure: +The tree structure: ``` - 6 - / \ - 2 8 - / \ / \ - 0 4 7 9 - / \ - 3 5 + 1 + / \ + 2 3 + \ \ + 5 4 ``` -**2.2 Start Checking:** +We initialize: +- `queue = deque([1])` +- `res = []` + +**2.2 Start BFS:** -We begin at the root node (value 6). +We begin processing level by level. **2.3 Trace Walkthrough:** -| Step | Current Root | p | q | Comparison | Action | -|------|--------------|---|---|------------|--------| -| 1 | 6 | 2 | 8 | $2 < 6$ and $8 > 6$ | Root (6) is LCA | - -Since $p = 2 < 6$ and $q = 8 > 6$, they are on opposite sides of the root. Therefore, the root (6) is the LCA. +| Level | Queue Before | Level Size | Process | Rightmost Node | res | +|-------|--------------|------------|---------|----------------|-----| +| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | +| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | +| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | -**2.4 Another Example:** +**2.4 Explanation:** -If $p = 2$ and $q = 4$: -- Step 1: Root = 6, both $2 < 6$ and $4 < 6$, so recurse left -- Step 2: Root = 2, $2 == 2$ and $4 > 2$, so root (2) is LCA +- Level 0: Only node 1 → add 1 +- Level 1: Nodes 2 and 3 → add 3 (rightmost) +- Level 2: Nodes 5 and 4 → add 4 (rightmost) **2.5 Return Result:** -We return the root node (6), which is the LCA. +We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. -> **Note:** The BST property makes this problem much simpler than finding LCA in a general binary tree. We don't need to search both subtrees - we can always determine which direction to go. +> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. ### Solution @@ -841,18 +715,33 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right +from typing import List +from collections import deque + class Solution: - def lowestCommonAncestor(self, root, p, q): - # If both p and q are less than root, LCA is in left subtree - if p.val < root.val and q.val < root.val: - return self.lowestCommonAncestor(root.left, p, q) + def rightSideView(self, root) -> List[int]: + if not root: + return [] - # If both p and q are greater than root, LCA is in right subtree - if p.val > root.val and q.val > root.val: - return self.lowestCommonAncestor(root.right, p, q) + res = [] + queue = deque([root]) - # Otherwise, root is the LCA - return root + while queue: + level_size = len(queue) + + for i in range(level_size): + node = queue.popleft() + + # Add the rightmost node of each level + if i == level_size - 1: + res.append(node.val) + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + return res ``` ## 208. Implement Trie (Prefix Tree) [Medium] @@ -1003,70 +892,100 @@ class Trie: return True ``` -## 1431. Kids With the Greatest Number of Candies [Easy] -https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/ +## 236. Lowest Common Ancestor of a Binary Tree [Medium] +https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ ### Explanation -## 1431. Kids With the Greatest Number of Candies [Easy] +## Explanation -https://leetcode.com/problems/kids-with-the-greatest-number-of-candies +### Strategy (The "Why") -## Description -There are `n` kids with candies. You are given an integer array `candies`, where each `candies[i]` represents the number of candies the `i`th kid has, and an integer `extraCandies`, denoting the number of extra candies that you have. +The problem asks us to find the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA is the deepest node that has both nodes as descendants (a node can be a descendant of itself). -Return a boolean array `result` of length `n`, where `result[i]` is `true` if, after giving the `i`th kid all the `extraCandies`, they will have the greatest number of candies among all the kids, or false otherwise. +**1.1 Constraints & Complexity:** -Note that multiple kids can have the greatest number of candies. +- **Input Constraints:** The tree has $2 \leq n \leq 10^5$ nodes with unique values in $[-10^9, 10^9]$. +- **Time Complexity:** $O(n)$ - We may need to visit all nodes in the worst case. +- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +- **Edge Case:** If one node is an ancestor of the other, return that ancestor node. -**Examples** +**1.2 High-level approach:** -```text -Input: candies = [2,3,5,1,3], extraCandies = 3 -Output: [true,true,true,false,true] -Explanation: If you give all extraCandies to: -- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids. -- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids. -- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids. -- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids. -- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids. +The goal is to find the deepest node that is an ancestor of both target nodes. We use recursive DFS: if we find both nodes in a subtree, the current root is the LCA. -Input: candies = [4,2,1,1,2], extraCandies = 1 -Output: [true,false,false,false,false] +![Binary Tree LCA](https://assets.leetcode.com/uploads/2018/12/14/binarytree.png) -Input: candies = [12,1,12], extraCandies = 10 -Output: [true,false,true] -``` +**1.3 Brute force vs. optimized strategy:** -**Constraints** +- **Brute Force:** Find paths to both nodes, then find the last common node in both paths. This requires storing paths and takes $O(n)$ time and $O(n)$ space. +- **Optimized (Recursive DFS):** Recursively search both subtrees. If both subtrees return non-null, the current root is the LCA. This takes $O(n)$ time and $O(h)$ space. +- **Emphasize the optimization:** The recursive approach finds the LCA in a single pass without storing paths, making it more space-efficient. -```text -- n == candies.length -- 2 <= n <= 100 -- 1 <= candies[i] <= 100 -- 1 <= extraCandies <= 50 -``` +**1.4 Decomposition:** -## Hint -For each kid, check if their candies plus `extraCandies` is at least as much as the current maximum. +1. **Base Case:** If root is `None` or equals `p` or `q`, return root. +2. **Recursive Search:** Recursively search left and right subtrees for `p` and `q`. +3. **Combine Results:** If both subtrees return non-null, root is the LCA. Otherwise, return whichever subtree found a node. -## Explanation -First, you want to know the highest number of candies any kid currently has. This is important because you need a reference point to see if giving extra candies to a kid will make them "the greatest." +### Steps (The "How") -For each kid, you add the `extraCandies` to their current amount. You do this because you want to see if, after the bonus, they can reach or beat the current maximum. If they do, you mark them as `True` in our answer list; otherwise, False. +**2.1 Initialization & Example Setup:** -You only need to find the maximum once, and then just compare each kid's total to it. Don't need to recalculate the maximum for every kid. +Let's trace through an example: `root = [3,5,1,6,2,0,8,null,null,7,4]`, `p = 5`, `q = 1`. + +**2.2 Start Searching:** + +Begin at root node `3`. + +**2.3 Trace Walkthrough:** + +| Node | Left Result | Right Result | Action | +|------|-------------|--------------|---------| +| 3 | Search left (5) | Search right (1) | Both found → Return 3 | +| 5 | Search left (6) | Search right (2) | Found p → Return 5 | +| 1 | Search left (0) | Search right (8) | Found q → Return 1 | + +**2.4 Recursive Unwinding:** + +- Node `5` returns itself (found `p`). +- Node `1` returns itself (found `q`). +- Node `3` receives both results, so it's the LCA. + +**2.5 Return Result:** + +The function returns node `3`, which is the LCA of nodes `5` and `1`. + +> **Note:** The key insight is that if both left and right subtrees return non-null, the current root must be the LCA. If only one subtree returns non-null, that subtree contains the LCA. ### Solution ```python -def kidsWithCandies(candies, extraCandies): - max_candies = max(candies) # Find the current maximum - return [(c + extraCandies) >= max_candies for c in candies] +def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None + +class Solution: + def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': + # Base case: if root is None or root is p or q, return root + if not root or root == p or root == q: + return root + + # Recursively search in left and right subtrees + left = self.lowestCommonAncestor(root.left, p, q) + right = self.lowestCommonAncestor(root.right, p, q) + + # If both left and right return non-None, root is the LCA + if left and right: + return root + + # Otherwise, return whichever side found p or q + return left if left else right ``` -## 104. Maximum Depth of Binary Tree [Easy] -https://leetcode.com/problems/maximum-depth-of-binary-tree/ +## 328. Odd Even Linked List [Medium] +https://leetcode.com/problems/odd-even-linked-list/ ### Explanation @@ -1074,103 +993,259 @@ https://leetcode.com/problems/maximum-depth-of-binary-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. -- **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** If the tree is empty (root is null), return 0. +* **Input Size:** The linked list can have up to 10^4 nodes. +* **Time Complexity:** O(n) - We traverse the list once, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 0 or 1 node, return it as-is since there's nothing to reorder. **1.2 High-level approach:** -The goal is to find the maximum depth of a binary tree. - -![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) +The goal is to group all nodes at odd positions together, followed by all nodes at even positions, while maintaining their relative order within each group. -We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. +![Linked list showing odd nodes (1,3,5) followed by even nodes (2,4)] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. -- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. -- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. +* **Brute Force:** Create two separate lists for odd and even nodes, then concatenate them. This requires O(n) extra space. +* **Optimized (In-place):** Use two pointers to separate odd and even nodes in-place by rewiring the next pointers. This uses O(1) extra space. +* **Why it's better:** The in-place approach meets the O(1) space requirement and is more memory efficient. **1.4 Decomposition:** -1. Base case: if the root is null, return 0. -2. Recursively find the maximum depth of the left subtree. -3. Recursively find the maximum depth of the right subtree. -4. Return 1 (for current node) plus the maximum of the two subtree depths. +1. Use two pointers: `odd` for odd-positioned nodes and `even` for even-positioned nodes. +2. Keep track of the head of the even list. +3. Rewire connections: odd.next = even.next, even.next = odd.next.next. +4. Move both pointers forward. +5. Connect the end of the odd list to the head of the even list. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3,9,20,null,null,15,7]$ +Let's use the example: head = [1,2,3,4,5] -The tree structure: -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` +We initialize: +* `odd = head` (points to node 1) +* `even = head.next` (points to node 2) +* `even_head = even` (save the head of even list) -**2.2 Start Recursion:** +**2.2 Start Checking/Processing:** -We begin from the root node (value 3). +We enter a loop while `even` and `even.next` exist. **2.3 Trace Walkthrough:** -| Node | Left Depth | Right Depth | Max Depth | Return Value | -|------|------------|--------------|-----------|--------------| -| 3 | ? | ? | - | Compute... | -| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | ? | ? | - | Compute... | -| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | -| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | +| Step | odd.val | even.val | odd.next.val | even.next.val | Action | +|------|---------|----------|--------------|---------------|--------| +| Initial | 1 | 2 | 3 | 3 | Setup | +| 1 | 1 | 2 | 3 | 4 | odd.next = 3, even.next = 4 | +| 2 | 3 | 4 | 5 | 5 | odd.next = 5, even.next = None | +| Final | 5 | 4 | 2 | - | Connect odd.next = even_head | -**2.4 Recursion Flow:** +**2.4 Increment and Loop:** -- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ -- Node 9: both children null, return $0 + 1 = 1$ -- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ +After each iteration, we move `odd = odd.next` and `even = even.next` to process the next pair. **2.5 Return Result:** -We return 3, which is the maximum depth of the tree. - -> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. +The final list is [1,3,5,2,4], which is returned. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]: + if not head or not head.next: + return head + + odd = head + even = head.next + even_head = even + + while even and even.next: + odd.next = even.next + odd = odd.next + even.next = odd.next + even = even.next + + odd.next = even_head + return head +``` + +## 437. Path Sum III [Medium] +https://leetcode.com/problems/path-sum-iii/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +* **Input Size:** The tree can have up to 1000 nodes. +* **Time Complexity:** O(n) - We visit each node once during DFS, where n is the number of nodes. +* **Space Complexity:** O(h) for recursion stack where h is the height, plus O(n) in worst case for the prefix sum map. +* **Edge Case:** If the tree is empty, return 0. If targetSum is 0 and there are nodes with value 0, we need to count paths correctly. + +**1.2 High-level approach:** + +The goal is to count all paths in a binary tree where the sum of node values equals targetSum. A path can start and end anywhere, but must go downward. We use prefix sums to efficiently count paths ending at each node. + +![Tree showing paths with prefix sum tracking] + +**1.3 Brute force vs. optimized strategy:** + +* **Brute Force:** For each node, explore all downward paths starting from it. This is O(n^2) in the worst case. +* **Optimized (Prefix Sum with Hash Map):** Use a hash map to store prefix sums along the current path. For each node, check if (current_sum - targetSum) exists in the map. This is O(n) time. +* **Why it's better:** The prefix sum approach avoids redundant calculations and reduces time complexity from O(n^2) to O(n). + +**1.4 Decomposition:** + +1. Use DFS to traverse the tree. +2. Maintain a prefix sum map that tracks sums along the current path. +3. At each node, add the node's value to current sum. +4. Check if (current_sum - targetSum) exists in the map to count paths ending here. +5. Recursively process left and right children. +6. Backtrack by decrementing the prefix sum count before returning. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = [10,5,-3,3,2,null,11,3,-2,null,1], targetSum = 8 + +We initialize: +* `res = 0` (count of paths) +* `prefix_sums = {}` (map of prefix sum -> count) +* `current_sum = 0` + +**2.2 Start Checking/Processing:** + +We call `dfs(root, 0)` to start traversal. + +**2.3 Trace Walkthrough:** + +| Node | current_sum | prefix_sums | current_sum - 8 | Paths Found | +|------|-------------|-------------|-----------------|-------------| +| 10 | 10 | {10:1} | 2 | 0 | +| 5 | 15 | {10:1, 15:1} | 7 | 0 | +| 3 | 18 | {10:1, 15:1, 18:1} | 10 | 1 (18-8=10 exists) | +| -2 | 16 | {10:1, 15:1, 18:1, 16:1} | 8 | 1 (16-8=8, but 8 not in map, but current_sum=16, check if 16==8: no) | +| 2 | 17 | {10:1, 15:1, 18:1, 16:1, 17:1} | 9 | 0 | +| 1 | 18 | {10:1, 15:1, 18:2, 16:1, 17:1} | 10 | 1 (18-8=10 exists) | + +**2.4 Increment and Loop:** + +After processing each node and its children, we backtrack by decrementing the prefix sum count. + +**2.5 Return Result:** + +After processing all nodes, `res = 3` is returned (paths: 5->3, 5->2->1, -3->11). + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right - class Solution: - def maxDepth(self, root) -> int: - if not root: - return 0 + def pathSum(self, root: Optional[TreeNode], targetSum: int) -> int: + res = 0 + prefix_sums = {} - # Recursively find max depth of left and right subtrees - left_depth = self.maxDepth(root.left) - right_depth = self.maxDepth(root.right) + def dfs(node, current_sum): + nonlocal res, prefix_sums + if not node: + return + + current_sum += node.val + if current_sum == targetSum: + res += 1 + + res += prefix_sums.get(current_sum - targetSum, 0) + prefix_sums[current_sum] = prefix_sums.get(current_sum, 0) + 1 + + dfs(node.left, current_sum) + dfs(node.right, current_sum) + + prefix_sums[current_sum] -= 1 - # Return max depth plus 1 for current node - return max(left_depth, right_depth) + 1 + dfs(root, 0) + return res +``` + +## 443. String Compression [Medium] +https://leetcode.com/problems/string-compression/ + +### Explanation + +## 443. String Compression [Medium] + +https://leetcode.com/problems/string-compression + +## Description +Given an array of characters chars, compress it using the following algorithm: +Begin with an empty string s. For each group of consecutive repeating characters in chars: +- If the group's length is 1, append the character to s. +- Otherwise, append the character followed by the group's length. +The compressed string s should not be returned separately, but instead, be stored in the input character array chars. Note that group lengths that are 10 or longer will be split into multiple characters in chars. +After you are done modifying the input array, return the new length of the array. +You must write an algorithm that uses only constant extra space. + +**Examples** +Input: chars = ["a","a","b","b","c","c","c"] +Output: Return 6, and the first 6 characters of the input array should be: ["a","2","b","2","c","3"] +Explanation: The groups are "aa", "bb", and "ccc". This compresses to "a2b2c3". + +Input: chars = ["a","b","b","b","b","b","b","b","b","b","b","b","b"] +Output: Return 4, and the first 4 characters of the input array should be: ["a","b","1","2"]. +Explanation: The groups are "a" and "bbbbbbbbbbbb". This compresses to "ab12". + +**Constraints** +- 1 <= chars.length <= 2000 +- chars[i] is a lowercase English letter, uppercase English letter, digit, or symbol. + +## Hint +Use two pointers: one for reading, one for writing. + +## Explanation +We want to compress the string by replacing sequences of the same character with that character followed by the count. We use two pointers: one to read through the array, and one to write the compressed result. + +We do this because it lets us modify the array in-place, which saves memory and meets the problem's requirements. By counting consecutive characters and writing the count only when needed, we keep the result as short as possible. + +This approach is efficient and avoids creating extra arrays, making it suitable for large inputs. + +### Solution + +```python +def compress(chars): + write = 0 + read = 0 + n = len(chars) + while read < n: + char = chars[read] + count = 0 + while read < n and chars[read] == char: + read += 1 + count += 1 + chars[write] = char + write += 1 + if count > 1: + for c in str(count): + chars[write] = c + write += 1 + return write ``` -## 116. Populating Next Right Pointers in Each Node [Medium] -https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ +## 450. Delete Node in a BST [Medium] +https://leetcode.com/problems/delete-node-in-a-bst/ ### Explanation @@ -1178,228 +1253,299 @@ https://leetcode.com/problems/populating-next-right-pointers-in-each-node/ ### Strategy (The "Why") -Given a perfect binary tree, we need to populate each node's `next` pointer to point to its next right node. If there is no next right node, the `next` pointer should be set to `NULL`. +Given the root of a binary search tree and a key, we need to delete the node with the given key and return the root of the BST. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $2^{12} - 1$ (perfect binary tree). -- **Value Range:** Node values are between $-1000$ and $1000$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space, not counting the recursion stack. The `next` pointers are part of the output. -- **Edge Case:** If the tree is empty, return null. For a perfect binary tree, all levels are completely filled. +- **Input Size:** The number of nodes can be up to $10^4$. +- **Value Range:** Node values are between $-10^5$ and $10^5$. +- **Time Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Space Complexity:** $O(h)$ - The recursion stack can be as deep as the height of the tree. +- **Edge Case:** If the key doesn't exist, return the original tree. If the node to delete has no children, simply remove it. **1.2 High-level approach:** -The goal is to connect nodes at the same level using the `next` pointer. - -![Next Right Pointers](https://assets.leetcode.com/uploads/2019/02/15/117_sample.png) +The goal is to delete a node from a BST while maintaining the BST property. -We use level-order traversal, but instead of using a queue, we leverage the `next` pointers we've already set. We process level by level, connecting children as we go. +We use recursion to find the node. If found, we handle three cases: no children, one child, or two children. For two children, we replace the node's value with the minimum value from its right subtree, then delete that minimum node. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Use BFS with a queue to process each level, then connect nodes at the same level. This takes $O(n)$ time and $O(n)$ space for the queue. -- **Optimized Strategy (Level-by-level):** Process level by level using the `next` pointers. For each node, connect its left child to right child, and right child to next node's left child. This takes $O(n)$ time and $O(1)$ extra space. -- **Why it's better:** The optimized approach uses $O(1)$ extra space instead of $O(n)$ for a queue, by leveraging the tree structure and `next` pointers we're building. +- **Brute Force:** There isn't really a brute force approach - we must maintain the BST structure. +- **Optimized Strategy (Recursion):** Use recursion to find and delete the node, handling each case appropriately. This is the standard and efficient approach. +- **Why it's better:** The recursive approach naturally handles the tree structure and maintains BST properties efficiently. **1.4 Decomposition:** -1. Start from the root level (which has no `next` pointers to set). -2. For each level, iterate through nodes using the `next` pointers. -3. For each node, connect its left child to its right child. -4. If the node has a `next` pointer, connect its right child to the `next` node's left child. -5. Move to the next level by following the leftmost node's left child. +1. If root is null, return null. +2. If key is less than root.val, recursively delete from left subtree. +3. If key is greater than root.val, recursively delete from right subtree. +4. If key equals root.val: + - If no left child, return right child. + - If no right child, return left child. + - If two children, find minimum in right subtree, replace root's value, and delete the minimum node. +5. Return the root. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,2,3,4,5,6,7]$ +Let's use the example: root = $[5,3,6,2,4,null,7]$, key = 3 The tree structure: ``` - 1 - / \ - 2 3 - / \ / \ - 4 5 6 7 + 5 + / \ + 3 6 + / \ \ +2 4 7 ``` -**2.2 Start Connecting:** +**2.2 Start Searching:** -We begin at the root level. +We search for the node with key = 3. **2.3 Trace Walkthrough:** -**Level 1 (root):** -- Node 1: No connections needed at root level +| Step | Current Node | Key Comparison | Action | +|------|--------------|----------------|--------| +| 1 | 5 | 3 < 5 | Go left | +| 2 | 3 | 3 == 3 | Found! Delete node 3 | -**Level 2:** -- Node 2: Connect 2.left (4) → 2.right (5) -- Node 2: Connect 2.right (5) → 2.next.left (6) [since 2.next = 3] -- Node 3: Connect 3.left (6) → 3.right (7) +**Deleting node 3:** +- Node 3 has two children (2 and 4) +- Find minimum in right subtree: min(4) = 4 +- Replace node 3's value with 4 +- Delete node 4 from right subtree (node 4 has no children, so simply remove it) -**2.4 Final Connections:** +**2.4 Final Tree:** -After processing: -- Level 1: 1 → NULL -- Level 2: 2 → 3 → NULL -- Level 3: 4 → 5 → 6 → 7 → NULL +After deletion: +``` + 5 + / \ + 4 6 + / \ +2 7 +``` **2.5 Return Result:** -We return the root with all `next` pointers properly set. +We return the root of the modified tree. -> **Note:** The key insight is that we can use the `next` pointers we've already set to traverse the current level, eliminating the need for a queue. This makes the space complexity $O(1)$. +> **Note:** The key insight is that when deleting a node with two children, we can replace it with the minimum node from its right subtree (or maximum from left subtree). This maintains the BST property because the minimum in the right subtree is greater than all left children and less than all other right children. ### Solution ```python -def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): +def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right -# self.next = next class Solution: - def connect(self, root: 'Node') -> 'Node': + def deleteNode(self, root, key: int): if not root: - return root - - # Start with the root node - leftmost = root + return None - # While we have a level to process - while leftmost.left: - # Current node in the current level - current = leftmost - - # Iterate through the current level - while current: - # Connect left child to right child - current.left.next = current.right - - # Connect right child to next node's left child (if exists) - if current.next: - current.right.next = current.next.left - - # Move to next node in the same level - current = current.next - - # Move to the next level - leftmost = leftmost.left + if key < root.val: + root.left = self.deleteNode(root.left, key) + elif key > root.val: + root.right = self.deleteNode(root.right, key) + else: + # Node to delete found + if not root.left: + return root.right + elif not root.right: + return root.left + else: + # Node has two children + # Find the minimum value in right subtree + min_node = self.findMin(root.right) + # Replace root's value with min value + root.val = min_node.val + # Delete the min node from right subtree + root.right = self.deleteNode(root.right, min_node.val) return root + + def findMin(self, node): + while node.left: + node = node.left + return node ``` -## 19. Remove Nth Node From End of List [Medium] -https://leetcode.com/problems/remove-nth-node-from-end-of-list/ +## 901. Online Stock Span [Medium] +https://leetcode.com/problems/online-stock-span/ ### Explanation +## 901. Online Stock Span [Medium] + +https://leetcode.com/problems/online-stock-span + +## Description +Design an algorithm that collects daily price quotes for some stock and returns the span of that stock's price for the current day. + +The span of the stock's price in one day is the maximum number of consecutive days (starting from that day and going backward) for which the stock price was less than or equal to the price of that day. + +Implement the StockSpanner class: +- StockSpanner() Initializes the object of the class. +- int next(int price) Returns the span of the stock's price given that today's price is price. + +## Examples + +Input: +["StockSpanner", "next", "next", "next", "next", "next", "next", "next"] +[[], [100], [80], [60], [70], [60], [75], [85]] + +Output: +[null, 1, 1, 1, 2, 1, 4, 6] + +Explanation: +StockSpanner stockSpanner = new StockSpanner(); +stockSpanner.next(100); // return 1 +stockSpanner.next(80); // return 1 +stockSpanner.next(60); // return 1 +stockSpanner.next(70); // return 2 +stockSpanner.next(60); // return 1 +stockSpanner.next(75); // return 4, because the last 4 prices (including today's price of 75) were less than or equal to today's price. +stockSpanner.next(85); // return 6 + +## Constraints +- 1 <= price <= 10^5 +- At most 10^4 calls will be made to next. + +## Hint +- We are interested in finding the span or reach back in time over consecutive elements that meet a certain criterion (in this case, previous stock prices that are less than or equal to the current day's price). +- A monotonic stack allows us to efficiently track and update spans as new prices come in, maintaining the necessary order of comparison and ensuring we can calculate each day's span in O(1) average time. + ## Explanation -### Strategy (The "Why") +This problem is a classic application of the monotonic stack technique. We want to efficiently find, for each new price, how many consecutive previous days (including today) had prices less than or equal to today's price. By maintaining a stack of pairs (price, span), we can pop off all previous prices that are less than or equal to the current price, summing their spans, and push the current price and its total span. This allows each price to be processed in amortized O(1) time, making the solution efficient for large input sizes. + +### Solution + +```python +def __init__(self): + self.stack = [] # Each element is a tuple (price, span) + + def next(self, price: int) -> int: + span = 1 + while self.stack and self.stack[-1][0] <= price: + _price, _span = self.stack.pop() + span += _span + self.stack.append([price, span]) + return span +``` + +## 1161. Maximum Level Sum of a Binary Tree [Medium] +https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/ + +### Explanation -Given the head of a linked list and an integer $n$, we need to remove the $n$-th node from the end of the list and return the head. +## Explanation + +### Strategy (The "Why") **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be between $1$ and $30$. -- **Value Range:** Node values are between $1$ and $100$. -- **Time Complexity:** $O(L)$ where $L$ is the length of the list. We make one pass through the list. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If we need to remove the head node ($n$ equals the list length), we need special handling. Using a dummy node simplifies this. +* **Input Size:** The tree can have up to 10^4 nodes. +* **Time Complexity:** O(n) - We visit each node once using BFS, where n is the number of nodes. +* **Space Complexity:** O(w) where w is the maximum width of the tree. In worst case O(n). +* **Edge Case:** If the tree is empty, return 0. If all level sums are equal, return the smallest level (1). **1.2 High-level approach:** -The goal is to remove the $n$-th node from the end of a linked list. +The goal is to find the level with the maximum sum of node values. We use BFS (level-order traversal) to process nodes level by level and track the sum for each level. -![Remove Nth Node](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg) - -We use two pointers: a fast pointer and a slow pointer. We move the fast pointer $n+1$ steps ahead, then move both pointers together. When fast reaches the end, slow will be at the node before the one to remove. +![BFS traversal showing level-by-level processing and sum calculation] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** First pass to count the length, second pass to find and remove the $(L-n+1)$-th node from the beginning. This takes two passes. -- **Optimized Strategy (Two Pointers):** Use two pointers with a gap of $n+1$ nodes. Move both together until the fast pointer reaches the end. This takes one pass. -- **Why it's better:** The two-pointer approach is more elegant and requires only one pass through the list, though both approaches have the same time complexity. +* **Brute Force:** Use DFS to collect all nodes by level, then calculate sums. This requires extra space to store level information. +* **Optimized (BFS):** Use BFS to process one level at a time, calculating the sum as we go. This is O(n) time and naturally processes levels in order. +* **Why it's better:** BFS naturally processes levels sequentially, making it straightforward to track level sums without extra data structures. **1.4 Decomposition:** -1. Create a dummy node pointing to the head (to handle edge cases). -2. Initialize two pointers (fast and slow) at the dummy node. -3. Move the fast pointer $n+1$ steps ahead. -4. Move both pointers together until fast reaches the end. -5. Remove the node after slow (which is the $n$-th node from the end). -6. Return the head (via dummy.next). +1. Use a queue for BFS traversal. +2. For each level: + - Process all nodes at the current level. + - Sum their values. + - Track the maximum sum and corresponding level. +3. Return the smallest level with maximum sum. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: head = $[1,2,3,4,5]$, $n = 2$ +Let's use the example: root = [1,7,0,7,-8,null,null] We initialize: -- `dummy = ListNode(0)`, `dummy.next = head` -- `fast = dummy`, `slow = dummy` +* `queue = deque([root])` +* `max_sum = -inf` +* `res = 1` +* `level = 1` -**2.2 Start Processing:** +**2.2 Start Checking/Processing:** -We move the fast pointer $n+1 = 3$ steps ahead. +We enter a while loop while the queue is not empty. **2.3 Trace Walkthrough:** -| Step | Fast Position | Slow Position | Action | -|------|---------------|---------------|--------| -| Initial | dummy | dummy | - | -| After moving fast 3 steps | node 4 | dummy | Fast is 3 steps ahead | -| Move both together | node 5 | node 1 | Continue... | -| Move both together | null | node 3 | Fast reached end | +| Level | Nodes | Level Sum | max_sum | res | +|-------|-------|-----------|---------|-----| +| 1 | [1] | 1 | 1 | 1 | +| 2 | [7, 0] | 7 | 7 | 2 | +| 3 | [7, -8] | -1 | 7 | 2 | -When fast is null, slow is at node 3 (the node before node 4, which is the 2nd from end). +**2.4 Increment and Loop:** -**2.4 Remove Node:** - -- `slow.next = slow.next.next` removes node 4 -- Result: $[1,2,3,5]$ +After processing each level, we increment the level counter and continue to the next level. **2.5 Return Result:** -We return `dummy.next` which points to the new head $[1,2,3,5]$. - -> **Note:** The dummy node is crucial because it handles the edge case where we need to remove the head node. Without it, we'd need special handling for that case. +After processing all levels, `res = 2` is returned (level 2 has maximum sum of 7). ### Solution ```python -def __init__(self, val=0, next=None): +def __init__(self, val=0, left=None, right=None): # self.val = val -# self.next = next - +# self.left = left +# self.right = right class Solution: - def removeNthFromEnd(self, head, n: int): - # Create a dummy node to handle edge cases - dummy = ListNode(0) - dummy.next = head - - # Two pointers: fast and slow - fast = dummy - slow = dummy - - # Move fast pointer n+1 steps ahead - for _ in range(n + 1): - fast = fast.next + def maxLevelSum(self, root: Optional[TreeNode]) -> int: + if not root: + return 0 - # Move both pointers until fast reaches the end - while fast: - fast = fast.next - slow = slow.next + from collections import deque + queue = deque([root]) + max_sum = float('-inf') + res = 1 + level = 1 - # Remove the nth node from end - slow.next = slow.next.next + while queue: + level_sum = 0 + size = len(queue) + + for _ in range(size): + node = queue.popleft() + level_sum += node.val + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + if level_sum > max_sum: + max_sum = level_sum + res = level + + level += 1 - return dummy.next + return res ``` ## 1372. Longest ZigZag Path in a Binary Tree [Medium] @@ -1517,160 +1663,162 @@ class Solution: return res ``` -## 1657. Determine if Two Strings Are Close [Medium] -https://leetcode.com/problems/determine-if-two-strings-are-close/ +## 1448. Count Good Nodes in Binary Tree [Medium] +https://leetcode.com/problems/count-good-nodes-in-binary-tree/ ### Explanation -## 1657. Determine if Two Strings Are Close [Medium] +## Explanation -https://leetcode.com/problems/determine-if-two-strings-are-close +### Strategy (The "Why") -## Description -Two strings are considered close if you can attain one from the other using the following operations: -- Operation 1: Swap any two existing characters (i.e., freely reorder the string). -- Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character (i.e., swap all a's with b's, and all b's with a's). -You can use the operations on either string as many times as necessary. +**1.1 Constraints & Complexity:** -Given two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise. +* **Input Size:** The tree can have up to 10^5 nodes. +* **Time Complexity:** O(n) - We visit each node once using DFS, where n is the number of nodes. +* **Space Complexity:** O(h) for the recursion stack where h is the height. In worst case O(n). +* **Edge Case:** The root is always a good node since there are no nodes above it. -**Examples** -Input: word1 = "abc", word2 = "bca" -Output: true -Explanation: You can attain word2 from word1 in 2 operations. -Apply Operation 1: "abc" -> "acb" -Apply Operation 1: "acb" -> "bca" +**1.2 High-level approach:** -Input: word1 = "a", word2 = "aa" -Output: false -Explanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations. +The goal is to count nodes where the path from root to that node has no node with value greater than the current node. We use DFS to traverse the tree, tracking the maximum value seen so far. -Input: word1 = "cabbba", word2 = "abbccc" -Output: true -Explanation: You can attain word2 from word1 in 3 operations. -Apply Operation 1: "cabbba" -> "caabbb" -Apply Operation 2: "caabbb" -> "baaccc" -Apply Operation 2: "baaccc" -> "abbccc" +![Tree traversal showing how we track maximum values along paths] -**Constraints** -- 1 <= word1.length, word2.length <= 10^5 -- word1 and word2 contain only lowercase English letters. - -## Hint -Operation 1 allows you to freely reorder the string. Operation 2 allows you to freely reassign the letters' frequencies. - -## Explanation -To determine if two strings are close, you need to check two things: -1. Both strings must have the same set of unique characters. If one string has a character the other doesn't, you can't transform one into the other. -2. The frequency of each character (regardless of which character) must be the same in both strings. This is because you can swap the frequencies between characters using Operation 2, but you can't create or destroy frequencies. - -This means you can sort the frequency counts of each string and compare them. If both the set of unique characters and the sorted frequency counts match, the strings are close. +**1.3 Brute force vs. optimized strategy:** -### Solution +* **Brute Force:** For each node, check all nodes on the path from root to it. This is O(n^2) in worst case. +* **Optimized (DFS with Max Tracking):** During DFS, pass the maximum value seen so far. If current node's value >= max, it's good. This is O(n) time. +* **Why it's better:** We check the condition during traversal without storing paths, making it O(n) instead of O(n^2). -```python -def closeStrings(word1, word2): - if set(word1) != set(word2): - return False - return sorted(Counter(word1).values()) == sorted(Counter(word2).values()) -``` +**1.4 Decomposition:** -## 933. Number of Recent Calls [Easy] -https://leetcode.com/problems/number-of-recent-calls/ +1. Use DFS to traverse the tree. +2. For each node, check if its value >= max_value_seen. +3. If yes, increment the count and update max_value_seen. +4. Recursively process left and right children with updated max_value. +5. Return the total count. -### Explanation +### Steps (The "How") -## Explanation +**2.1 Initialization & Example Setup:** -### Strategy (The "Why") +Let's use the example: root = [3,1,4,3,null,1,5] -We need to implement a `RecentCounter` class that counts the number of recent requests within the past 3000 milliseconds. Each call to `ping(t)` adds a new request at time $t$ and returns the number of requests in the range $[t-3000, t]$. +We initialize: +* `res = 0` +* Start DFS from root with `max_val = 3` (root value) -**1.1 Constraints & Complexity:** +**2.2 Start Checking/Processing:** -- **Input Size:** The number of calls to `ping` can be up to $10^4$. -- **Value Range:** Time values $t$ are strictly increasing and between $1$ and $10^9$. -- **Time Complexity:** $O(1)$ amortized - Each `ping` operation is $O(1)$ amortized because each request is added once and removed at most once. -- **Space Complexity:** $O(n)$ where $n$ is the number of requests in the current 3000ms window. In the worst case, if all requests are within 3000ms, this is $O(n)$. -- **Edge Case:** If `ping` is called with times that are more than 3000ms apart, old requests are removed from the queue. +We call `dfs(root, root.val)`. -**1.2 High-level approach:** +**2.3 Trace Walkthrough:** -The goal is to maintain a sliding window of requests within the past 3000ms. +| Node | Value | max_val | Value >= max? | Action | res | +|------|-------|---------|---------------|--------|-----| +| 3 | 3 | 3 | Yes | Count++, max=3 | 1 | +| 1 | 1 | 3 | No | Skip | 1 | +| 3 | 3 | 3 | Yes | Count++, max=3 | 2 | +| 4 | 4 | 3 | Yes | Count++, max=4 | 3 | +| 1 | 1 | 4 | No | Skip | 3 | +| 5 | 5 | 4 | Yes | Count++, max=5 | 4 | -![Recent Counter](https://assets.leetcode.com/uploads/2021/09/03/chrome_2021-09-03_10-30-58.png) +**2.4 Increment and Loop:** -We use a queue (deque) to store request times. When a new request arrives, we remove all requests outside the 3000ms window, then add the new request and return the queue size. +After processing each node, we recursively process its children. -**1.3 Brute force vs. optimized strategy:** +**2.5 Return Result:** -- **Brute Force:** Store all requests in a list and filter out old ones each time. This could be inefficient if we check all requests. -- **Optimized Strategy (Queue):** Use a deque to store requests. Since times are strictly increasing, we only need to remove from the front. This is efficient. -- **Why it's better:** The queue approach allows us to efficiently remove old requests from the front while adding new ones at the back. Since times are increasing, we never need to check the middle of the queue. +After processing all nodes, `res = 4` is returned (nodes 3, 3, 4, and 5 are good). -**1.4 Decomposition:** +### Solution -1. Initialize an empty deque in the constructor. -2. In `ping(t)`: - - Add the current time $t$ to the queue. - - Remove all requests from the front that are older than $t - 3000$. - - Return the size of the queue (number of requests in the window). +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def goodNodes(self, root: TreeNode) -> int: + res = 0 + + def dfs(node, max_val): + nonlocal res + if not node: + return + + if node.val >= max_val: + res += 1 + max_val = node.val + + dfs(node.left, max_val) + dfs(node.right, max_val) + + dfs(root, root.val) + return res +``` -### Steps (The "How") +## 1657. Determine if Two Strings Are Close [Medium] +https://leetcode.com/problems/determine-if-two-strings-are-close/ -**2.1 Initialization & Example Setup:** +### Explanation -Let's use the example: `ping(1)`, `ping(100)`, `ping(3001)`, `ping(3002)` +## 1657. Determine if Two Strings Are Close [Medium] -We initialize: -- `queue = deque()` +https://leetcode.com/problems/determine-if-two-strings-are-close -**2.2 Start Processing:** +## Description +Two strings are considered close if you can attain one from the other using the following operations: +- Operation 1: Swap any two existing characters (i.e., freely reorder the string). +- Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character (i.e., swap all a's with b's, and all b's with a's). +You can use the operations on either string as many times as necessary. -We process each ping call. +Given two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise. -**2.3 Trace Walkthrough:** +**Examples** +Input: word1 = "abc", word2 = "bca" +Output: true +Explanation: You can attain word2 from word1 in 2 operations. +Apply Operation 1: "abc" -> "acb" +Apply Operation 1: "acb" -> "bca" -| Call | Time | Queue Before | Remove Old | Queue After | Return | -|------|------|--------------|------------|-------------|--------| -| `ping(1)` | 1 | [] | None | [1] | 1 | -| `ping(100)` | 100 | [1] | None ($1 \geq 100-3000$) | [1, 100] | 2 | -| `ping(3001)` | 3001 | [1, 100] | Remove 1 ($1 < 3001-3000$) | [100, 3001] | 2 | -| `ping(3002)` | 3002 | [100, 3001] | Remove 100 ($100 < 3002-3000$) | [3001, 3002] | 2 | +Input: word1 = "a", word2 = "aa" +Output: false +Explanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations. -**2.4 Explanation:** +Input: word1 = "cabbba", word2 = "abbccc" +Output: true +Explanation: You can attain word2 from word1 in 3 operations. +Apply Operation 1: "cabbba" -> "caabbb" +Apply Operation 2: "caabbb" -> "baaccc" +Apply Operation 2: "baaccc" -> "abbccc" -- `ping(1)`: Window $[1-3000, 1] = [-2999, 1]$, contains [1] → return 1 -- `ping(100)`: Window $[100-3000, 100] = [-2900, 100]$, contains [1, 100] → return 2 -- `ping(3001)`: Window $[3001-3000, 3001] = [1, 3001]$, contains [100, 3001] (1 is removed) → return 2 -- `ping(3002)`: Window $[3002-3000, 3002] = [2, 3002]$, contains [3001, 3002] (100 is removed) → return 2 +**Constraints** +- 1 <= word1.length, word2.length <= 10^5 +- word1 and word2 contain only lowercase English letters. -**2.5 Return Result:** +## Hint +Operation 1 allows you to freely reorder the string. Operation 2 allows you to freely reassign the letters' frequencies. -Each `ping` call returns the number of requests in the current 3000ms window. +## Explanation +To determine if two strings are close, you need to check two things: +1. Both strings must have the same set of unique characters. If one string has a character the other doesn't, you can't transform one into the other. +2. The frequency of each character (regardless of which character) must be the same in both strings. This is because you can swap the frequencies between characters using Operation 2, but you can't create or destroy frequencies. -> **Note:** Since times are strictly increasing, we only need to check and remove from the front of the queue. All requests in the queue are already in order, so we never need to check the middle or back. +This means you can sort the frequency counts of each string and compare them. If both the set of unique characters and the sorted frequency counts match, the strings are close. ### Solution ```python -def __init__(self): - self.queue = deque() - - def ping(self, t: int) -> int: - # Add current request time - self.queue.append(t) - - # Remove requests outside the 3000ms window - while self.queue[0] < t - 3000: - self.queue.popleft() - - # Return number of requests in the window - return len(self.queue) +def closeStrings(word1, word2): + if set(word1) != set(word2): + return False + return sorted(Counter(word1).values()) == sorted(Counter(word2).values()) ``` -## 102. Binary Tree Level Order Traversal [Medium] -https://leetcode.com/problems/binary-tree-level-order-traversal/ +## 2095. Delete the Middle Node of a Linked List [Medium] +https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/ ### Explanation @@ -1678,122 +1826,94 @@ https://leetcode.com/problems/binary-tree-level-order-traversal/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the level-order traversal of its nodes' values (i.e., from left to right, level by level). - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $2000$. -- **Value Range:** Node values are between $-1000$ and $1000$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level, which is $O(n)$ in the worst case. -- **Edge Case:** If the tree is empty, return an empty list. +* **Input Size:** The linked list can have up to 10^5 nodes. +* **Time Complexity:** O(n) - We traverse the list once to find the middle, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 0 or 1 node, return None (no middle node to delete). **1.2 High-level approach:** -The goal is to traverse the tree level by level, collecting values at each level. - -![Level Order Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) +The goal is to delete the middle node of a linked list. The middle node is at index floor(n/2) using 0-based indexing. We use the two-pointer technique to find the middle node. -We use BFS (breadth-first search) with a queue. We process nodes level by level, adding all nodes at the current level to a list before moving to the next level. +![Two-pointer technique showing fast and slow pointers finding the middle] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS with Queue):** Use a queue to process nodes level by level. For each level, process all nodes in the queue (which represents the current level), then add their children for the next level. -- **Why it's better:** BFS naturally processes nodes level by level. Using a queue ensures we process all nodes at one level before moving to the next. +* **Brute Force:** Traverse the list to count nodes, then traverse again to find and delete the middle node. This requires two passes. +* **Optimized (Two Pointers):** Use fast and slow pointers. When fast reaches the end, slow is at the middle. This is one pass. +* **Why it's better:** The two-pointer approach finds the middle in one pass, making it more efficient. **1.4 Decomposition:** -1. If the tree is empty, return an empty list. -2. Initialize a queue with the root node. -3. While the queue is not empty: - - Get the number of nodes at the current level (queue size). - - Process all nodes at this level, adding their values to a level list. - - Add all children of these nodes to the queue for the next level. - - Add the level list to the result. -4. Return the result. +1. Handle edge cases: if list has 0 or 1 node, return None. +2. Use two pointers: slow and fast, both starting at head. +3. Also track prev to point to the node before slow. +4. Move fast two steps and slow one step until fast reaches the end. +5. Delete the middle node by setting prev.next = slow.next. +6. Return head. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3,9,20,null,null,15,7]$ - -The tree structure: -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` +Let's use the example: head = [1,3,4,7,1,2,6] We initialize: -- `queue = deque([3])` -- `res = []` +* `slow = head` (node 1) +* `fast = head` (node 1) +* `prev = None` -**2.2 Start BFS:** +**2.2 Start Checking/Processing:** -We begin processing level by level. +We enter a while loop while `fast` and `fast.next` exist. **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process Nodes | Level List | Queue After | -|-------|--------------|------------|---------------|------------|-------------| -| 0 | [3] | 1 | 3 | [3] | [9, 20] | -| 1 | [9, 20] | 2 | 9, 20 | [9, 20] | [15, 7] | -| 2 | [15, 7] | 2 | 15, 7 | [15, 7] | [] | +| Step | slow.val | fast.val | prev.val | Action | +|------|----------|----------|----------|--------| +| Initial | 1 | 1 | None | Setup | +| 1 | 3 | 4 | 1 | Move pointers | +| 2 | 4 | 1 | 3 | Move pointers | +| 3 | 7 | 2 | 4 | Move pointers | +| 4 | 1 | 6 | 7 | fast.next is None, stop | +| Final | 7 | - | 4 | Delete: prev.next = slow.next | -**2.4 Final Result:** +**2.4 Increment and Loop:** -After processing all levels: -- `res = [[3], [9, 20], [15, 7]]` +After each iteration, we update prev = slow, then move slow and fast. **2.5 Return Result:** -We return `[[3], [9, 20], [15, 7]]`, which represents the level-order traversal. - -> **Note:** The key is to process all nodes at the current level before moving to the next. We do this by getting the queue size at the start of each iteration, which represents the number of nodes at the current level. +After deletion, the list is [1,3,4,1,2,6], and head is returned. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right - -from typing import List -from collections import deque - +# self.next = next class Solution: - def levelOrder(self, root) -> List[List[int]]: - if not root: - return [] + def deleteMiddle(self, head: Optional[ListNode]) -> Optional[ListNode]: + if not head or not head.next: + return None - res = [] - queue = deque([root]) + slow = head + fast = head + prev = None - while queue: - level_size = len(queue) - level = [] - - for _ in range(level_size): - node = queue.popleft() - level.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) - - res.append(level) + while fast and fast.next: + prev = slow + slow = slow.next + fast = fast.next.next - return res + prev.next = slow.next + return head ``` -## 199. Binary Tree Right Side View [Medium] -https://leetcode.com/problems/binary-tree-right-side-view/ +## 2130. Maximum Twin Sum of a Linked List [Medium] +https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/ ### Explanation @@ -1801,123 +1921,94 @@ https://leetcode.com/problems/binary-tree-right-side-view/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $100$. -- **Value Range:** Node values are between $0$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. -- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. +* **Input Size:** The linked list has an even number of nodes, up to 10^5. +* **Time Complexity:** O(n) - We traverse the list to find the middle, reverse the second half, and compare pairs, where n is the number of nodes. +* **Space Complexity:** O(1) - We only use a constant amount of extra space for pointers. +* **Edge Case:** If the list has 2 nodes, return the sum of their values. **1.2 High-level approach:** -The goal is to find the rightmost node at each level of the tree. +The goal is to find the maximum sum of twin pairs. Twins are nodes at positions i and n-1-i. We split the list at the middle, reverse the second half, then compare pairs. -![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) - -We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. +![Linked list showing twin pairs and their sums] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. -- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. +* **Brute Force:** Store all node values in an array, then calculate all twin sums. This uses O(n) extra space. +* **Optimized (In-place Reversal):** Find the middle, reverse the second half in-place, then traverse both halves simultaneously to find max sum. This uses O(1) extra space. +* **Why it's better:** The in-place approach meets the O(1) space requirement and is more memory efficient. **1.4 Decomposition:** -1. If the tree is empty, return an empty list. -2. Initialize a queue with the root node. -3. While the queue is not empty: - - Get the number of nodes at the current level. - - Process all nodes at this level. - - For the last node at each level (rightmost), add its value to the result. - - Add all children to the queue for the next level. -4. Return the result. +1. Use two pointers to find the middle of the list. +2. Reverse the second half of the list. +3. Traverse both halves simultaneously, calculating twin sums. +4. Track and return the maximum sum. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,2,3,null,5,null,4]$ - -The tree structure: -``` - 1 - / \ - 2 3 - \ \ - 5 4 -``` +Let's use the example: head = [5,4,2,1] We initialize: -- `queue = deque([1])` -- `res = []` +* Find middle: after two-pointer, slow points to node 2 (middle). -**2.2 Start BFS:** +**2.2 Start Checking/Processing:** -We begin processing level by level. +We reverse the second half starting from slow. **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process | Rightmost Node | res | -|-------|--------------|------------|---------|----------------|-----| -| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | -| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | -| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | +| Step | First Half | Second Half (reversed) | Twin Sum | Max | +|------|------------|------------------------|----------|-----| +| Initial | [5,4] | [2,1] → reverse → [1,2] | - | 0 | +| 1 | 5 | 1 | 5+1=6 | 6 | +| 2 | 4 | 2 | 4+2=6 | 6 | -**2.4 Explanation:** +**2.4 Increment and Loop:** -- Level 0: Only node 1 → add 1 -- Level 1: Nodes 2 and 3 → add 3 (rightmost) -- Level 2: Nodes 5 and 4 → add 4 (rightmost) +After calculating each twin sum, we move both pointers forward and update the maximum. **2.5 Return Result:** -We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. - -> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. +After processing all pairs, `res = 6` is returned (both pairs sum to 6). ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right - -from typing import List -from collections import deque - +# self.next = next class Solution: - def rightSideView(self, root) -> List[int]: - if not root: - return [] + def pairSum(self, head: Optional[ListNode]) -> int: + slow = fast = head + while fast and fast.next: + slow = slow.next + fast = fast.next.next - res = [] - queue = deque([root]) + prev = None + while slow: + next_node = slow.next + slow.next = prev + prev = slow + slow = next_node - while queue: - level_size = len(queue) - - for i in range(level_size): - node = queue.popleft() - - # Add the rightmost node of each level - if i == level_size - 1: - res.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) + res = 0 + first = head + second = prev + while second: + res = max(res, first.val + second.val) + first = first.next + second = second.next return res ``` -## 450. Delete Node in a BST [Medium] -https://leetcode.com/problems/delete-node-in-a-bst/ +## 2336. Smallest Number in Infinite Set [Medium] +https://leetcode.com/problems/smallest-number-in-infinite-set/ ### Explanation @@ -1925,124 +2016,136 @@ https://leetcode.com/problems/delete-node-in-a-bst/ ### Strategy (The "Why") -Given the root of a binary search tree and a key, we need to delete the node with the given key and return the root of the BST. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-10^5$ and $10^5$. -- **Time Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Space Complexity:** $O(h)$ - The recursion stack can be as deep as the height of the tree. -- **Edge Case:** If the key doesn't exist, return the original tree. If the node to delete has no children, simply remove it. +* **Input Size:** At most 1000 calls to popSmallest and addBack. Numbers are between 1 and 1000. +* **Time Complexity:** O(log k) for popSmallest and addBack where k is the number of added-back numbers. O(1) for the infinite set part. +* **Space Complexity:** O(k) where k is the number of distinct numbers that have been popped and added back. +* **Edge Case:** If we pop all numbers 1-1000 and add some back, those added-back numbers should be returned before continuing with 1001+. **1.2 High-level approach:** -The goal is to delete a node from a BST while maintaining the BST property. +The goal is to implement a set that contains all positive integers, with operations to pop the smallest and add numbers back. We use a min-heap for added-back numbers and track the next number in the infinite sequence. -We use recursion to find the node. If found, we handle three cases: no children, one child, or two children. For two children, we replace the node's value with the minimum value from its right subtree, then delete that minimum node. +![Data structure showing heap for added-back numbers and counter for infinite sequence] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must maintain the BST structure. -- **Optimized Strategy (Recursion):** Use recursion to find and delete the node, handling each case appropriately. This is the standard and efficient approach. -- **Why it's better:** The recursive approach naturally handles the tree structure and maintains BST properties efficiently. +* **Brute Force:** Store all popped numbers in a set, then for popSmallest, iterate from 1 to find the first not in the set. This is O(n) per pop. +* **Optimized (Heap + Counter):** Use a min-heap for added-back numbers and a counter for the infinite sequence. popSmallest returns min(heap.pop(), counter++). This is O(log k) per pop. +* **Why it's better:** The heap allows O(log k) access to the minimum added-back number, and the counter handles the infinite sequence in O(1). **1.4 Decomposition:** -1. If root is null, return null. -2. If key is less than root.val, recursively delete from left subtree. -3. If key is greater than root.val, recursively delete from right subtree. -4. If key equals root.val: - - If no left child, return right child. - - If no right child, return left child. - - If two children, find minimum in right subtree, replace root's value, and delete the minimum node. -5. Return the root. +1. Maintain a min-heap for numbers that were popped and added back. +2. Maintain a counter (next_num) for the infinite sequence starting from 1. +3. Maintain a set to track which numbers are currently removed. +4. For popSmallest: if heap is not empty, pop from heap; otherwise, return and increment counter. +5. For addBack: if number is in removed set, add it to heap and remove from set. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[5,3,6,2,4,null,7]$, key = 3 - -The tree structure: -``` - 5 - / \ - 3 6 - / \ \ -2 4 7 -``` +We initialize: +* `removed = set()` (track removed numbers) +* `added_back = []` (min-heap) +* `next_num = 1` (next number in infinite sequence) -**2.2 Start Searching:** +**2.2 Start Checking/Processing:** -We search for the node with key = 3. +Operations are called: addBack(2), popSmallest(), popSmallest(), popSmallest(), addBack(1), popSmallest() **2.3 Trace Walkthrough:** -| Step | Current Node | Key Comparison | Action | -|------|--------------|----------------|--------| -| 1 | 5 | 3 < 5 | Go left | -| 2 | 3 | 3 == 3 | Found! Delete node 3 | +| Operation | added_back | next_num | removed | Return | +|-----------|------------|----------|---------|--------| +| addBack(2) | [] | 1 | {} | None (2 already in set) | +| popSmallest() | [] | 1 | {1} | 1, next_num=2 | +| popSmallest() | [] | 2 | {1,2} | 2, next_num=3 | +| popSmallest() | [] | 3 | {1,2,3} | 3, next_num=4 | +| addBack(1) | [1] | 4 | {2,3} | None | +| popSmallest() | [] | 4 | {2,3,1} | 1 (from heap), next_num=4 | -**Deleting node 3:** -- Node 3 has two children (2 and 4) -- Find minimum in right subtree: min(4) = 4 -- Replace node 3's value with 4 -- Delete node 4 from right subtree (node 4 has no children, so simply remove it) +**2.4 Increment and Loop:** -**2.4 Final Tree:** +After each operation, we update the data structures accordingly. -After deletion: -``` - 5 - / \ - 4 6 - / \ -2 7 +**2.5 Return Result:** + +The operations return [null, 1, 2, 3, null, 1] as expected. + +### Solution + +```python +def __init__(self): + self.removed = set() + self.added_back = [] + self.next_num = 1 + + def popSmallest(self) -> int: + if self.added_back: + res = heapq.heappop(self.added_back) + self.removed.add(res) + return res + else: + res = self.next_num + self.next_num += 1 + self.removed.add(res) + return res + + def addBack(self, num: int) -> None: + if num in self.removed: + self.removed.remove(num) + heapq.heappush(self.added_back, num) ``` -**2.5 Return Result:** +## 2352. Equal Row and Column Pairs [Medium] +https://leetcode.com/problems/equal-row-and-column-pairs/ -We return the root of the modified tree. +### Explanation -> **Note:** The key insight is that when deleting a node with two children, we can replace it with the minimum node from its right subtree (or maximum from left subtree). This maintains the BST property because the minimum in the right subtree is greater than all left children and less than all other right children. +## 2352. Equal Row and Column Pairs [Medium] + +https://leetcode.com/problems/equal-row-and-column-pairs + +## Description +Given a 0-indexed n x n integer matrix grid, return the number of pairs (r_i, c_j) such that row r_i and column c_j are equal. + +A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array). + +**Examples** +Input: grid = [[3,2,1],[1,7,6],[2,7,7]] +Output: 1 +Explanation: There is 1 equal row and column pair: +- (Row 2, Column 1): [2,7,7] + +Input: grid = [[3,1,2,2],[1,4,4,5],[2,4,2,2],[2,4,2,2]] +Output: 3 +Explanation: There are 3 equal row and column pairs: +- (Row 0, Column 0): [3,1,2,2] +- (Row 2, Column 2): [2,4,2,2] +- (Row 3, Column 2): [2,4,2,2] + +**Constraints** +- n == grid.length == grid[i].length +- 1 <= n <= 200 +- 1 <= grid[i][j] <= 10^5 + +## Hint +We can use nested loops to compare every row against every column. Another loop is necessary to compare the row and column element by element. It is also possible to hash the arrays and compare the hashed values instead. + +## Explanation +To count equal row and column pairs, we can compare each row with each column. For each row, we check if it matches any column by comparing their elements one by one. To make this efficient, we can use tuples or hashable representations of rows and columns and count their occurrences. If a row matches a column, we increment our answer. + +This approach is efficient for n up to 200, and using hash maps or tuples makes the comparison fast and easy to implement. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right - -class Solution: - def deleteNode(self, root, key: int): - if not root: - return None - - if key < root.val: - root.left = self.deleteNode(root.left, key) - elif key > root.val: - root.right = self.deleteNode(root.right, key) - else: - # Node to delete found - if not root.left: - return root.right - elif not root.right: - return root.left - else: - # Node has two children - # Find the minimum value in right subtree - min_node = self.findMin(root.right) - # Replace root's value with min value - root.val = min_node.val - # Delete the min node from right subtree - root.right = self.deleteNode(root.right, min_node.val) - - return root - - def findMin(self, node): - while node.left: - node = node.left - return node +def equalPairs(grid): + n = len(grid) + row_counts = Counter(tuple(row) for row in grid) + col_counts = Counter(tuple(grid[i][j] for i in range(n)) for j in range(n)) + return sum(row_counts[row] * col_counts[row] for row in row_counts) ``` diff --git a/books/LeetCode_Top_150.md b/books/LeetCode_Top_150.md index 118d17b..0eb5887 100644 --- a/books/LeetCode_Top_150.md +++ b/books/LeetCode_Top_150.md @@ -2,144 +2,144 @@ Problem list from official https://leetcode.com/studyplan/top-interview-150 -## 274. H-Index [Medium] -https://leetcode.com/problems/h-index/ +## 1. Two Sum [Easy] +https://leetcode.com/problems/two-sum/ ### Explanation -## 274. H-Index [Medium] +To solve the Two Sum problem, we want to find two numbers in the array that add up to a given target. The most efficient way is to use a hash map (dictionary) to store the numbers we have seen so far and their indices. As we iterate through the array, for each number, we check if the complement (target - current number) exists in the hash map. If it does, we have found the solution. Otherwise, we add the current number and its index to the hash map. This approach has O(n) time complexity. -https://leetcode.com/problems/h-index +## Hint -## Description -Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `iᵗʰ` paper, return *the researcher's h-index*. +Try using a hash map to keep track of the numbers you have seen so far and their indices. -According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such that the given researcher has published at least `h` papers that have each been cited at least `h` times. +## Points -**Examples** +- Time complexity: O(n) using a hash map. +- Brute-force solution is O(n^2) and not efficient for large arrays. +- There is always exactly one solution, and you may not use the same element twice. +- Be careful with duplicate numbers in the array. -```tex -Example 1: -Input: citations = [3,0,6,1,5] -Output: 3 -Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. -Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3. +### Solution -Example 2: -Input: citations = [1,3,1] -Output: 1 +```python +def two_sum(nums, target): + """Find two numbers that add up to target using a hash map for O(n) time complexity.""" + num_to_index = {} + for i, num in enumerate(nums): + complement = target - num + if complement in num_to_index: + return [num_to_index[complement], i] + num_to_index[num] = i + return [] ``` -**Constraints** -```tex -- n == citations.length -- 1 <= n <= 5000 -- 0 <= citations[i] <= 1000 -``` +## 21. Merge Two Sorted Lists [Easy] +https://leetcode.com/problems/merge-two-sorted-lists/ + +### Explanation ## Explanation -### Strategy -Let's restate the problem: You're given an array representing the number of citations for each paper a researcher has published. You need to find the maximum value `h` such that the researcher has at least `h` papers with at least `h` citations each. +### Strategy (The "Why") -This is a **sorting problem** that requires understanding the definition of h-index and finding the optimal value efficiently. +Given two sorted linked lists `list1` and `list2`, we need to merge them into one sorted list and return the head of the merged list. -**What is given?** An array of integers representing citation counts for each paper. +**1.1 Constraints & Complexity:** -**What is being asked?** Find the maximum h-index value that satisfies the h-index definition. +- **Input Size:** The total number of nodes can be up to $50$. +- **Value Range:** Node values are between $-100$ and $100$. +- **Time Complexity:** $O(n + m)$ where $n$ and $m$ are the lengths of the two lists. We visit each node exactly once. +- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for the dummy node and pointers. +- **Edge Case:** If one list is empty, return the other list. If both are empty, return `null`. -**Constraints:** The array can be up to 5000 elements long, with citation counts ranging from 0 to 1000. +**1.2 High-level approach:** -**Edge cases:** -- Array with all zeros -- Array with all high citation counts -- Array with single element -- Array with mixed citation counts +The goal is to merge two sorted linked lists into one sorted list. -**High-level approach:** -The solution involves understanding the h-index definition and using sorting to efficiently find the maximum valid h value. +We use a dummy node to simplify edge cases and a current pointer to build the merged list. We compare nodes from both lists and attach the smaller one to the result, then move the pointer of the list we took from. -**Decomposition:** -1. **Sort the array**: Arrange citations in descending order to easily check h-index conditions -2. **Iterate through sorted array**: Check each position as a potential h-index -3. **Verify h-index condition**: Ensure at least h papers have at least h citations -4. **Return maximum valid h**: Find the largest h that satisfies the condition +**1.3 Brute force vs. optimized strategy:** -**Brute force vs. optimized strategy:** -- **Brute force**: Try each possible h value and check if it satisfies the condition. This takes O(n²) time. -- **Optimized**: Sort the array and use a single pass to find the h-index. This takes O(n log n) time. +- **Brute Force:** Convert both lists to arrays, merge the arrays, then convert back to a linked list. This takes $O(n + m)$ time and $O(n + m)$ space. +- **Optimized Strategy (Two Pointers):** Use two pointers to traverse both lists simultaneously, building the merged list in-place. This takes $O(n + m)$ time and $O(1)$ space. +- **Why it's better:** The two-pointer approach uses $O(1)$ extra space instead of $O(n + m)$ for arrays, while maintaining the same time complexity. -### Steps -Let's walk through the solution step by step using the first example: `citations = [3,0,6,1,5]` +**1.4 Decomposition:** -**Step 1: Sort the array in descending order** -- Original: `[3,0,6,1,5]` -- Sorted: `[6,5,3,1,0]` +1. Create a dummy node to simplify edge cases. +2. Initialize a current pointer at the dummy node. +3. While both lists have nodes, compare the values and attach the smaller node to the result. +4. Move the pointer of the list we took from. +5. Attach the remaining nodes from the non-empty list. +6. Return the head of the merged list (dummy.next). -**Step 2: Check each position as potential h-index** -- Position 0: `h = 1`, check if `citations[0] >= 1` ✓ (6 >= 1) -- Position 1: `h = 2`, check if `citations[1] >= 2` ✓ (5 >= 2) -- Position 2: `h = 3`, check if `citations[2] >= 3` ✓ (3 >= 3) -- Position 3: `h = 4`, check if `citations[3] >= 4` ✗ (1 < 4) +### Steps (The "How") -**Step 3: Find the maximum valid h** -- The largest h where `citations[h-1] >= h` is 3 -- At position 2 (0-indexed), we have `h = 3` and `citations[2] = 3 >= 3` +**2.1 Initialization & Example Setup:** -**Step 4: Verify the h-index condition** -- We need at least 3 papers with at least 3 citations -- Papers with ≥3 citations: 6, 5, 3 (3 papers) ✓ -- Remaining papers: 1, 0 (≤3 citations) ✓ -- H-index is 3 +Let's use the example: $list1 = [1,2,4]$, $list2 = [1,3,4]$ -**Why this works:** -After sorting in descending order, the array position `i` (0-indexed) represents `h = i + 1`. For a position to be a valid h-index, we need `citations[i] >= h`. The largest valid h is our answer. +We initialize: +- `dummy = ListNode(0)` +- `current = dummy` -> **Note:** The key insight is that after sorting, we can directly check each position as a potential h-index. The sorting makes it easy to verify the h-index condition in a single pass. +**2.2 Start Merging:** -**Time Complexity:** O(n log n) - dominated by sorting the array -**Space Complexity:** O(1) - we only use a constant amount of extra space (excluding the sorted array if we modify the input) +We begin comparing nodes from both lists. + +**2.3 Trace Walkthrough:** + +| Step | list1.val | list2.val | Compare | Attach | current.next | list1/list2 After | +|------|-----------|-----------|---------|--------|--------------|-------------------| +| 1 | 1 | 1 | Equal | list1 | 1 | list1 = 2 | +| 2 | 2 | 1 | 2 > 1 | list2 | 1 | list2 = 3 | +| 3 | 2 | 3 | 2 < 3 | list1 | 2 | list1 = 4 | +| 4 | 4 | 3 | 4 > 3 | list2 | 3 | list2 = 4 | +| 5 | 4 | 4 | Equal | list1 | 4 | list1 = null | +| 6 | null | 4 | - | list2 | 4 | list2 = null | + +**2.4 Final Result:** + +After merging: $[1,1,2,3,4,4]$ + +**2.5 Return Result:** + +We return the head of the merged list: $[1,1,2,3,4,4]$ + +> **Note:** The dummy node simplifies the code by providing a starting point. Without it, we'd need special handling for the first node. The key is to always attach the smaller node and move the corresponding pointer forward. ### Solution ```python -def hIndex(citations): - """ - Calculate the h-index for a researcher based on their paper citations. - - Args: - citations: List[int] - Array of citation counts for each paper +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next + +class Solution: + def mergeTwoLists(self, list1, list2): + # Create a dummy node to simplify edge cases + dummy = ListNode(0) + current = dummy - Returns: - int - The researcher's h-index - """ - # Handle edge cases - if not citations: - return 0 - - # Sort citations in descending order - citations.sort(reverse=True) - - # Check each position as a potential h-index - for i in range(len(citations)): - # h-index is i + 1 (1-indexed) - h = i + 1 + # Merge while both lists have nodes + while list1 and list2: + if list1.val <= list2.val: + current.next = list1 + list1 = list1.next + else: + current.next = list2 + list2 = list2.next + current = current.next - # Check if citations[i] >= h - # If not, we've found our answer - if citations[i] < h: - return i + # Append remaining nodes + current.next = list1 if list1 else list2 - # If we reach the end, the h-index is the length of the array - if i == len(citations) - 1: - return h - - # This line should never be reached - return 0 + return dummy.next ``` -## 380. Insert Delete GetRandom O(1) [Medium] -https://leetcode.com/problems/insert-delete-getrandom-o1/ +## 100. Same Tree [Easy] +https://leetcode.com/problems/same-tree/ ### Explanation @@ -147,1355 +147,645 @@ https://leetcode.com/problems/insert-delete-getrandom-o1/ ### Strategy (The "Why") +The problem asks us to determine if two binary trees are structurally identical and have the same node values. + **1.1 Constraints & Complexity:** -- **Input Size:** At most `2 * 10^5` calls to insert, remove, getRandom. -- **Time Complexity:** O(1) average for all operations - using array and hash map. -- **Space Complexity:** O(n) where n is the number of elements stored. -- **Edge Case:** Removing the last element, getting random from single element. + +- **Input Constraints:** Both trees have at most 100 nodes, and node values are in the range $[-10^4, 10^4]$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once, where $n$ is the minimum number of nodes in the two trees. +- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In the worst case (skewed tree), $h = n$, giving $O(n)$ space. +- **Edge Case:** Both trees are empty (both roots are `None`), which should return `True`. **1.2 High-level approach:** -The goal is to implement a data structure with O(1) insert, remove, and getRandom. We use an array for random access and a hash map to track indices for O(1) removal. + +The goal is to check if two trees have the same structure and values by comparing them node by node recursively. We compare the root values, then recursively check left and right subtrees. + +![Binary tree comparison](https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg) **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Use only array - remove is O(n), getRandom is O(1). -- **Optimized Strategy:** Use array + hash map - all operations O(1) average. + +- **Brute Force:** Convert both trees to arrays using traversal, then compare arrays. This requires $O(n)$ time and $O(n)$ space for storing both arrays. +- **Optimized (Recursive Comparison):** Compare nodes directly during traversal without storing intermediate results. This uses $O(n)$ time but only $O(h)$ space for the recursion stack. +- **Emphasize the optimization:** By comparing nodes directly during traversal, we can short-circuit early if we find a mismatch, potentially avoiding full tree traversal. **1.4 Decomposition:** -1. Maintain an array of values and a hash map from value to index. -2. Insert: Add to array, store index in map. -3. Remove: Swap with last element, update map, remove last. -4. GetRandom: Use random.choice on array. + +1. **Base Cases:** If both nodes are `None`, return `True`. If only one is `None`, return `False`. +2. **Value Comparison:** Check if the current nodes have the same value. +3. **Recursive Check:** Recursively check if left subtrees match and right subtrees match. +4. **Combine Results:** Return `True` only if values match and both subtrees match. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Initialize `nums = []`, `val_to_index = {}`. -**2.2 Start Checking:** -We perform operations: insert(1), remove(2), insert(2), getRandom(). +Let's trace through an example: `p = [1,2,3]`, `q = [1,2,3]`. -**2.3 Trace Walkthrough:** +Both trees have the same structure and values. -| Operation | nums | val_to_index | Result | -|-----------|------|--------------|--------| -| insert(1) | [1] | {1:0} | True | -| remove(2) | [1] | {1:0} | False | -| insert(2) | [1,2] | {1:0,2:1} | True | -| getRandom() | [1,2] | {1:0,2:1} | 1 or 2 | +**2.2 Start Comparison:** -**2.4 Increment and Loop:** -Not applicable - these are individual operations. +We begin at the root nodes of both trees. -**2.5 Return Result:** -Operations return their respective results. +**2.3 Trace Walkthrough:** -### Solution +| Node Pair | p.val | q.val | Match? | Left Check | Right Check | Result | +|-----------|-------|-------|--------|------------|-------------|--------| +| Root (1, 1) | 1 | 1 | Yes | Check (2, 2) | Check (3, 3) | Continue | +| Left (2, 2) | 2 | 2 | Yes | Check (None, None) | Check (None, None) | True | +| Right (3, 3) | 3 | 3 | Yes | Check (None, None) | Check (None, None) | True | -```python -def __init__(self): - self.nums = [] - self.val_to_index = {} +**2.4 Recursive Unwinding:** - def insert(self, val: int) -> bool: - if val in self.val_to_index: - return False - - self.val_to_index[val] = len(self.nums) - self.nums.append(val) - return True +- Both left subtrees (2, 2) match: both have value 2 and no children. +- Both right subtrees (3, 3) match: both have value 3 and no children. +- Root nodes (1, 1) match. - def remove(self, val: int) -> bool: - if val not in self.val_to_index: - return False - - # Move last element to the position of element to remove - index = self.val_to_index[val] - last_val = self.nums[-1] +**2.5 Return Result:** + +Since all nodes match in structure and value, the function returns `True`. + +> **Note:** The algorithm short-circuits: if any node comparison fails, the entire function returns `False` immediately without checking remaining nodes. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool: + # Both are None + if not p and not q: + return True - self.nums[index] = last_val - self.val_to_index[last_val] = index + # One is None, the other is not + if not p or not q: + return False - # Remove the last element - self.nums.pop() - del self.val_to_index[val] + # Both exist, check values and recursively check children + if p.val != q.val: + return False - return True - - def getRandom(self) -> int: - return random.choice(self.nums) + return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right) ``` -## 42. Trapping Rain Water [Hard] -https://leetcode.com/problems/trapping-rain-water/ +## 101. Symmetric Tree [Easy] +https://leetcode.com/problems/symmetric-tree/ ### Explanation -## 42. Trapping Rain Water [Hard] +## Explanation -https://leetcode.com/problems/trapping-rain-water +### Strategy (The "Why") -## Description -Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. +Given the root of a binary tree, we need to check whether it is a mirror of itself (symmetric around its center). -**Examples** +**1.1 Constraints & Complexity:** -```text -Example 1: -Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] -Output: 6 -Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. +- **Input Size:** The number of nodes can be up to $1000$. +- **Value Range:** Node values are between $-100$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. +- **Edge Case:** An empty tree is symmetric. A tree with only one node is symmetric. -Example 2: -Input: height = [4,2,0,3,2,5] -Output: 9 -``` +**1.2 High-level approach:** -**Constraints** -```text -- n == height.length -- 1 <= n <= 2 * 10^4 -- 0 <= height[i] <= 10^5 -``` +The goal is to determine if a binary tree is symmetric (mirror of itself). -## Explanation +We use recursion to check if the left and right subtrees are mirrors of each other. Two trees are mirrors if their roots have the same value, and the left subtree of one is a mirror of the right subtree of the other, and vice versa. -### Strategy -Let's restate the problem: You're given an array representing the heights of walls in a landscape. When it rains, water gets trapped between these walls. Your job is to calculate how much water can be trapped. +**1.3 Brute force vs. optimized strategy:** -This is a **two-pointer and dynamic programming problem** that requires understanding how water trapping works in real life. +- **Brute Force:** There isn't really a brute force approach - we must check the mirror property. +- **Optimized Strategy (Recursion):** Use recursion to check if left and right subtrees are mirrors. This is the standard and efficient approach. +- **Why it's better:** Recursion naturally checks the mirror property by comparing corresponding nodes in the left and right subtrees. -**What is given?** An array of non-negative integers representing wall heights. +**1.4 Decomposition:** -**What is being asked?** Calculate the total amount of water that can be trapped between the walls. +1. Define a helper function that checks if two trees are mirrors. +2. Two trees are mirrors if: + - Both are null (base case: true). + - One is null and the other is not (false). + - Both roots have the same value, and: + - Left subtree of first is mirror of right subtree of second. + - Right subtree of first is mirror of left subtree of second. +3. Check if root's left and right subtrees are mirrors. -**Constraints:** The array can be quite large (up to 20,000 elements), so we need an efficient solution. All heights are non-negative. +### Steps (The "How") -**Edge cases:** -- If the array has less than 3 elements, no water can be trapped (need at least 3 walls to form a container) -- If all heights are the same, no water can be trapped -- If heights are strictly increasing or decreasing, no water can be trapped +**2.1 Initialization & Example Setup:** -**High-level approach:** -The key insight is that for any position, the amount of water that can be trapped depends on the **minimum** of the highest wall to its left and the highest wall to its right. Water can only be trapped up to the height of the shorter of these two walls. +Let's use the example: root = $[1,2,2,3,4,4,3]$ -Think of it like this: at any point, water will rise to the level of the lower "dam" on either side. If you're in a valley between two mountains, the water level is limited by the shorter mountain. +The tree structure: +``` + 1 + / \ + 2 2 + / \ / \ + 3 4 4 3 +``` -**Decomposition:** -1. **Precompute left and right maximums**: For each position, find the highest wall to its left and right -2. **Calculate trapped water**: For each position, the trapped water is the minimum of left and right max, minus the current height (if positive) -3. **Sum up all trapped water**: Add up the water trapped at each position +We initialize: +- Call `is_mirror(root.left, root.right)` -**Brute force vs. optimized strategy:** -- **Brute force**: For each position, scan left and right to find maximums. This takes O(n²) time. -- **Optimized**: Precompute left and right maximums in two passes, then calculate water in one pass. This takes O(n) time. +**2.2 Start Checking:** -### Steps -Let's walk through the solution step by step using the first example: `height = [0,1,0,2,1,0,1,3,2,1,2,1]` +We begin checking if left and right subtrees are mirrors. -**Step 1: Understand the visualization** -Imagine this array as a landscape: -``` - ■ - ■ ■ ■ - ■ ■ ■ ■ ■ ■ ■ ■ -■ ■ ■ ■ ■ ■ ■ ■ ■ ■ -0 1 0 2 1 0 1 3 2 1 2 1 -``` +**2.3 Trace Walkthrough:** -**Step 2: Precompute left maximums** -We'll create an array `left_max` where `left_max[i]` is the highest wall to the left of position `i` (including position `i` itself). +| left | right | left.val | right.val | Check | Result | +|------|-------|----------|-----------|-------|--------| +| 2 | 2 | 2 | 2 | Equal ✓ | Check children | +| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | +| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | +| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | +| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | -``` -height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -left_max: [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3] -``` +**2.4 Explanation:** -How we calculate this: -- `left_max[0] = height[0] = 0` (no walls to the left) -- `left_max[1] = max(left_max[0], height[1]) = max(0, 1) = 1` -- `left_max[2] = max(left_max[1], height[2]) = max(1, 0) = 1` -- `left_max[3] = max(left_max[2], height[3]) = max(1, 2) = 2` -- And so on... +- Root's left (2) and right (2) have same value ✓ +- Left's left (3) and right's right (3) are mirrors ✓ +- Left's right (4) and right's left (4) are mirrors ✓ -**Step 3: Precompute right maximums** -Similarly, create `right_max` where `right_max[i]` is the highest wall to the right of position `i` (including position `i` itself). +**2.5 Return Result:** -``` -height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -right_max: [3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1] -``` +We return `True` because the tree is symmetric. -How we calculate this (from right to left): -- `right_max[11] = height[11] = 1` (no walls to the right) -- `right_max[10] = max(right_max[11], height[10]) = max(1, 2) = 2` -- `right_max[9] = max(right_max[10], height[9]) = max(2, 1) = 2` -- And so on... +> **Note:** The key insight is that a tree is symmetric if its left and right subtrees are mirrors. Two trees are mirrors if their roots match and the left of one mirrors the right of the other (and vice versa). -**Step 4: Calculate trapped water at each position** -For each position `i`, the water trapped is: -``` -water[i] = min(left_max[i], right_max[i]) - height[i] +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def isSymmetric(self, root) -> bool: + def is_mirror(left, right): + if not left and not right: + return True + if not left or not right: + return False + return (left.val == right.val and + is_mirror(left.left, right.right) and + is_mirror(left.right, right.left)) + + if not root: + return True + + return is_mirror(root.left, root.right) ``` -But only if this value is positive (we can't have negative water). +## 104. Maximum Depth of Binary Tree [Easy] +https://leetcode.com/problems/maximum-depth-of-binary-tree/ -Let's calculate for a few positions: -- Position 0: `min(0, 3) - 0 = 0` (no water trapped) -- Position 1: `min(1, 3) - 1 = 0` (no water trapped) -- Position 2: `min(1, 3) - 0 = 1` (1 unit of water trapped) -- Position 3: `min(2, 3) - 2 = 0` (no water trapped) -- Position 4: `min(2, 3) - 1 = 1` (1 unit of water trapped) -- Position 5: `min(2, 3) - 0 = 2` (2 units of water trapped) +### Explanation -**Step 5: Sum up all trapped water** -``` -water = [0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 0] -total = 0 + 0 + 1 + 0 + 1 + 2 + 1 + 0 + 0 + 1 + 0 + 0 = 6 -``` +## Explanation -> **Note:** The key insight is that water can only be trapped up to the height of the lower "dam" on either side. This is why we take the minimum of the left and right maximums. +### Strategy (The "Why") -**Time Complexity:** O(n) - we make three passes through the array -**Space Complexity:** O(n) - we store two additional arrays of size n +Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. -### Solution +**1.1 Constraints & Complexity:** -```python -def trap(height): - """ - Calculate the amount of water that can be trapped between walls. - - Args: - height: List[int] - Array representing wall heights - - Returns: - int - Total amount of water trapped - """ - # Handle edge cases - if not height or len(height) < 3: - return 0 - - n = len(height) - - # Step 1: Precompute left maximums - # left_max[i] = highest wall to the left of position i (including i) - left_max = [0] * n - left_max[0] = height[0] - - for i in range(1, n): - left_max[i] = max(left_max[i-1], height[i]) - - # Step 2: Precompute right maximums - # right_max[i] = highest wall to the right of position i (including i) - right_max = [0] * n - right_max[n-1] = height[n-1] - - for i in range(n-2, -1, -1): - right_max[i] = max(right_max[i+1], height[i]) - - # Step 3: Calculate trapped water at each position - res = 0 - for i in range(n): - # Water trapped = min(left_max, right_max) - current_height - # But only if positive (can't have negative water) - water = min(left_max[i], right_max[i]) - height[i] - if water > 0: - res += water - - return res -``` - -## 125. Valid Palindrome [Easy] -https://leetcode.com/problems/valid-palindrome/ - -### Explanation - -## 125. Valid Palindrome [Easy] - -https://leetcode.com/problems/valid-palindrome - -## Description -A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. - -Given a string `s`, return `true` *if it is a **palindrome**, or *`false`* otherwise.* - -**Examples** - -```tex -Example 1: -Input: s = "A man, a plan, a canal: Panama" -Output: true -Explanation: "amanaplanacanalpanama" is a palindrome. - -Example 2: -Input: s = "race a car" -Output: false -Explanation: "raceacar" is not a palindrome. - -Example 3: -Input: s = " " -Output: true -Explanation: s is an empty string "" after removing non-alphanumeric characters. -Since an empty string reads the same forward and backward, it is a palindrome. -``` - -**Constraints** -```tex -- 1 <= s.length <= 2 * 10^5 -- s consists only of printable ASCII characters -``` - -## Explanation - -### Strategy -Let's restate the problem: You're given a string that may contain letters, numbers, spaces, and punctuation marks. You need to determine if it's a palindrome after cleaning it up (removing non-alphanumeric characters and converting to lowercase). - -This is a **two-pointer problem** that involves string preprocessing and then checking for palindrome properties. - -**What is given?** A string that may contain various characters including letters, numbers, spaces, and punctuation. - -**What is being asked?** Determine if the cleaned string (only alphanumeric characters, all lowercase) is a palindrome. - -**Constraints:** The string can be up to 200,000 characters long and contains only printable ASCII characters. - -**Edge cases:** -- Empty string (should return true) -- String with only non-alphanumeric characters (should return true) -- Single character (should return true) -- String with mixed case and punctuation - -**High-level approach:** -The solution involves two main steps: -1. **Preprocessing**: Clean the string by removing non-alphanumeric characters and converting to lowercase -2. **Palindrome check**: Use two pointers to check if the cleaned string reads the same forward and backward - -**Decomposition:** -1. **Clean the string**: Remove all non-alphanumeric characters and convert to lowercase -2. **Initialize pointers**: Place one pointer at the start and one at the end -3. **Compare characters**: Move pointers inward while comparing characters -4. **Return result**: Return true if all characters match, false otherwise - -**Brute force vs. optimized strategy:** -- **Brute force**: Create a new cleaned string and then check if it equals its reverse. This takes O(n) time and O(n) space. -- **Optimized**: Use two pointers to check palindrome property in-place. This takes O(n) time and O(1) space. - -### Steps -Let's walk through the solution step by step using the first example: `s = "A man, a plan, a canal: Panama"` - -**Step 1: Preprocessing** -- Remove all non-alphanumeric characters: spaces, commas, colons -- Convert all letters to lowercase -- Result: `"amanaplanacanalpanama"` - -**Step 2: Initialize pointers** -- `left = 0` (points to the first character: 'a') -- `right = 24` (points to the last character: 'a') - -**Step 3: Compare characters** -- `s[left] = 'a'`, `s[right] = 'a'` -- `'a' == 'a'` ✓, so move both pointers inward -- `left = 1`, `right = 23` - -**Step 4: Continue comparison** -- `s[left] = 'm'`, `s[right] = 'm'` -- `'m' == 'm'` ✓, so move both pointers inward -- `left = 2`, `right = 22` - -**Step 5: Continue until pointers meet** -- Continue this process, comparing characters at both ends -- Move pointers inward after each successful comparison -- Stop when `left >= right` - -**Step 6: Check result** -- If we reach the middle without finding a mismatch, it's a palindrome -- In this case, all characters match, so return `true` - -**Why this works:** -A palindrome reads the same forward and backward. By using two pointers that start at opposite ends and move inward, we can efficiently check this property. If at any point the characters don't match, we know it's not a palindrome. If we reach the middle with all characters matching, it must be a palindrome. - -> **Note:** The key insight is that we don't need to create a new cleaned string. We can process the original string character by character, skipping non-alphanumeric characters and converting case on-the-fly. - -**Time Complexity:** O(n) - we process each character at most once -**Space Complexity:** O(1) - we only use a constant amount of extra space for the pointers - -### Solution - -```python -def isPalindrome(s): - """ - Check if a string is a palindrome after removing non-alphanumeric characters - and converting to lowercase. - - Args: - s: str - Input string that may contain various characters - - Returns: - bool - True if the cleaned string is a palindrome, False otherwise - """ - # Initialize two pointers - left = 0 - right = len(s) - 1 - - # Use two pointers to check palindrome property - while left < right: - # Skip non-alphanumeric characters from left - while left < right and not s[left].isalnum(): - left += 1 - - # Skip non-alphanumeric characters from right - while left < right and not s[right].isalnum(): - right -= 1 - - # If pointers haven't crossed, compare characters - if left < right: - # Convert to lowercase and compare - if s[left].lower() != s[right].lower(): - return False - - # Move pointers inward - left += 1 - right -= 1 - - # If we reach here, all characters matched - return True -``` - -## 289. Game of Life [Medium] -https://leetcode.com/problems/game-of-life/ - -### Explanation - -## 289. Game of Life [Medium] - -https://leetcode.com/problems/game-of-life - -## Description -According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." - -The board is made up of an `m x n` grid of cells, where each cell has an initial state: **live** (represented by a `1`) or **dead** (represented by a `0`). Each cell interacts with its [eight neighbors](https://en.wikipedia.org/wiki/Moore_neighborhood) (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article): - -1. Any live cell with fewer than two live neighbors dies as if caused by under-population. -2. Any live cell with two or three live neighbors lives on to the next generation. -3. Any live cell with more than three live neighbors dies, as if by over-population. -4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. - -The next state of the board is determined by applying the above rules simultaneously to every cell in the current state of the `m x n` grid `board`. In this process, births and deaths occur **simultaneously**. - -Given the current state of the `board`, **update** the `board` to reflect its next state. - -**Note** that you do not need to return anything. - -**Examples** - -```tex -Example 1: -Input: board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]] -Output: [[0,0,0],[1,0,1],[0,1,1],[0,1,0]] - -Example 2: -Input: board = [[1,1],[1,0]] -Output: [[1,1],[1,1]] -``` - -**Constraints** -```tex -- m == board.length -- n == board[i].length -- 1 <= m, n <= 25 -- board[i][j] is 0 or 1 -``` - -**Follow up:** -- Could you solve it in-place? Remember that the board needs to be updated simultaneously: You cannot update some cells first and then use their updated values to update other cells. -- In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches upon the border of the array (i.e., live cells reach the border). How would you address these problems? - -## Explanation - -### Strategy -Let's restate the problem: You're given a 2D grid representing the current state of Conway's Game of Life, where each cell is either alive (1) or dead (0). You need to update the board to the next generation based on specific rules about cell survival and reproduction. - -This is a **simulation problem** that requires careful handling to update all cells simultaneously without interfering with the calculation of other cells. - -**What is given?** An m x n grid where each cell is either 0 (dead) or 1 (live). - -**What is being asked?** Update the board to the next generation based on the Game of Life rules. - -**Constraints:** The grid can be up to 25x25, and all cells contain only 0 or 1. - -**Edge cases:** -- Grid with all dead cells -- Grid with all live cells -- Single row or column -- Grid with live cells on borders - -**High-level approach:** -The solution involves using a two-pass approach where we first mark cells with their next state using special values, then convert these markers to the final states. - -**Decomposition:** -1. **First pass**: Mark cells with their next state using special values (2 for live→dead, 3 for dead→live) -2. **Second pass**: Convert special values to final states (2→0, 3→1) -3. **Count neighbors**: For each cell, count its eight neighbors to determine its fate - -**Brute force vs. optimized strategy:** -- **Brute force**: Create a copy of the board and update it. This takes O(mn) space. -- **Optimized**: Use special values to mark next states in-place. This takes O(1) space. - -### Steps -Let's walk through the solution step by step using the first example: `board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]]` - -**Step 1: First pass - mark cells with next state** -- For each cell, count its eight neighbors -- Apply Game of Life rules and mark with special values: - - `2` = currently live, will die (live→dead) - - `3` = currently dead, will live (dead→live) - - `0` = currently dead, will stay dead - - `1` = currently live, will stay live - -**Step 2: Count neighbors for each cell** -- For cell `board[0][1] = 1` (live): - - Neighbors: `[0,0,1,0,0,1,1,1]` = 4 live neighbors - - Rule 3: More than 3 live neighbors → dies - - Mark as `2` (live→dead) - -- For cell `board[1][2] = 1` (live): - - Neighbors: `[1,0,1,1,1,0,0,0]` = 4 live neighbors - - Rule 3: More than 3 live neighbors → dies - - Mark as `2` (live→dead) - -**Step 3: Second pass - convert special values** -- Convert `2` → `0` (dead) -- Convert `3` → `1` (live) -- Final board: `[[0,0,0],[1,0,1],[0,1,1],[0,1,0]]` - -**Why this works:** -By using special values (2 and 3) to mark the next state, we can update the board in-place without losing information about the current state. The two-pass approach ensures all cells are updated simultaneously as required. - -> **Note:** The key insight is using special values to represent both current and next states, allowing us to solve the problem in-place while maintaining the requirement that all cells update simultaneously. - -**Time Complexity:** O(mn) - we visit each cell twice -**Space Complexity:** O(1) - we only use a constant amount of extra space - -### Solution - -```python -def gameOfLife(board): - """ - Update the board to the next generation of Conway's Game of Life. - This is done in-place using O(1) space. - - Args: - board: List[List[int]] - The board to update in-place - - Returns: - None - Modifies the board in-place - """ - if not board or not board[0]: - return - - m, n = len(board), len(board[0]) - - # First pass: mark cells with their next state using special values - # 2 = currently live, will die (live→dead) - # 3 = currently dead, will live (dead→live) - for i in range(m): - for j in range(n): - live_neighbors = countLiveNeighbors(board, i, j, m, n) - - if board[i][j] == 1: # Currently live - if live_neighbors < 2 or live_neighbors > 3: - board[i][j] = 2 # Mark as live→dead - else: # Currently dead - if live_neighbors == 3: - board[i][j] = 3 # Mark as dead→live - - # Second pass: convert special values to final states - for i in range(m): - for j in range(n): - if board[i][j] == 2: - board[i][j] = 0 # Convert live→dead to dead - elif board[i][j] == 3: - board[i][j] = 1 # Convert dead→live to live -``` - -## 290. Word Pattern [Easy] -https://leetcode.com/problems/word-pattern/ - -### Explanation - -## 290. Word Pattern [Easy] - -https://leetcode.com/problems/word-pattern - -## Description -Given a `pattern` and a string `s`, find if `s` follows the same pattern. - -Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`. Specifically: - -- Each letter in `pattern` maps to **exactly** one unique word in `s`. -- Each unique word in `s` maps to **exactly** one letter in `pattern`. -- No two letters map to the same word, and no two words map to the same letter. - -**Examples** - -```tex -Example 1: -Input: pattern = "abba", s = "dog cat cat dog" -Output: true -Explanation: -The bijection can be established as: -- 'a' maps to "dog". -- 'b' maps to "cat". - -Example 2: -Input: pattern = "abba", s = "dog cat cat fish" -Output: false - -Example 3: -Input: pattern = "aaaa", s = "dog cat cat dog" -Output: false -``` - -**Constraints** -```tex -- 1 <= pattern.length <= 300 -- pattern contains only lower-case English letters -- 1 <= s.length <= 3000 -- s contains only lowercase English letters and spaces ' ' -- s does not contain any leading or trailing spaces -- All the words in s are separated by a single space -``` - -## Explanation - -### Strategy -Let's restate the problem: You're given a pattern string (like "abba") and a string of words (like "dog cat cat dog"), and you need to determine if the words follow the same pattern. This means there should be a one-to-one mapping between letters in the pattern and words in the string. - -This is a **hash table problem** that requires tracking bidirectional mappings between pattern characters and words, similar to the isomorphic strings problem but with words instead of individual characters. - -**What is given?** A pattern string and a string of space-separated words. - -**What is being asked?** Determine if the words follow the same pattern as the given pattern string. - -**Constraints:** The pattern can be up to 300 characters, and the string can be up to 3000 characters with words separated by single spaces. - -**Edge cases:** -- Pattern and words have different lengths -- Empty pattern or empty string -- Pattern with repeated characters -- String with repeated words - -**High-level approach:** -The solution involves using two hash maps to track character-to-word and word-to-character mappings, ensuring that the bijection property is maintained. - -**Decomposition:** -1. **Split the string into words**: Convert the space-separated string into a list of words -2. **Check length consistency**: If pattern length doesn't match word count, return false -3. **Create mapping dictionaries**: Track character-to-word and word-to-character mappings -4. **Verify bijection**: Ensure each character maps to exactly one word and vice versa - -**Brute force vs. optimized strategy:** -- **Brute force**: Try all possible mappings. This is extremely inefficient. -- **Optimized**: Use hash tables to track mappings in a single pass. This takes O(n) time. - -### Steps -Let's walk through the solution step by step using the first example: `pattern = "abba"`, `s = "dog cat cat dog"` - -**Step 1: Split the string into words** -- `s = "dog cat cat dog"` -- `words = ["dog", "cat", "cat", "dog"]` - -**Step 2: Check length consistency** -- `pattern.length = 4` -- `words.length = 4` -- Lengths match ✓ - -**Step 3: Initialize mapping dictionaries** -- `char_to_word = {}` (maps pattern characters to words) -- `word_to_char = {}` (maps words to pattern characters) - -**Step 4: Check first character-word pair** -- `pattern[0] = 'a'`, `words[0] = "dog"` -- Check if 'a' is already mapped: No -- Check if "dog" is already mapped: No -- Add mappings: `char_to_word['a'] = "dog"`, `word_to_char["dog"] = 'a'` - -**Step 5: Check second character-word pair** -- `pattern[1] = 'b'`, `words[1] = "cat"` -- Check if 'b' is already mapped: No -- Check if "cat" is already mapped: No -- Add mappings: `char_to_word['b'] = "cat"`, `word_to_char["cat"] = 'b'` - -**Step 6: Check third character-word pair** -- `pattern[2] = 'b'`, `words[2] = "cat"` -- Check if 'b' is already mapped: Yes, to "cat" -- Verify consistency: `char_to_word['b'] == "cat"` ✓ -- Check if "cat" is already mapped: Yes, to 'b' -- Verify consistency: `word_to_char["cat"] == 'b'` ✓ - -**Step 7: Check fourth character-word pair** -- `pattern[3] = 'a'`, `words[3] = "dog"` -- Check if 'a' is already mapped: Yes, to "dog" -- Verify consistency: `char_to_word['a'] == "dog"` ✓ -- Check if "dog" is already mapped: Yes, to 'a' -- Verify consistency: `word_to_char["dog"] == 'a'` ✓ +- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. +- **Value Range:** Node values are between $-100$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Edge Case:** If the tree is empty (root is null), return 0. -**Step 8: Result** -- All character-word pairs are consistent -- Pattern is followed: `true` +**1.2 High-level approach:** -**Why this works:** -By maintaining mappings in both directions, we ensure that: -1. Each character in the pattern maps to exactly one word -2. Each word maps to exactly one character -3. The bijection property is maintained throughout the pattern +The goal is to find the maximum depth of a binary tree. -> **Note:** The key insight is using bidirectional mapping to ensure the bijection property. This is similar to the isomorphic strings problem but operates on words instead of individual characters. +![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) -**Time Complexity:** O(n) - we visit each character/word once -**Space Complexity:** O(k) - where k is the number of unique characters/words +We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. -### Solution +**1.3 Brute force vs. optimized strategy:** -```python -def wordPattern(pattern, s): - """ - Determine if the string s follows the given pattern. - - Args: - pattern: str - The pattern string to match against - s: str - The string of space-separated words - - Returns: - bool - True if s follows the pattern, False otherwise - """ - # Split the string into words - words = s.split() - - # Check if pattern length matches word count - if len(pattern) != len(words): - return False - - # Create mapping dictionaries for both directions - char_to_word = {} # maps pattern characters to words - word_to_char = {} # maps words to pattern characters - - # Check each character-word pair - for i in range(len(pattern)): - char = pattern[i] - word = words[i] - - # Check if char is already mapped - if char in char_to_word: - # Verify the mapping is consistent - if char_to_word[char] != word: - return False - else: - # Check if word is already mapped to by another character - if word in word_to_char: - return False - - # Add new mapping - char_to_word[char] = word - word_to_char[word] = char - - return True -``` +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. +- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. +- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. -## 242. Valid Anagram [Easy] -https://leetcode.com/problems/valid-anagram/ +**1.4 Decomposition:** -### Explanation +1. Base case: if the root is null, return 0. +2. Recursively find the maximum depth of the left subtree. +3. Recursively find the maximum depth of the right subtree. +4. Return 1 (for current node) plus the maximum of the two subtree depths. -Given two strings `s` and `t`, return `true` if `t` is an [anagram](https://en.wikipedia.org/wiki/Anagram) of `s`, and `false` otherwise. +### Steps (The "How") -**Examples** +**2.1 Initialization & Example Setup:** -```tex -Example 1: -Input: s = "anagram", t = "nagaram" -Output: true +Let's use the example: root = $[3,9,20,null,null,15,7]$ -Example 2: -Input: s = "rat", t = "car" -Output: false +The tree structure: ``` - -**Constraints** -```tex -- 1 <= s.length, t.length <= 5 * 10^4 -- s and t consist of lowercase English letters + 3 + / \ + 9 20 + / \ + 15 7 ``` -**Follow up:** What if the inputs contain Unicode characters? How would you adapt your solution to such a case? - -## Explanation - -### Strategy -Let's restate the problem: You're given two strings, and you need to determine if one is an anagram of the other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. - -This is a **character counting problem** that can be solved using hash tables to track the frequency of each character in both strings. - -**What is given?** Two strings `s` and `t` of potentially different lengths. - -**What is being asked?** Determine if `t` is an anagram of `s`. - -**Constraints:** The strings can be up to 50,000 characters long and contain only lowercase English letters. - -**Edge cases:** -- Strings of different lengths -- Empty strings -- Strings with repeated characters -- Strings with all identical characters - -**High-level approach:** -The solution involves counting the frequency of each character in both strings and comparing them. If the character counts match exactly, the strings are anagrams. - -**Decomposition:** -1. **Check length equality**: If strings have different lengths, they can't be anagrams -2. **Count characters in first string**: Use a hash table to track character frequencies -3. **Decrement counts for second string**: For each character in the second string, decrement its count -4. **Verify all counts are zero**: If any count is not zero, the strings are not anagrams - -**Brute force vs. optimized strategy:** -- **Brute force**: Try all possible permutations of one string. This takes O(n!) time. -- **Optimized**: Use character counting with hash tables. This takes O(n) time. - -### Steps -Let's walk through the solution step by step using the first example: `s = "anagram"`, `t = "nagaram"` - -**Step 1: Check string lengths** -- `s.length = 7`, `t.length = 7` -- Lengths match ✓ - -**Step 2: Initialize character count dictionary** -- `char_count = {}` - -**Step 3: Count characters in first string (s)** -- `s = "anagram"` -- `char_count['a'] = 3` (appears 3 times) -- `char_count['n'] = 1` (appears 1 time) -- `char_count['g'] = 1` (appears 1 time) -- `char_count['r'] = 1` (appears 1 time) -- `char_count['m'] = 1` (appears 1 time) - -**Step 4: Decrement counts for second string (t)** -- `t = "nagaram"` -- `t[0] = 'n'`: `char_count['n'] = 1 - 1 = 0` -- `t[1] = 'a'`: `char_count['a'] = 3 - 1 = 2` -- `t[2] = 'g'`: `char_count['g'] = 1 - 1 = 0` -- `t[3] = 'a'`: `char_count['a'] = 2 - 1 = 1` -- `t[4] = 'r'`: `char_count['r'] = 1 - 1 = 0` -- `t[5] = 'a'`: `char_count['a'] = 1 - 1 = 0` -- `t[6] = 'm'`: `char_count['m'] = 1 - 1 = 0` - -**Step 5: Verify all counts are zero** -- All character counts are now 0 -- The strings are anagrams: `true` - -**Why this works:** -By counting characters in the first string and then decrementing for the second string, we ensure that: -1. Both strings contain the same characters -2. Each character appears the same number of times in both strings -3. The final count of 0 for all characters confirms the anagram property - -> **Note:** The key insight is using character frequency counting to verify that both strings contain exactly the same characters with the same frequencies. This is much more efficient than trying to find permutations. - -**Time Complexity:** O(n) - we visit each character once in each string -**Space Complexity:** O(k) - where k is the number of unique characters (bounded by the character set size) - -### Solution - -```python -def isAnagram(s, t): - if len(s) != len(t): - return False - - char_count = {} - - for char in s: - char_count[char] = char_count.get(char, 0) + 1 - - for char in t: - if char not in char_count: - return False - - char_count[char] -= 1 - - # If count becomes negative, strings are not anagrams - if char_count[char] < 0: - return False - - # Check if all counts are zero - for count in char_count.values(): - if count != 0: - return False - - return True -``` +**2.2 Start Recursion:** -## 1. Two Sum [Easy] -https://leetcode.com/problems/two-sum/ +We begin from the root node (value 3). -### Explanation +**2.3 Trace Walkthrough:** -To solve the Two Sum problem, we want to find two numbers in the array that add up to a given target. The most efficient way is to use a hash map (dictionary) to store the numbers we have seen so far and their indices. As we iterate through the array, for each number, we check if the complement (target - current number) exists in the hash map. If it does, we have found the solution. Otherwise, we add the current number and its index to the hash map. This approach has O(n) time complexity. +| Node | Left Depth | Right Depth | Max Depth | Return Value | +|------|------------|--------------|-----------|--------------| +| 3 | ? | ? | - | Compute... | +| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | ? | ? | - | Compute... | +| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | +| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | -## Hint +**2.4 Recursion Flow:** -Try using a hash map to keep track of the numbers you have seen so far and their indices. +- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ +- Node 9: both children null, return $0 + 1 = 1$ +- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ -## Points +**2.5 Return Result:** -- Time complexity: O(n) using a hash map. -- Brute-force solution is O(n^2) and not efficient for large arrays. -- There is always exactly one solution, and you may not use the same element twice. -- Be careful with duplicate numbers in the array. +We return 3, which is the maximum depth of the tree. + +> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. ### Solution ```python -def two_sum(nums, target): - """Find two numbers that add up to target using a hash map for O(n) time complexity.""" - num_to_index = {} - for i, num in enumerate(nums): - complement = target - num - if complement in num_to_index: - return [num_to_index[complement], i] - num_to_index[num] = i - return [] +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def maxDepth(self, root) -> int: + if not root: + return 0 + + # Recursively find max depth of left and right subtrees + left_depth = self.maxDepth(root.left) + right_depth = self.maxDepth(root.right) + + # Return max depth plus 1 for current node + return max(left_depth, right_depth) + 1 ``` -## 128. Longest Consecutive Sequence [Medium] -https://leetcode.com/problems/longest-consecutive-sequence/ +## 108. Convert Sorted Array to Binary Search Tree [Easy] +https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ ### Explanation -## 128. Longest Consecutive Sequence [Medium] - -https://leetcode.com/problems/longest-consecutive-sequence - -## Description -Given an unsorted array of integers `nums`, return *the length of the longest consecutive elements sequence.* - -You must write an algorithm that runs in `O(n)` time. - -**Examples** +## Explanation -```tex -Example 1: -Input: nums = [100,4,200,1,3,2] -Output: 4 -Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. +### Strategy (The "Why") -Example 2: -Input: nums = [0,3,7,2,5,8,4,6,0,1] -Output: 9 +**1.1 Constraints & Complexity** -Example 3: -Input: nums = [1,0,1,2] -Output: 3 -``` +* **Input Size:** The array $nums$ has length $1 \leq n \leq 10^4$, with values in $[-10^4, 10^4]$. +* **Time Complexity:** $O(n)$ - We visit each element exactly once to build the tree. +* **Space Complexity:** $O(n)$ - The recursion stack depth is $O(\log n)$ for a balanced tree, and the tree itself uses $O(n)$ space. +* **Edge Case:** An empty array returns `None`. A single-element array creates a tree with one node. -**Constraints** -```tex -- 0 <= nums.length <= 10^5 -- -10^9 <= nums[i] <= 10^9 -``` +**1.2 High-level approach** -## Explanation +The goal is to convert a sorted array into a height-balanced binary search tree. We use the middle element as the root to ensure balance, then recursively build left and right subtrees. -### Strategy -Let's restate the problem: You're given an unsorted array of integers, and you need to find the length of the longest sequence of consecutive integers. The challenge is to do this in O(n) time, which means we can't sort the array (as sorting takes O(n log n) time). +![BST construction from sorted array showing how middle element becomes root] -This is a **hash table problem** that requires finding sequences of consecutive numbers efficiently by using the properties of consecutive sequences. +**1.3 Brute force vs. optimized strategy** -**What is given?** An unsorted array of integers that can be very large (up to 100,000 elements). +* **Brute Force:** Try all possible tree structures and check if they're balanced. This is exponential in complexity. +* **Optimized (Divide and Conquer):** Always choose the middle element as root, ensuring the tree is balanced. This achieves $O(n)$ time and creates an optimal height-balanced tree. -**What is being asked?** Find the length of the longest sequence of consecutive integers. +**1.4 Decomposition** -**Constraints:** The array can be up to 100,000 elements long, with values ranging from -10⁹ to 10⁹. +1. **Choose Root:** Select the middle element of the current range as the root. +2. **Build Left Subtree:** Recursively build BST from elements before the middle. +3. **Build Right Subtree:** Recursively build BST from elements after the middle. +4. **Return Root:** Connect subtrees and return the root node. -**Edge cases:** -- Empty array -- Array with single element -- Array with all identical elements -- Array with no consecutive sequences +### Steps (The "How") -**High-level approach:** -The solution involves using a hash set to quickly check if numbers exist, then for each number, expanding in both directions to find the complete consecutive sequence. +**2.1 Initialization & Example Setup** -**Decomposition:** -1. **Convert array to hash set**: For O(1) lookup time -2. **Find sequence starting points**: Look for numbers that are the start of a consecutive sequence -3. **Expand sequences**: For each starting point, expand in both directions to find the complete sequence -4. **Track maximum length**: Keep track of the longest sequence found +Let's use the example $nums = [-10,-3,0,5,9]$. -**Brute force vs. optimized strategy:** -- **Brute force**: Sort the array and find consecutive sequences. This takes O(n log n) time. -- **Optimized**: Use hash set and expand sequences from starting points. This takes O(n) time. +We initialize: +* `left = 0`, `right = 4` +* Middle index: $mid = (0 + 4) // 2 = 2$ -### Steps -Let's walk through the solution step by step using the first example: `nums = [100,4,200,1,3,2]` +**2.2 Start Building** -**Step 1: Convert array to hash set** -- `nums = [100,4,200,1,3,2]` -- `num_set = {100, 4, 200, 1, 3, 2}` +Root is `nums[2] = 0`. -**Step 2: Find sequence starting points** -- For each number, check if it's the start of a consecutive sequence -- A number is a starting point if `num - 1` is NOT in the set -- Starting points: `[100, 200, 1]` (because 99, 199, and 0 are not in the set) +**2.3 Trace Walkthrough** -**Step 3: Expand sequences from starting points** -- **Starting point 100**: - - Check if 101 exists: No - - Sequence length: 1 -- **Starting point 200**: - - Check if 201 exists: No - - Sequence length: 1 -- **Starting point 1**: - - Check if 2 exists: Yes - - Check if 3 exists: Yes - - Check if 4 exists: Yes - - Check if 5 exists: No - - Sequence: [1, 2, 3, 4] - - Sequence length: 4 +| Level | left | right | mid | nums[mid] | Left Range | Right Range | Action | +|-------|------|-------|-----|-----------|------------|-------------|--------| +| 0 | 0 | 4 | 2 | 0 | [0,1] | [3,4] | Create root(0) | +| 1 (left) | 0 | 1 | 0 | -10 | [0,-1] | [1,1] | Create left(-10) | +| 1 (right) | 3 | 4 | 3 | 5 | [3,2] | [4,4] | Create right(5) | +| 2 (left) | 1 | 1 | 1 | -3 | [1,0] | [1,1] | Create right(-3) | +| 2 (right) | 4 | 4 | 4 | 9 | [4,3] | [4,4] | Create right(9) | -**Step 4: Track maximum length** -- Maximum sequence length found: 4 -- Result: 4 +**2.4 Recursive Building** -**Why this works:** -By identifying starting points (numbers that don't have a predecessor in the set), we ensure that we only expand each sequence once. This gives us O(n) time complexity because: -1. We visit each number at most twice (once when checking if it's a starting point, once when expanding sequences) -2. Each number is part of at most one sequence -3. The total work is bounded by O(n) +For each recursive call: +1. If `left > right`, return `None` (base case) +2. Calculate `mid = (left + right) // 2` +3. Create root with `nums[mid]` +4. Recursively build left subtree: `build(left, mid - 1)` +5. Recursively build right subtree: `build(mid + 1, right)` -> **Note:** The key insight is identifying starting points of consecutive sequences and expanding from there. This avoids redundant work and ensures O(n) time complexity. +**2.5 Return Result** -**Time Complexity:** O(n) - we visit each number at most twice -**Space Complexity:** O(n) - we need to store the hash set +The function returns the root of the balanced BST: `[0,-10,5,null,-3,null,9]`. ### Solution ```python -def longestConsecutive(nums): - if not nums: - return 0 - - # Convert array to hash set for O(1) lookup - num_set = set(nums) - max_length = 0 - - # For each number, check if it's the start of a consecutive sequence - for num in num_set: - # A number is a starting point if num - 1 is NOT in the set - if num - 1 not in num_set: - current_length = 1 - current_num = num +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]: + def build(left, right): + if left > right: + return None - # Expand the sequence by checking consecutive numbers - while current_num + 1 in num_set: - current_length += 1 - current_num += 1 + # Choose middle element as root + mid = (left + right) // 2 + root = TreeNode(nums[mid]) - # Update maximum length if current sequence is longer - max_length = max(max_length, current_length) - - return max_length + # Recursively build left and right subtrees + root.left = build(left, mid - 1) + root.right = build(mid + 1, right) + + return root + + return build(0, len(nums) - 1) ``` -## 228. Summary Ranges [Easy] -https://leetcode.com/problems/summary-ranges/ +## 112. Path Sum [Easy] +https://leetcode.com/problems/path-sum/ ### Explanation -## 228. Summary Ranges [Easy] - -https://leetcode.com/problems/summary-ranges - -## Description -You are given a **sorted unique** integer array `nums`. - -A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). - -Return *the **smallest sorted** list of ranges that **cover all the numbers in the array exactly***. That is, each element of `nums` is covered by exactly one of the ranges, and there is no integer `x` such that `x` is in one of the ranges but not in `nums`. - -Each range `[a,b]` in the list should be output as: - -- `"a->b"` if `a != b` -- `"a"` if `a == b` +## Explanation -**Examples** +### Strategy (The "Why") -```tex -Example 1: -Input: nums = [0,1,2,4,5,7] -Output: ["0->2","4->5","7"] -Explanation: The ranges are: -[0,2] --> "0->2" -[4,5] --> "4->5" -[7,7] --> "7" +**1.1 Constraints & Complexity** -Example 2: -Input: nums = [0,2,3,4,6,8,9] -Output: ["0","2->4","6","8->9"] -Explanation: The ranges are: -[0,0] --> "0" -[2,4] --> "2->4" -[6,6] --> "6" -[8,9] --> "8->9" -``` +* **Input Size:** The tree has $0 \leq n \leq 5000$ nodes, with values in $[-1000, 1000]$. +* **Time Complexity:** $O(n)$ - We visit each node at most once in the worst case. +* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +* **Edge Case:** An empty tree returns `False`. A single-node tree returns `True` if the node value equals `targetSum`. -**Constraints** -```tex -- 0 <= nums.length <= 20 -- -2^31 <= nums[i] <= 2^31 - 1 -- All the values of nums are unique -- nums is sorted in ascending order -``` +**1.2 High-level approach** -## Explanation +The goal is to check if there exists a root-to-leaf path where the sum of node values equals `targetSum`. We traverse the tree recursively, subtracting each node's value from the remaining sum, and check if we reach a leaf with the correct sum. -### Strategy -Let's restate the problem: You're given a sorted array of unique integers, and you need to create a summary of consecutive ranges. The goal is to represent consecutive sequences as ranges (e.g., "0->2") and single numbers as themselves (e.g., "7"). +![Path sum visualization showing root-to-leaf paths and their sums] -This is an **array traversal problem** that requires identifying consecutive sequences and formatting them appropriately. +**1.3 Brute force vs. optimized strategy** -**What is given?** A sorted array of unique integers (up to 20 elements). +* **Brute Force:** Find all root-to-leaf paths, calculate their sums, then check if any equals `targetSum`. This requires storing all paths, using $O(n \times h)$ space. +* **Optimized (Recursive DFS):** Traverse the tree and check the sum incrementally. If we find a valid path, return immediately. This uses $O(h)$ space for recursion stack. -**What is being asked?** Create a list of ranges that cover all numbers exactly, representing consecutive sequences as ranges and single numbers as themselves. +**1.4 Decomposition** -**Constraints:** The array is small (up to 20 elements), sorted, and contains unique values. +1. **Base Case:** If node is `None`, return `False`. +2. **Leaf Check:** If node is a leaf, check if its value equals the remaining sum. +3. **Recursive Check:** Recursively check left and right subtrees with updated remaining sum. +4. **Return Result:** Return `True` if either subtree has a valid path. -**Edge cases:** -- Empty array -- Single element array -- Array with no consecutive sequences -- Array with all consecutive sequences +### Steps (The "How") -**High-level approach:** -The solution involves traversing the array and identifying consecutive sequences. When we find a break in the sequence, we format the range appropriately and continue. +**2.1 Initialization & Example Setup** -**Decomposition:** -1. **Handle edge cases**: Empty array returns empty list -2. **Initialize variables**: Track start of current range and result list -3. **Traverse array**: Look for consecutive sequences -4. **Format ranges**: Convert consecutive sequences to appropriate string format -5. **Handle final range**: Don't forget the last range when loop ends +Let's use the example $root = [5,4,8,11,null,13,4,7,2,null,null,null,1]$, $targetSum = 22$. -**Brute force vs. optimized strategy:** -- **Brute force**: Check each possible range combination. This is inefficient. -- **Optimized**: Single pass through the array, identifying consecutive sequences as we go. This takes O(n) time. +We start at the root node with value 5. -### Steps -Let's walk through the solution step by step using the first example: `nums = [0,1,2,4,5,7]` +**2.2 Start Checking** -**Step 1: Handle edge case** -- Array is not empty, continue +We call `hasPathSum(root, 22)`. -**Step 2: Initialize variables** -- `start = 0` (start of current range) -- `result = []` (list to store ranges) +**2.3 Trace Walkthrough** -**Step 3: Traverse array looking for consecutive sequences** -- `i = 0`: `nums[0] = 0` - - Start new range: `start = 0` -- `i = 1`: `nums[1] = 1` - - Check if consecutive: `1 == 0 + 1` ✓ - - Continue current range -- `i = 2`: `nums[2] = 2` - - Check if consecutive: `2 == 1 + 1` ✓ - - Continue current range -- `i = 3`: `nums[3] = 4` - - Check if consecutive: `4 == 2 + 1` ✗ - - Break in sequence! Format range [0,2] as "0->2" - - Add to result: `result = ["0->2"]` - - Start new range: `start = 3` -- `i = 4`: `nums[4] = 5` - - Check if consecutive: `5 == 4 + 1` ✓ - - Continue current range -- `i = 5`: `nums[5] = 7` - - Check if consecutive: `7 == 5 + 1` ✗ - - Break in sequence! Format range [4,5] as "4->5" - - Add to result: `result = ["0->2", "4->5"]` - - Start new range: `start = 5` +| Node | targetSum (before) | Is Leaf? | targetSum (after) | Left Result | Right Result | Final Result | +|------|-------------------|----------|-------------------|-------------|--------------|--------------| +| 5 | 22 | No | 17 | Check(4, 17) | Check(8, 17) | OR result | +| 4 | 17 | No | 13 | Check(11, 13) | None | OR result | +| 11 | 13 | No | 2 | Check(7, 2) | Check(2, 2) | OR result | +| 7 | 2 | Yes | -5 | - | - | False | +| 2 | 2 | Yes | 0 | - | - | **True** | -**Step 4: Handle final range** -- Loop ended, need to handle the last range [7,7] -- Since start == end (7 == 7), format as "7" -- Add to result: `result = ["0->2", "4->5", "7"]` +Since node 2 is a leaf and `2 == 2`, we return `True` for the path $5 \to 4 \to 11 \to 2$. -**Step 5: Return result** -- Final result: `["0->2","4->5","7"]` +**2.4 Recursive Processing** -**Why this works:** -By traversing the array once and checking for consecutive numbers, we can identify ranges efficiently. The key insights are: -1. A break in the sequence occurs when `nums[i] != nums[i-1] + 1` -2. Single numbers (where start == end) are formatted as "a" -3. Ranges (where start != end) are formatted as "a->b" +For each node: +1. If `not root`, return `False` +2. If leaf (`not root.left and not root.right`), return `root.val == targetSum` +3. Otherwise, recursively check: `hasPathSum(root.left, targetSum - root.val) or hasPathSum(root.right, targetSum - root.val)` -> **Note:** The key insight is identifying consecutive sequences by checking if each number is exactly one more than the previous number. This allows us to build ranges efficiently in a single pass. +**2.5 Return Result** -**Time Complexity:** O(n) - we visit each element once -**Space Complexity:** O(n) - we need to store the result list +The function returns `True` because there exists a path $5 \to 4 \to 11 \to 2$ with sum $5 + 4 + 11 + 2 = 22$. ### Solution ```python -def summaryRanges(nums): - """ - Create a summary of ranges from a sorted array of unique integers. - - Args: - nums: List[int] - Sorted array of unique integers +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: + if not root: + return False - Returns: - List[str] - List of range strings - """ - # Handle edge case - if not nums: - return [] - - result = [] - start = 0 - - # Traverse array looking for consecutive sequences - for i in range(1, len(nums)): - # Check if current number is consecutive to previous - if nums[i] != nums[i-1] + 1: - # Break in sequence, format the range - if start == i - 1: - # Single number - result.append(str(nums[start])) - else: - # Range of numbers - result.append(f"{nums[start]}->{nums[i-1]}") - - # Start new range - start = i - - # Handle the final range - if start == len(nums) - 1: - # Single number - result.append(str(nums[start])) - else: - # Range of numbers - result.append(f"{nums[start]}->{nums[-1]}") - - return result + # If leaf node, check if value equals remaining sum + if not root.left and not root.right: + return root.val == targetSum + + # Recursively check left and right subtrees + remaining = targetSum - root.val + return self.hasPathSum(root.left, remaining) or self.hasPathSum(root.right, remaining) ``` -## 155. Min Stack [Medium] -https://leetcode.com/problems/min-stack/ +## 125. Valid Palindrome [Easy] +https://leetcode.com/problems/valid-palindrome/ ### Explanation -## Explanation - -### Strategy (The "Why") +## 125. Valid Palindrome [Easy] -**1.1 Constraints & Complexity:** +https://leetcode.com/problems/valid-palindrome -- **Constraints:** Values are in the range $[-2^{31}, 2^{31} - 1]$. At most $3 \times 10^4$ operations will be performed. Operations are called on non-empty stacks. -- **Time Complexity:** $O(1)$ for all operations (push, pop, top, getMin). Each operation is constant time. -- **Space Complexity:** $O(n)$ where $n$ is the number of elements pushed. We maintain two stacks. -- **Edge Case:** If we push the same minimum value multiple times, we need to track all occurrences to handle pops correctly. +## Description +A phrase is a **palindrome** if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. -**1.2 High-level approach:** +Given a string `s`, return `true` *if it is a **palindrome**, or *`false`* otherwise.* -The goal is to design a stack that supports retrieving the minimum element in $O(1)$ time. We use two stacks: one for all elements and one to track minimum values. When pushing, if the new value is less than or equal to the current minimum, we also push it to the min stack. +**Examples** -**1.3 Brute force vs. optimized strategy:** +```tex +Example 1: +Input: s = "A man, a plan, a canal: Panama" +Output: true +Explanation: "amanaplanacanalpanama" is a palindrome. -- **Brute Force:** Store all elements and scan for minimum when `getMin()` is called. This is $O(n)$ time for `getMin()`. -- **Optimized Strategy:** Maintain a separate stack for minimum values. When pushing, if the value is $\leq$ current min, push to min stack. When popping, if the popped value equals the current min, pop from min stack. This gives $O(1)$ for all operations. -- **Why optimized is better:** The optimized strategy achieves $O(1)$ time for `getMin()` by trading a small amount of space for constant-time operations. +Example 2: +Input: s = "race a car" +Output: false +Explanation: "raceacar" is not a palindrome. -**1.4 Decomposition:** +Example 3: +Input: s = " " +Output: true +Explanation: s is an empty string "" after removing non-alphanumeric characters. +Since an empty string reads the same forward and backward, it is a palindrome. +``` -1. Maintain two stacks: `stack` for all elements and `min_stack` for minimum values. -2. `push(val)`: Push to `stack`. If `min_stack` is empty or `val <= min_stack[-1]`, push to `min_stack`. -3. `pop()`: Pop from `stack`. If the popped value equals `min_stack[-1]`, pop from `min_stack`. -4. `top()`: Return `stack[-1]`. -5. `getMin()`: Return `min_stack[-1]`. +**Constraints** +```tex +- 1 <= s.length <= 2 * 10^5 +- s consists only of printable ASCII characters +``` -### Steps (The "How") +## Explanation -**2.1 Initialization & Example Setup:** +### Strategy +Let's restate the problem: You're given a string that may contain letters, numbers, spaces, and punctuation marks. You need to determine if it's a palindrome after cleaning it up (removing non-alphanumeric characters and converting to lowercase). -Let's use the example: `["MinStack","push","push","push","getMin","pop","top","getMin"]` with values `[[],[-2],[0],[-3],[],[],[],[]]` +This is a **two-pointer problem** that involves string preprocessing and then checking for palindrome properties. -We initialize: -- `stack = []` -- `min_stack = []` +**What is given?** A string that may contain various characters including letters, numbers, spaces, and punctuation. -**2.2 Start Checking:** +**What is being asked?** Determine if the cleaned string (only alphanumeric characters, all lowercase) is a palindrome. -We perform each operation in sequence. +**Constraints:** The string can be up to 200,000 characters long and contains only printable ASCII characters. -**2.3 Trace Walkthrough:** +**Edge cases:** +- Empty string (should return true) +- String with only non-alphanumeric characters (should return true) +- Single character (should return true) +- String with mixed case and punctuation -| Operation | Value | stack | min_stack | Return | -|-----------|-------|-------|-----------|--------| -| push(-2) | -2 | [-2] | [-2] | - | -| push(0) | 0 | [-2,0] | [-2] | - | -| push(-3) | -3 | [-2,0,-3] | [-2,-3] | - | -| getMin() | - | [-2,0,-3] | [-2,-3] | -3 | -| pop() | - | [-2,0] | [-2] | - | -| top() | - | [-2,0] | [-2] | 0 | -| getMin() | - | [-2,0] | [-2] | -2 | +**High-level approach:** +The solution involves two main steps: +1. **Preprocessing**: Clean the string by removing non-alphanumeric characters and converting to lowercase +2. **Palindrome check**: Use two pointers to check if the cleaned string reads the same forward and backward -**2.4 Increment and Loop:** +**Decomposition:** +1. **Clean the string**: Remove all non-alphanumeric characters and convert to lowercase +2. **Initialize pointers**: Place one pointer at the start and one at the end +3. **Compare characters**: Move pointers inward while comparing characters +4. **Return result**: Return true if all characters match, false otherwise -- **push(val)**: - - `stack.append(val)` - - If `not min_stack or val <= min_stack[-1]`: `min_stack.append(val)` +**Brute force vs. optimized strategy:** +- **Brute force**: Create a new cleaned string and then check if it equals its reverse. This takes O(n) time and O(n) space. +- **Optimized**: Use two pointers to check palindrome property in-place. This takes O(n) time and O(1) space. -- **pop()**: - - `val = stack.pop()` - - If `val == min_stack[-1]`: `min_stack.pop()` +### Steps +Let's walk through the solution step by step using the first example: `s = "A man, a plan, a canal: Panama"` -**2.5 Return Result:** +**Step 1: Preprocessing** +- Remove all non-alphanumeric characters: spaces, commas, colons +- Convert all letters to lowercase +- Result: `"amanaplanacanalpanama"` -After all operations: -- `top()` returns `0` (the top element). -- `getMin()` returns `-2` (the minimum element in the remaining stack). +**Step 2: Initialize pointers** +- `left = 0` (points to the first character: 'a') +- `right = 24` (points to the last character: 'a') -The stack correctly maintains both the elements and the minimum value in $O(1)$ time for all operations. +**Step 3: Compare characters** +- `s[left] = 'a'`, `s[right] = 'a'` +- `'a' == 'a'` ✓, so move both pointers inward +- `left = 1`, `right = 23` -### Solution +**Step 4: Continue comparison** +- `s[left] = 'm'`, `s[right] = 'm'` +- `'m' == 'm'` ✓, so move both pointers inward +- `left = 2`, `right = 22` -```python -def __init__(self): - self.stack = [] - self.min_stack = [] +**Step 5: Continue until pointers meet** +- Continue this process, comparing characters at both ends +- Move pointers inward after each successful comparison +- Stop when `left >= right` - def push(self, val: int) -> None: - self.stack.append(val) - # Push to min_stack only if it's empty or val <= current min - if not self.min_stack or val <= self.min_stack[-1]: - self.min_stack.append(val) +**Step 6: Check result** +- If we reach the middle without finding a mismatch, it's a palindrome +- In this case, all characters match, so return `true` - def pop(self) -> None: - val = self.stack.pop() - # Pop from min_stack if the popped value is the current min - if val == self.min_stack[-1]: - self.min_stack.pop() +**Why this works:** +A palindrome reads the same forward and backward. By using two pointers that start at opposite ends and move inward, we can efficiently check this property. If at any point the characters don't match, we know it's not a palindrome. If we reach the middle with all characters matching, it must be a palindrome. - def top(self) -> int: - return self.stack[-1] +> **Note:** The key insight is that we don't need to create a new cleaned string. We can process the original string character by character, skipping non-alphanumeric characters and converting case on-the-fly. - def getMin(self) -> int: - return self.min_stack[-1] +**Time Complexity:** O(n) - we process each character at most once +**Space Complexity:** O(1) - we only use a constant amount of extra space for the pointers +### Solution -# Your MinStack object will be instantiated and called as such: -# obj = MinStack() -# obj.push(val) -# obj.pop() -# param_3 = obj.top() -# param_4 = obj.getMin() +```python +def isPalindrome(s): + """ + Check if a string is a palindrome after removing non-alphanumeric characters + and converting to lowercase. + + Args: + s: str - Input string that may contain various characters + + Returns: + bool - True if the cleaned string is a palindrome, False otherwise + """ + # Initialize two pointers + left = 0 + right = len(s) - 1 + + # Use two pointers to check palindrome property + while left < right: + # Skip non-alphanumeric characters from left + while left < right and not s[left].isalnum(): + left += 1 + + # Skip non-alphanumeric characters from right + while left < right and not s[right].isalnum(): + right -= 1 + + # If pointers haven't crossed, compare characters + if left < right: + # Convert to lowercase and compare + if s[left].lower() != s[right].lower(): + return False + + # Move pointers inward + left += 1 + right -= 1 + + # If we reach here, all characters matched + return True ``` ## 141. Linked List Cycle [Easy] @@ -1600,396 +890,702 @@ Step 4: slow = 2, fast = 2 (they meet!) Result: Return true (cycle detected) ``` -> **Note:** Floyd's Cycle-Finding Algorithm is optimal because it uses O(1) space and O(n) time. The mathematical proof shows that if there's a cycle, the fast pointer will eventually catch the slow pointer within one cycle length. - -**Time Complexity:** O(n) - in the worst case, you visit each node at most twice -**Space Complexity:** O(1) - you only use two pointers regardless of input size +> **Note:** Floyd's Cycle-Finding Algorithm is optimal because it uses O(1) space and O(n) time. The mathematical proof shows that if there's a cycle, the fast pointer will eventually catch the slow pointer within one cycle length. + +**Time Complexity:** O(n) - in the worst case, you visit each node at most twice +**Space Complexity:** O(1) - you only use two pointers regardless of input size + +### Solution + +```python +def __init__(self, x): +# self.val = x +# self.next = None +``` + +## 222. Count Complete Tree Nodes [Easy] +https://leetcode.com/problems/count-complete-tree-nodes/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** +- **Constraints:** The tree has 0 to 5*10^4 nodes and is guaranteed to be complete. +- **Time Complexity:** O(log² n) - We do O(log n) work at each level, and there are O(log n) levels. +- **Space Complexity:** O(log n) for the recursion stack. +- **Edge Case:** If the root is None, return 0. + +**1.2 High-level approach:** +The goal is to count nodes in a complete binary tree efficiently. We use the property that in a complete tree, we can check if subtrees are full by comparing left and right heights. + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Recursively count all nodes: O(n) time. +- **Optimized Strategy:** Use the complete tree property. If left and right heights are equal, the left subtree is full. Otherwise, the right subtree is full. This allows us to skip counting full subtrees. +- **Why optimized is better:** We avoid counting nodes in full subtrees, reducing time complexity to O(log² n). + +**1.4 Decomposition:** +1. Calculate the height of the left subtree by following left children. +2. Calculate the height of the right subtree by following left children from the right child. +3. If heights are equal, the left subtree is full (2^height - 1 nodes), so recursively count the right subtree. +4. If heights differ, the right subtree is full, so recursively count the left subtree. +5. Add 1 for the root and the full subtree size. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Example tree: `[1,2,3,4,5,6]` (complete binary tree with 6 nodes) + +Root = 1, left = 2, right = 3 + +**2.2 Start Checking:** +Calculate left height from root.left (node 2): follow left children → 4 → None, height = 2 +Calculate right height from root.right (node 3): follow left children → None, height = 0 + +**2.3 Trace Walkthrough:** + +| Node | Left Height | Right Height | Action | +|------|-------------|---------------|--------| +| 1 | 2 | 0 | Heights differ, right is full. Count = 2^0 + countNodes(left) | +| 2 | 1 | 0 | Heights differ, right is full. Count = 2^0 + countNodes(left) | +| 4 | 0 | 0 | Heights equal, left is full. Count = 2^0 + countNodes(right) | +| 5 | 0 | 0 | Base case, return 1 | + +**2.4 Increment and Loop:** +Recursively: +- If left_height == right_height: return (1 << left_height) + countNodes(right) +- Else: return (1 << right_height) + countNodes(left) + +**2.5 Return Result:** +Total count = 1 (root) + 1 (node 2) + 1 (node 4) + 1 (node 5) + 1 (node 3) + 1 (node 6) = 6 nodes. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def countNodes(self, root: Optional[TreeNode]) -> int: + if not root: + return 0 + + # Get left and right heights + left_height = self.get_height(root.left) + right_height = self.get_height(root.right) + + if left_height == right_height: + # Left subtree is full, right subtree may not be + return (1 << left_height) + self.countNodes(root.right) + else: + # Right subtree is full, left subtree may not be + return (1 << right_height) + self.countNodes(root.left) + + def get_height(self, node): + height = 0 + while node: + height += 1 + node = node.left + return height +``` + +## 226. Invert Binary Tree [Easy] +https://leetcode.com/problems/invert-binary-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** +- **Constraints:** The tree has 0 to 100 nodes, and node values range from -100 to 100. +- **Time Complexity:** O(n) where n is the number of nodes. We visit each node once. +- **Space Complexity:** O(h) where h is the height of the tree for the recursion stack. In worst case (skewed tree), this is O(n). +- **Edge Case:** If the root is None, return None. + +**1.2 High-level approach:** +The goal is to invert a binary tree by swapping left and right children at every node. We use recursion to process each node. + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Same recursive approach - there's no significantly different brute force method for this problem. +- **Optimized Strategy:** Use recursion to swap children at each node, then recursively invert the subtrees. +- **Why optimized is better:** This is the natural and most efficient approach for tree problems. + +**1.4 Decomposition:** +1. If the node is None, return None (base case). +2. Swap the left and right children of the current node. +3. Recursively invert the left subtree. +4. Recursively invert the right subtree. +5. Return the root. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Example tree: `[4,2,7,1,3,6,9]` + +``` + 4 + / \ + 2 7 + / \ / \ +1 3 6 9 +``` + +**2.2 Start Checking:** +Start from the root and recursively process each node. + +**2.3 Trace Walkthrough:** + +| Node | Before Swap | After Swap | Left Child | Right Child | +|------|------------|------------|------------|--------------| +| 4 | left=2, right=7 | left=7, right=2 | Invert 7 | Invert 2 | +| 7 | left=6, right=9 | left=9, right=6 | Invert 9 | Invert 6 | +| 2 | left=1, right=3 | left=3, right=1 | Invert 3 | Invert 1 | + +**2.4 Increment and Loop:** +For each node: +- Swap: `root.left, root.right = root.right, root.left` +- Recursively invert: `self.invertTree(root.left)`, `self.invertTree(root.right)` + +**2.5 Return Result:** +After inversion: +``` + 4 + / \ + 7 2 + / \ / \ +9 6 3 1 +``` + +Return the root node. ### Solution ```python -def __init__(self, x): -# self.val = x -# self.next = None +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + if not root: + return None + + # Swap left and right children + root.left, root.right = root.right, root.left + + # Recursively invert subtrees + self.invertTree(root.left) + self.invertTree(root.right) + + return root ``` -## 2. Add Two Numbers [Medium] -https://leetcode.com/problems/add-two-numbers/ +## 228. Summary Ranges [Easy] +https://leetcode.com/problems/summary-ranges/ ### Explanation -You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. - -You may assume the two numbers do not contain any leading zero, except the number 0 itself. - -Example: -```text -Input: l1 = [2,4,3], l2 = [5,6,4] -Output: [7,0,8] -Explanation: 342 + 465 = 807. - -Input: l1 = [0], l2 = [0] -Output: [0] - -Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] -Output: [8,9,9,9,0,0,0,1] -``` +## 228. Summary Ranges [Easy] -Constraints: -```text -The number of nodes in each linked list is in the range [1, 100]. -0 <= Node.val <= 9 -It is guaranteed that the list represents a number that does not have leading zeros. -``` +https://leetcode.com/problems/summary-ranges -## Explanation +## Description +You are given a **sorted unique** integer array `nums`. -The Add Two Numbers problem involves adding two numbers represented by linked lists, where each node contains a single digit and the digits are stored in reverse order. To solve this, we iterate through both linked lists, adding corresponding digits along with any carry from the previous addition. We create a new linked list to store the result. If one list is shorter, treat missing digits as 0. If there is a carry left after processing both lists, add a new node with the carry value. +A **range** `[a,b]` is the set of all integers from `a` to `b` (inclusive). -## Hint +Return *the **smallest sorted** list of ranges that **cover all the numbers in the array exactly***. That is, each element of `nums` is covered by exactly one of the ranges, and there is no integer `x` such that `x` is in one of the ranges but not in `nums`. -Use a dummy head node to simplify the code for building the result list. Remember to handle the carry at the end. +Each range `[a,b]` in the list should be output as: -## Points +- `"a->b"` if `a != b` +- `"a"` if `a == b` -- Time complexity: O(max(m, n)), where m and n are the lengths of the two lists. -- Handle different lengths of input lists. -- Don’t forget to add a node if there is a carry left after the main loop. -- Each node contains a single digit (0-9). +**Examples** -### Solution +```tex +Example 1: +Input: nums = [0,1,2,4,5,7] +Output: ["0->2","4->5","7"] +Explanation: The ranges are: +[0,2] --> "0->2" +[4,5] --> "4->5" +[7,7] --> "7" -```python -def __init__(self, val=0, next=None): - self.val = val - self.next = next +Example 2: +Input: nums = [0,2,3,4,6,8,9] +Output: ["0","2->4","6","8->9"] +Explanation: The ranges are: +[0,0] --> "0" +[2,4] --> "2->4" +[6,6] --> "6" +[8,9] --> "8->9" ``` -## 21. Merge Two Sorted Lists [Easy] -https://leetcode.com/problems/merge-two-sorted-lists/ - -### Explanation +**Constraints** +```tex +- 0 <= nums.length <= 20 +- -2^31 <= nums[i] <= 2^31 - 1 +- All the values of nums are unique +- nums is sorted in ascending order +``` ## Explanation -### Strategy (The "Why") - -Given two sorted linked lists `list1` and `list2`, we need to merge them into one sorted list and return the head of the merged list. +### Strategy +Let's restate the problem: You're given a sorted array of unique integers, and you need to create a summary of consecutive ranges. The goal is to represent consecutive sequences as ranges (e.g., "0->2") and single numbers as themselves (e.g., "7"). -**1.1 Constraints & Complexity:** +This is an **array traversal problem** that requires identifying consecutive sequences and formatting them appropriately. -- **Input Size:** The total number of nodes can be up to $50$. -- **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n + m)$ where $n$ and $m$ are the lengths of the two lists. We visit each node exactly once. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for the dummy node and pointers. -- **Edge Case:** If one list is empty, return the other list. If both are empty, return `null`. +**What is given?** A sorted array of unique integers (up to 20 elements). -**1.2 High-level approach:** +**What is being asked?** Create a list of ranges that cover all numbers exactly, representing consecutive sequences as ranges and single numbers as themselves. -The goal is to merge two sorted linked lists into one sorted list. +**Constraints:** The array is small (up to 20 elements), sorted, and contains unique values. -We use a dummy node to simplify edge cases and a current pointer to build the merged list. We compare nodes from both lists and attach the smaller one to the result, then move the pointer of the list we took from. +**Edge cases:** +- Empty array +- Single element array +- Array with no consecutive sequences +- Array with all consecutive sequences -**1.3 Brute force vs. optimized strategy:** +**High-level approach:** +The solution involves traversing the array and identifying consecutive sequences. When we find a break in the sequence, we format the range appropriately and continue. -- **Brute Force:** Convert both lists to arrays, merge the arrays, then convert back to a linked list. This takes $O(n + m)$ time and $O(n + m)$ space. -- **Optimized Strategy (Two Pointers):** Use two pointers to traverse both lists simultaneously, building the merged list in-place. This takes $O(n + m)$ time and $O(1)$ space. -- **Why it's better:** The two-pointer approach uses $O(1)$ extra space instead of $O(n + m)$ for arrays, while maintaining the same time complexity. +**Decomposition:** +1. **Handle edge cases**: Empty array returns empty list +2. **Initialize variables**: Track start of current range and result list +3. **Traverse array**: Look for consecutive sequences +4. **Format ranges**: Convert consecutive sequences to appropriate string format +5. **Handle final range**: Don't forget the last range when loop ends -**1.4 Decomposition:** +**Brute force vs. optimized strategy:** +- **Brute force**: Check each possible range combination. This is inefficient. +- **Optimized**: Single pass through the array, identifying consecutive sequences as we go. This takes O(n) time. -1. Create a dummy node to simplify edge cases. -2. Initialize a current pointer at the dummy node. -3. While both lists have nodes, compare the values and attach the smaller node to the result. -4. Move the pointer of the list we took from. -5. Attach the remaining nodes from the non-empty list. -6. Return the head of the merged list (dummy.next). +### Steps +Let's walk through the solution step by step using the first example: `nums = [0,1,2,4,5,7]` -### Steps (The "How") +**Step 1: Handle edge case** +- Array is not empty, continue -**2.1 Initialization & Example Setup:** +**Step 2: Initialize variables** +- `start = 0` (start of current range) +- `result = []` (list to store ranges) -Let's use the example: $list1 = [1,2,4]$, $list2 = [1,3,4]$ +**Step 3: Traverse array looking for consecutive sequences** +- `i = 0`: `nums[0] = 0` + - Start new range: `start = 0` +- `i = 1`: `nums[1] = 1` + - Check if consecutive: `1 == 0 + 1` ✓ + - Continue current range +- `i = 2`: `nums[2] = 2` + - Check if consecutive: `2 == 1 + 1` ✓ + - Continue current range +- `i = 3`: `nums[3] = 4` + - Check if consecutive: `4 == 2 + 1` ✗ + - Break in sequence! Format range [0,2] as "0->2" + - Add to result: `result = ["0->2"]` + - Start new range: `start = 3` +- `i = 4`: `nums[4] = 5` + - Check if consecutive: `5 == 4 + 1` ✓ + - Continue current range +- `i = 5`: `nums[5] = 7` + - Check if consecutive: `7 == 5 + 1` ✗ + - Break in sequence! Format range [4,5] as "4->5" + - Add to result: `result = ["0->2", "4->5"]` + - Start new range: `start = 5` -We initialize: -- `dummy = ListNode(0)` -- `current = dummy` +**Step 4: Handle final range** +- Loop ended, need to handle the last range [7,7] +- Since start == end (7 == 7), format as "7" +- Add to result: `result = ["0->2", "4->5", "7"]` -**2.2 Start Merging:** +**Step 5: Return result** +- Final result: `["0->2","4->5","7"]` -We begin comparing nodes from both lists. +**Why this works:** +By traversing the array once and checking for consecutive numbers, we can identify ranges efficiently. The key insights are: +1. A break in the sequence occurs when `nums[i] != nums[i-1] + 1` +2. Single numbers (where start == end) are formatted as "a" +3. Ranges (where start != end) are formatted as "a->b" -**2.3 Trace Walkthrough:** +> **Note:** The key insight is identifying consecutive sequences by checking if each number is exactly one more than the previous number. This allows us to build ranges efficiently in a single pass. -| Step | list1.val | list2.val | Compare | Attach | current.next | list1/list2 After | -|------|-----------|-----------|---------|--------|--------------|-------------------| -| 1 | 1 | 1 | Equal | list1 | 1 | list1 = 2 | -| 2 | 2 | 1 | 2 > 1 | list2 | 1 | list2 = 3 | -| 3 | 2 | 3 | 2 < 3 | list1 | 2 | list1 = 4 | -| 4 | 4 | 3 | 4 > 3 | list2 | 3 | list2 = 4 | -| 5 | 4 | 4 | Equal | list1 | 4 | list1 = null | -| 6 | null | 4 | - | list2 | 4 | list2 = null | +**Time Complexity:** O(n) - we visit each element once +**Space Complexity:** O(n) - we need to store the result list -**2.4 Final Result:** +### Solution -After merging: $[1,1,2,3,4,4]$ +```python +def summaryRanges(nums): + """ + Create a summary of ranges from a sorted array of unique integers. + + Args: + nums: List[int] - Sorted array of unique integers + + Returns: + List[str] - List of range strings + """ + # Handle edge case + if not nums: + return [] + + result = [] + start = 0 + + # Traverse array looking for consecutive sequences + for i in range(1, len(nums)): + # Check if current number is consecutive to previous + if nums[i] != nums[i-1] + 1: + # Break in sequence, format the range + if start == i - 1: + # Single number + result.append(str(nums[start])) + else: + # Range of numbers + result.append(f"{nums[start]}->{nums[i-1]}") + + # Start new range + start = i + + # Handle the final range + if start == len(nums) - 1: + # Single number + result.append(str(nums[start])) + else: + # Range of numbers + result.append(f"{nums[start]}->{nums[-1]}") + + return result +``` -**2.5 Return Result:** +## 242. Valid Anagram [Easy] +https://leetcode.com/problems/valid-anagram/ -We return the head of the merged list: $[1,1,2,3,4,4]$ +### Explanation -> **Note:** The dummy node simplifies the code by providing a starting point. Without it, we'd need special handling for the first node. The key is to always attach the smaller node and move the corresponding pointer forward. +Given two strings `s` and `t`, return `true` if `t` is an [anagram](https://en.wikipedia.org/wiki/Anagram) of `s`, and `false` otherwise. -### Solution +**Examples** -```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next +```tex +Example 1: +Input: s = "anagram", t = "nagaram" +Output: true -class Solution: - def mergeTwoLists(self, list1, list2): - # Create a dummy node to simplify edge cases - dummy = ListNode(0) - current = dummy - - # Merge while both lists have nodes - while list1 and list2: - if list1.val <= list2.val: - current.next = list1 - list1 = list1.next - else: - current.next = list2 - list2 = list2.next - current = current.next - - # Append remaining nodes - current.next = list1 if list1 else list2 - - return dummy.next +Example 2: +Input: s = "rat", t = "car" +Output: false ``` -## 138. Copy List with Random Pointer [Medium] -https://leetcode.com/problems/copy-list-with-random-pointer/ +**Constraints** +```tex +- 1 <= s.length, t.length <= 5 * 10^4 +- s and t consist of lowercase English letters +``` -### Explanation +**Follow up:** What if the inputs contain Unicode characters? How would you adapt your solution to such a case? ## Explanation -### Strategy (The "Why") +### Strategy +Let's restate the problem: You're given two strings, and you need to determine if one is an anagram of the other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. -**1.1 Constraints & Complexity:** +This is a **character counting problem** that can be solved using hash tables to track the frequency of each character in both strings. -- **Constraints:** $0 \leq n \leq 1000$ nodes. Node values are in the range $[-10^4, 10^4]$. Random pointers can point to any node or `None`. -- **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We make two passes through the list. -- **Space Complexity:** $O(n)$ for the hash map storing original-to-clone node mappings. -- **Edge Case:** If the list is empty (`head` is `None`), return `None`. +**What is given?** Two strings `s` and `t` of potentially different lengths. -**1.2 High-level approach:** +**What is being asked?** Determine if `t` is an anagram of `s`. -The goal is to create a deep copy of the linked list where each node has both `next` and `random` pointers. We use a hash map to store mappings from original nodes to cloned nodes, then set up the pointers in a second pass. +**Constraints:** The strings can be up to 50,000 characters long and contain only lowercase English letters. -**1.3 Brute force vs. optimized strategy:** +**Edge cases:** +- Strings of different lengths +- Empty strings +- Strings with repeated characters +- Strings with all identical characters -- **Brute Force:** Create all nodes first, then try to set random pointers. This is complex because random pointers can point to nodes we haven't created yet. -- **Optimized Strategy:** Two-pass approach: first pass creates all nodes and stores mappings, second pass sets `next` and `random` pointers using the map. This is $O(n)$ time and $O(n)$ space. -- **Why optimized is better:** The two-pass approach cleanly separates node creation from pointer setup, making the logic straightforward. +**High-level approach:** +The solution involves counting the frequency of each character in both strings and comparing them. If the character counts match exactly, the strings are anagrams. -**1.4 Decomposition:** +**Decomposition:** +1. **Check length equality**: If strings have different lengths, they can't be anagrams +2. **Count characters in first string**: Use a hash table to track character frequencies +3. **Decrement counts for second string**: For each character in the second string, decrement its count +4. **Verify all counts are zero**: If any count is not zero, the strings are not anagrams -1. Create a hash map to store mappings from original nodes to cloned nodes. -2. First pass: traverse the list and create a clone of each node, storing the mapping. -3. Second pass: traverse the list again and set `next` and `random` pointers for each clone using the map. -4. Return the cloned head node. +**Brute force vs. optimized strategy:** +- **Brute force**: Try all possible permutations of one string. This takes O(n!) time. +- **Optimized**: Use character counting with hash tables. This takes O(n) time. -### Steps (The "How") +### Steps +Let's walk through the solution step by step using the first example: `s = "anagram"`, `t = "nagaram"` -**2.1 Initialization & Example Setup:** +**Step 1: Check string lengths** +- `s.length = 7`, `t.length = 7` +- Lengths match ✓ -Let's use the example: `head = [[7,null],[13,0],[11,4],[10,2],[1,0]]` +**Step 2: Initialize character count dictionary** +- `char_count = {}` -This represents: -- Node 0: value 7, random = null -- Node 1: value 13, random = node 0 -- Node 2: value 11, random = node 4 -- Node 3: value 10, random = node 2 -- Node 4: value 1, random = node 0 +**Step 3: Count characters in first string (s)** +- `s = "anagram"` +- `char_count['a'] = 3` (appears 3 times) +- `char_count['n'] = 1` (appears 1 time) +- `char_count['g'] = 1` (appears 1 time) +- `char_count['r'] = 1` (appears 1 time) +- `char_count['m'] = 1` (appears 1 time) -We initialize `node_map = {}`. +**Step 4: Decrement counts for second string (t)** +- `t = "nagaram"` +- `t[0] = 'n'`: `char_count['n'] = 1 - 1 = 0` +- `t[1] = 'a'`: `char_count['a'] = 3 - 1 = 2` +- `t[2] = 'g'`: `char_count['g'] = 1 - 1 = 0` +- `t[3] = 'a'`: `char_count['a'] = 2 - 1 = 1` +- `t[4] = 'r'`: `char_count['r'] = 1 - 1 = 0` +- `t[5] = 'a'`: `char_count['a'] = 1 - 1 = 0` +- `t[6] = 'm'`: `char_count['m'] = 1 - 1 = 0` -**2.2 Start Checking:** +**Step 5: Verify all counts are zero** +- All character counts are now 0 +- The strings are anagrams: `true` -We perform two passes: first to create nodes, second to set pointers. +**Why this works:** +By counting characters in the first string and then decrementing for the second string, we ensure that: +1. Both strings contain the same characters +2. Each character appears the same number of times in both strings +3. The final count of 0 for all characters confirms the anagram property -**2.3 Trace Walkthrough:** +> **Note:** The key insight is using character frequency counting to verify that both strings contain exactly the same characters with the same frequencies. This is much more efficient than trying to find permutations. -**First pass (create nodes):** +**Time Complexity:** O(n) - we visit each character once in each string +**Space Complexity:** O(k) - where k is the number of unique characters (bounded by the character set size) -| Original Node | Value | Clone Created | node_map | -|---------------|-------|---------------|----------| -| Node 0 | 7 | Clone(7) | {Node0: Clone(7)} | -| Node 1 | 13 | Clone(13) | {Node0: Clone(7), Node1: Clone(13)} | -| Node 2 | 11 | Clone(11) | {Node0: Clone(7), Node1: Clone(13), Node2: Clone(11)} | -| Node 3 | 10 | Clone(10) | {Node0: Clone(7), Node1: Clone(13), Node2: Clone(11), Node3: Clone(10)} | -| Node 4 | 1 | Clone(1) | {Node0: Clone(7), ..., Node4: Clone(1)} | +### Solution -**Second pass (set pointers):** +```python +def isAnagram(s, t): + if len(s) != len(t): + return False + + char_count = {} + + for char in s: + char_count[char] = char_count.get(char, 0) + 1 + + for char in t: + if char not in char_count: + return False + + char_count[char] -= 1 + + # If count becomes negative, strings are not anagrams + if char_count[char] < 0: + return False + + # Check if all counts are zero + for count in char_count.values(): + if count != 0: + return False + + return True +``` -| Original Node | next points to | random points to | Clone's next | Clone's random | -|---------------|----------------|------------------|--------------|----------------| -| Node 0 | Node 1 | null | Clone(13) | null | -| Node 1 | Node 2 | Node 0 | Clone(11) | Clone(7) | -| Node 2 | Node 3 | Node 4 | Clone(10) | Clone(1) | -| Node 3 | Node 4 | Node 2 | Clone(1) | Clone(11) | -| Node 4 | null | Node 0 | null | Clone(7) | +## 290. Word Pattern [Easy] +https://leetcode.com/problems/word-pattern/ -**2.4 Increment and Loop:** +### Explanation -- First pass: `while curr: node_map[curr] = Node(curr.val); curr = curr.next` -- Second pass: `while curr: node_map[curr].next = node_map.get(curr.next); node_map[curr].random = node_map.get(curr.random); curr = curr.next` +## 290. Word Pattern [Easy] -**2.5 Return Result:** +https://leetcode.com/problems/word-pattern -We return `node_map[head]`, which is the cloned head node. The entire list structure is cloned with all `next` and `random` pointers correctly set. +## Description +Given a `pattern` and a string `s`, find if `s` follows the same pattern. -### Solution +Here **follow** means a full match, such that there is a bijection between a letter in `pattern` and a **non-empty** word in `s`. Specifically: -```python -def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): - self.val = int(x) - self.next = next - self.random = random -""" +- Each letter in `pattern` maps to **exactly** one unique word in `s`. +- Each unique word in `s` maps to **exactly** one letter in `pattern`. +- No two letters map to the same word, and no two words map to the same letter. -class Solution: - def copyRandomList(self, head: 'Optional[Node]') -> 'Optional[Node]': - if not head: - return None - - # First pass: create new nodes and map old to new - node_map = {} - curr = head - - while curr: - node_map[curr] = Node(curr.val) - curr = curr.next - - # Second pass: set next and random pointers - curr = head - while curr: - if curr.next: - node_map[curr].next = node_map[curr.next] - if curr.random: - node_map[curr].random = node_map[curr.random] - curr = curr.next - - return node_map[head] -``` +**Examples** -## 92. Reverse Linked List II [Medium] -https://leetcode.com/problems/reverse-linked-list-ii/ +```tex +Example 1: +Input: pattern = "abba", s = "dog cat cat dog" +Output: true +Explanation: +The bijection can be established as: +- 'a' maps to "dog". +- 'b' maps to "cat". -### Explanation +Example 2: +Input: pattern = "abba", s = "dog cat cat fish" +Output: false -## Explanation +Example 3: +Input: pattern = "aaaa", s = "dog cat cat dog" +Output: false +``` -### Strategy (The "Why") +**Constraints** +```tex +- 1 <= pattern.length <= 300 +- pattern contains only lower-case English letters +- 1 <= s.length <= 3000 +- s contains only lowercase English letters and spaces ' ' +- s does not contain any leading or trailing spaces +- All the words in s are separated by a single space +``` -**1.1 Constraints & Complexity** +## Explanation -* **Input Size:** The linked list has $n$ nodes where $1 \leq n \leq 500$, and $1 \leq left \leq right \leq n$. -* **Time Complexity:** $O(n)$ - We traverse the list once to find the reversal segment, then reverse it in-place. -* **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -* **Edge Case:** If $left == right$, no reversal is needed, return the list as is. +### Strategy +Let's restate the problem: You're given a pattern string (like "abba") and a string of words (like "dog cat cat dog"), and you need to determine if the words follow the same pattern. This means there should be a one-to-one mapping between letters in the pattern and words in the string. -**1.2 High-level approach** +This is a **hash table problem** that requires tracking bidirectional mappings between pattern characters and words, similar to the isomorphic strings problem but with words instead of individual characters. -The goal is to reverse a specific segment of a linked list from position $left$ to position $right$, while keeping the rest of the list unchanged. We use a dummy node to handle the case when reversal starts at the head. +**What is given?** A pattern string and a string of space-separated words. -![Linked list partial reversal showing how nodes are reversed in a segment] +**What is being asked?** Determine if the words follow the same pattern as the given pattern string. -**1.3 Brute force vs. optimized strategy** +**Constraints:** The pattern can be up to 300 characters, and the string can be up to 3000 characters with words separated by single spaces. -* **Brute Force:** Convert the linked list to an array, reverse the segment, then rebuild the list. This uses $O(n)$ extra space. -* **Optimized (In-Place Reversal):** Use pointer manipulation to reverse the segment in-place. We find the segment boundaries, then reverse nodes one by one. This uses $O(1)$ extra space. +**Edge cases:** +- Pattern and words have different lengths +- Empty pattern or empty string +- Pattern with repeated characters +- String with repeated words -**1.4 Decomposition** +**High-level approach:** +The solution involves using two hash maps to track character-to-word and word-to-character mappings, ensuring that the bijection property is maintained. -1. Create a dummy node to handle edge cases. -2. Move to the node before the reversal segment. -3. Reverse the segment by adjusting pointers iteratively. -4. Connect the reversed segment back to the list. +**Decomposition:** +1. **Split the string into words**: Convert the space-separated string into a list of words +2. **Check length consistency**: If pattern length doesn't match word count, return false +3. **Create mapping dictionaries**: Track character-to-word and word-to-character mappings +4. **Verify bijection**: Ensure each character maps to exactly one word and vice versa -### Steps (The "How") +**Brute force vs. optimized strategy:** +- **Brute force**: Try all possible mappings. This is extremely inefficient. +- **Optimized**: Use hash tables to track mappings in a single pass. This takes O(n) time. -**2.1 Initialization & Example Setup** +### Steps +Let's walk through the solution step by step using the first example: `pattern = "abba"`, `s = "dog cat cat dog"` -Let's use the example $head = [1,2,3,4,5]$, $left = 2$, $right = 4$. +**Step 1: Split the string into words** +- `s = "dog cat cat dog"` +- `words = ["dog", "cat", "cat", "dog"]` -We initialize: -* `dummy = ListNode(0)` with `dummy.next = head` -* `prev = dummy` (will point to node before reversal segment) +**Step 2: Check length consistency** +- `pattern.length = 4` +- `words.length = 4` +- Lengths match ✓ -**2.2 Start Processing** +**Step 3: Initialize mapping dictionaries** +- `char_to_word = {}` (maps pattern characters to words) +- `word_to_char = {}` (maps words to pattern characters) -We move `prev` to position $left - 1$ (node with value 1). +**Step 4: Check first character-word pair** +- `pattern[0] = 'a'`, `words[0] = "dog"` +- Check if 'a' is already mapped: No +- Check if "dog" is already mapped: No +- Add mappings: `char_to_word['a'] = "dog"`, `word_to_char["dog"] = 'a'` -**2.3 Trace Walkthrough** +**Step 5: Check second character-word pair** +- `pattern[1] = 'b'`, `words[1] = "cat"` +- Check if 'b' is already mapped: No +- Check if "cat" is already mapped: No +- Add mappings: `char_to_word['b'] = "cat"`, `word_to_char["cat"] = 'b'` -| Step | prev | curr | next_node | List State | -|------|------|------|-----------|------------| -| Initial | node(0) | node(1) | - | [0,1,2,3,4,5] | -| Move prev | node(1) | node(2) | - | [0,1,2,3,4,5] | -| Reverse 1 | node(1) | node(2) | node(3) | [0,1,3,2,4,5] | -| Reverse 2 | node(1) | node(2) | node(4) | [0,1,4,3,2,5] | +**Step 6: Check third character-word pair** +- `pattern[2] = 'b'`, `words[2] = "cat"` +- Check if 'b' is already mapped: Yes, to "cat" +- Verify consistency: `char_to_word['b'] == "cat"` ✓ +- Check if "cat" is already mapped: Yes, to 'b' +- Verify consistency: `word_to_char["cat"] == 'b'` ✓ -After reversal: `[1,4,3,2,5]` (segment [2,3,4] reversed to [4,3,2]). +**Step 7: Check fourth character-word pair** +- `pattern[3] = 'a'`, `words[3] = "dog"` +- Check if 'a' is already mapped: Yes, to "dog" +- Verify consistency: `char_to_word['a'] == "dog"` ✓ +- Check if "dog" is already mapped: Yes, to 'a' +- Verify consistency: `word_to_char["dog"] == 'a'` ✓ -**2.4 Increment and Loop** +**Step 8: Result** +- All character-word pairs are consistent +- Pattern is followed: `true` -For each iteration in the reversal loop: -1. Save `next_node = curr.next` -2. Set `curr.next = next_node.next` (skip next_node) -3. Set `next_node.next = prev.next` (insert next_node at start) -4. Set `prev.next = next_node` (update prev's next) +**Why this works:** +By maintaining mappings in both directions, we ensure that: +1. Each character in the pattern maps to exactly one word +2. Each word maps to exactly one character +3. The bijection property is maintained throughout the pattern -**2.5 Return Result** +> **Note:** The key insight is using bidirectional mapping to ensure the bijection property. This is similar to the isomorphic strings problem but operates on words instead of individual characters. -After reversal, `dummy.next` points to the modified list: `[1,4,3,2,5]`. +**Time Complexity:** O(n) - we visit each character/word once +**Space Complexity:** O(k) - where k is the number of unique characters/words ### Solution ```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next -class Solution: - def reverseBetween(self, head: Optional[ListNode], left: int, right: int) -> Optional[ListNode]: - if not head or left == right: - return head - - # Create dummy node to handle edge case when left = 1 - dummy = ListNode(0) - dummy.next = head - prev = dummy - - # Move to the node before the reversal starts - for _ in range(left - 1): - prev = prev.next +def wordPattern(pattern, s): + """ + Determine if the string s follows the given pattern. + + Args: + pattern: str - The pattern string to match against + s: str - The string of space-separated words - # Reverse the segment - curr = prev.next - for _ in range(right - left): - next_node = curr.next - curr.next = next_node.next - next_node.next = prev.next - prev.next = next_node + Returns: + bool - True if s follows the pattern, False otherwise + """ + # Split the string into words + words = s.split() + + # Check if pattern length matches word count + if len(pattern) != len(words): + return False + + # Create mapping dictionaries for both directions + char_to_word = {} # maps pattern characters to words + word_to_char = {} # maps words to pattern characters + + # Check each character-word pair + for i in range(len(pattern)): + char = pattern[i] + word = words[i] - return dummy.next + # Check if char is already mapped + if char in char_to_word: + # Verify the mapping is consistent + if char_to_word[char] != word: + return False + else: + # Check if word is already mapped to by another character + if word in word_to_char: + return False + + # Add new mapping + char_to_word[char] = word + word_to_char[word] = char + + return True ``` -## 25. Reverse Nodes in k-Group [Hard] -https://leetcode.com/problems/reverse-nodes-in-k-group/ +## 530. Minimum Absolute Difference in BST [Easy] +https://leetcode.com/problems/minimum-absolute-difference-in-bst/ ### Explanation @@ -1997,127 +1593,74 @@ https://leetcode.com/problems/reverse-nodes-in-k-group/ ### Strategy (The "Why") -**1.1 Constraints & Complexity** - -* **Input Size:** The linked list has $n$ nodes where $1 \leq k \leq n \leq 5000$. -* **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We visit each node exactly once. -* **Space Complexity:** $O(n/k)$ for the recursion stack, which is $O(n)$ in the worst case when $k = 1$. -* **Edge Case:** If the number of nodes is not a multiple of $k$, the remaining nodes at the end stay in their original order. - -**1.2 High-level approach** - -The goal is to reverse nodes in groups of $k$. We reverse each group of $k$ nodes, then recursively process the remaining list. If there are fewer than $k$ nodes remaining, we leave them unchanged. - -![Linked list reversal in groups showing how k nodes are reversed at a time] - -**1.3 Brute force vs. optimized strategy** +**1.1 Constraints & Complexity:** +- **Input Size:** `2 <= nodes <= 10^4`, `0 <= Node.val <= 10^5`. +- **Time Complexity:** O(n) - we traverse the tree once to collect values. +- **Space Complexity:** O(n) - we store all node values. +- **Edge Case:** Tree with only two nodes. -* **Brute Force:** Convert the linked list to an array, reverse groups in the array, then rebuild the list. This uses $O(n)$ extra space. -* **Optimized (In-Place Reversal):** Reverse groups of $k$ nodes in-place using pointer manipulation. This uses $O(1)$ extra space (excluding recursion stack) and maintains the linked list structure. +**1.2 High-level approach:** +The goal is to find the minimum absolute difference between any two nodes in a BST. We use in-order traversal to get sorted values, then find minimum difference between consecutive values. -**1.4 Decomposition** +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Compare all pairs - O(n²) time. +- **Optimized Strategy:** In-order traversal gives sorted order, check adjacent pairs - O(n) time. -1. Check if there are at least $k$ nodes remaining. -2. If yes, reverse the first $k$ nodes. -3. Recursively process the remaining list. -4. Connect the reversed group with the result of the recursive call. -5. If fewer than $k$ nodes remain, return the list as is. +**1.4 Decomposition:** +1. Perform in-order traversal to get sorted values. +2. Iterate through sorted values. +3. Calculate difference between consecutive values. +4. Track minimum difference. +5. Return minimum. ### Steps (The "How") -**2.1 Initialization & Example Setup** - -Let's use the example $head = [1,2,3,4,5]$, $k = 2$. - -The linked list: `1 -> 2 -> 3 -> 4 -> 5 -> None` - -**2.2 Start Checking/Processing** - -We first check if there are at least $k$ nodes. For the first call, we have 5 nodes, which is more than 2. - -**2.3 Trace Walkthrough** - -**First group (nodes 1-2):** -1. Count nodes: We have 5 nodes, so we can reverse a group of 2. -2. Reverse nodes 1-2: - - Before: `1 -> 2 -> 3 -> 4 -> 5` - - After: `2 -> 1 -> 3 -> 4 -> 5` -3. Recursively process remaining: `3 -> 4 -> 5` - -**Second group (nodes 3-4):** -1. Count nodes: We have 3 nodes, so we can reverse a group of 2. -2. Reverse nodes 3-4: - - Before: `3 -> 4 -> 5` - - After: `4 -> 3 -> 5` -3. Recursively process remaining: `5` - -**Remaining (node 5):** -1. Count nodes: We have 1 node, which is less than 2. -2. Return as is: `5` - -**Final result:** `2 -> 1 -> 4 -> 3 -> 5` - -**2.4 Increment and Loop** +**2.1 Initialization & Example Setup:** +Let's use `root = [4,2,6,1,3]`. In-order traversal gives [1,2,3,4,6]. -The reversal process: -1. Use a helper function to reverse a segment from `start` to `end` (exclusive). -2. The helper reverses the segment by: - - Setting `prev = None` - - For each node, save `next`, point `curr.next` to `prev`, move `prev` and `curr` forward -3. After reversing $k$ nodes, recursively call on the remaining list. -4. Connect the reversed head with the result of recursion. +**2.2 Start Checking:** +We compare consecutive values in sorted order. -**2.5 Return Result** +**2.3 Trace Walkthrough:** -After processing all groups, the list becomes `[2,1,4,3,5]`: -* Group 1: `[1,2]` → `[2,1]` -* Group 2: `[3,4]` → `[4,3]` -* Remaining: `[5]` → `[5]` +| i | values[i] | values[i+1] | Difference | Min | +|---|-----------|-------------|------------|-----| +| 0 | 1 | 2 | 1 | 1 | +| 1 | 2 | 3 | 1 | 1 | +| 2 | 3 | 4 | 1 | 1 | +| 3 | 4 | 6 | 2 | 1 | -The final result is `2 -> 1 -> 4 -> 3 -> 5`. +**2.4 Increment and Loop:** +After checking each pair, we move to the next. + +**2.5 Return Result:** +Return `res = 1`, the minimum absolute difference. ### Solution ```python -def __init__(self, val=0, next=None): +def __init__(self, val=0, left=None, right=None): # self.val = val -# self.next = next -from typing import Optional - +# self.left = left +# self.right = right class Solution: - def reverseKGroup(self, head: Optional[ListNode], k: int) -> Optional[ListNode]: - # Helper function to reverse a linked list segment - def reverse_segment(start, end): - prev = None - curr = start - while curr != end: - next_node = curr.next - curr.next = prev - prev = curr - curr = next_node - return prev + def getMinimumDifference(self, root: Optional[TreeNode]) -> int: + def inorder(node): + if not node: + return [] + return inorder(node.left) + [node.val] + inorder(node.right) - # Count nodes to check if we have enough for a group - count = 0 - curr = head - while curr and count < k: - curr = curr.next - count += 1 + values = inorder(root) + res = float('inf') - # If we have k nodes, reverse them - if count == k: - # Reverse the first k nodes - reversed_head = reverse_segment(head, curr) - # Recursively reverse the rest - head.next = self.reverseKGroup(curr, k) - return reversed_head + for i in range(len(values) - 1): + res = min(res, values[i + 1] - values[i]) - # Not enough nodes, return as is - return head + return res ``` -## 19. Remove Nth Node From End of List [Medium] -https://leetcode.com/problems/remove-nth-node-from-end-of-list/ +## 637. Average of Levels in Binary Tree [Easy] +https://leetcode.com/problems/average-of-levels-in-binary-tree/ ### Explanation @@ -2125,109 +1668,138 @@ https://leetcode.com/problems/remove-nth-node-from-end-of-list/ ### Strategy (The "Why") -Given the head of a linked list and an integer $n$, we need to remove the $n$-th node from the end of the list and return the head. - **1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes $N$ can be between $1$ and $30$. -- **Value Range:** Node values are between $1$ and $100$. -- **Time Complexity:** $O(L)$ where $L$ is the length of the list. We make one pass through the list. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If we need to remove the head node ($n$ equals the list length), we need special handling. Using a dummy node simplifies this. +- **Input Size:** `1 <= nodes <= 10^4`. +- **Time Complexity:** O(n) - we visit each node once using BFS. +- **Space Complexity:** O(w) where w is maximum width - queue storage. +- **Edge Case:** Single node tree returns [node.val]. **1.2 High-level approach:** +The goal is to calculate the average value of nodes at each level. We use BFS (level-order traversal) to process nodes level by level, calculating the sum and count for each level. -The goal is to remove the $n$-th node from the end of a linked list. +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Same as optimized - BFS is the natural approach. +- **Optimized Strategy:** BFS processes one level at a time, calculate average per level. -![Remove Nth Node](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg) +**1.4 Decomposition:** +1. Use BFS with a queue. +2. For each level, process all nodes at that level. +3. Calculate sum and count of nodes in the level. +4. Compute average (sum / count). +5. Add to result list. +6. Continue to next level. -We use two pointers: a fast pointer and a slow pointer. We move the fast pointer $n+1$ steps ahead, then move both pointers together. When fast reaches the end, slow will be at the node before the one to remove. +### Steps (The "How") -**1.3 Brute force vs. optimized strategy:** +**2.1 Initialization & Example Setup:** +Let's use `root = [3,9,20,null,null,15,7]`. Initialize queue with [root], res = []. -- **Brute Force:** First pass to count the length, second pass to find and remove the $(L-n+1)$-th node from the beginning. This takes two passes. -- **Optimized Strategy (Two Pointers):** Use two pointers with a gap of $n+1$ nodes. Move both together until the fast pointer reaches the end. This takes one pass. -- **Why it's better:** The two-pointer approach is more elegant and requires only one pass through the list, though both approaches have the same time complexity. +**2.2 Start Checking:** +We process nodes level by level. -**1.4 Decomposition:** +**2.3 Trace Walkthrough:** -1. Create a dummy node pointing to the head (to handle edge cases). -2. Initialize two pointers (fast and slow) at the dummy node. -3. Move the fast pointer $n+1$ steps ahead. -4. Move both pointers together until fast reaches the end. -5. Remove the node after slow (which is the $n$-th node from the end). -6. Return the head (via dummy.next). +| Level | Nodes | Sum | Count | Average | res | +|-------|-------|-----|-------|---------|-----| +| 0 | [3] | 3 | 1 | 3.0 | [3.0] | +| 1 | [9,20] | 29 | 2 | 14.5 | [3.0,14.5] | +| 2 | [15,7] | 22 | 2 | 11.0 | [3.0,14.5,11.0] | -### Steps (The "How") +**2.4 Increment and Loop:** +After processing each level, we move to the next. -**2.1 Initialization & Example Setup:** +**2.5 Return Result:** +Return `res = [3.0,14.5,11.0]`, averages for each level. -Let's use the example: head = $[1,2,3,4,5]$, $n = 2$ +### Solution -We initialize: -- `dummy = ListNode(0)`, `dummy.next = head` -- `fast = dummy`, `slow = dummy` +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +from collections import deque -**2.2 Start Processing:** +class Solution: + def averageOfLevels(self, root: Optional[TreeNode]) -> List[float]: + if not root: + return [] + + queue = deque([root]) + res = [] + + while queue: + level_size = len(queue) + level_sum = 0 + + for _ in range(level_size): + node = queue.popleft() + level_sum += node.val + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + res.append(level_sum / level_size) + + return res +``` -We move the fast pointer $n+1 = 3$ steps ahead. +## 2. Add Two Numbers [Medium] +https://leetcode.com/problems/add-two-numbers/ -**2.3 Trace Walkthrough:** +### Explanation -| Step | Fast Position | Slow Position | Action | -|------|---------------|---------------|--------| -| Initial | dummy | dummy | - | -| After moving fast 3 steps | node 4 | dummy | Fast is 3 steps ahead | -| Move both together | node 5 | node 1 | Continue... | -| Move both together | null | node 3 | Fast reached end | +You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. -When fast is null, slow is at node 3 (the node before node 4, which is the 2nd from end). +You may assume the two numbers do not contain any leading zero, except the number 0 itself. -**2.4 Remove Node:** +Example: +```text +Input: l1 = [2,4,3], l2 = [5,6,4] +Output: [7,0,8] +Explanation: 342 + 465 = 807. -- `slow.next = slow.next.next` removes node 4 -- Result: $[1,2,3,5]$ +Input: l1 = [0], l2 = [0] +Output: [0] -**2.5 Return Result:** +Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] +Output: [8,9,9,9,0,0,0,1] +``` -We return `dummy.next` which points to the new head $[1,2,3,5]$. +Constraints: +```text +The number of nodes in each linked list is in the range [1, 100]. +0 <= Node.val <= 9 +It is guaranteed that the list represents a number that does not have leading zeros. +``` -> **Note:** The dummy node is crucial because it handles the edge case where we need to remove the head node. Without it, we'd need special handling for that case. +## Explanation + +The Add Two Numbers problem involves adding two numbers represented by linked lists, where each node contains a single digit and the digits are stored in reverse order. To solve this, we iterate through both linked lists, adding corresponding digits along with any carry from the previous addition. We create a new linked list to store the result. If one list is shorter, treat missing digits as 0. If there is a carry left after processing both lists, add a new node with the carry value. + +## Hint + +Use a dummy head node to simplify the code for building the result list. Remember to handle the carry at the end. + +## Points + +- Time complexity: O(max(m, n)), where m and n are the lengths of the two lists. +- Handle different lengths of input lists. +- Don’t forget to add a node if there is a carry left after the main loop. +- Each node contains a single digit (0-9). ### Solution ```python def __init__(self, val=0, next=None): -# self.val = val -# self.next = next - -class Solution: - def removeNthFromEnd(self, head, n: int): - # Create a dummy node to handle edge cases - dummy = ListNode(0) - dummy.next = head - - # Two pointers: fast and slow - fast = dummy - slow = dummy - - # Move fast pointer n+1 steps ahead - for _ in range(n + 1): - fast = fast.next - - # Move both pointers until fast reaches the end - while fast: - fast = fast.next - slow = slow.next - - # Remove the nth node from end - slow.next = slow.next.next - - return dummy.next + self.val = val + self.next = next ``` -## 82. Remove Duplicates from Sorted List II [Medium] -https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ +## 19. Remove Nth Node From End of List [Medium] +https://leetcode.com/problems/remove-nth-node-from-end-of-list/ ### Explanation @@ -2235,69 +1807,74 @@ https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ ### Strategy (The "Why") +Given the head of a linked list and an integer $n$, we need to remove the $n$-th node from the end of the list and return the head. + **1.1 Constraints & Complexity:** -- **Constraints:** The list has at most 300 nodes, with values in the range $[-100, 100]$. The list is guaranteed to be sorted in ascending order. -- **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We traverse the list once. -- **Space Complexity:** $O(1)$ as we only use a constant amount of extra space (dummy node and pointers). -- **Edge Case:** If the list is empty or contains only duplicates, we return an empty list. +- **Input Size:** The number of nodes $N$ can be between $1$ and $30$. +- **Value Range:** Node values are between $1$ and $100$. +- **Time Complexity:** $O(L)$ where $L$ is the length of the list. We make one pass through the list. +- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. +- **Edge Case:** If we need to remove the head node ($n$ equals the list length), we need special handling. Using a dummy node simplifies this. **1.2 High-level approach:** -The goal is to remove all nodes that have duplicate values, keeping only nodes with unique values. We use a two-pointer approach with a dummy node to handle edge cases where the head needs to be removed. +The goal is to remove the $n$-th node from the end of a linked list. + +![Remove Nth Node](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg) + +We use two pointers: a fast pointer and a slow pointer. We move the fast pointer $n+1$ steps ahead, then move both pointers together. When fast reaches the end, slow will be at the node before the one to remove. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Count occurrences of each value, then rebuild the list with only unique values. This requires $O(n)$ space for counting and $O(n)$ time, but is less efficient in practice. -- **Optimized Strategy:** Use two pointers (`prev` and `curr`) to traverse the list. When duplicates are found, skip all nodes with that value and link `prev` to the node after the duplicates. This is $O(n)$ time and $O(1)$ space. -- **Why optimized is better:** The optimized approach processes the list in a single pass without extra space for counting. +- **Brute Force:** First pass to count the length, second pass to find and remove the $(L-n+1)$-th node from the beginning. This takes two passes. +- **Optimized Strategy (Two Pointers):** Use two pointers with a gap of $n+1$ nodes. Move both together until the fast pointer reaches the end. This takes one pass. +- **Why it's better:** The two-pointer approach is more elegant and requires only one pass through the list, though both approaches have the same time complexity. **1.4 Decomposition:** -1. Create a dummy node to handle cases where the head is removed. -2. Use two pointers: `prev` (points to the last unique node) and `curr` (current node being examined). -3. When duplicates are detected, skip all nodes with the duplicate value. -4. Link `prev.next` to the node after the duplicates. -5. Continue until the end of the list. +1. Create a dummy node pointing to the head (to handle edge cases). +2. Initialize two pointers (fast and slow) at the dummy node. +3. Move the fast pointer $n+1$ steps ahead. +4. Move both pointers together until fast reaches the end. +5. Remove the node after slow (which is the $n$-th node from the end). +6. Return the head (via dummy.next). ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: `head = [1,2,3,3,4,4,5]` +Let's use the example: head = $[1,2,3,4,5]$, $n = 2$ -We create a dummy node with value 0, and set `dummy.next = head`. This gives us: -- `dummy -> 1 -> 2 -> 3 -> 3 -> 4 -> 4 -> 5` -- `prev = dummy` -- `curr = head` (node with value 1) +We initialize: +- `dummy = ListNode(0)`, `dummy.next = head` +- `fast = dummy`, `slow = dummy` -**2.2 Start Checking:** +**2.2 Start Processing:** -We begin traversing the list. `prev` points to the last confirmed unique node, and `curr` points to the current node being examined. +We move the fast pointer $n+1 = 3$ steps ahead. **2.3 Trace Walkthrough:** -| Step | prev.val | curr.val | curr.next.val | Action | -|------|----------|----------|---------------|--------| -| 1 | 0 (dummy) | 1 | 2 | No duplicates, move both pointers | -| 2 | 1 | 2 | 3 | No duplicates, move both pointers | -| 3 | 2 | 3 | 3 | Duplicates found! Skip all 3s | -| 4 | 2 | 4 | 4 | Duplicates found! Skip all 4s | -| 5 | 2 | 5 | None | No duplicates, move both pointers | -| 6 | 5 | None | - | End of list | +| Step | Fast Position | Slow Position | Action | +|------|---------------|---------------|--------| +| Initial | dummy | dummy | - | +| After moving fast 3 steps | node 4 | dummy | Fast is 3 steps ahead | +| Move both together | node 5 | node 1 | Continue... | +| Move both together | null | node 3 | Fast reached end | -**2.4 Increment and Loop:** +When fast is null, slow is at node 3 (the node before node 4, which is the 2nd from end). -When duplicates are found (e.g., `curr.val == curr.next.val`), we: -1. Store the duplicate value. -2. Skip all nodes with that value: `while curr and curr.val == duplicate_val: curr = curr.next` -3. Link `prev.next = curr` to remove the duplicates. +**2.4 Remove Node:** -When no duplicates are found, we move both pointers: `prev = curr` and `curr = curr.next`. +- `slow.next = slow.next.next` removes node 4 +- Result: $[1,2,3,5]$ **2.5 Return Result:** -After processing, `dummy.next` points to the first unique node. For our example `[1,2,3,3,4,4,5]`, the result is `[1,2,5]`, which is returned. +We return `dummy.next` which points to the new head $[1,2,3,5]$. + +> **Note:** The dummy node is crucial because it handles the edge case where we need to remove the head node. Without it, we'd need special handling for that case. ### Solution @@ -2305,28 +1882,28 @@ After processing, `dummy.next` points to the first unique node. For our example def __init__(self, val=0, next=None): # self.val = val # self.next = next + class Solution: - def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]: + def removeNthFromEnd(self, head, n: int): # Create a dummy node to handle edge cases dummy = ListNode(0) dummy.next = head - prev = dummy - curr = head + # Two pointers: fast and slow + fast = dummy + slow = dummy - while curr and curr.next: - # If we find duplicates - if curr.val == curr.next.val: - # Skip all nodes with the same value - duplicate_val = curr.val - while curr and curr.val == duplicate_val: - curr = curr.next - # Link prev to the node after duplicates - prev.next = curr - else: - # No duplicates, move both pointers - prev = curr - curr = curr.next + # Move fast pointer n+1 steps ahead + for _ in range(n + 1): + fast = fast.next + + # Move both pointers until fast reaches the end + while fast: + fast = fast.next + slow = slow.next + + # Remove the nth node from end + slow.next = slow.next.next return dummy.next ``` @@ -2440,8 +2017,8 @@ def __init__(self, val=0, next=None): # self.next = next ``` -## 86. Partition List [Medium] -https://leetcode.com/problems/partition-list/ +## 82. Remove Duplicates from Sorted List II [Medium] +https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ ### Explanation @@ -2451,66 +2028,67 @@ https://leetcode.com/problems/partition-list/ **1.1 Constraints & Complexity:** -- **Constraints:** The list has at most 200 nodes, with values in the range $[-100, 100]$. The partition value $x$ is in the range $[-200, 200]$. +- **Constraints:** The list has at most 300 nodes, with values in the range $[-100, 100]$. The list is guaranteed to be sorted in ascending order. - **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We traverse the list once. -- **Space Complexity:** $O(1)$ as we only use constant extra space (two dummy nodes and pointers). -- **Edge Case:** If the list is empty, return `None`. If all nodes are less than $x$ or all are greater than or equal to $x$, we still maintain relative order. +- **Space Complexity:** $O(1)$ as we only use a constant amount of extra space (dummy node and pointers). +- **Edge Case:** If the list is empty or contains only duplicates, we return an empty list. **1.2 High-level approach:** -The goal is to partition the list such that all nodes with values less than $x$ come before nodes with values greater than or equal to $x$, while preserving the original relative order within each partition. +The goal is to remove all nodes that have duplicate values, keeping only nodes with unique values. We use a two-pointer approach with a dummy node to handle edge cases where the head needs to be removed. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Create two separate lists, collect nodes less than $x$ in one list and nodes greater than or equal to $x$ in another, then concatenate them. This requires $O(n)$ space. -- **Optimized Strategy:** Use two dummy nodes to build two partitions in-place as we traverse. This is $O(n)$ time and $O(1)$ space. -- **Why optimized is better:** The optimized approach maintains $O(1)$ space complexity while still being straightforward to implement. +- **Brute Force:** Count occurrences of each value, then rebuild the list with only unique values. This requires $O(n)$ space for counting and $O(n)$ time, but is less efficient in practice. +- **Optimized Strategy:** Use two pointers (`prev` and `curr`) to traverse the list. When duplicates are found, skip all nodes with that value and link `prev` to the node after the duplicates. This is $O(n)$ time and $O(1)$ space. +- **Why optimized is better:** The optimized approach processes the list in a single pass without extra space for counting. **1.4 Decomposition:** -1. Create two dummy nodes: one for nodes less than $x$, one for nodes greater than or equal to $x$. -2. Traverse the original list, appending each node to the appropriate partition. -3. Connect the two partitions: link the end of the "less than" partition to the start of the "greater than or equal to" partition. -4. Set the tail of the "greater than or equal to" partition to `None` to terminate the list. +1. Create a dummy node to handle cases where the head is removed. +2. Use two pointers: `prev` (points to the last unique node) and `curr` (current node being examined). +3. When duplicates are detected, skip all nodes with the duplicate value. +4. Link `prev.next` to the node after the duplicates. +5. Continue until the end of the list. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: `head = [1,4,3,2,5,2]`, `x = 3` - -We create two dummy nodes: -- `less_head` for nodes with value < 3 -- `greater_head` for nodes with value >= 3 +Let's use the example: `head = [1,2,3,3,4,4,5]` -We also create pointers `less` and `greater` that point to the current tail of each partition. +We create a dummy node with value 0, and set `dummy.next = head`. This gives us: +- `dummy -> 1 -> 2 -> 3 -> 3 -> 4 -> 4 -> 5` +- `prev = dummy` +- `curr = head` (node with value 1) **2.2 Start Checking:** -We begin traversing the list from `head`. For each node, we check if its value is less than $x$ or greater than or equal to $x$. +We begin traversing the list. `prev` points to the last confirmed unique node, and `curr` points to the current node being examined. **2.3 Trace Walkthrough:** -| Node Value | Comparison | Action | less partition | greater partition | -|------------|------------|--------|----------------|-------------------| -| 1 | 1 < 3 | Append to less | [1] | [] | -| 4 | 4 >= 3 | Append to greater | [1] | [4] | -| 3 | 3 >= 3 | Append to greater | [1] | [4,3] | -| 2 | 2 < 3 | Append to less | [1,2] | [4,3] | -| 5 | 5 >= 3 | Append to greater | [1,2] | [4,3,5] | -| 2 | 2 < 3 | Append to less | [1,2,2] | [4,3,5] | +| Step | prev.val | curr.val | curr.next.val | Action | +|------|----------|----------|---------------|--------| +| 1 | 0 (dummy) | 1 | 2 | No duplicates, move both pointers | +| 2 | 1 | 2 | 3 | No duplicates, move both pointers | +| 3 | 2 | 3 | 3 | Duplicates found! Skip all 3s | +| 4 | 2 | 4 | 4 | Duplicates found! Skip all 4s | +| 5 | 2 | 5 | None | No duplicates, move both pointers | +| 6 | 5 | None | - | End of list | **2.4 Increment and Loop:** -After processing all nodes: -- `less` partition: `1 -> 2 -> 2` -- `greater` partition: `4 -> 3 -> 5` +When duplicates are found (e.g., `curr.val == curr.next.val`), we: +1. Store the duplicate value. +2. Skip all nodes with that value: `while curr and curr.val == duplicate_val: curr = curr.next` +3. Link `prev.next = curr` to remove the duplicates. -We connect them: `less.next = greater_head.next`, which gives: `1 -> 2 -> 2 -> 4 -> 3 -> 5` +When no duplicates are found, we move both pointers: `prev = curr` and `curr = curr.next`. **2.5 Return Result:** -We set `greater.next = None` to terminate the list, then return `less_head.next`, which points to `1`. The final result is `[1,2,2,4,3,5]`. +After processing, `dummy.next` points to the first unique node. For our example `[1,2,3,3,4,4,5]`, the result is `[1,2,5]`, which is returned. ### Solution @@ -2519,225 +2097,138 @@ def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: - def partition(self, head: Optional[ListNode], x: int) -> Optional[ListNode]: - # Create two dummy nodes for less than x and greater than or equal to x - less_head = ListNode(0) - greater_head = ListNode(0) - - less = less_head - greater = greater_head + def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]: + # Create a dummy node to handle edge cases + dummy = ListNode(0) + dummy.next = head + prev = dummy curr = head - while curr: - if curr.val < x: - less.next = curr - less = less.next - else: - greater.next = curr - greater = greater.next - curr = curr.next - - # Connect the two partitions - less.next = greater_head.next - greater.next = None # Important: break the chain - - return less_head.next -``` - -## 146. LRU Cache [Medium] -https://leetcode.com/problems/lru-cache/ - -### Explanation - -Design a data structure that follows the constraints of a **Least Recently Used (LRU) cache**. - -Implement the `LRUCache` class: - -- `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. -- `int get(int key)` Return the value of the `key` if the key exists, otherwise return `-1`. -- `void put(int key, int value)` Update the value of the `key` if the `key` exists. Otherwise, add the `key-value` pair to the cache. If the number of keys exceeds the `capacity` from this operation, **evict** the least recently used key. - -The functions `get` and `put` must each run in `O(1)` average time complexity. - -**Example 1:** - -```raw -Input -["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] -[[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] -Output -[null, null, null, 1, null, -1, null, -1, 3, 4] - -Explanation: - -LRUCache lRUCache = new LRUCache(2); -lRUCache.put(1, 1); // cache is {1=1} -lRUCache.put(2, 2); // cache is {1=1, 2=2} -lRUCache.get(1); // return 1 -lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} -lRUCache.get(2); // returns -1 (not found) -lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} -lRUCache.get(1); // return -1 (not found) -lRUCache.get(3); // return 3 -lRUCache.get(4); // return 4 -``` - -**Constraints:** -- `1 <= capacity <= 3000` -- `0 <= key <= 10^4` -- `0 <= value <= 10^5` -- At most `2 * 10^5` calls will be made to `get` and `put`. - -## Explanation - -### Strategy - -This is a **design problem** that requires implementing an LRU (Least Recently Used) cache. The key insight is to combine a hash map for O(1) lookups with a doubly linked list for O(1) insertions/deletions to maintain the order of usage. - -**Key observations:** - -- We need O(1) time for both get and put operations -- We need to track the order of usage (most recently used to least recently used) -- When capacity is exceeded, we need to remove the least recently used item -- A hash map provides O(1) lookups, but doesn't maintain order -- A doubly linked list maintains order and allows O(1) insertions/deletions - -**High-level approach:** - -1. **Use a hash map**: For O(1) key-value lookups -2. **Use a doubly linked list**: To maintain usage order -3. **Combine both**: Hash map stores key -> node mappings -4. **Update order**: Move accessed items to front (most recently used) -5. **Evict LRU**: Remove from end when capacity exceeded - -### Steps + while curr and curr.next: + # If we find duplicates + if curr.val == curr.next.val: + # Skip all nodes with the same value + duplicate_val = curr.val + while curr and curr.val == duplicate_val: + curr = curr.next + # Link prev to the node after duplicates + prev.next = curr + else: + # No duplicates, move both pointers + prev = curr + curr = curr.next + + return dummy.next +``` -Let's break down the solution step by step: +## 86. Partition List [Medium] +https://leetcode.com/problems/partition-list/ -**Step 1: Design the data structure** +### Explanation -- `capacity`: Maximum number of items in cache -- `cache`: Hash map for key -> node mappings -- `head`: Dummy head node of doubly linked list -- `tail`: Dummy tail node of doubly linked list +## Explanation -**Step 2: Implement get operation** +### Strategy (The "Why") -- Check if key exists in hash map -- If not found, return -1 -- If found, move node to front (most recently used) -- Return the value +**1.1 Constraints & Complexity:** -**Step 3: Implement put operation** +- **Constraints:** The list has at most 200 nodes, with values in the range $[-100, 100]$. The partition value $x$ is in the range $[-200, 200]$. +- **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We traverse the list once. +- **Space Complexity:** $O(1)$ as we only use constant extra space (two dummy nodes and pointers). +- **Edge Case:** If the list is empty, return `None`. If all nodes are less than $x$ or all are greater than or equal to $x$, we still maintain relative order. -- If key exists, update value and move to front -- If key doesn't exist: - - Create new node - - Add to front of list - - Add to hash map - - If capacity exceeded, remove LRU item (from end) +**1.2 High-level approach:** -**Step 4: Helper methods** +The goal is to partition the list such that all nodes with values less than $x$ come before nodes with values greater than or equal to $x$, while preserving the original relative order within each partition. -- `_add_to_front(node)`: Add node to front of list -- `_remove_node(node)`: Remove node from list -- `_remove_lru()`: Remove least recently used item +**1.3 Brute force vs. optimized strategy:** -**Example walkthrough:** +- **Brute Force:** Create two separate lists, collect nodes less than $x$ in one list and nodes greater than or equal to $x$ in another, then concatenate them. This requires $O(n)$ space. +- **Optimized Strategy:** Use two dummy nodes to build two partitions in-place as we traverse. This is $O(n)$ time and $O(1)$ space. +- **Why optimized is better:** The optimized approach maintains $O(1)$ space complexity while still being straightforward to implement. -Let's trace through the example: +**1.4 Decomposition:** -```raw -capacity = 2 +1. Create two dummy nodes: one for nodes less than $x$, one for nodes greater than or equal to $x$. +2. Traverse the original list, appending each node to the appropriate partition. +3. Connect the two partitions: link the end of the "less than" partition to the start of the "greater than or equal to" partition. +4. Set the tail of the "greater than or equal to" partition to `None` to terminate the list. -put(1, 1): cache = {1=1}, list = [1] -put(2, 2): cache = {1=1, 2=2}, list = [2, 1] -get(1): return 1, list = [1, 2] (move 1 to front) -put(3, 3): cache = {1=1, 3=3}, list = [3, 1] (evict 2) -get(2): return -1 (not found) -put(4, 4): cache = {3=3, 4=4}, list = [4, 3] (evict 1) -get(1): return -1 (not found) -get(3): return 3, list = [3, 4] -get(4): return 4, list = [4, 3] -``` +### Steps (The "How") -> **Note:** The doubly linked list with dummy head and tail nodes makes it easy to add/remove nodes at the beginning and end. The hash map provides O(1) access to any node, and the list maintains the order of usage. +**2.1 Initialization & Example Setup:** -**Time Complexity:** O(1) for both get and put operations -**Space Complexity:** O(capacity) - we store at most capacity items +Let's use the example: `head = [1,4,3,2,5,2]`, `x = 3` -### Solution +We create two dummy nodes: +- `less_head` for nodes with value < 3 +- `greater_head` for nodes with value >= 3 -```python -def __init__(self, capacity: int): - self.capacity = capacity - self.cache = {} # key -> node mapping +We also create pointers `less` and `greater` that point to the current tail of each partition. - # Initialize doubly linked list with dummy nodes - self.head = Node(0, 0) # dummy head - self.tail = Node(0, 0) # dummy tail - self.head.next = self.tail - self.tail.prev = self.head +**2.2 Start Checking:** - def get(self, key: int) -> int: - # Check if key exists - if key not in self.cache: - return -1 +We begin traversing the list from `head`. For each node, we check if its value is less than $x$ or greater than or equal to $x$. - # Move node to front (most recently used) - node = self.cache[key] - self._remove_node(node) - self._add_to_front(node) +**2.3 Trace Walkthrough:** - return node.value +| Node Value | Comparison | Action | less partition | greater partition | +|------------|------------|--------|----------------|-------------------| +| 1 | 1 < 3 | Append to less | [1] | [] | +| 4 | 4 >= 3 | Append to greater | [1] | [4] | +| 3 | 3 >= 3 | Append to greater | [1] | [4,3] | +| 2 | 2 < 3 | Append to less | [1,2] | [4,3] | +| 5 | 5 >= 3 | Append to greater | [1,2] | [4,3,5] | +| 2 | 2 < 3 | Append to less | [1,2,2] | [4,3,5] | - def put(self, key: int, value: int) -> None: - # If key exists, update value and move to front - if key in self.cache: - node = self.cache[key] - node.value = value - self._remove_node(node) - self._add_to_front(node) - else: - # Create new node - node = Node(key, value) - self.cache[key] = node - self._add_to_front(node) +**2.4 Increment and Loop:** - # If capacity exceeded, remove LRU item - if len(self.cache) > self.capacity: - self._remove_lru() +After processing all nodes: +- `less` partition: `1 -> 2 -> 2` +- `greater` partition: `4 -> 3 -> 5` - def _add_to_front(self, node): - """Add node to front of list (after dummy head)""" - node.next = self.head.next - node.prev = self.head - self.head.next.prev = node - self.head.next = node +We connect them: `less.next = greater_head.next`, which gives: `1 -> 2 -> 2 -> 4 -> 3 -> 5` - def _remove_node(self, node): - """Remove node from list""" - node.prev.next = node.next - node.next.prev = node.prev +**2.5 Return Result:** - def _remove_lru(self): - """Remove least recently used item (before dummy tail)""" - lru_node = self.tail.prev - self._remove_node(lru_node) - del self.cache[lru_node.key] +We set `greater.next = None` to terminate the list, then return `less_head.next`, which points to `1`. The final result is `[1,2,2,4,3,5]`. +### Solution -class Node: - def __init__(self, key, value): - self.key = key - self.value = value - self.prev = None - self.next = None +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next +class Solution: + def partition(self, head: Optional[ListNode], x: int) -> Optional[ListNode]: + # Create two dummy nodes for less than x and greater than or equal to x + less_head = ListNode(0) + greater_head = ListNode(0) + + less = less_head + greater = greater_head + + curr = head + + while curr: + if curr.val < x: + less.next = curr + less = less.next + else: + greater.next = curr + greater = greater.next + curr = curr.next + + # Connect the two partitions + less.next = greater_head.next + greater.next = None # Important: break the chain + + return less_head.next ``` -## 104. Maximum Depth of Binary Tree [Easy] -https://leetcode.com/problems/maximum-depth-of-binary-tree/ +## 92. Reverse Linked List II [Medium] +https://leetcode.com/problems/reverse-linked-list-ii/ ### Explanation @@ -2745,103 +2236,101 @@ https://leetcode.com/problems/maximum-depth-of-binary-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. - -**1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. -- **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** If the tree is empty (root is null), return 0. +**1.1 Constraints & Complexity** -**1.2 High-level approach:** +* **Input Size:** The linked list has $n$ nodes where $1 \leq n \leq 500$, and $1 \leq left \leq right \leq n$. +* **Time Complexity:** $O(n)$ - We traverse the list once to find the reversal segment, then reverse it in-place. +* **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. +* **Edge Case:** If $left == right$, no reversal is needed, return the list as is. -The goal is to find the maximum depth of a binary tree. +**1.2 High-level approach** -![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) +The goal is to reverse a specific segment of a linked list from position $left$ to position $right$, while keeping the rest of the list unchanged. We use a dummy node to handle the case when reversal starts at the head. -We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. +![Linked list partial reversal showing how nodes are reversed in a segment] -**1.3 Brute force vs. optimized strategy:** +**1.3 Brute force vs. optimized strategy** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. -- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. -- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. +* **Brute Force:** Convert the linked list to an array, reverse the segment, then rebuild the list. This uses $O(n)$ extra space. +* **Optimized (In-Place Reversal):** Use pointer manipulation to reverse the segment in-place. We find the segment boundaries, then reverse nodes one by one. This uses $O(1)$ extra space. -**1.4 Decomposition:** +**1.4 Decomposition** -1. Base case: if the root is null, return 0. -2. Recursively find the maximum depth of the left subtree. -3. Recursively find the maximum depth of the right subtree. -4. Return 1 (for current node) plus the maximum of the two subtree depths. +1. Create a dummy node to handle edge cases. +2. Move to the node before the reversal segment. +3. Reverse the segment by adjusting pointers iteratively. +4. Connect the reversed segment back to the list. ### Steps (The "How") -**2.1 Initialization & Example Setup:** - -Let's use the example: root = $[3,9,20,null,null,15,7]$ - -The tree structure: -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` - -**2.2 Start Recursion:** +**2.1 Initialization & Example Setup** -We begin from the root node (value 3). +Let's use the example $head = [1,2,3,4,5]$, $left = 2$, $right = 4$. -**2.3 Trace Walkthrough:** +We initialize: +* `dummy = ListNode(0)` with `dummy.next = head` +* `prev = dummy` (will point to node before reversal segment) -| Node | Left Depth | Right Depth | Max Depth | Return Value | -|------|------------|--------------|-----------|--------------| -| 3 | ? | ? | - | Compute... | -| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | ? | ? | - | Compute... | -| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | -| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | +**2.2 Start Processing** -**2.4 Recursion Flow:** +We move `prev` to position $left - 1$ (node with value 1). -- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ -- Node 9: both children null, return $0 + 1 = 1$ -- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ +**2.3 Trace Walkthrough** -**2.5 Return Result:** +| Step | prev | curr | next_node | List State | +|------|------|------|-----------|------------| +| Initial | node(0) | node(1) | - | [0,1,2,3,4,5] | +| Move prev | node(1) | node(2) | - | [0,1,2,3,4,5] | +| Reverse 1 | node(1) | node(2) | node(3) | [0,1,3,2,4,5] | +| Reverse 2 | node(1) | node(2) | node(4) | [0,1,4,3,2,5] | -We return 3, which is the maximum depth of the tree. +After reversal: `[1,4,3,2,5]` (segment [2,3,4] reversed to [4,3,2]). -> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. +**2.4 Increment and Loop** + +For each iteration in the reversal loop: +1. Save `next_node = curr.next` +2. Set `curr.next = next_node.next` (skip next_node) +3. Set `next_node.next = prev.next` (insert next_node at start) +4. Set `prev.next = next_node` (update prev's next) + +**2.5 Return Result** + +After reversal, `dummy.next` points to the modified list: `[1,4,3,2,5]`. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right - +# self.next = next class Solution: - def maxDepth(self, root) -> int: - if not root: - return 0 + def reverseBetween(self, head: Optional[ListNode], left: int, right: int) -> Optional[ListNode]: + if not head or left == right: + return head - # Recursively find max depth of left and right subtrees - left_depth = self.maxDepth(root.left) - right_depth = self.maxDepth(root.right) + # Create dummy node to handle edge case when left = 1 + dummy = ListNode(0) + dummy.next = head + prev = dummy - # Return max depth plus 1 for current node - return max(left_depth, right_depth) + 1 + # Move to the node before the reversal starts + for _ in range(left - 1): + prev = prev.next + + # Reverse the segment + curr = prev.next + for _ in range(right - left): + next_node = curr.next + curr.next = next_node.next + next_node.next = prev.next + prev.next = next_node + + return dummy.next ``` -## 100. Same Tree [Easy] -https://leetcode.com/problems/same-tree/ +## 98. Validate Binary Search Tree [Medium] +https://leetcode.com/problems/validate-binary-search-tree/ ### Explanation @@ -2849,65 +2338,78 @@ https://leetcode.com/problems/same-tree/ ### Strategy (The "Why") -The problem asks us to determine if two binary trees are structurally identical and have the same node values. +Given the root of a binary tree, we need to determine if it is a valid binary search tree (BST). A BST is valid if for every node, all nodes in its left subtree are less than it, and all nodes in its right subtree are greater than it. **1.1 Constraints & Complexity:** -- **Input Constraints:** Both trees have at most 100 nodes, and node values are in the range $[-10^4, 10^4]$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once, where $n$ is the minimum number of nodes in the two trees. -- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In the worst case (skewed tree), $h = n$, giving $O(n)$ space. -- **Edge Case:** Both trees are empty (both roots are `None`), which should return `True`. +- **Input Size:** The number of nodes can be up to $10^4$. +- **Value Range:** Node values are between $-2^{31}$ and $2^{31} - 1$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Edge Case:** An empty tree is a valid BST. A tree with only one node is a valid BST. **1.2 High-level approach:** -The goal is to check if two trees have the same structure and values by comparing them node by node recursively. We compare the root values, then recursively check left and right subtrees. +The goal is to validate that a binary tree satisfies the BST property. -![Binary tree comparison](https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg) +We use recursion with range validation. For each node, we check if its value is within the valid range (min_val, max_val). The range is updated as we traverse: left children must be less than the parent, right children must be greater than the parent. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Convert both trees to arrays using traversal, then compare arrays. This requires $O(n)$ time and $O(n)$ space for storing both arrays. -- **Optimized (Recursive Comparison):** Compare nodes directly during traversal without storing intermediate results. This uses $O(n)$ time but only $O(h)$ space for the recursion stack. -- **Emphasize the optimization:** By comparing nodes directly during traversal, we can short-circuit early if we find a mismatch, potentially avoiding full tree traversal. +- **Brute Force:** For each node, check if all nodes in its left subtree are less and all nodes in its right subtree are greater. This would be $O(n^2)$ time. +- **Optimized Strategy (Range Validation):** Use recursion with min and max bounds. Each node must be within its allowed range. This takes $O(n)$ time. +- **Why it's better:** The range validation approach reduces time complexity from $O(n^2)$ to $O(n)$ by passing down constraints instead of checking all descendants for each node. **1.4 Decomposition:** -1. **Base Cases:** If both nodes are `None`, return `True`. If only one is `None`, return `False`. -2. **Value Comparison:** Check if the current nodes have the same value. -3. **Recursive Check:** Recursively check if left subtrees match and right subtrees match. -4. **Combine Results:** Return `True` only if values match and both subtrees match. +1. Define a recursive function that takes a node and its allowed range (min_val, max_val). +2. If the node is null, return true (base case). +3. Check if the node's value is within the range (strictly greater than min_val and strictly less than max_val). +4. Recursively validate left subtree with range (min_val, node.val). +5. Recursively validate right subtree with range (node.val, max_val). +6. Return true only if all checks pass. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's trace through an example: `p = [1,2,3]`, `q = [1,2,3]`. +Let's use the example: root = $[5,1,4,null,null,3,6]$ -Both trees have the same structure and values. +The tree structure: +``` + 5 + / \ + 1 4 + / \ + 3 6 +``` -**2.2 Start Comparison:** +We initialize: +- Call `validate(root, -∞, +∞)` -We begin at the root nodes of both trees. +**2.2 Start Validation:** + +We begin validating from the root. **2.3 Trace Walkthrough:** -| Node Pair | p.val | q.val | Match? | Left Check | Right Check | Result | -|-----------|-------|-------|--------|------------|-------------|--------| -| Root (1, 1) | 1 | 1 | Yes | Check (2, 2) | Check (3, 3) | Continue | -| Left (2, 2) | 2 | 2 | Yes | Check (None, None) | Check (None, None) | True | -| Right (3, 3) | 3 | 3 | Yes | Check (None, None) | Check (None, None) | True | +| Node | min_val | max_val | node.val | Check | Result | +|------|---------|---------|----------|-------|--------| +| 5 | -∞ | +∞ | 5 | $-∞ < 5 < +∞$ | ✓ | +| 1 | -∞ | 5 | 1 | $-∞ < 1 < 5$ | ✓ | +| 4 | 5 | +∞ | 4 | $5 < 4 < +∞$ | ✗ | -**2.4 Recursive Unwinding:** +**2.4 Explanation:** -- Both left subtrees (2, 2) match: both have value 2 and no children. -- Both right subtrees (3, 3) match: both have value 3 and no children. -- Root nodes (1, 1) match. +- Root (5): Valid, within range (-∞, +∞) +- Left child (1): Valid, within range (-∞, 5) +- Right child (4): Invalid! It should be greater than 5, but 4 < 5 **2.5 Return Result:** -Since all nodes match in structure and value, the function returns `True`. +We return `False` because node 4 violates the BST property (it's in the right subtree of 5 but is less than 5). -> **Note:** The algorithm short-circuits: if any node comparison fails, the entire function returns `False` immediately without checking remaining nodes. +> **Note:** The key insight is to pass down the allowed range for each node. A node's value must be strictly within its range, and we update the range for children: left children get (min_val, node.val) and right children get (node.val, max_val). ### Solution @@ -2916,25 +2418,27 @@ def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right + class Solution: - def isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool: - # Both are None - if not p and not q: - return True - - # One is None, the other is not - if not p or not q: - return False - - # Both exist, check values and recursively check children - if p.val != q.val: - return False + def isValidBST(self, root) -> bool: + def validate(node, min_val, max_val): + # Empty tree is valid + if not node: + return True + + # Check if current node value is within valid range + if node.val <= min_val or node.val >= max_val: + return False + + # Recursively validate left and right subtrees + return (validate(node.left, min_val, node.val) and + validate(node.right, node.val, max_val)) - return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right) + return validate(root, float('-inf'), float('inf')) ``` -## 226. Invert Binary Tree [Easy] -https://leetcode.com/problems/invert-binary-tree/ +## 102. Binary Tree Level Order Traversal [Medium] +https://leetcode.com/problems/binary-tree-level-order-traversal/ ### Explanation @@ -2942,67 +2446,82 @@ https://leetcode.com/problems/invert-binary-tree/ ### Strategy (The "Why") +Given the root of a binary tree, we need to return the level-order traversal of its nodes' values (i.e., from left to right, level by level). + **1.1 Constraints & Complexity:** -- **Constraints:** The tree has 0 to 100 nodes, and node values range from -100 to 100. -- **Time Complexity:** O(n) where n is the number of nodes. We visit each node once. -- **Space Complexity:** O(h) where h is the height of the tree for the recursion stack. In worst case (skewed tree), this is O(n). -- **Edge Case:** If the root is None, return None. + +- **Input Size:** The number of nodes $N$ can be up to $2000$. +- **Value Range:** Node values are between $-1000$ and $1000$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level, which is $O(n)$ in the worst case. +- **Edge Case:** If the tree is empty, return an empty list. **1.2 High-level approach:** -The goal is to invert a binary tree by swapping left and right children at every node. We use recursion to process each node. + +The goal is to traverse the tree level by level, collecting values at each level. + +![Level Order Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) + +We use BFS (breadth-first search) with a queue. We process nodes level by level, adding all nodes at the current level to a list before moving to the next level. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Same recursive approach - there's no significantly different brute force method for this problem. -- **Optimized Strategy:** Use recursion to swap children at each node, then recursively invert the subtrees. -- **Why optimized is better:** This is the natural and most efficient approach for tree problems. + +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. +- **Optimized Strategy (BFS with Queue):** Use a queue to process nodes level by level. For each level, process all nodes in the queue (which represents the current level), then add their children for the next level. +- **Why it's better:** BFS naturally processes nodes level by level. Using a queue ensures we process all nodes at one level before moving to the next. **1.4 Decomposition:** -1. If the node is None, return None (base case). -2. Swap the left and right children of the current node. -3. Recursively invert the left subtree. -4. Recursively invert the right subtree. -5. Return the root. + +1. If the tree is empty, return an empty list. +2. Initialize a queue with the root node. +3. While the queue is not empty: + - Get the number of nodes at the current level (queue size). + - Process all nodes at this level, adding their values to a level list. + - Add all children of these nodes to the queue for the next level. + - Add the level list to the result. +4. Return the result. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Example tree: `[4,2,7,1,3,6,9]` +Let's use the example: root = $[3,9,20,null,null,15,7]$ + +The tree structure: ``` - 4 + 3 / \ - 2 7 - / \ / \ -1 3 6 9 + 9 20 + / \ + 15 7 ``` -**2.2 Start Checking:** -Start from the root and recursively process each node. +We initialize: +- `queue = deque([3])` +- `res = []` + +**2.2 Start BFS:** + +We begin processing level by level. **2.3 Trace Walkthrough:** -| Node | Before Swap | After Swap | Left Child | Right Child | -|------|------------|------------|------------|--------------| -| 4 | left=2, right=7 | left=7, right=2 | Invert 7 | Invert 2 | -| 7 | left=6, right=9 | left=9, right=6 | Invert 9 | Invert 6 | -| 2 | left=1, right=3 | left=3, right=1 | Invert 3 | Invert 1 | +| Level | Queue Before | Level Size | Process Nodes | Level List | Queue After | +|-------|--------------|------------|---------------|------------|-------------| +| 0 | [3] | 1 | 3 | [3] | [9, 20] | +| 1 | [9, 20] | 2 | 9, 20 | [9, 20] | [15, 7] | +| 2 | [15, 7] | 2 | 15, 7 | [15, 7] | [] | -**2.4 Increment and Loop:** -For each node: -- Swap: `root.left, root.right = root.right, root.left` -- Recursively invert: `self.invertTree(root.left)`, `self.invertTree(root.right)` +**2.4 Final Result:** -**2.5 Return Result:** -After inversion: -``` - 4 - / \ - 7 2 - / \ / \ -9 6 3 1 -``` +After processing all levels: +- `res = [[3], [9, 20], [15, 7]]` + +**2.5 Return Result:** -Return the root node. +We return `[[3], [9, 20], [15, 7]]`, which represents the level-order traversal. + +> **Note:** The key is to process all nodes at the current level before moving to the next. We do this by getting the queue size at the start of each iteration, which represents the number of nodes at the current level. ### Solution @@ -3012,23 +2531,37 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right +from typing import List +from collections import deque + class Solution: - def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + def levelOrder(self, root) -> List[List[int]]: if not root: - return None + return [] - # Swap left and right children - root.left, root.right = root.right, root.left + res = [] + queue = deque([root]) - # Recursively invert subtrees - self.invertTree(root.left) - self.invertTree(root.right) + while queue: + level_size = len(queue) + level = [] + + for _ in range(level_size): + node = queue.popleft() + level.append(node.val) + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + res.append(level) - return root + return res ``` -## 101. Symmetric Tree [Easy] -https://leetcode.com/problems/symmetric-tree/ +## 103. Binary Tree Zigzag Level Order Traversal [Medium] +https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ ### Explanation @@ -3036,82 +2569,63 @@ https://leetcode.com/problems/symmetric-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to check whether it is a mirror of itself (symmetric around its center). +The problem asks us to return the zigzag level order traversal of a binary tree: left-to-right for even levels, right-to-left for odd levels. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be up to $1000$. -- **Value Range:** Node values are between $-100$ and $100$. +- **Input Constraints:** The tree has $0 \leq n \leq 2000$ nodes with values in $[-100, 100]$. - **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. -- **Edge Case:** An empty tree is symmetric. A tree with only one node is symmetric. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. +- **Edge Case:** Empty tree returns empty list. **1.2 High-level approach:** -The goal is to determine if a binary tree is symmetric (mirror of itself). +The goal is to traverse the tree level by level, alternating the direction at each level. We use BFS with a flag to track direction. -We use recursion to check if the left and right subtrees are mirrors of each other. Two trees are mirrors if their roots have the same value, and the left subtree of one is a mirror of the right subtree of the other, and vice versa. +![Zigzag Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must check the mirror property. -- **Optimized Strategy (Recursion):** Use recursion to check if left and right subtrees are mirrors. This is the standard and efficient approach. -- **Why it's better:** Recursion naturally checks the mirror property by comparing corresponding nodes in the left and right subtrees. +- **Brute Force:** Do regular level-order traversal, then reverse every other level. This takes $O(n)$ time and $O(n)$ space. +- **Optimized (BFS with Direction Flag):** Use BFS and reverse the level list when needed based on a flag. This takes $O(n)$ time and $O(n)$ space. +- **Emphasize the optimization:** While complexity is the same, the direction flag approach is cleaner and more efficient than reversing after collection. **1.4 Decomposition:** -1. Define a helper function that checks if two trees are mirrors. -2. Two trees are mirrors if: - - Both are null (base case: true). - - One is null and the other is not (false). - - Both roots have the same value, and: - - Left subtree of first is mirror of right subtree of second. - - Right subtree of first is mirror of left subtree of second. -3. Check if root's left and right subtrees are mirrors. +1. **BFS Traversal:** Use a queue to process nodes level by level. +2. **Track Direction:** Use a boolean flag to alternate between left-to-right and right-to-left. +3. **Reverse When Needed:** For odd levels (right-to-left), reverse the level list before adding to result. +4. **Return Result:** Return the list of levels. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,2,2,3,4,4,3]$ - -The tree structure: -``` - 1 - / \ - 2 2 - / \ / \ - 3 4 4 3 -``` +Let's trace through an example: `root = [3,9,20,null,null,15,7]`. -We initialize: -- Call `is_mirror(root.left, root.right)` +Initialize: `queue = [3]`, `left_to_right = True`, `res = []` -**2.2 Start Checking:** +**2.2 Start Processing:** -We begin checking if left and right subtrees are mirrors. +Process level 0 (root). **2.3 Trace Walkthrough:** -| left | right | left.val | right.val | Check | Result | -|------|-------|----------|-----------|-------|--------| -| 2 | 2 | 2 | 2 | Equal ✓ | Check children | -| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | -| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | -| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | -| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | +| Level | Queue Before | Level Values | Direction | After Reverse | Result | +|-------|--------------|--------------|-----------|---------------|--------| +| 0 | [3] | [3] | L→R | [3] | [[3]] | +| 1 | [9, 20] | [9, 20] | R→L | [20, 9] | [[3], [20, 9]] | +| 2 | [15, 7] | [15, 7] | L→R | [15, 7] | [[3], [20, 9], [15, 7]] | -**2.4 Explanation:** +**2.4 Complete Traversal:** -- Root's left (2) and right (2) have same value ✓ -- Left's left (3) and right's right (3) are mirrors ✓ -- Left's right (4) and right's left (4) are mirrors ✓ +All levels processed: Level 0 (L→R), Level 1 (R→L), Level 2 (L→R). **2.5 Return Result:** -We return `True` because the tree is symmetric. +The function returns `[[3], [20, 9], [15, 7]]`. -> **Note:** The key insight is that a tree is symmetric if its left and right subtrees are mirrors. Two trees are mirrors if their roots match and the left of one mirrors the right of the other (and vice versa). +> **Note:** The direction alternates at each level: even levels (0, 2, ...) are left-to-right, odd levels (1, 3, ...) are right-to-left. ### Solution @@ -3120,22 +2634,36 @@ def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right - class Solution: - def isSymmetric(self, root) -> bool: - def is_mirror(left, right): - if not left and not right: - return True - if not left or not right: - return False - return (left.val == right.val and - is_mirror(left.left, right.right) and - is_mirror(left.right, right.left)) - + def zigzagLevelOrder(self, root: Optional[TreeNode]) -> List[List[int]]: if not root: - return True + return [] - return is_mirror(root.left, root.right) + res = [] + queue = [root] + left_to_right = True + + while queue: + level_size = len(queue) + level = [] + + for _ in range(level_size): + node = queue.pop(0) + level.append(node.val) + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + # Reverse if needed for zigzag + if not left_to_right: + level.reverse() + + res.append(level) + left_to_right = not left_to_right + + return res ``` ## 105. Construct Binary Tree from Preorder and Inorder Traversal [Medium] @@ -3304,165 +2832,52 @@ Root is `postorder[4] = 3`. Find its position in inorder: `inorder[1] = 3`. | 15 | [2:2] | [1:1] | 0 | None | None | | 7 | [3:4] | [2:2] | 0 | None | None | -**2.4 Complete Construction:** - -Tree structure: `3` (root) with left child `9` and right child `20`. `20` has left child `15` and right child `7`. - -**2.5 Return Result:** - -The function returns the root node of the constructed tree. - -> **Note:** Similar to problem 105, but here the root is the last element in postorder instead of the first in preorder. - -### Solution - -```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]: - if not inorder or not postorder: - return None - - # Create a map for O(1) lookup of inorder indices - inorder_map = {val: idx for idx, val in enumerate(inorder)} - - def build(in_start, in_end, post_start, post_end): - if in_start > in_end: - return None - - # Root is the last element in postorder - root_val = postorder[post_end] - root = TreeNode(root_val) - - # Find root position in inorder - root_idx = inorder_map[root_val] - - # Calculate sizes of left and right subtrees - left_size = root_idx - in_start - - # Recursively build left and right subtrees - root.left = build(in_start, root_idx - 1, post_start, post_start + left_size - 1) - root.right = build(root_idx + 1, in_end, post_start + left_size, post_end - 1) - - return root - - return build(0, len(inorder) - 1, 0, len(postorder) - 1) -``` - -## 117. Populating Next Right Pointers in Each Node II [Medium] -https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -**1.1 Constraints & Complexity** - -* **Input Size:** The tree has $0 \leq n \leq 6000$ nodes, with values in $[-100, 100]$. -* **Time Complexity:** $O(n)$ - We visit each node exactly once using BFS. -* **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. -* **Edge Case:** An empty tree returns `None`. A single-node tree has no next pointers to set. - -**1.2 High-level approach** - -The goal is to connect each node's `next` pointer to its next right node at the same level. We use level-order traversal (BFS) to process nodes level by level, connecting them as we go. - -![Next pointer connection showing how nodes are connected level by level] - -**1.3 Brute force vs. optimized strategy** - -* **Brute Force:** Store nodes by level in separate arrays, then connect them. This uses $O(n)$ extra space for level arrays. -* **Optimized (BFS with Queue):** Use a queue to process nodes level by level. Connect nodes within the same level as we process them. This uses $O(n)$ space for the queue, which is necessary for BFS. - -**1.4 Decomposition** - -1. **Level-Order Traversal:** Use BFS to process nodes level by level. -2. **Track Level Size:** Process exactly `level_size` nodes at each iteration. -3. **Connect Nodes:** For each node in a level, set `prev.next = node` (except the first node). -4. **Update Queue:** Add children to queue for next level. - -### Steps (The "How") - -**2.1 Initialization & Example Setup** - -Let's use the example $root = [1,2,3,4,5,null,7]$. - -We initialize: -* `queue = deque([1])` (root node) -* `prev = None` (previous node in current level) - -**2.2 Start Processing** - -We process level 0 (root). - -**2.3 Trace Walkthrough** - -| Level | Queue Before | Level Size | Process | prev | Queue After | Next Pointers | -|-------|--------------|------------|---------|------|-------------|---------------| -| 0 | [1] | 1 | 1 | None | [2,3] | 1.next = None | -| 1 | [2,3] | 2 | 2 | None | [3,4,5] | 2.next = None | -| 1 | [3,4,5] | - | 3 | 2 | [4,5,7] | 2.next = 3, 3.next = None | -| 2 | [4,5,7] | 3 | 4 | None | [5,7] | 4.next = None | -| 2 | [5,7] | - | 5 | 4 | [7] | 4.next = 5, 5.next = None | -| 2 | [7] | - | 7 | 5 | [] | 5.next = 7, 7.next = None | +**2.4 Complete Construction:** -**2.4 Level Processing** +Tree structure: `3` (root) with left child `9` and right child `20`. `20` has left child `15` and right child `7`. -For each level: -1. Get `level_size = len(queue)` -2. Initialize `prev = None` -3. For `level_size` iterations: - - Pop node from queue - - If `prev` exists, set `prev.next = node` - - Update `prev = node` - - Add children to queue +**2.5 Return Result:** -**2.5 Return Result** +The function returns the root node of the constructed tree. -After processing, all nodes have their `next` pointers set correctly: -- Level 0: `1.next = None` -- Level 1: `2.next = 3`, `3.next = None` -- Level 2: `4.next = 5`, `5.next = 7`, `7.next = None` +> **Note:** Similar to problem 105, but here the root is the last element in postorder instead of the first in preorder. ### Solution ```python -def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): - self.val = val - self.left = left - self.right = right - self.next = next -""" - +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right class Solution: - def connect(self, root: 'Node') -> 'Node': - if not root: - return root + def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]: + if not inorder or not postorder: + return None - queue = deque([root]) + # Create a map for O(1) lookup of inorder indices + inorder_map = {val: idx for idx, val in enumerate(inorder)} - while queue: - level_size = len(queue) - prev = None + def build(in_start, in_end, post_start, post_end): + if in_start > in_end: + return None - for _ in range(level_size): - node = queue.popleft() - - if prev: - prev.next = node - prev = node - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) + # Root is the last element in postorder + root_val = postorder[post_end] + root = TreeNode(root_val) + + # Find root position in inorder + root_idx = inorder_map[root_val] + + # Calculate sizes of left and right subtrees + left_size = root_idx - in_start + + # Recursively build left and right subtrees + root.left = build(in_start, root_idx - 1, post_start, post_start + left_size - 1) + root.right = build(root_idx + 1, in_end, post_start + left_size, post_end - 1) + + return root - return root + return build(0, len(inorder) - 1, 0, len(postorder) - 1) ``` ## 114. Flatten Binary Tree to Linked List [Medium] @@ -3584,8 +2999,8 @@ class Solution: curr.right = right ``` -## 112. Path Sum [Easy] -https://leetcode.com/problems/path-sum/ +## 117. Populating Next Right Pointers in Each Node II [Medium] +https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ ### Explanation @@ -3595,83 +3010,246 @@ https://leetcode.com/problems/path-sum/ **1.1 Constraints & Complexity** -* **Input Size:** The tree has $0 \leq n \leq 5000$ nodes, with values in $[-1000, 1000]$. -* **Time Complexity:** $O(n)$ - We visit each node at most once in the worst case. -* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -* **Edge Case:** An empty tree returns `False`. A single-node tree returns `True` if the node value equals `targetSum`. +* **Input Size:** The tree has $0 \leq n \leq 6000$ nodes, with values in $[-100, 100]$. +* **Time Complexity:** $O(n)$ - We visit each node exactly once using BFS. +* **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. +* **Edge Case:** An empty tree returns `None`. A single-node tree has no next pointers to set. **1.2 High-level approach** -The goal is to check if there exists a root-to-leaf path where the sum of node values equals `targetSum`. We traverse the tree recursively, subtracting each node's value from the remaining sum, and check if we reach a leaf with the correct sum. +The goal is to connect each node's `next` pointer to its next right node at the same level. We use level-order traversal (BFS) to process nodes level by level, connecting them as we go. -![Path sum visualization showing root-to-leaf paths and their sums] +![Next pointer connection showing how nodes are connected level by level] **1.3 Brute force vs. optimized strategy** -* **Brute Force:** Find all root-to-leaf paths, calculate their sums, then check if any equals `targetSum`. This requires storing all paths, using $O(n \times h)$ space. -* **Optimized (Recursive DFS):** Traverse the tree and check the sum incrementally. If we find a valid path, return immediately. This uses $O(h)$ space for recursion stack. +* **Brute Force:** Store nodes by level in separate arrays, then connect them. This uses $O(n)$ extra space for level arrays. +* **Optimized (BFS with Queue):** Use a queue to process nodes level by level. Connect nodes within the same level as we process them. This uses $O(n)$ space for the queue, which is necessary for BFS. **1.4 Decomposition** -1. **Base Case:** If node is `None`, return `False`. -2. **Leaf Check:** If node is a leaf, check if its value equals the remaining sum. -3. **Recursive Check:** Recursively check left and right subtrees with updated remaining sum. -4. **Return Result:** Return `True` if either subtree has a valid path. +1. **Level-Order Traversal:** Use BFS to process nodes level by level. +2. **Track Level Size:** Process exactly `level_size` nodes at each iteration. +3. **Connect Nodes:** For each node in a level, set `prev.next = node` (except the first node). +4. **Update Queue:** Add children to queue for next level. ### Steps (The "How") **2.1 Initialization & Example Setup** -Let's use the example $root = [5,4,8,11,null,13,4,7,2,null,null,null,1]$, $targetSum = 22$. +Let's use the example $root = [1,2,3,4,5,null,7]$. -We start at the root node with value 5. +We initialize: +* `queue = deque([1])` (root node) +* `prev = None` (previous node in current level) -**2.2 Start Checking** +**2.2 Start Processing** -We call `hasPathSum(root, 22)`. +We process level 0 (root). **2.3 Trace Walkthrough** -| Node | targetSum (before) | Is Leaf? | targetSum (after) | Left Result | Right Result | Final Result | -|------|-------------------|----------|-------------------|-------------|--------------|--------------| -| 5 | 22 | No | 17 | Check(4, 17) | Check(8, 17) | OR result | -| 4 | 17 | No | 13 | Check(11, 13) | None | OR result | -| 11 | 13 | No | 2 | Check(7, 2) | Check(2, 2) | OR result | -| 7 | 2 | Yes | -5 | - | - | False | -| 2 | 2 | Yes | 0 | - | - | **True** | +| Level | Queue Before | Level Size | Process | prev | Queue After | Next Pointers | +|-------|--------------|------------|---------|------|-------------|---------------| +| 0 | [1] | 1 | 1 | None | [2,3] | 1.next = None | +| 1 | [2,3] | 2 | 2 | None | [3,4,5] | 2.next = None | +| 1 | [3,4,5] | - | 3 | 2 | [4,5,7] | 2.next = 3, 3.next = None | +| 2 | [4,5,7] | 3 | 4 | None | [5,7] | 4.next = None | +| 2 | [5,7] | - | 5 | 4 | [7] | 4.next = 5, 5.next = None | +| 2 | [7] | - | 7 | 5 | [] | 5.next = 7, 7.next = None | + +**2.4 Level Processing** + +For each level: +1. Get `level_size = len(queue)` +2. Initialize `prev = None` +3. For `level_size` iterations: + - Pop node from queue + - If `prev` exists, set `prev.next = node` + - Update `prev = node` + - Add children to queue + +**2.5 Return Result** + +After processing, all nodes have their `next` pointers set correctly: +- Level 0: `1.next = None` +- Level 1: `2.next = 3`, `3.next = None` +- Level 2: `4.next = 5`, `5.next = 7`, `7.next = None` + +### Solution + +```python +def __init__(self, val: int = 0, left: 'Node' = None, right: 'Node' = None, next: 'Node' = None): + self.val = val + self.left = left + self.right = right + self.next = next +""" + +class Solution: + def connect(self, root: 'Node') -> 'Node': + if not root: + return root + + queue = deque([root]) + + while queue: + level_size = len(queue) + prev = None + + for _ in range(level_size): + node = queue.popleft() + + if prev: + prev.next = node + prev = node + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + return root +``` + +## 128. Longest Consecutive Sequence [Medium] +https://leetcode.com/problems/longest-consecutive-sequence/ + +### Explanation + +## 128. Longest Consecutive Sequence [Medium] + +https://leetcode.com/problems/longest-consecutive-sequence + +## Description +Given an unsorted array of integers `nums`, return *the length of the longest consecutive elements sequence.* + +You must write an algorithm that runs in `O(n)` time. + +**Examples** + +```tex +Example 1: +Input: nums = [100,4,200,1,3,2] +Output: 4 +Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. + +Example 2: +Input: nums = [0,3,7,2,5,8,4,6,0,1] +Output: 9 + +Example 3: +Input: nums = [1,0,1,2] +Output: 3 +``` + +**Constraints** +```tex +- 0 <= nums.length <= 10^5 +- -10^9 <= nums[i] <= 10^9 +``` + +## Explanation + +### Strategy +Let's restate the problem: You're given an unsorted array of integers, and you need to find the length of the longest sequence of consecutive integers. The challenge is to do this in O(n) time, which means we can't sort the array (as sorting takes O(n log n) time). + +This is a **hash table problem** that requires finding sequences of consecutive numbers efficiently by using the properties of consecutive sequences. + +**What is given?** An unsorted array of integers that can be very large (up to 100,000 elements). + +**What is being asked?** Find the length of the longest sequence of consecutive integers. + +**Constraints:** The array can be up to 100,000 elements long, with values ranging from -10⁹ to 10⁹. + +**Edge cases:** +- Empty array +- Array with single element +- Array with all identical elements +- Array with no consecutive sequences + +**High-level approach:** +The solution involves using a hash set to quickly check if numbers exist, then for each number, expanding in both directions to find the complete consecutive sequence. + +**Decomposition:** +1. **Convert array to hash set**: For O(1) lookup time +2. **Find sequence starting points**: Look for numbers that are the start of a consecutive sequence +3. **Expand sequences**: For each starting point, expand in both directions to find the complete sequence +4. **Track maximum length**: Keep track of the longest sequence found + +**Brute force vs. optimized strategy:** +- **Brute force**: Sort the array and find consecutive sequences. This takes O(n log n) time. +- **Optimized**: Use hash set and expand sequences from starting points. This takes O(n) time. + +### Steps +Let's walk through the solution step by step using the first example: `nums = [100,4,200,1,3,2]` + +**Step 1: Convert array to hash set** +- `nums = [100,4,200,1,3,2]` +- `num_set = {100, 4, 200, 1, 3, 2}` -Since node 2 is a leaf and `2 == 2`, we return `True` for the path $5 \to 4 \to 11 \to 2$. +**Step 2: Find sequence starting points** +- For each number, check if it's the start of a consecutive sequence +- A number is a starting point if `num - 1` is NOT in the set +- Starting points: `[100, 200, 1]` (because 99, 199, and 0 are not in the set) -**2.4 Recursive Processing** +**Step 3: Expand sequences from starting points** +- **Starting point 100**: + - Check if 101 exists: No + - Sequence length: 1 +- **Starting point 200**: + - Check if 201 exists: No + - Sequence length: 1 +- **Starting point 1**: + - Check if 2 exists: Yes + - Check if 3 exists: Yes + - Check if 4 exists: Yes + - Check if 5 exists: No + - Sequence: [1, 2, 3, 4] + - Sequence length: 4 -For each node: -1. If `not root`, return `False` -2. If leaf (`not root.left and not root.right`), return `root.val == targetSum` -3. Otherwise, recursively check: `hasPathSum(root.left, targetSum - root.val) or hasPathSum(root.right, targetSum - root.val)` +**Step 4: Track maximum length** +- Maximum sequence length found: 4 +- Result: 4 -**2.5 Return Result** +**Why this works:** +By identifying starting points (numbers that don't have a predecessor in the set), we ensure that we only expand each sequence once. This gives us O(n) time complexity because: +1. We visit each number at most twice (once when checking if it's a starting point, once when expanding sequences) +2. Each number is part of at most one sequence +3. The total work is bounded by O(n) -The function returns `True` because there exists a path $5 \to 4 \to 11 \to 2$ with sum $5 + 4 + 11 + 2 = 22$. +> **Note:** The key insight is identifying starting points of consecutive sequences and expanding from there. This avoids redundant work and ensures O(n) time complexity. + +**Time Complexity:** O(n) - we visit each number at most twice +**Space Complexity:** O(n) - we need to store the hash set ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def hasPathSum(self, root: Optional[TreeNode], targetSum: int) -> bool: - if not root: - return False - - # If leaf node, check if value equals remaining sum - if not root.left and not root.right: - return root.val == targetSum - - # Recursively check left and right subtrees - remaining = targetSum - root.val - return self.hasPathSum(root.left, remaining) or self.hasPathSum(root.right, remaining) +def longestConsecutive(nums): + if not nums: + return 0 + + # Convert array to hash set for O(1) lookup + num_set = set(nums) + max_length = 0 + + # For each number, check if it's the start of a consecutive sequence + for num in num_set: + # A number is a starting point if num - 1 is NOT in the set + if num - 1 not in num_set: + current_length = 1 + current_num = num + + # Expand the sequence by checking consecutive numbers + while current_num + 1 in num_set: + current_length += 1 + current_num += 1 + + # Update maximum length if current sequence is longer + max_length = max(max_length, current_length) + + return max_length ``` ## 129. Sum Root to Leaf Numbers [Medium] @@ -3782,8 +3360,8 @@ class Solution: return res ``` -## 124. Binary Tree Maximum Path Sum [Hard] -https://leetcode.com/problems/binary-tree-maximum-path-sum/ +## 133. Clone Graph [Medium] +https://leetcode.com/problems/clone-graph/ ### Explanation @@ -3791,402 +3369,583 @@ https://leetcode.com/problems/binary-tree-maximum-path-sum/ ### Strategy (The "Why") -**1.1 Constraints & Complexity** +**1.1 Constraints & Complexity:** -* **Input Size:** The tree has $1 \leq n \leq 3 \times 10^4$ nodes, with values in $[-1000, 1000]$. -* **Time Complexity:** $O(n)$ - We visit each node exactly once during DFS traversal. -* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -* **Edge Case:** A single-node tree returns the node's value. All negative values require careful handling (we use `max(0, ...)` to avoid negative contributions). +- **Constraints:** The graph has at most 100 nodes. Each node has a unique value in the range $[1, 100]$. The graph is connected and undirected. +- **Time Complexity:** $O(V + E)$ where $V$ is the number of vertices and $E$ is the number of edges. We visit each node and edge once. +- **Space Complexity:** $O(V)$ for the hash map storing original-to-clone mappings and the recursion stack. +- **Edge Case:** If the input node is `None`, return `None`. If the graph has only one node, return a clone of that node. -**1.2 High-level approach** +**1.2 High-level approach:** -The goal is to find the maximum path sum in a binary tree, where a path can start and end at any nodes (not necessarily root or leaf). We use DFS to calculate the maximum path sum that can be extended upward from each node, while tracking the global maximum. +The goal is to create a deep copy of the graph. We use a hash map to track which nodes have been cloned, and recursively clone each node and its neighbors. -![Maximum path sum visualization showing paths that can go through any node] +**1.3 Brute force vs. optimized strategy:** -**1.3 Brute force vs. optimized strategy** +- **Brute Force:** Create all nodes first, then set up connections. This requires two passes and is more complex. +- **Optimized Strategy:** Use DFS with a hash map. When cloning a node, recursively clone its neighbors. The hash map prevents creating duplicate clones of the same node. +- **Why optimized is better:** The optimized approach handles cycles naturally and is more elegant, requiring only one traversal. -* **Brute Force:** Try all possible paths in the tree. This is exponential in complexity. -* **Optimized (DFS with Global Tracking):** For each node, calculate the maximum path sum that can be extended upward (for parent) and the maximum path sum through the node (for global maximum). This achieves $O(n)$ time. +**1.4 Decomposition:** -**1.4 Decomposition** +1. Create a hash map to store mappings from original nodes to cloned nodes. +2. Use DFS to clone nodes recursively. +3. For each node, if it's already cloned, return the clone from the map. +4. Otherwise, create a new node, add it to the map, and recursively clone all neighbors. +5. Return the cloned graph starting from the given node. -1. **DFS Traversal:** Recursively visit each node. -2. **Calculate Contributions:** For each node, get maximum contributions from left and right subtrees (non-negative only). -3. **Update Global Maximum:** Calculate path sum through current node and update global maximum. -4. **Return Upward Contribution:** Return the maximum path sum that can be extended to parent. +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: `adjList = [[2,4],[1,3],[2,4],[1,3]]` + +This represents a graph with 4 nodes: +- Node 1 is connected to nodes 2 and 4 +- Node 2 is connected to nodes 1 and 3 +- Node 3 is connected to nodes 2 and 4 +- Node 4 is connected to nodes 1 and 3 + +We initialize an empty hash map `node_map = {}`. + +**2.2 Start Checking:** + +We call the `clone` function with the given node (node 1). + +**2.3 Trace Walkthrough:** + +| Step | Node | Action | node_map | +|------|------|--------|----------| +| 1 | 1 | Create clone(1), add to map | {1: clone(1)} | +| 2 | Clone neighbors of 1: [2,4] | Clone node 2 | {1: clone(1), 2: clone(2)} | +| 3 | Clone neighbors of 2: [1,3] | Node 1 already cloned, use it | {1: clone(1), 2: clone(2), 3: clone(3)} | +| 4 | Clone neighbors of 3: [2,4] | Node 2 already cloned, use it | {1: clone(1), 2: clone(2), 3: clone(3), 4: clone(4)} | +| 5 | Clone neighbors of 4: [1,3] | Both already cloned, use them | Complete | + +**2.4 Increment and Loop:** + +The recursive `clone` function: +1. Checks if the node is already in `node_map`. If yes, returns the clone. +2. Creates a new `Node` with the same value. +3. Adds the mapping to `node_map`. +4. Recursively clones all neighbors and adds them to the clone's neighbors list. + +**2.5 Return Result:** + +The function returns `clone(node)`, which is the cloned version of the input node. The entire graph structure is cloned, with all connections preserved. + +### Solution + +```python +def __init__(self, val = 0, neighbors = None): + self.val = val + self.neighbors = neighbors if neighbors is not None else [] +""" + +from typing import Optional +class Solution: + def cloneGraph(self, node: Optional['Node']) -> Optional['Node']: + if not node: + return None + + # Dictionary to map original nodes to cloned nodes + node_map = {} + + def clone(node): + # If already cloned, return the clone + if node in node_map: + return node_map[node] + + # Create a new node + clone_node = Node(node.val) + node_map[node] = clone_node + + # Clone all neighbors + for neighbor in node.neighbors: + clone_node.neighbors.append(clone(neighbor)) + + return clone_node + + return clone(node) +``` + +## 138. Copy List with Random Pointer [Medium] +https://leetcode.com/problems/copy-list-with-random-pointer/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity:** + +- **Constraints:** $0 \leq n \leq 1000$ nodes. Node values are in the range $[-10^4, 10^4]$. Random pointers can point to any node or `None`. +- **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We make two passes through the list. +- **Space Complexity:** $O(n)$ for the hash map storing original-to-clone node mappings. +- **Edge Case:** If the list is empty (`head` is `None`), return `None`. + +**1.2 High-level approach:** + +The goal is to create a deep copy of the linked list where each node has both `next` and `random` pointers. We use a hash map to store mappings from original nodes to cloned nodes, then set up the pointers in a second pass. + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** Create all nodes first, then try to set random pointers. This is complex because random pointers can point to nodes we haven't created yet. +- **Optimized Strategy:** Two-pass approach: first pass creates all nodes and stores mappings, second pass sets `next` and `random` pointers using the map. This is $O(n)$ time and $O(n)$ space. +- **Why optimized is better:** The two-pass approach cleanly separates node creation from pointer setup, making the logic straightforward. + +**1.4 Decomposition:** + +1. Create a hash map to store mappings from original nodes to cloned nodes. +2. First pass: traverse the list and create a clone of each node, storing the mapping. +3. Second pass: traverse the list again and set `next` and `random` pointers for each clone using the map. +4. Return the cloned head node. ### Steps (The "How") -**2.1 Initialization & Example Setup** +**2.1 Initialization & Example Setup:** -Let's use the example $root = [-10,9,20,null,null,15,7]$. +Let's use the example: `head = [[7,null],[13,0],[11,4],[10,2],[1,0]]` -We initialize: -* `res = -inf` (global maximum path sum) -* Start DFS from root node (-10) +This represents: +- Node 0: value 7, random = null +- Node 1: value 13, random = node 0 +- Node 2: value 11, random = node 4 +- Node 3: value 10, random = node 2 +- Node 4: value 1, random = node 0 -**2.2 Start Processing** +We initialize `node_map = {}`. -We call `dfs(root)`. +**2.2 Start Checking:** -**2.3 Trace Walkthrough** +We perform two passes: first to create nodes, second to set pointers. -| Node | left_sum | right_sum | Path Through Node | Return Value | res (after) | -|------|----------|-----------|-------------------|--------------|-------------| -| -10 | max(0, dfs(9)) | max(0, dfs(20)) | -10 + 0 + 0 = -10 | -10 + max(0,0) = -10 | -10 | -| 9 | 0 | 0 | 9 + 0 + 0 = 9 | 9 + 0 = 9 | 9 | -| 20 | max(0, dfs(15)) | max(0, dfs(7)) | 20 + 15 + 7 = 42 | 20 + max(15,7) = 35 | 42 | -| 15 | 0 | 0 | 15 + 0 + 0 = 15 | 15 + 0 = 15 | 42 | -| 7 | 0 | 0 | 7 + 0 + 0 = 7 | 7 + 0 = 7 | 42 | +**2.3 Trace Walkthrough:** + +**First pass (create nodes):** + +| Original Node | Value | Clone Created | node_map | +|---------------|-------|---------------|----------| +| Node 0 | 7 | Clone(7) | {Node0: Clone(7)} | +| Node 1 | 13 | Clone(13) | {Node0: Clone(7), Node1: Clone(13)} | +| Node 2 | 11 | Clone(11) | {Node0: Clone(7), Node1: Clone(13), Node2: Clone(11)} | +| Node 3 | 10 | Clone(10) | {Node0: Clone(7), Node1: Clone(13), Node2: Clone(11), Node3: Clone(10)} | +| Node 4 | 1 | Clone(1) | {Node0: Clone(7), ..., Node4: Clone(1)} | -**2.4 Recursive Processing** +**Second pass (set pointers):** -For each node: -1. If `not node`, return 0 (base case) -2. Recursively get `left_sum = max(0, dfs(node.left))` (non-negative only) -3. Recursively get `right_sum = max(0, dfs(node.right))` (non-negative only) -4. Update global: `res = max(res, node.val + left_sum + right_sum)` -5. Return: `node.val + max(left_sum, right_sum)` (for parent) +| Original Node | next points to | random points to | Clone's next | Clone's random | +|---------------|----------------|------------------|--------------|----------------| +| Node 0 | Node 1 | null | Clone(13) | null | +| Node 1 | Node 2 | Node 0 | Clone(11) | Clone(7) | +| Node 2 | Node 3 | Node 4 | Clone(10) | Clone(1) | +| Node 3 | Node 4 | Node 2 | Clone(1) | Clone(11) | +| Node 4 | null | Node 0 | null | Clone(7) | -**2.5 Return Result** +**2.4 Increment and Loop:** -After processing all nodes, `res = 42`, which is the maximum path sum from the path $15 \to 20 \to 7$. +- First pass: `while curr: node_map[curr] = Node(curr.val); curr = curr.next` +- Second pass: `while curr: node_map[curr].next = node_map.get(curr.next); node_map[curr].random = node_map.get(curr.random); curr = curr.next` -> **Note:** We use `max(0, ...)` to ensure we only consider positive contributions from subtrees. If a subtree contributes negatively, we ignore it (treat as 0). +**2.5 Return Result:** + +We return `node_map[head]`, which is the cloned head node. The entire list structure is cloned with all `next` and `random` pointers correctly set. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): + self.val = int(x) + self.next = next + self.random = random +""" + class Solution: - def maxPathSum(self, root: Optional[TreeNode]) -> int: - res = float('-inf') + def copyRandomList(self, head: 'Optional[Node]') -> 'Optional[Node]': + if not head: + return None - def dfs(node): - nonlocal res - if not node: - return 0 - - # Get max path sum from left and right subtrees - left_sum = max(0, dfs(node.left)) - right_sum = max(0, dfs(node.right)) - - # Update global maximum (path through current node) - res = max(res, node.val + left_sum + right_sum) - - # Return max path sum that can be extended upward - return node.val + max(left_sum, right_sum) + # First pass: create new nodes and map old to new + node_map = {} + curr = head - dfs(root) - return res + while curr: + node_map[curr] = Node(curr.val) + curr = curr.next + + # Second pass: set next and random pointers + curr = head + while curr: + if curr.next: + node_map[curr].next = node_map[curr.next] + if curr.random: + node_map[curr].random = node_map[curr.random] + curr = curr.next + + return node_map[head] ``` -## 173. Binary Search Tree Iterator [Medium] -https://leetcode.com/problems/binary-search-tree-iterator/ +## 146. LRU Cache [Medium] +https://leetcode.com/problems/lru-cache/ ### Explanation +Design a data structure that follows the constraints of a **Least Recently Used (LRU) cache**. + +Implement the `LRUCache` class: + +- `LRUCache(int capacity)` Initialize the LRU cache with **positive** size `capacity`. +- `int get(int key)` Return the value of the `key` if the key exists, otherwise return `-1`. +- `void put(int key, int value)` Update the value of the `key` if the `key` exists. Otherwise, add the `key-value` pair to the cache. If the number of keys exceeds the `capacity` from this operation, **evict** the least recently used key. + +The functions `get` and `put` must each run in `O(1)` average time complexity. + +**Example 1:** + +```raw +Input +["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] +[[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] +Output +[null, null, null, 1, null, -1, null, -1, 3, 4] + +Explanation: + +LRUCache lRUCache = new LRUCache(2); +lRUCache.put(1, 1); // cache is {1=1} +lRUCache.put(2, 2); // cache is {1=1, 2=2} +lRUCache.get(1); // return 1 +lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} +lRUCache.get(2); // returns -1 (not found) +lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} +lRUCache.get(1); // return -1 (not found) +lRUCache.get(3); // return 3 +lRUCache.get(4); // return 4 +``` + +**Constraints:** +- `1 <= capacity <= 3000` +- `0 <= key <= 10^4` +- `0 <= value <= 10^5` +- At most `2 * 10^5` calls will be made to `get` and `put`. + ## Explanation -### Strategy (The "Why") +### Strategy -**1.1 Constraints & Complexity:** +This is a **design problem** that requires implementing an LRU (Least Recently Used) cache. The key insight is to combine a hash map for O(1) lookups with a doubly linked list for O(1) insertions/deletions to maintain the order of usage. -- **Constraints:** $1 \leq n \leq 10^5$ nodes. Node values are in the range $[0, 10^6]$. At most $10^5$ calls to `next()` and `hasNext()`. -- **Time Complexity:** - - `__init__`: $O(h)$ where $h$ is the height of the tree (we push left nodes). - - `next()`: Amortized $O(1)$ per call. - - `hasNext()`: $O(1)$. -- **Space Complexity:** $O(h)$ for the stack storing nodes along the path to the leftmost node. -- **Edge Case:** If the tree has only one node, the stack contains that node initially. +**Key observations:** -**1.2 High-level approach:** +- We need O(1) time for both get and put operations +- We need to track the order of usage (most recently used to least recently used) +- When capacity is exceeded, we need to remove the least recently used item +- A hash map provides O(1) lookups, but doesn't maintain order +- A doubly linked list maintains order and allows O(1) insertions/deletions -The goal is to implement an iterator that returns nodes in in-order traversal (left, root, right) order. We use a stack to simulate the in-order traversal. Initially, we push all left nodes. When `next()` is called, we pop a node, push its right subtree's left nodes, and return the node's value. +**High-level approach:** -**1.3 Brute force vs. optimized strategy:** +1. **Use a hash map**: For O(1) key-value lookups +2. **Use a doubly linked list**: To maintain usage order +3. **Combine both**: Hash map stores key -> node mappings +4. **Update order**: Move accessed items to front (most recently used) +5. **Evict LRU**: Remove from end when capacity exceeded -- **Brute Force:** Perform full in-order traversal, store all values in a list, then iterate through the list. This requires $O(n)$ space and doesn't meet the $O(h)$ space requirement. -- **Optimized Strategy:** Use a stack to maintain only the nodes needed for the current path. Push left nodes initially, and when popping, push left nodes of the right child. This uses $O(h)$ space. -- **Why optimized is better:** The optimized approach meets the $O(h)$ space requirement and provides amortized $O(1)$ time for `next()`. +### Steps -**1.4 Decomposition:** +Let's break down the solution step by step: -1. In `__init__`, push all left nodes starting from the root. -2. In `next()`, pop a node from the stack, push all left nodes of its right child, and return the node's value. -3. In `hasNext()`, check if the stack is non-empty. +**Step 1: Design the data structure** -### Steps (The "How") +- `capacity`: Maximum number of items in cache +- `cache`: Hash map for key -> node mappings +- `head`: Dummy head node of doubly linked list +- `tail`: Dummy tail node of doubly linked list -**2.1 Initialization & Example Setup:** +**Step 2: Implement get operation** -Let's use the example: `root = [7, 3, 15, null, null, 9, 20]` +- Check if key exists in hash map +- If not found, return -1 +- If found, move node to front (most recently used) +- Return the value -The tree structure: -``` - 7 - / \ - 3 15 - / \ - 9 20 -``` +**Step 3: Implement put operation** -We initialize `stack = []` and call `_push_left(root)`. +- If key exists, update value and move to front +- If key doesn't exist: + - Create new node + - Add to front of list + - Add to hash map + - If capacity exceeded, remove LRU item (from end) -**2.2 Start Checking:** +**Step 4: Helper methods** -The `_push_left` function pushes all left nodes: 7, then 3. So `stack = [7, 3]` (top is 3). +- `_add_to_front(node)`: Add node to front of list +- `_remove_node(node)`: Remove node from list +- `_remove_lru()`: Remove least recently used item -**2.3 Trace Walkthrough:** +**Example walkthrough:** -| Operation | Stack before | Action | Stack after | Return | -|-----------|--------------|--------|-------------|--------| -| __init__ | [] | Push left: 7, 3 | [7, 3] | - | -| next() | [7, 3] | Pop 3, push left of 3.right (none) | [7] | 3 | -| next() | [7] | Pop 7, push left of 7.right: 15, 9 | [15, 9] | 7 | -| hasNext() | [15, 9] | Check stack non-empty | [15, 9] | True | -| next() | [15, 9] | Pop 9, push left of 9.right (none) | [15] | 9 | -| next() | [15] | Pop 15, push left of 15.right: 20 | [20] | 15 | -| next() | [20] | Pop 20, push left of 20.right (none) | [] | 20 | -| hasNext() | [] | Check stack empty | [] | False | +Let's trace through the example: -**2.4 Increment and Loop:** +```raw +capacity = 2 -- **`_push_left(node)`**: While `node` is not None, push `node` to stack and move to `node.left`. -- **`next()`**: - - Pop a node from the stack. - - Call `_push_left(node.right)` to push all left nodes of the right subtree. - - Return the popped node's value. +put(1, 1): cache = {1=1}, list = [1] +put(2, 2): cache = {1=1, 2=2}, list = [2, 1] +get(1): return 1, list = [1, 2] (move 1 to front) +put(3, 3): cache = {1=1, 3=3}, list = [3, 1] (evict 2) +get(2): return -1 (not found) +put(4, 4): cache = {3=3, 4=4}, list = [4, 3] (evict 1) +get(1): return -1 (not found) +get(3): return 3, list = [3, 4] +get(4): return 4, list = [4, 3] +``` -**2.5 Return Result:** +> **Note:** The doubly linked list with dummy head and tail nodes makes it easy to add/remove nodes at the beginning and end. The hash map provides O(1) access to any node, and the list maintains the order of usage. -The iterator returns values in in-order order: 3, 7, 9, 15, 20. Each call to `next()` returns the next value, and `hasNext()` correctly indicates when more values are available. +**Time Complexity:** O(1) for both get and put operations +**Space Complexity:** O(capacity) - we store at most capacity items ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class BSTIterator: +def __init__(self, capacity: int): + self.capacity = capacity + self.cache = {} # key -> node mapping + + # Initialize doubly linked list with dummy nodes + self.head = Node(0, 0) # dummy head + self.tail = Node(0, 0) # dummy tail + self.head.next = self.tail + self.tail.prev = self.head + + def get(self, key: int) -> int: + # Check if key exists + if key not in self.cache: + return -1 + + # Move node to front (most recently used) + node = self.cache[key] + self._remove_node(node) + self._add_to_front(node) + + return node.value + + def put(self, key: int, value: int) -> None: + # If key exists, update value and move to front + if key in self.cache: + node = self.cache[key] + node.value = value + self._remove_node(node) + self._add_to_front(node) + else: + # Create new node + node = Node(key, value) + self.cache[key] = node + self._add_to_front(node) - def __init__(self, root: Optional[TreeNode]): - self.stack = [] - self._push_left(root) + # If capacity exceeded, remove LRU item + if len(self.cache) > self.capacity: + self._remove_lru() - def _push_left(self, node): - # Push all left nodes to stack - while node: - self.stack.append(node) - node = node.left + def _add_to_front(self, node): + """Add node to front of list (after dummy head)""" + node.next = self.head.next + node.prev = self.head + self.head.next.prev = node + self.head.next = node - def next(self) -> int: - # Pop the smallest element - node = self.stack.pop() - # Push all left nodes of the right child - if node.right: - self._push_left(node.right) - return node.val + def _remove_node(self, node): + """Remove node from list""" + node.prev.next = node.next + node.next.prev = node.prev - def hasNext(self) -> bool: - return len(self.stack) > 0 + def _remove_lru(self): + """Remove least recently used item (before dummy tail)""" + lru_node = self.tail.prev + self._remove_node(lru_node) + del self.cache[lru_node.key] -# Your BSTIterator object will be instantiated and called as such: -# obj = BSTIterator(root) -# param_1 = obj.next() -# param_2 = obj.hasNext() +class Node: + def __init__(self, key, value): + self.key = key + self.value = value + self.prev = None + self.next = None ``` -## 222. Count Complete Tree Nodes [Easy] -https://leetcode.com/problems/count-complete-tree-nodes/ +## 148. Sort List [Medium] +https://leetcode.com/problems/sort-list/ ### Explanation -## Explanation +Given the `head` of a linked list, return *the list after sorting it in **ascending order***. -### Strategy (The "Why") +**Example 1:** -**1.1 Constraints & Complexity:** -- **Constraints:** The tree has 0 to 5*10^4 nodes and is guaranteed to be complete. -- **Time Complexity:** O(log² n) - We do O(log n) work at each level, and there are O(log n) levels. -- **Space Complexity:** O(log n) for the recursion stack. -- **Edge Case:** If the root is None, return 0. +```tex +Input: head = [4,2,1,3] +Output: [1,2,3,4] +``` -**1.2 High-level approach:** -The goal is to count nodes in a complete binary tree efficiently. We use the property that in a complete tree, we can check if subtrees are full by comparing left and right heights. +**Example 2:** -**1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Recursively count all nodes: O(n) time. -- **Optimized Strategy:** Use the complete tree property. If left and right heights are equal, the left subtree is full. Otherwise, the right subtree is full. This allows us to skip counting full subtrees. -- **Why optimized is better:** We avoid counting nodes in full subtrees, reducing time complexity to O(log² n). +```tex +Input: head = [-1,5,3,4,0] +Output: [-1,0,3,4,5] +``` -**1.4 Decomposition:** -1. Calculate the height of the left subtree by following left children. -2. Calculate the height of the right subtree by following left children from the right child. -3. If heights are equal, the left subtree is full (2^height - 1 nodes), so recursively count the right subtree. -4. If heights differ, the right subtree is full, so recursively count the left subtree. -5. Add 1 for the root and the full subtree size. +**Example 3:** -### Steps (The "How") +```tex +Input: head = [] +Output: [] +``` -**2.1 Initialization & Example Setup:** -Example tree: `[1,2,3,4,5,6]` (complete binary tree with 6 nodes) +**Constraints:** +- The number of nodes in the list is in the range `[0, 5 * 10^4]`. +- `-10^5 <= Node.val <= 10^5` -Root = 1, left = 2, right = 3 +**Follow up:** Can you sort the linked list in `O(n logn)` time and `O(1)` memory (i.e. constant space)? -**2.2 Start Checking:** -Calculate left height from root.left (node 2): follow left children → 4 → None, height = 2 -Calculate right height from root.right (node 3): follow left children → None, height = 0 +## Explanation -**2.3 Trace Walkthrough:** +### Strategy -| Node | Left Height | Right Height | Action | -|------|-------------|---------------|--------| -| 1 | 2 | 0 | Heights differ, right is full. Count = 2^0 + countNodes(left) | -| 2 | 1 | 0 | Heights differ, right is full. Count = 2^0 + countNodes(left) | -| 4 | 0 | 0 | Heights equal, left is full. Count = 2^0 + countNodes(right) | -| 5 | 0 | 0 | Base case, return 1 | +This is a **divide-and-conquer problem** that requires sorting a linked list in O(n log n) time and O(1) space. The key insight is to use merge sort, which naturally works well with linked lists and can be implemented in-place. -**2.4 Increment and Loop:** -Recursively: -- If left_height == right_height: return (1 << left_height) + countNodes(right) -- Else: return (1 << right_height) + countNodes(left) +**Key observations:** +- We need O(n log n) time complexity for optimal sorting +- We need O(1) space complexity (no extra data structures) +- Merge sort is perfect for linked lists because we can split and merge in-place +- We can use the fast/slow pointer technique to find the middle -**2.5 Return Result:** -Total count = 1 (root) + 1 (node 2) + 1 (node 4) + 1 (node 5) + 1 (node 3) + 1 (node 6) = 6 nodes. +**High-level approach:** +1. **Find the middle**: Use fast/slow pointers to split the list +2. **Recursively sort**: Sort the left and right halves +3. **Merge sorted lists**: Merge the two sorted halves +4. **Return result**: Return the merged sorted list -### Solution +### Steps -```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +Let's break down the solution step by step: -class Solution: - def countNodes(self, root: Optional[TreeNode]) -> int: - if not root: - return 0 - - # Get left and right heights - left_height = self.get_height(root.left) - right_height = self.get_height(root.right) - - if left_height == right_height: - # Left subtree is full, right subtree may not be - return (1 << left_height) + self.countNodes(root.right) - else: - # Right subtree is full, left subtree may not be - return (1 << right_height) + self.countNodes(root.left) - - def get_height(self, node): - height = 0 - while node: - height += 1 - node = node.left - return height -``` +**Step 1: Handle base cases** +- If head is null or head.next is null, return head (already sorted) -## 236. Lowest Common Ancestor of a Binary Tree [Medium] -https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ +**Step 2: Find the middle of the list** +- Use fast/slow pointer technique +- Slow pointer moves 1 step, fast pointer moves 2 steps +- When fast reaches end, slow is at middle -### Explanation +**Step 3: Split the list** +- Set `mid = slow.next` +- Set `slow.next = None` to split the list -## Explanation +**Step 4: Recursively sort halves** -### Strategy (The "Why") +- Sort the left half: `left = sortList(head)` +- Sort the right half: `right = sortList(mid)` -The problem asks us to find the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA is the deepest node that has both nodes as descendants (a node can be a descendant of itself). +**Step 5: Merge the sorted halves** -**1.1 Constraints & Complexity:** +- Use a dummy node to simplify merging +- Compare nodes from both lists and link them in order -- **Input Constraints:** The tree has $2 \leq n \leq 10^5$ nodes with unique values in $[-10^9, 10^9]$. -- **Time Complexity:** $O(n)$ - We may need to visit all nodes in the worst case. -- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -- **Edge Case:** If one node is an ancestor of the other, return that ancestor node. +**Example walkthrough:** -**1.2 High-level approach:** +Let's trace through the first example: -The goal is to find the deepest node that is an ancestor of both target nodes. We use recursive DFS: if we find both nodes in a subtree, the current root is the LCA. +```tex +head = [4,2,1,3] -![Binary Tree LCA](https://assets.leetcode.com/uploads/2018/12/14/binarytree.png) +Step 1: Find middle +slow = 4, fast = 4 +slow = 2, fast = 1 +slow = 1, fast = 3 +slow = 3, fast = null +middle = 3 -**1.3 Brute force vs. optimized strategy:** +Step 2: Split list +left = [4,2,1], right = [3] -- **Brute Force:** Find paths to both nodes, then find the last common node in both paths. This requires storing paths and takes $O(n)$ time and $O(n)$ space. -- **Optimized (Recursive DFS):** Recursively search both subtrees. If both subtrees return non-null, the current root is the LCA. This takes $O(n)$ time and $O(h)$ space. -- **Emphasize the optimization:** The recursive approach finds the LCA in a single pass without storing paths, making it more space-efficient. +Step 3: Recursively sort left +left = [4,2,1] → [1,2,4] -**1.4 Decomposition:** +Step 4: Recursively sort right +right = [3] → [3] -1. **Base Case:** If root is `None` or equals `p` or `q`, return root. -2. **Recursive Search:** Recursively search left and right subtrees for `p` and `q`. -3. **Combine Results:** If both subtrees return non-null, root is the LCA. Otherwise, return whichever subtree found a node. +Step 5: Merge [1,2,4] and [3] +result = [1,2,3,4] +``` -### Steps (The "How") +> **Note:** Merge sort is ideal for linked lists because we can split and merge in-place without extra space. The fast/slow pointer technique efficiently finds the middle, and the merge step can be done by simply relinking nodes. -**2.1 Initialization & Example Setup:** +**Time Complexity:** O(n log n) - merge sort time complexity +**Space Complexity:** O(log n) - recursion stack space (not O(1) due to recursion) -Let's trace through an example: `root = [3,5,1,6,2,0,8,null,null,7,4]`, `p = 5`, `q = 1`. +### Solution -**2.2 Start Searching:** +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next -Begin at root node `3`. -**2.3 Trace Walkthrough:** +class Solution: + def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: + if not head or not head.next: + return head -| Node | Left Result | Right Result | Action | -|------|-------------|--------------|---------| -| 3 | Search left (5) | Search right (1) | Both found → Return 3 | -| 5 | Search left (6) | Search right (2) | Found p → Return 5 | -| 1 | Search left (0) | Search right (8) | Found q → Return 1 | + # Find the middle of the list + slow = head + fast = head.next -**2.4 Recursive Unwinding:** + while fast and fast.next: + slow = slow.next + fast = fast.next.next -- Node `5` returns itself (found `p`). -- Node `1` returns itself (found `q`). -- Node `3` receives both results, so it's the LCA. + # Split the list + mid = slow.next + slow.next = None -**2.5 Return Result:** + left = self.sortList(head) + right = self.sortList(mid) -The function returns node `3`, which is the LCA of nodes `5` and `1`. + return self.merge(left, right) -> **Note:** The key insight is that if both left and right subtrees return non-null, the current root must be the LCA. If only one subtree returns non-null, that subtree contains the LCA. + def merge( + self, left: Optional[ListNode], right: Optional[ListNode] + ) -> Optional[ListNode]: + # Create a dummy node to simplify merging + dummy = ListNode(0) + current = dummy -### Solution + # Merge the two sorted lists + while left and right: + if left.val <= right.val: + current.next = left + left = left.next + else: + current.next = right + right = right.next + current = current.next -```python -def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None + # Attach remaining nodes + if left: + current.next = left + if right: + current.next = right -class Solution: - def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': - # Base case: if root is None or root is p or q, return root - if not root or root == p or root == q: - return root - - # Recursively search in left and right subtrees - left = self.lowestCommonAncestor(root.left, p, q) - right = self.lowestCommonAncestor(root.right, p, q) - - # If both left and right return non-None, root is the LCA - if left and right: - return root - - # Otherwise, return whichever side found p or q - return left if left else right + # Return the merged list (skip dummy node) + return dummy.next ``` -## 199. Binary Tree Right Side View [Medium] -https://leetcode.com/problems/binary-tree-right-side-view/ +## 155. Min Stack [Medium] +https://leetcode.com/problems/min-stack/ ### Explanation @@ -4194,123 +3953,111 @@ https://leetcode.com/problems/binary-tree-right-side-view/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $100$. -- **Value Range:** Node values are between $0$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. -- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. +- **Constraints:** Values are in the range $[-2^{31}, 2^{31} - 1]$. At most $3 \times 10^4$ operations will be performed. Operations are called on non-empty stacks. +- **Time Complexity:** $O(1)$ for all operations (push, pop, top, getMin). Each operation is constant time. +- **Space Complexity:** $O(n)$ where $n$ is the number of elements pushed. We maintain two stacks. +- **Edge Case:** If we push the same minimum value multiple times, we need to track all occurrences to handle pops correctly. **1.2 High-level approach:** -The goal is to find the rightmost node at each level of the tree. - -![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) - -We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. +The goal is to design a stack that supports retrieving the minimum element in $O(1)$ time. We use two stacks: one for all elements and one to track minimum values. When pushing, if the new value is less than or equal to the current minimum, we also push it to the min stack. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. -- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. +- **Brute Force:** Store all elements and scan for minimum when `getMin()` is called. This is $O(n)$ time for `getMin()`. +- **Optimized Strategy:** Maintain a separate stack for minimum values. When pushing, if the value is $\leq$ current min, push to min stack. When popping, if the popped value equals the current min, pop from min stack. This gives $O(1)$ for all operations. +- **Why optimized is better:** The optimized strategy achieves $O(1)$ time for `getMin()` by trading a small amount of space for constant-time operations. **1.4 Decomposition:** -1. If the tree is empty, return an empty list. -2. Initialize a queue with the root node. -3. While the queue is not empty: - - Get the number of nodes at the current level. - - Process all nodes at this level. - - For the last node at each level (rightmost), add its value to the result. - - Add all children to the queue for the next level. -4. Return the result. +1. Maintain two stacks: `stack` for all elements and `min_stack` for minimum values. +2. `push(val)`: Push to `stack`. If `min_stack` is empty or `val <= min_stack[-1]`, push to `min_stack`. +3. `pop()`: Pop from `stack`. If the popped value equals `min_stack[-1]`, pop from `min_stack`. +4. `top()`: Return `stack[-1]`. +5. `getMin()`: Return `min_stack[-1]`. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,2,3,null,5,null,4]$ - -The tree structure: -``` - 1 - / \ - 2 3 - \ \ - 5 4 -``` +Let's use the example: `["MinStack","push","push","push","getMin","pop","top","getMin"]` with values `[[],[-2],[0],[-3],[],[],[],[]]` We initialize: -- `queue = deque([1])` -- `res = []` +- `stack = []` +- `min_stack = []` -**2.2 Start BFS:** +**2.2 Start Checking:** -We begin processing level by level. +We perform each operation in sequence. **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process | Rightmost Node | res | -|-------|--------------|------------|---------|----------------|-----| -| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | -| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | -| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | +| Operation | Value | stack | min_stack | Return | +|-----------|-------|-------|-----------|--------| +| push(-2) | -2 | [-2] | [-2] | - | +| push(0) | 0 | [-2,0] | [-2] | - | +| push(-3) | -3 | [-2,0,-3] | [-2,-3] | - | +| getMin() | - | [-2,0,-3] | [-2,-3] | -3 | +| pop() | - | [-2,0] | [-2] | - | +| top() | - | [-2,0] | [-2] | 0 | +| getMin() | - | [-2,0] | [-2] | -2 | -**2.4 Explanation:** +**2.4 Increment and Loop:** -- Level 0: Only node 1 → add 1 -- Level 1: Nodes 2 and 3 → add 3 (rightmost) -- Level 2: Nodes 5 and 4 → add 4 (rightmost) +- **push(val)**: + - `stack.append(val)` + - If `not min_stack or val <= min_stack[-1]`: `min_stack.append(val)` + +- **pop()**: + - `val = stack.pop()` + - If `val == min_stack[-1]`: `min_stack.pop()` **2.5 Return Result:** -We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. +After all operations: +- `top()` returns `0` (the top element). +- `getMin()` returns `-2` (the minimum element in the remaining stack). -> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. +The stack correctly maintains both the elements and the minimum value in $O(1)$ time for all operations. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self): + self.stack = [] + self.min_stack = [] -from typing import List -from collections import deque + def push(self, val: int) -> None: + self.stack.append(val) + # Push to min_stack only if it's empty or val <= current min + if not self.min_stack or val <= self.min_stack[-1]: + self.min_stack.append(val) -class Solution: - def rightSideView(self, root) -> List[int]: - if not root: - return [] - - res = [] - queue = deque([root]) - - while queue: - level_size = len(queue) - - for i in range(level_size): - node = queue.popleft() - - # Add the rightmost node of each level - if i == level_size - 1: - res.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) - - return res + def pop(self) -> None: + val = self.stack.pop() + # Pop from min_stack if the popped value is the current min + if val == self.min_stack[-1]: + self.min_stack.pop() + + def top(self) -> int: + return self.stack[-1] + + def getMin(self) -> int: + return self.min_stack[-1] + + +# Your MinStack object will be instantiated and called as such: +# obj = MinStack() +# obj.push(val) +# obj.pop() +# param_3 = obj.top() +# param_4 = obj.getMin() ``` -## 637. Average of Levels in Binary Tree [Easy] -https://leetcode.com/problems/average-of-levels-in-binary-tree/ +## 173. Binary Search Tree Iterator [Medium] +https://leetcode.com/problems/binary-search-tree-iterator/ ### Explanation @@ -4319,47 +4066,76 @@ https://leetcode.com/problems/average-of-levels-in-binary-tree/ ### Strategy (The "Why") **1.1 Constraints & Complexity:** -- **Input Size:** `1 <= nodes <= 10^4`. -- **Time Complexity:** O(n) - we visit each node once using BFS. -- **Space Complexity:** O(w) where w is maximum width - queue storage. -- **Edge Case:** Single node tree returns [node.val]. + +- **Constraints:** $1 \leq n \leq 10^5$ nodes. Node values are in the range $[0, 10^6]$. At most $10^5$ calls to `next()` and `hasNext()`. +- **Time Complexity:** + - `__init__`: $O(h)$ where $h$ is the height of the tree (we push left nodes). + - `next()`: Amortized $O(1)$ per call. + - `hasNext()`: $O(1)$. +- **Space Complexity:** $O(h)$ for the stack storing nodes along the path to the leftmost node. +- **Edge Case:** If the tree has only one node, the stack contains that node initially. **1.2 High-level approach:** -The goal is to calculate the average value of nodes at each level. We use BFS (level-order traversal) to process nodes level by level, calculating the sum and count for each level. + +The goal is to implement an iterator that returns nodes in in-order traversal (left, root, right) order. We use a stack to simulate the in-order traversal. Initially, we push all left nodes. When `next()` is called, we pop a node, push its right subtree's left nodes, and return the node's value. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Same as optimized - BFS is the natural approach. -- **Optimized Strategy:** BFS processes one level at a time, calculate average per level. + +- **Brute Force:** Perform full in-order traversal, store all values in a list, then iterate through the list. This requires $O(n)$ space and doesn't meet the $O(h)$ space requirement. +- **Optimized Strategy:** Use a stack to maintain only the nodes needed for the current path. Push left nodes initially, and when popping, push left nodes of the right child. This uses $O(h)$ space. +- **Why optimized is better:** The optimized approach meets the $O(h)$ space requirement and provides amortized $O(1)$ time for `next()`. **1.4 Decomposition:** -1. Use BFS with a queue. -2. For each level, process all nodes at that level. -3. Calculate sum and count of nodes in the level. -4. Compute average (sum / count). -5. Add to result list. -6. Continue to next level. + +1. In `__init__`, push all left nodes starting from the root. +2. In `next()`, pop a node from the stack, push all left nodes of its right child, and return the node's value. +3. In `hasNext()`, check if the stack is non-empty. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use `root = [3,9,20,null,null,15,7]`. Initialize queue with [root], res = []. + +Let's use the example: `root = [7, 3, 15, null, null, 9, 20]` + +The tree structure: +``` + 7 + / \ + 3 15 + / \ + 9 20 +``` + +We initialize `stack = []` and call `_push_left(root)`. **2.2 Start Checking:** -We process nodes level by level. + +The `_push_left` function pushes all left nodes: 7, then 3. So `stack = [7, 3]` (top is 3). **2.3 Trace Walkthrough:** -| Level | Nodes | Sum | Count | Average | res | -|-------|-------|-----|-------|---------|-----| -| 0 | [3] | 3 | 1 | 3.0 | [3.0] | -| 1 | [9,20] | 29 | 2 | 14.5 | [3.0,14.5] | -| 2 | [15,7] | 22 | 2 | 11.0 | [3.0,14.5,11.0] | +| Operation | Stack before | Action | Stack after | Return | +|-----------|--------------|--------|-------------|--------| +| __init__ | [] | Push left: 7, 3 | [7, 3] | - | +| next() | [7, 3] | Pop 3, push left of 3.right (none) | [7] | 3 | +| next() | [7] | Pop 7, push left of 7.right: 15, 9 | [15, 9] | 7 | +| hasNext() | [15, 9] | Check stack non-empty | [15, 9] | True | +| next() | [15, 9] | Pop 9, push left of 9.right (none) | [15] | 9 | +| next() | [15] | Pop 15, push left of 15.right: 20 | [20] | 15 | +| next() | [20] | Pop 20, push left of 20.right (none) | [] | 20 | +| hasNext() | [] | Check stack empty | [] | False | **2.4 Increment and Loop:** -After processing each level, we move to the next. + +- **`_push_left(node)`**: While `node` is not None, push `node` to stack and move to `node.left`. +- **`next()`**: + - Pop a node from the stack. + - Call `_push_left(node.right)` to push all left nodes of the right subtree. + - Return the popped node's value. **2.5 Return Result:** -Return `res = [3.0,14.5,11.0]`, averages for each level. + +The iterator returns values in in-order order: 3, 7, 9, 15, 20. Each call to `next()` returns the next value, and `hasNext()` correctly indicates when more values are available. ### Solution @@ -4368,36 +4144,38 @@ def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right -from collections import deque +class BSTIterator: -class Solution: - def averageOfLevels(self, root: Optional[TreeNode]) -> List[float]: - if not root: - return [] - - queue = deque([root]) - res = [] - - while queue: - level_size = len(queue) - level_sum = 0 - - for _ in range(level_size): - node = queue.popleft() - level_sum += node.val - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) - - res.append(level_sum / level_size) - - return res + def __init__(self, root: Optional[TreeNode]): + self.stack = [] + self._push_left(root) + + def _push_left(self, node): + # Push all left nodes to stack + while node: + self.stack.append(node) + node = node.left + + def next(self) -> int: + # Pop the smallest element + node = self.stack.pop() + # Push all left nodes of the right child + if node.right: + self._push_left(node.right) + return node.val + + def hasNext(self) -> bool: + return len(self.stack) > 0 + + +# Your BSTIterator object will be instantiated and called as such: +# obj = BSTIterator(root) +# param_1 = obj.next() +# param_2 = obj.hasNext() ``` -## 102. Binary Tree Level Order Traversal [Medium] -https://leetcode.com/problems/binary-tree-level-order-traversal/ +## 199. Binary Tree Right Side View [Medium] +https://leetcode.com/problems/binary-tree-right-side-view/ ### Explanation @@ -4405,58 +4183,58 @@ https://leetcode.com/problems/binary-tree-level-order-traversal/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the level-order traversal of its nodes' values (i.e., from left to right, level by level). +Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $2000$. -- **Value Range:** Node values are between $-1000$ and $1000$. +- **Input Size:** The number of nodes $N$ can be up to $100$. +- **Value Range:** Node values are between $0$ and $100$. - **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level, which is $O(n)$ in the worst case. -- **Edge Case:** If the tree is empty, return an empty list. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. +- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. **1.2 High-level approach:** -The goal is to traverse the tree level by level, collecting values at each level. +The goal is to find the rightmost node at each level of the tree. -![Level Order Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) +![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) -We use BFS (breadth-first search) with a queue. We process nodes level by level, adding all nodes at the current level to a list before moving to the next level. +We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. **1.3 Brute force vs. optimized strategy:** - **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS with Queue):** Use a queue to process nodes level by level. For each level, process all nodes in the queue (which represents the current level), then add their children for the next level. -- **Why it's better:** BFS naturally processes nodes level by level. Using a queue ensures we process all nodes at one level before moving to the next. +- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. +- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. **1.4 Decomposition:** 1. If the tree is empty, return an empty list. 2. Initialize a queue with the root node. 3. While the queue is not empty: - - Get the number of nodes at the current level (queue size). - - Process all nodes at this level, adding their values to a level list. - - Add all children of these nodes to the queue for the next level. - - Add the level list to the result. + - Get the number of nodes at the current level. + - Process all nodes at this level. + - For the last node at each level (rightmost), add its value to the result. + - Add all children to the queue for the next level. 4. Return the result. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3,9,20,null,null,15,7]$ +Let's use the example: root = $[1,2,3,null,5,null,4]$ The tree structure: ``` - 3 + 1 / \ - 9 20 - / \ - 15 7 + 2 3 + \ \ + 5 4 ``` We initialize: -- `queue = deque([3])` +- `queue = deque([1])` - `res = []` **2.2 Start BFS:** @@ -4465,22 +4243,23 @@ We begin processing level by level. **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process Nodes | Level List | Queue After | -|-------|--------------|------------|---------------|------------|-------------| -| 0 | [3] | 1 | 3 | [3] | [9, 20] | -| 1 | [9, 20] | 2 | 9, 20 | [9, 20] | [15, 7] | -| 2 | [15, 7] | 2 | 15, 7 | [15, 7] | [] | +| Level | Queue Before | Level Size | Process | Rightmost Node | res | +|-------|--------------|------------|---------|----------------|-----| +| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | +| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | +| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | -**2.4 Final Result:** +**2.4 Explanation:** -After processing all levels: -- `res = [[3], [9, 20], [15, 7]]` +- Level 0: Only node 1 → add 1 +- Level 1: Nodes 2 and 3 → add 3 (rightmost) +- Level 2: Nodes 5 and 4 → add 4 (rightmost) **2.5 Return Result:** -We return `[[3], [9, 20], [15, 7]]`, which represents the level-order traversal. +We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. -> **Note:** The key is to process all nodes at the current level before moving to the next. We do this by getting the queue size at the start of each iteration, which represents the number of nodes at the current level. +> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. ### Solution @@ -4494,7 +4273,7 @@ from typing import List from collections import deque class Solution: - def levelOrder(self, root) -> List[List[int]]: + def rightSideView(self, root) -> List[int]: if not root: return [] @@ -4503,24 +4282,24 @@ class Solution: while queue: level_size = len(queue) - level = [] - for _ in range(level_size): + for i in range(level_size): node = queue.popleft() - level.append(node.val) + + # Add the rightmost node of each level + if i == level_size - 1: + res.append(node.val) if node.left: queue.append(node.left) if node.right: queue.append(node.right) - - res.append(level) return res ``` -## 103. Binary Tree Zigzag Level Order Traversal [Medium] -https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ +## 208. Implement Trie (Prefix Tree) [Medium] +https://leetcode.com/problems/implement-trie-prefix-tree/ ### Explanation @@ -4528,105 +4307,147 @@ https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ ### Strategy (The "Why") -The problem asks us to return the zigzag level order traversal of a binary tree: left-to-right for even levels, right-to-left for odd levels. +We need to implement a Trie (prefix tree) data structure that supports inserting words, searching for complete words, and checking if any word starts with a given prefix. **1.1 Constraints & Complexity:** -- **Input Constraints:** The tree has $0 \leq n \leq 2000$ nodes with values in $[-100, 100]$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. -- **Edge Case:** Empty tree returns empty list. +- **Input Size:** The number of operations $N$ can be up to $3 \times 10^4$. +- **Value Range:** Words and prefixes consist of lowercase English letters only, with length between 1 and 2000. +- **Time Complexity:** + - `insert`: $O(m)$ where $m$ is the length of the word + - `search`: $O(m)$ where $m$ is the length of the word + - `startsWith`: $O(m)$ where $m$ is the length of the prefix +- **Space Complexity:** $O(ALPHABET\_SIZE \times N \times M)$ where $N$ is the number of words and $M$ is the average length. In practice, this is $O(\text{total characters in all words})$. +- **Edge Case:** Searching for an empty string should return false (unless an empty word was inserted). Checking prefix of empty string should return true if any word exists. **1.2 High-level approach:** -The goal is to traverse the tree level by level, alternating the direction at each level. We use BFS with a flag to track direction. +The goal is to implement a Trie data structure that efficiently stores and retrieves words. -![Zigzag Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) +![Trie Structure](https://assets.leetcode.com/uploads/2021/04/28/trie-1.png) + +A Trie is a tree-like data structure where each node represents a character. Words that share common prefixes share the same path in the tree. This makes prefix searches very efficient. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Do regular level-order traversal, then reverse every other level. This takes $O(n)$ time and $O(n)$ space. -- **Optimized (BFS with Direction Flag):** Use BFS and reverse the level list when needed based on a flag. This takes $O(n)$ time and $O(n)$ space. -- **Emphasize the optimization:** While complexity is the same, the direction flag approach is cleaner and more efficient than reversing after collection. +- **Brute Force:** Store all words in a list. For search and prefix operations, iterate through all words checking each one. This takes $O(n \times m)$ time where $n$ is the number of words. +- **Optimized Strategy (Trie):** Use a tree structure where each node has children representing possible next characters. This allows us to search in $O(m)$ time regardless of how many words are stored. +- **Why it's better:** The Trie structure eliminates the need to check every word. We only traverse the path relevant to the word or prefix we're looking for, making it much more efficient for large datasets. **1.4 Decomposition:** -1. **BFS Traversal:** Use a queue to process nodes level by level. -2. **Track Direction:** Use a boolean flag to alternate between left-to-right and right-to-left. -3. **Reverse When Needed:** For odd levels (right-to-left), reverse the level list before adding to result. -4. **Return Result:** Return the list of levels. +1. Create a `TrieNode` class with a dictionary of children and a flag indicating if it's the end of a word. +2. Initialize the Trie with a root `TrieNode`. +3. For `insert`: Traverse the tree, creating nodes as needed, and mark the final node as an end-of-word. +4. For `search`: Traverse the tree following the word's characters. Return true only if we reach the end and the final node is marked as end-of-word. +5. For `startsWith`: Similar to search, but return true if we can traverse the entire prefix, regardless of whether it's a complete word. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's trace through an example: `root = [3,9,20,null,null,15,7]`. +Let's use the example operations: +- `insert("apple")` +- `search("apple")` → returns true +- `search("app")` → returns false +- `startsWith("app")` → returns true +- `insert("app")` +- `search("app")` → returns true -Initialize: `queue = [3]`, `left_to_right = True`, `res = []` +We initialize: +- A root `TrieNode` with empty children dictionary +- `is_end = False` for all nodes initially -**2.2 Start Processing:** +**2.2 Start Inserting:** -Process level 0 (root). +We begin by inserting "apple". **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Values | Direction | After Reverse | Result | -|-------|--------------|--------------|-----------|---------------|--------| -| 0 | [3] | [3] | L→R | [3] | [[3]] | -| 1 | [9, 20] | [9, 20] | R→L | [20, 9] | [[3], [20, 9]] | -| 2 | [15, 7] | [15, 7] | L→R | [15, 7] | [[3], [20, 9], [15, 7]] | +**Insert "apple":** -**2.4 Complete Traversal:** +| Step | Current Node | Character | Action | New Node Created? | +|------|--------------|-----------|--------|-------------------| +| 1 | root | 'a' | Create node for 'a' | Yes | +| 2 | a-node | 'p' | Create node for 'p' | Yes | +| 3 | p-node | 'p' | Create node for 'p' | Yes | +| 4 | p-node | 'l' | Create node for 'l' | Yes | +| 5 | l-node | 'e' | Create node for 'e', mark as end | Yes | -All levels processed: Level 0 (L→R), Level 1 (R→L), Level 2 (L→R). +**Search "apple":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | Move to 'p' node | +| 4 | p-node | 'l' | Yes | Move to 'l' node | +| 5 | l-node | 'e' | Yes | Check is_end → true → Return true | + +**Search "app":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | Check is_end → false → Return false | + +**startsWith "app":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | All characters found → Return true | + +**2.4 Insert "app" and Search Again:** + +After inserting "app", the second 'p' node now has `is_end = true`. So searching "app" will now return true. **2.5 Return Result:** -The function returns `[[3], [20, 9], [15, 7]]`. +The Trie correctly handles all operations, allowing efficient word storage and prefix matching. + +> **Note:** The key difference between `search` and `startsWith` is that `search` requires the final node to be marked as an end-of-word, while `startsWith` only requires that the path exists. + +### Solution + +```python +def __init__(self): + self.children = {} + self.is_end = False + +class Trie: + def __init__(self): + self.root = TrieNode() -> **Note:** The direction alternates at each level: even levels (0, 2, ...) are left-to-right, odd levels (1, 3, ...) are right-to-left. + def insert(self, word: str) -> None: + node = self.root + for char in word: + if char not in node.children: + node.children[char] = TrieNode() + node = node.children[char] + node.is_end = True -### Solution + def search(self, word: str) -> bool: + node = self.root + for char in word: + if char not in node.children: + return False + node = node.children[char] + return node.is_end -```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def zigzagLevelOrder(self, root: Optional[TreeNode]) -> List[List[int]]: - if not root: - return [] - - res = [] - queue = [root] - left_to_right = True - - while queue: - level_size = len(queue) - level = [] - - for _ in range(level_size): - node = queue.pop(0) - level.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) - - # Reverse if needed for zigzag - if not left_to_right: - level.reverse() - - res.append(level) - left_to_right = not left_to_right - - return res + def startsWith(self, prefix: str) -> bool: + node = self.root + for char in prefix: + if char not in node.children: + return False + node = node.children[char] + return True ``` -## 530. Minimum Absolute Difference in BST [Easy] -https://leetcode.com/problems/minimum-absolute-difference-in-bst/ +## 211. Design Add and Search Words Data Structure [Medium] +https://leetcode.com/problems/design-add-and-search-words-data-structure/ ### Explanation @@ -4635,69 +4456,93 @@ https://leetcode.com/problems/minimum-absolute-difference-in-bst/ ### Strategy (The "Why") **1.1 Constraints & Complexity:** -- **Input Size:** `2 <= nodes <= 10^4`, `0 <= Node.val <= 10^5`. -- **Time Complexity:** O(n) - we traverse the tree once to collect values. -- **Space Complexity:** O(n) - we store all node values. -- **Edge Case:** Tree with only two nodes. +- **Constraints:** Word length is 1 to 25, and there are at most 10^4 calls to `addWord` and `search`. Search queries have at most 2 dots. +- **Time Complexity:** + - `addWord`: O(m) where m is the word length + - `search`: O(m * 26^k) in worst case where k is the number of dots, but typically much better +- **Space Complexity:** O(N * M) where N is the number of words and M is the average word length. +- **Edge Case:** Searching for a word with no dots is O(m) time, same as a regular trie search. **1.2 High-level approach:** -The goal is to find the minimum absolute difference between any two nodes in a BST. We use in-order traversal to get sorted values, then find minimum difference between consecutive values. +The goal is to design a data structure that supports adding words and searching with wildcard characters (dots). A trie (prefix tree) is perfect for this, with special handling for dots during search. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Compare all pairs - O(n²) time. -- **Optimized Strategy:** In-order traversal gives sorted order, check adjacent pairs - O(n) time. +- **Brute Force:** Store words in a list. For search with dots, check each word character by character. This is O(N * M) per search. +- **Optimized Strategy:** Use a trie to store words. For dots, recursively search all possible children. This is much more efficient for prefix matching. +- **Why optimized is better:** Trie allows early termination when prefixes don't match and efficiently handles wildcard searches. **1.4 Decomposition:** -1. Perform in-order traversal to get sorted values. -2. Iterate through sorted values. -3. Calculate difference between consecutive values. -4. Track minimum difference. -5. Return minimum. +1. Build a trie data structure with nodes containing children and an `is_end` flag. +2. For `addWord`, traverse the trie, creating nodes as needed, and mark the end. +3. For `search`, use DFS to handle dots by recursively searching all children when encountering a dot. +4. Return true if we find a complete word matching the pattern. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use `root = [4,2,6,1,3]`. In-order traversal gives [1,2,3,4,6]. +Initialize: `root = TrieNode()` + +Add words: "bad", "dad", "mad" **2.2 Start Checking:** -We compare consecutive values in sorted order. +Search for: ".ad" **2.3 Trace Walkthrough:** -| i | values[i] | values[i+1] | Difference | Min | -|---|-----------|-------------|------------|-----| -| 0 | 1 | 2 | 1 | 1 | -| 1 | 2 | 3 | 1 | 1 | -| 2 | 3 | 4 | 1 | 1 | -| 3 | 4 | 6 | 2 | 1 | +| Step | Current Node | Char | Action | +|------|---------------|------|--------| +| 0 | root | '.' | Check all children (b, d, m) | +| 1 | node['b'] | 'a' | Check if 'a' in children | +| 2 | node['b']['a'] | 'd' | Check if 'd' in children and is_end | +| 3 | - | - | Found "bad", return True | + +For ".ad", we check all first-level children (b, d, m), then continue with 'a' and 'd'. **2.4 Increment and Loop:** -After checking each pair, we move to the next. +For each character in the search word: +- If it's a dot, recursively search all children +- If it's a regular character, follow that child if it exists +- If we reach the end and `is_end` is true, return true **2.5 Return Result:** -Return `res = 1`, the minimum absolute difference. +The search ".ad" matches "bad", "dad", or "mad", so return `True`. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def getMinimumDifference(self, root: Optional[TreeNode]) -> int: - def inorder(node): - if not node: - return [] - return inorder(node.left) + [node.val] + inorder(node.right) - - values = inorder(root) - res = float('inf') - - for i in range(len(values) - 1): - res = min(res, values[i + 1] - values[i]) +def __init__(self): + self.children = {} + self.is_end = False + +class WordDictionary: + def __init__(self): + self.root = TrieNode() + + def addWord(self, word: str) -> None: + node = self.root + for char in word: + if char not in node.children: + node.children[char] = TrieNode() + node = node.children[char] + node.is_end = True + + def search(self, word: str) -> bool: + def dfs(node, index): + if index == len(word): + return node.is_end + + char = word[index] + if char == '.': + for child in node.children.values(): + if dfs(child, index + 1): + return True + return False + else: + if char not in node.children: + return False + return dfs(node.children[char], index + 1) - return res + return dfs(self.root, 0) ``` ## 230. Kth Smallest Element in a BST [Medium] @@ -4791,257 +4636,425 @@ After traversal: `res = [1, 2, 3, 4]` **2.4 Return Result:** -Since $k = 1$ (1-indexed), we return `res[0] = 1`, which is the 1st smallest element. +Since $k = 1$ (1-indexed), we return `res[0] = 1`, which is the 1st smallest element. + +For $k = 3$, we would return `res[2] = 3`, which is the 3rd smallest element. + +> **Note:** In-order traversal of a BST always produces values in ascending order because of the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def kthSmallest(self, root, k: int) -> int: + # In-order traversal to get elements in sorted order + res = [] + + def inorder(node): + if not node: + return + inorder(node.left) + res.append(node.val) + inorder(node.right) + + inorder(root) + + # Return the k-th smallest element (1-indexed) + return res[k - 1] +``` + +## 236. Lowest Common Ancestor of a Binary Tree [Medium] +https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +The problem asks us to find the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA is the deepest node that has both nodes as descendants (a node can be a descendant of itself). + +**1.1 Constraints & Complexity:** + +- **Input Constraints:** The tree has $2 \leq n \leq 10^5$ nodes with unique values in $[-10^9, 10^9]$. +- **Time Complexity:** $O(n)$ - We may need to visit all nodes in the worst case. +- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +- **Edge Case:** If one node is an ancestor of the other, return that ancestor node. + +**1.2 High-level approach:** + +The goal is to find the deepest node that is an ancestor of both target nodes. We use recursive DFS: if we find both nodes in a subtree, the current root is the LCA. + +![Binary Tree LCA](https://assets.leetcode.com/uploads/2018/12/14/binarytree.png) + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** Find paths to both nodes, then find the last common node in both paths. This requires storing paths and takes $O(n)$ time and $O(n)$ space. +- **Optimized (Recursive DFS):** Recursively search both subtrees. If both subtrees return non-null, the current root is the LCA. This takes $O(n)$ time and $O(h)$ space. +- **Emphasize the optimization:** The recursive approach finds the LCA in a single pass without storing paths, making it more space-efficient. + +**1.4 Decomposition:** + +1. **Base Case:** If root is `None` or equals `p` or `q`, return root. +2. **Recursive Search:** Recursively search left and right subtrees for `p` and `q`. +3. **Combine Results:** If both subtrees return non-null, root is the LCA. Otherwise, return whichever subtree found a node. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's trace through an example: `root = [3,5,1,6,2,0,8,null,null,7,4]`, `p = 5`, `q = 1`. + +**2.2 Start Searching:** + +Begin at root node `3`. + +**2.3 Trace Walkthrough:** + +| Node | Left Result | Right Result | Action | +|------|-------------|--------------|---------| +| 3 | Search left (5) | Search right (1) | Both found → Return 3 | +| 5 | Search left (6) | Search right (2) | Found p → Return 5 | +| 1 | Search left (0) | Search right (8) | Found q → Return 1 | + +**2.4 Recursive Unwinding:** + +- Node `5` returns itself (found `p`). +- Node `1` returns itself (found `q`). +- Node `3` receives both results, so it's the LCA. + +**2.5 Return Result:** -For $k = 3$, we would return `res[2] = 3`, which is the 3rd smallest element. +The function returns node `3`, which is the LCA of nodes `5` and `1`. -> **Note:** In-order traversal of a BST always produces values in ascending order because of the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. +> **Note:** The key insight is that if both left and right subtrees return non-null, the current root must be the LCA. If only one subtree returns non-null, that subtree contains the LCA. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None class Solution: - def kthSmallest(self, root, k: int) -> int: - # In-order traversal to get elements in sorted order - res = [] + def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': + # Base case: if root is None or root is p or q, return root + if not root or root == p or root == q: + return root - def inorder(node): - if not node: - return - inorder(node.left) - res.append(node.val) - inorder(node.right) + # Recursively search in left and right subtrees + left = self.lowestCommonAncestor(root.left, p, q) + right = self.lowestCommonAncestor(root.right, p, q) - inorder(root) + # If both left and right return non-None, root is the LCA + if left and right: + return root - # Return the k-th smallest element (1-indexed) - return res[k - 1] + # Otherwise, return whichever side found p or q + return left if left else right ``` -## 98. Validate Binary Search Tree [Medium] -https://leetcode.com/problems/validate-binary-search-tree/ +## 274. H-Index [Medium] +https://leetcode.com/problems/h-index/ ### Explanation -## Explanation +## 274. H-Index [Medium] -### Strategy (The "Why") +https://leetcode.com/problems/h-index -Given the root of a binary tree, we need to determine if it is a valid binary search tree (BST). A BST is valid if for every node, all nodes in its left subtree are less than it, and all nodes in its right subtree are greater than it. +## Description +Given an array of integers `citations` where `citations[i]` is the number of citations a researcher received for their `iᵗʰ` paper, return *the researcher's h-index*. -**1.1 Constraints & Complexity:** +According to the [definition of h-index on Wikipedia](https://en.wikipedia.org/wiki/H-index): The h-index is defined as the maximum value of `h` such that the given researcher has published at least `h` papers that have each been cited at least `h` times. -- **Input Size:** The number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-2^{31}$ and $2^{31} - 1$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** An empty tree is a valid BST. A tree with only one node is a valid BST. +**Examples** -**1.2 High-level approach:** +```tex +Example 1: +Input: citations = [3,0,6,1,5] +Output: 3 +Explanation: [3,0,6,1,5] means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. +Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, their h-index is 3. -The goal is to validate that a binary tree satisfies the BST property. +Example 2: +Input: citations = [1,3,1] +Output: 1 +``` -We use recursion with range validation. For each node, we check if its value is within the valid range (min_val, max_val). The range is updated as we traverse: left children must be less than the parent, right children must be greater than the parent. +**Constraints** +```tex +- n == citations.length +- 1 <= n <= 5000 +- 0 <= citations[i] <= 1000 +``` -**1.3 Brute force vs. optimized strategy:** +## Explanation -- **Brute Force:** For each node, check if all nodes in its left subtree are less and all nodes in its right subtree are greater. This would be $O(n^2)$ time. -- **Optimized Strategy (Range Validation):** Use recursion with min and max bounds. Each node must be within its allowed range. This takes $O(n)$ time. -- **Why it's better:** The range validation approach reduces time complexity from $O(n^2)$ to $O(n)$ by passing down constraints instead of checking all descendants for each node. +### Strategy +Let's restate the problem: You're given an array representing the number of citations for each paper a researcher has published. You need to find the maximum value `h` such that the researcher has at least `h` papers with at least `h` citations each. -**1.4 Decomposition:** +This is a **sorting problem** that requires understanding the definition of h-index and finding the optimal value efficiently. -1. Define a recursive function that takes a node and its allowed range (min_val, max_val). -2. If the node is null, return true (base case). -3. Check if the node's value is within the range (strictly greater than min_val and strictly less than max_val). -4. Recursively validate left subtree with range (min_val, node.val). -5. Recursively validate right subtree with range (node.val, max_val). -6. Return true only if all checks pass. +**What is given?** An array of integers representing citation counts for each paper. -### Steps (The "How") +**What is being asked?** Find the maximum h-index value that satisfies the h-index definition. -**2.1 Initialization & Example Setup:** +**Constraints:** The array can be up to 5000 elements long, with citation counts ranging from 0 to 1000. -Let's use the example: root = $[5,1,4,null,null,3,6]$ +**Edge cases:** +- Array with all zeros +- Array with all high citation counts +- Array with single element +- Array with mixed citation counts -The tree structure: -``` - 5 - / \ - 1 4 - / \ - 3 6 -``` +**High-level approach:** +The solution involves understanding the h-index definition and using sorting to efficiently find the maximum valid h value. -We initialize: -- Call `validate(root, -∞, +∞)` +**Decomposition:** +1. **Sort the array**: Arrange citations in descending order to easily check h-index conditions +2. **Iterate through sorted array**: Check each position as a potential h-index +3. **Verify h-index condition**: Ensure at least h papers have at least h citations +4. **Return maximum valid h**: Find the largest h that satisfies the condition -**2.2 Start Validation:** +**Brute force vs. optimized strategy:** +- **Brute force**: Try each possible h value and check if it satisfies the condition. This takes O(n²) time. +- **Optimized**: Sort the array and use a single pass to find the h-index. This takes O(n log n) time. -We begin validating from the root. +### Steps +Let's walk through the solution step by step using the first example: `citations = [3,0,6,1,5]` -**2.3 Trace Walkthrough:** +**Step 1: Sort the array in descending order** +- Original: `[3,0,6,1,5]` +- Sorted: `[6,5,3,1,0]` -| Node | min_val | max_val | node.val | Check | Result | -|------|---------|---------|----------|-------|--------| -| 5 | -∞ | +∞ | 5 | $-∞ < 5 < +∞$ | ✓ | -| 1 | -∞ | 5 | 1 | $-∞ < 1 < 5$ | ✓ | -| 4 | 5 | +∞ | 4 | $5 < 4 < +∞$ | ✗ | +**Step 2: Check each position as potential h-index** +- Position 0: `h = 1`, check if `citations[0] >= 1` ✓ (6 >= 1) +- Position 1: `h = 2`, check if `citations[1] >= 2` ✓ (5 >= 2) +- Position 2: `h = 3`, check if `citations[2] >= 3` ✓ (3 >= 3) +- Position 3: `h = 4`, check if `citations[3] >= 4` ✗ (1 < 4) -**2.4 Explanation:** +**Step 3: Find the maximum valid h** +- The largest h where `citations[h-1] >= h` is 3 +- At position 2 (0-indexed), we have `h = 3` and `citations[2] = 3 >= 3` -- Root (5): Valid, within range (-∞, +∞) -- Left child (1): Valid, within range (-∞, 5) -- Right child (4): Invalid! It should be greater than 5, but 4 < 5 +**Step 4: Verify the h-index condition** +- We need at least 3 papers with at least 3 citations +- Papers with ≥3 citations: 6, 5, 3 (3 papers) ✓ +- Remaining papers: 1, 0 (≤3 citations) ✓ +- H-index is 3 -**2.5 Return Result:** +**Why this works:** +After sorting in descending order, the array position `i` (0-indexed) represents `h = i + 1`. For a position to be a valid h-index, we need `citations[i] >= h`. The largest valid h is our answer. -We return `False` because node 4 violates the BST property (it's in the right subtree of 5 but is less than 5). +> **Note:** The key insight is that after sorting, we can directly check each position as a potential h-index. The sorting makes it easy to verify the h-index condition in a single pass. -> **Note:** The key insight is to pass down the allowed range for each node. A node's value must be strictly within its range, and we update the range for children: left children get (min_val, node.val) and right children get (node.val, max_val). +**Time Complexity:** O(n log n) - dominated by sorting the array +**Space Complexity:** O(1) - we only use a constant amount of extra space (excluding the sorted array if we modify the input) ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right - -class Solution: - def isValidBST(self, root) -> bool: - def validate(node, min_val, max_val): - # Empty tree is valid - if not node: - return True - - # Check if current node value is within valid range - if node.val <= min_val or node.val >= max_val: - return False - - # Recursively validate left and right subtrees - return (validate(node.left, min_val, node.val) and - validate(node.right, node.val, max_val)) +def hIndex(citations): + """ + Calculate the h-index for a researcher based on their paper citations. + + Args: + citations: List[int] - Array of citation counts for each paper - return validate(root, float('-inf'), float('inf')) + Returns: + int - The researcher's h-index + """ + # Handle edge cases + if not citations: + return 0 + + # Sort citations in descending order + citations.sort(reverse=True) + + # Check each position as a potential h-index + for i in range(len(citations)): + # h-index is i + 1 (1-indexed) + h = i + 1 + + # Check if citations[i] >= h + # If not, we've found our answer + if citations[i] < h: + return i + + # If we reach the end, the h-index is the length of the array + if i == len(citations) - 1: + return h + + # This line should never be reached + return 0 ``` -## 133. Clone Graph [Medium] -https://leetcode.com/problems/clone-graph/ +## 289. Game of Life [Medium] +https://leetcode.com/problems/game-of-life/ ### Explanation -## Explanation +## 289. Game of Life [Medium] -### Strategy (The "Why") +https://leetcode.com/problems/game-of-life -**1.1 Constraints & Complexity:** +## Description +According to [Wikipedia's article](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life): "The **Game of Life**, also known simply as **Life**, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." -- **Constraints:** The graph has at most 100 nodes. Each node has a unique value in the range $[1, 100]$. The graph is connected and undirected. -- **Time Complexity:** $O(V + E)$ where $V$ is the number of vertices and $E$ is the number of edges. We visit each node and edge once. -- **Space Complexity:** $O(V)$ for the hash map storing original-to-clone mappings and the recursion stack. -- **Edge Case:** If the input node is `None`, return `None`. If the graph has only one node, return a clone of that node. +The board is made up of an `m x n` grid of cells, where each cell has an initial state: **live** (represented by a `1`) or **dead** (represented by a `0`). Each cell interacts with its [eight neighbors](https://en.wikipedia.org/wiki/Moore_neighborhood) (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article): + +1. Any live cell with fewer than two live neighbors dies as if caused by under-population. +2. Any live cell with two or three live neighbors lives on to the next generation. +3. Any live cell with more than three live neighbors dies, as if by over-population. +4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. + +The next state of the board is determined by applying the above rules simultaneously to every cell in the current state of the `m x n` grid `board`. In this process, births and deaths occur **simultaneously**. + +Given the current state of the `board`, **update** the `board` to reflect its next state. + +**Note** that you do not need to return anything. + +**Examples** + +```tex +Example 1: +Input: board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]] +Output: [[0,0,0],[1,0,1],[0,1,1],[0,1,0]] + +Example 2: +Input: board = [[1,1],[1,0]] +Output: [[1,1],[1,1]] +``` + +**Constraints** +```tex +- m == board.length +- n == board[i].length +- 1 <= m, n <= 25 +- board[i][j] is 0 or 1 +``` -**1.2 High-level approach:** +**Follow up:** +- Could you solve it in-place? Remember that the board needs to be updated simultaneously: You cannot update some cells first and then use their updated values to update other cells. +- In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches upon the border of the array (i.e., live cells reach the border). How would you address these problems? -The goal is to create a deep copy of the graph. We use a hash map to track which nodes have been cloned, and recursively clone each node and its neighbors. +## Explanation -**1.3 Brute force vs. optimized strategy:** +### Strategy +Let's restate the problem: You're given a 2D grid representing the current state of Conway's Game of Life, where each cell is either alive (1) or dead (0). You need to update the board to the next generation based on specific rules about cell survival and reproduction. -- **Brute Force:** Create all nodes first, then set up connections. This requires two passes and is more complex. -- **Optimized Strategy:** Use DFS with a hash map. When cloning a node, recursively clone its neighbors. The hash map prevents creating duplicate clones of the same node. -- **Why optimized is better:** The optimized approach handles cycles naturally and is more elegant, requiring only one traversal. +This is a **simulation problem** that requires careful handling to update all cells simultaneously without interfering with the calculation of other cells. -**1.4 Decomposition:** +**What is given?** An m x n grid where each cell is either 0 (dead) or 1 (live). -1. Create a hash map to store mappings from original nodes to cloned nodes. -2. Use DFS to clone nodes recursively. -3. For each node, if it's already cloned, return the clone from the map. -4. Otherwise, create a new node, add it to the map, and recursively clone all neighbors. -5. Return the cloned graph starting from the given node. +**What is being asked?** Update the board to the next generation based on the Game of Life rules. -### Steps (The "How") +**Constraints:** The grid can be up to 25x25, and all cells contain only 0 or 1. -**2.1 Initialization & Example Setup:** +**Edge cases:** +- Grid with all dead cells +- Grid with all live cells +- Single row or column +- Grid with live cells on borders -Let's use the example: `adjList = [[2,4],[1,3],[2,4],[1,3]]` +**High-level approach:** +The solution involves using a two-pass approach where we first mark cells with their next state using special values, then convert these markers to the final states. -This represents a graph with 4 nodes: -- Node 1 is connected to nodes 2 and 4 -- Node 2 is connected to nodes 1 and 3 -- Node 3 is connected to nodes 2 and 4 -- Node 4 is connected to nodes 1 and 3 +**Decomposition:** +1. **First pass**: Mark cells with their next state using special values (2 for live→dead, 3 for dead→live) +2. **Second pass**: Convert special values to final states (2→0, 3→1) +3. **Count neighbors**: For each cell, count its eight neighbors to determine its fate -We initialize an empty hash map `node_map = {}`. +**Brute force vs. optimized strategy:** +- **Brute force**: Create a copy of the board and update it. This takes O(mn) space. +- **Optimized**: Use special values to mark next states in-place. This takes O(1) space. -**2.2 Start Checking:** +### Steps +Let's walk through the solution step by step using the first example: `board = [[0,1,0],[0,0,1],[1,1,1],[0,0,0]]` -We call the `clone` function with the given node (node 1). +**Step 1: First pass - mark cells with next state** +- For each cell, count its eight neighbors +- Apply Game of Life rules and mark with special values: + - `2` = currently live, will die (live→dead) + - `3` = currently dead, will live (dead→live) + - `0` = currently dead, will stay dead + - `1` = currently live, will stay live -**2.3 Trace Walkthrough:** +**Step 2: Count neighbors for each cell** +- For cell `board[0][1] = 1` (live): + - Neighbors: `[0,0,1,0,0,1,1,1]` = 4 live neighbors + - Rule 3: More than 3 live neighbors → dies + - Mark as `2` (live→dead) -| Step | Node | Action | node_map | -|------|------|--------|----------| -| 1 | 1 | Create clone(1), add to map | {1: clone(1)} | -| 2 | Clone neighbors of 1: [2,4] | Clone node 2 | {1: clone(1), 2: clone(2)} | -| 3 | Clone neighbors of 2: [1,3] | Node 1 already cloned, use it | {1: clone(1), 2: clone(2), 3: clone(3)} | -| 4 | Clone neighbors of 3: [2,4] | Node 2 already cloned, use it | {1: clone(1), 2: clone(2), 3: clone(3), 4: clone(4)} | -| 5 | Clone neighbors of 4: [1,3] | Both already cloned, use them | Complete | +- For cell `board[1][2] = 1` (live): + - Neighbors: `[1,0,1,1,1,0,0,0]` = 4 live neighbors + - Rule 3: More than 3 live neighbors → dies + - Mark as `2` (live→dead) -**2.4 Increment and Loop:** +**Step 3: Second pass - convert special values** +- Convert `2` → `0` (dead) +- Convert `3` → `1` (live) +- Final board: `[[0,0,0],[1,0,1],[0,1,1],[0,1,0]]` -The recursive `clone` function: -1. Checks if the node is already in `node_map`. If yes, returns the clone. -2. Creates a new `Node` with the same value. -3. Adds the mapping to `node_map`. -4. Recursively clones all neighbors and adds them to the clone's neighbors list. +**Why this works:** +By using special values (2 and 3) to mark the next state, we can update the board in-place without losing information about the current state. The two-pass approach ensures all cells are updated simultaneously as required. -**2.5 Return Result:** +> **Note:** The key insight is using special values to represent both current and next states, allowing us to solve the problem in-place while maintaining the requirement that all cells update simultaneously. -The function returns `clone(node)`, which is the cloned version of the input node. The entire graph structure is cloned, with all connections preserved. +**Time Complexity:** O(mn) - we visit each cell twice +**Space Complexity:** O(1) - we only use a constant amount of extra space ### Solution ```python -def __init__(self, val = 0, neighbors = None): - self.val = val - self.neighbors = neighbors if neighbors is not None else [] -""" - -from typing import Optional -class Solution: - def cloneGraph(self, node: Optional['Node']) -> Optional['Node']: - if not node: - return None - - # Dictionary to map original nodes to cloned nodes - node_map = {} +def gameOfLife(board): + """ + Update the board to the next generation of Conway's Game of Life. + This is done in-place using O(1) space. + + Args: + board: List[List[int]] - The board to update in-place - def clone(node): - # If already cloned, return the clone - if node in node_map: - return node_map[node] - - # Create a new node - clone_node = Node(node.val) - node_map[node] = clone_node - - # Clone all neighbors - for neighbor in node.neighbors: - clone_node.neighbors.append(clone(neighbor)) + Returns: + None - Modifies the board in-place + """ + if not board or not board[0]: + return + + m, n = len(board), len(board[0]) + + # First pass: mark cells with their next state using special values + # 2 = currently live, will die (live→dead) + # 3 = currently dead, will live (dead→live) + for i in range(m): + for j in range(n): + live_neighbors = countLiveNeighbors(board, i, j, m, n) - return clone_node - - return clone(node) + if board[i][j] == 1: # Currently live + if live_neighbors < 2 or live_neighbors > 3: + board[i][j] = 2 # Mark as live→dead + else: # Currently dead + if live_neighbors == 3: + board[i][j] = 3 # Mark as dead→live + + # Second pass: convert special values to final states + for i in range(m): + for j in range(n): + if board[i][j] == 2: + board[i][j] = 0 # Convert live→dead to dead + elif board[i][j] == 3: + board[i][j] = 1 # Convert dead→live to live ``` -## 208. Implement Trie (Prefix Tree) [Medium] -https://leetcode.com/problems/implement-trie-prefix-tree/ +## 380. Insert Delete GetRandom O(1) [Medium] +https://leetcode.com/problems/insert-delete-getrandom-o1/ ### Explanation @@ -5049,147 +5062,86 @@ https://leetcode.com/problems/implement-trie-prefix-tree/ ### Strategy (The "Why") -We need to implement a Trie (prefix tree) data structure that supports inserting words, searching for complete words, and checking if any word starts with a given prefix. - **1.1 Constraints & Complexity:** - -- **Input Size:** The number of operations $N$ can be up to $3 \times 10^4$. -- **Value Range:** Words and prefixes consist of lowercase English letters only, with length between 1 and 2000. -- **Time Complexity:** - - `insert`: $O(m)$ where $m$ is the length of the word - - `search`: $O(m)$ where $m$ is the length of the word - - `startsWith`: $O(m)$ where $m$ is the length of the prefix -- **Space Complexity:** $O(ALPHABET\_SIZE \times N \times M)$ where $N$ is the number of words and $M$ is the average length. In practice, this is $O(\text{total characters in all words})$. -- **Edge Case:** Searching for an empty string should return false (unless an empty word was inserted). Checking prefix of empty string should return true if any word exists. +- **Input Size:** At most `2 * 10^5` calls to insert, remove, getRandom. +- **Time Complexity:** O(1) average for all operations - using array and hash map. +- **Space Complexity:** O(n) where n is the number of elements stored. +- **Edge Case:** Removing the last element, getting random from single element. **1.2 High-level approach:** - -The goal is to implement a Trie data structure that efficiently stores and retrieves words. - -![Trie Structure](https://assets.leetcode.com/uploads/2021/04/28/trie-1.png) - -A Trie is a tree-like data structure where each node represents a character. Words that share common prefixes share the same path in the tree. This makes prefix searches very efficient. +The goal is to implement a data structure with O(1) insert, remove, and getRandom. We use an array for random access and a hash map to track indices for O(1) removal. **1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** Store all words in a list. For search and prefix operations, iterate through all words checking each one. This takes $O(n \times m)$ time where $n$ is the number of words. -- **Optimized Strategy (Trie):** Use a tree structure where each node has children representing possible next characters. This allows us to search in $O(m)$ time regardless of how many words are stored. -- **Why it's better:** The Trie structure eliminates the need to check every word. We only traverse the path relevant to the word or prefix we're looking for, making it much more efficient for large datasets. +- **Brute Force:** Use only array - remove is O(n), getRandom is O(1). +- **Optimized Strategy:** Use array + hash map - all operations O(1) average. **1.4 Decomposition:** - -1. Create a `TrieNode` class with a dictionary of children and a flag indicating if it's the end of a word. -2. Initialize the Trie with a root `TrieNode`. -3. For `insert`: Traverse the tree, creating nodes as needed, and mark the final node as an end-of-word. -4. For `search`: Traverse the tree following the word's characters. Return true only if we reach the end and the final node is marked as end-of-word. -5. For `startsWith`: Similar to search, but return true if we can traverse the entire prefix, regardless of whether it's a complete word. +1. Maintain an array of values and a hash map from value to index. +2. Insert: Add to array, store index in map. +3. Remove: Swap with last element, update map, remove last. +4. GetRandom: Use random.choice on array. ### Steps (The "How") **2.1 Initialization & Example Setup:** +Initialize `nums = []`, `val_to_index = {}`. -Let's use the example operations: -- `insert("apple")` -- `search("apple")` → returns true -- `search("app")` → returns false -- `startsWith("app")` → returns true -- `insert("app")` -- `search("app")` → returns true - -We initialize: -- A root `TrieNode` with empty children dictionary -- `is_end = False` for all nodes initially - -**2.2 Start Inserting:** - -We begin by inserting "apple". +**2.2 Start Checking:** +We perform operations: insert(1), remove(2), insert(2), getRandom(). **2.3 Trace Walkthrough:** -**Insert "apple":** - -| Step | Current Node | Character | Action | New Node Created? | -|------|--------------|-----------|--------|-------------------| -| 1 | root | 'a' | Create node for 'a' | Yes | -| 2 | a-node | 'p' | Create node for 'p' | Yes | -| 3 | p-node | 'p' | Create node for 'p' | Yes | -| 4 | p-node | 'l' | Create node for 'l' | Yes | -| 5 | l-node | 'e' | Create node for 'e', mark as end | Yes | - -**Search "apple":** - -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | Move to 'p' node | -| 4 | p-node | 'l' | Yes | Move to 'l' node | -| 5 | l-node | 'e' | Yes | Check is_end → true → Return true | - -**Search "app":** - -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | Check is_end → false → Return false | - -**startsWith "app":** - -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | All characters found → Return true | - -**2.4 Insert "app" and Search Again:** +| Operation | nums | val_to_index | Result | +|-----------|------|--------------|--------| +| insert(1) | [1] | {1:0} | True | +| remove(2) | [1] | {1:0} | False | +| insert(2) | [1,2] | {1:0,2:1} | True | +| getRandom() | [1,2] | {1:0,2:1} | 1 or 2 | -After inserting "app", the second 'p' node now has `is_end = true`. So searching "app" will now return true. +**2.4 Increment and Loop:** +Not applicable - these are individual operations. **2.5 Return Result:** - -The Trie correctly handles all operations, allowing efficient word storage and prefix matching. - -> **Note:** The key difference between `search` and `startsWith` is that `search` requires the final node to be marked as an end-of-word, while `startsWith` only requires that the path exists. +Operations return their respective results. ### Solution ```python def __init__(self): - self.children = {} - self.is_end = False - -class Trie: - def __init__(self): - self.root = TrieNode() - - def insert(self, word: str) -> None: - node = self.root - for char in word: - if char not in node.children: - node.children[char] = TrieNode() - node = node.children[char] - node.is_end = True + self.nums = [] + self.val_to_index = {} - def search(self, word: str) -> bool: - node = self.root - for char in word: - if char not in node.children: - return False - node = node.children[char] - return node.is_end + def insert(self, val: int) -> bool: + if val in self.val_to_index: + return False + + self.val_to_index[val] = len(self.nums) + self.nums.append(val) + return True - def startsWith(self, prefix: str) -> bool: - node = self.root - for char in prefix: - if char not in node.children: - return False - node = node.children[char] + def remove(self, val: int) -> bool: + if val not in self.val_to_index: + return False + + # Move last element to the position of element to remove + index = self.val_to_index[val] + last_val = self.nums[-1] + + self.nums[index] = last_val + self.val_to_index[last_val] = index + + # Remove the last element + self.nums.pop() + del self.val_to_index[val] + return True + + def getRandom(self) -> int: + return random.choice(self.nums) ``` -## 211. Design Add and Search Words Data Structure [Medium] -https://leetcode.com/problems/design-add-and-search-words-data-structure/ +## 427. Construct Quad Tree [Medium] +https://leetcode.com/problems/construct-quad-tree/ ### Explanation @@ -5198,97 +5150,97 @@ https://leetcode.com/problems/design-add-and-search-words-data-structure/ ### Strategy (The "Why") **1.1 Constraints & Complexity:** -- **Constraints:** Word length is 1 to 25, and there are at most 10^4 calls to `addWord` and `search`. Search queries have at most 2 dots. -- **Time Complexity:** - - `addWord`: O(m) where m is the word length - - `search`: O(m * 26^k) in worst case where k is the number of dots, but typically much better -- **Space Complexity:** O(N * M) where N is the number of words and M is the average word length. -- **Edge Case:** Searching for a word with no dots is O(m) time, same as a regular trie search. +- **Input Size:** `n == grid.length == grid[i].length`, `n == 2^x` where `0 <= x <= 6`. +- **Time Complexity:** O(n²) - we process each cell, but with divide-and-conquer optimization. +- **Space Complexity:** O(log n) - recursion depth. +- **Edge Case:** All cells have the same value, single leaf node. **1.2 High-level approach:** -The goal is to design a data structure that supports adding words and searching with wildcard characters (dots). A trie (prefix tree) is perfect for this, with special handling for dots during search. +The goal is to construct a Quad-Tree from a binary grid. We use divide-and-conquer: if all values in a region are the same, create a leaf; otherwise, divide into 4 quadrants and recurse. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Store words in a list. For search with dots, check each word character by character. This is O(N * M) per search. -- **Optimized Strategy:** Use a trie to store words. For dots, recursively search all possible children. This is much more efficient for prefix matching. -- **Why optimized is better:** Trie allows early termination when prefixes don't match and efficiently handles wildcard searches. +- **Brute Force:** Same as optimized - divide-and-conquer is the natural approach. +- **Optimized Strategy:** Recursively divide grid into quadrants until uniform or single cell. **1.4 Decomposition:** -1. Build a trie data structure with nodes containing children and an `is_end` flag. -2. For `addWord`, traverse the trie, creating nodes as needed, and mark the end. -3. For `search`, use DFS to handle dots by recursively searching all children when encountering a dot. -4. Return true if we find a complete word matching the pattern. +1. Check if all values in current region are the same. +2. If yes, create a leaf node with that value. +3. If no, divide into 4 quadrants (top-left, top-right, bottom-left, bottom-right). +4. Recursively construct each quadrant. +5. Create internal node with 4 children. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Initialize: `root = TrieNode()` - -Add words: "bad", "dad", "mad" +Let's use `grid = [[0,1],[1,0]]`. We start with the entire 2x2 grid. **2.2 Start Checking:** -Search for: ".ad" +We check if all values are the same. **2.3 Trace Walkthrough:** -| Step | Current Node | Char | Action | -|------|---------------|------|--------| -| 0 | root | '.' | Check all children (b, d, m) | -| 1 | node['b'] | 'a' | Check if 'a' in children | -| 2 | node['b']['a'] | 'd' | Check if 'd' in children and is_end | -| 3 | - | - | Found "bad", return True | - -For ".ad", we check all first-level children (b, d, m), then continue with 'a' and 'd'. +| Region | All Same? | Action | Result | +|--------|-----------|--------|--------| +| [[0,1],[1,0]] | No | Divide | Internal node | +| Top-left [0] | Yes | Leaf | Node(val=0, isLeaf=True) | +| Top-right [1] | Yes | Leaf | Node(val=1, isLeaf=True) | +| Bottom-left [1] | Yes | Leaf | Node(val=1, isLeaf=True) | +| Bottom-right [0] | Yes | Leaf | Node(val=0, isLeaf=True) | **2.4 Increment and Loop:** -For each character in the search word: -- If it's a dot, recursively search all children -- If it's a regular character, follow that child if it exists -- If we reach the end and `is_end` is true, return true +After processing each quadrant, we combine results. **2.5 Return Result:** -The search ".ad" matches "bad", "dad", or "mad", so return `True`. +Return root node with 4 leaf children. ### Solution ```python -def __init__(self): - self.children = {} - self.is_end = False - -class WordDictionary: - def __init__(self): - self.root = TrieNode() - - def addWord(self, word: str) -> None: - node = self.root - for char in word: - if char not in node.children: - node.children[char] = TrieNode() - node = node.children[char] - node.is_end = True +def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): + self.val = val + self.isLeaf = isLeaf + self.topLeft = topLeft + self.topRight = topRight + self.bottomLeft = bottomLeft + self.bottomRight = bottomRight +""" - def search(self, word: str) -> bool: - def dfs(node, index): - if index == len(word): - return node.is_end +class Solution: + def construct(self, grid: List[List[int]]) -> 'Node': + def build(r1, c1, r2, c2): + # Check if all values in the grid are the same + all_same = True + first_val = grid[r1][c1] - char = word[index] - if char == '.': - for child in node.children.values(): - if dfs(child, index + 1): - return True - return False - else: - if char not in node.children: - return False - return dfs(node.children[char], index + 1) + for i in range(r1, r2 + 1): + for j in range(c1, c2 + 1): + if grid[i][j] != first_val: + all_same = False + break + if not all_same: + break + + if all_same: + return Node(first_val == 1, True, None, None, None, None) + + # Divide into four quadrants + mid_r = (r1 + r2) // 2 + mid_c = (c1 + c2) // 2 + + top_left = build(r1, c1, mid_r, mid_c) + top_right = build(r1, mid_c + 1, mid_r, c2) + bottom_left = build(mid_r + 1, c1, r2, mid_c) + bottom_right = build(mid_r + 1, mid_c + 1, r2, c2) + + return Node(False, False, top_left, top_right, bottom_left, bottom_right) - return dfs(self.root, 0) + n = len(grid) + res = build(0, 0, n - 1, n - 1) + return res ``` -## 212. Word Search II [Hard] -https://leetcode.com/problems/word-search-ii/ +## 23. Merge k Sorted Lists [Hard] +https://leetcode.com/problems/merge-k-sorted-lists/ ### Explanation @@ -5296,117 +5248,112 @@ https://leetcode.com/problems/word-search-ii/ ### Strategy (The "Why") +Given an array of $k$ sorted linked lists, we need to merge all of them into one sorted linked list and return it. + **1.1 Constraints & Complexity:** -- **Constraints:** Board size is up to 12x12, word length is 1 to 10, and there are up to 3*10^4 words. -- **Time Complexity:** O(M * N * 4^L) where M and N are board dimensions and L is the maximum word length. With trie optimization, we can prune early. -- **Space Complexity:** O(AL) where A is the alphabet size and L is the total length of all words for the trie, plus O(L) for recursion stack. -- **Edge Case:** If no words can be formed, return an empty list. + +- **Input Size:** $k$ can be between $0$ and $10^4$, and the total number of nodes can be up to $10^4$. +- **Value Range:** Node values are between $-10^4$ and $10^4$. +- **Time Complexity:** $O(n \log k)$ where $n$ is the total number of nodes. We use a heap of size $k$, and each insertion/extraction takes $O(\log k)$ time. We do this for $n$ nodes. +- **Space Complexity:** $O(k)$ - We maintain a heap of size $k$. +- **Edge Case:** If the array is empty, return null. If all lists are empty, return null. **1.2 High-level approach:** -The goal is to find all words from a list that can be formed on the board by moving to adjacent cells. We use a trie to store words and backtracking to explore the board. + +The goal is to merge $k$ sorted linked lists into one sorted list. + +We use a min heap to always get the smallest node among all lists. We add the first node from each list to the heap, then repeatedly extract the minimum, add it to the result, and add the next node from that list to the heap. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** For each word, use DFS to search the board. This is O(W * M * N * 4^L) where W is the number of words. -- **Optimized Strategy:** Build a trie from all words, then use backtracking with the trie to search all words simultaneously. Prune branches when the current path doesn't match any word prefix. -- **Why optimized is better:** The trie allows us to search all words in parallel and prune early when no words match the current path. + +- **Brute Force:** Merge lists one by one. This takes $O(kn)$ time where $n$ is the average list length. +- **Optimized Strategy (Min Heap):** Use a min heap to efficiently get the minimum node at each step. This takes $O(n \log k)$ time. +- **Why it's better:** The heap approach reduces time complexity by maintaining only $k$ nodes in the heap instead of comparing all $k$ lists at each step. **1.4 Decomposition:** -1. Build a trie from all words, storing the complete word at the end node. -2. For each cell on the board, start DFS if the cell's character matches a trie root child. -3. During DFS, mark the cell as visited, check if we found a word, explore neighbors, and restore the cell. -4. Prune the trie by removing nodes with no children after processing. -5. Collect all found words and return them. + +1. Create a min heap and add the first node from each non-empty list. +2. Create a dummy node to simplify edge cases. +3. While the heap is not empty: + - Extract the minimum node from the heap. + - Add it to the result list. + - If that node has a next node, add the next node to the heap. +4. Return the head of the merged list. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Board: `[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]]` -Words: `["oath","pea","eat","rain"]` -Build trie with all words. +Let's use the example: $lists = [[1,4,5],[1,3,4],[2,6]]$ -**2.2 Start Checking:** -Start DFS from each cell that matches a trie root child. +We initialize: +- `heap = [(1,0,node1), (1,1,node1), (2,2,node2)]` +- `dummy = ListNode(0)` +- `current = dummy` + +**2.2 Start Merging:** + +We begin extracting from the heap. **2.3 Trace Walkthrough:** -Starting from (0,0) with 'o': -- 'o' matches trie root child -- Mark (0,0) as '#' -- Explore neighbors: (0,1)='a', (1,0)='e' -- From (0,1): 'a' matches, continue to 't', then 'h' -- Found "oath", add to result -- Continue exploring... +| Step | Extract | current.next | Add to heap | heap After | +|------|---------|--------------|-------------|------------| +| 1 | (1,0) | 1 | (4,0) | [(1,1), (2,2), (4,0)] | +| 2 | (1,1) | 1 | (3,1) | [(2,2), (3,1), (4,0)] | +| 3 | (2,2) | 2 | (6,2) | [(3,1), (4,0), (6,2)] | +| 4 | (3,1) | 3 | (4,1) | [(4,0), (4,1), (6,2)] | +| ... | ... | ... | ... | ... | -**2.4 Increment and Loop:** -For each cell (i, j): -- If board[i][j] matches a trie child, start DFS -- During DFS: mark visited, check for word, explore neighbors, restore cell -- Prune trie nodes with no children +**2.4 Final Result:** + +After merging: $[1,1,2,3,4,4,5,6]$ **2.5 Return Result:** -After processing all cells, `res = ["eat","oath"]`. Return this list. + +We return the head of the merged list: $[1,1,2,3,4,4,5,6]$. + +> **Note:** The key insight is to use a min heap to efficiently get the minimum node among all lists at each step. By maintaining only the current head of each list in the heap, we avoid storing all nodes and achieve $O(n \log k)$ time complexity. ### Solution ```python -def __init__(self): - self.children = {} - self.word = None +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next from typing import List +import heapq class Solution: - def findWords(self, board: List[List[str]], words: List[str]) -> List[str]: - # Build trie - root = TrieNode() - for word in words: - node = root - for char in word: - if char not in node.children: - node.children[char] = TrieNode() - node = node.children[char] - node.word = word + def mergeKLists(self, lists: List[ListNode]) -> ListNode: + # Create a min heap + heap = [] - res = [] - rows, cols = len(board), len(board[0]) + # Add first node from each list to heap + for i, node in enumerate(lists): + if node: + heapq.heappush(heap, (node.val, i, node)) - def dfs(row, col, node): - char = board[row][col] - curr_node = node.children[char] - - # Check if we found a word - if curr_node.word: - res.append(curr_node.word) - curr_node.word = None # Avoid duplicates - - # Mark as visited - board[row][col] = '#' - - # Explore neighbors - for dr, dc in [(0, 1), (0, -1), (1, 0), (-1, 0)]: - new_row, new_col = row + dr, col + dc - if (0 <= new_row < rows and 0 <= new_col < cols and - board[new_row][new_col] in curr_node.children): - dfs(new_row, new_col, curr_node) - - # Restore character - board[row][col] = char - - # Prune if node has no children - if not curr_node.children: - node.children.pop(char) + # Create dummy node + dummy = ListNode(0) + current = dummy - for i in range(rows): - for j in range(cols): - if board[i][j] in root.children: - dfs(i, j, root) + # Merge lists + while heap: + val, idx, node = heapq.heappop(heap) + current.next = node + current = current.next + + # Add next node from the same list if it exists + if node.next: + heapq.heappush(heap, (node.next.val, idx, node.next)) - return res + return dummy.next ``` -## 108. Convert Sorted Array to Binary Search Tree [Easy] -https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ +## 25. Reverse Nodes in k-Group [Hard] +https://leetcode.com/problems/reverse-nodes-in-k-group/ ### Explanation @@ -5416,360 +5363,408 @@ https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ **1.1 Constraints & Complexity** -* **Input Size:** The array $nums$ has length $1 \leq n \leq 10^4$, with values in $[-10^4, 10^4]$. -* **Time Complexity:** $O(n)$ - We visit each element exactly once to build the tree. -* **Space Complexity:** $O(n)$ - The recursion stack depth is $O(\log n)$ for a balanced tree, and the tree itself uses $O(n)$ space. -* **Edge Case:** An empty array returns `None`. A single-element array creates a tree with one node. +* **Input Size:** The linked list has $n$ nodes where $1 \leq k \leq n \leq 5000$. +* **Time Complexity:** $O(n)$ where $n$ is the number of nodes. We visit each node exactly once. +* **Space Complexity:** $O(n/k)$ for the recursion stack, which is $O(n)$ in the worst case when $k = 1$. +* **Edge Case:** If the number of nodes is not a multiple of $k$, the remaining nodes at the end stay in their original order. **1.2 High-level approach** -The goal is to convert a sorted array into a height-balanced binary search tree. We use the middle element as the root to ensure balance, then recursively build left and right subtrees. +The goal is to reverse nodes in groups of $k$. We reverse each group of $k$ nodes, then recursively process the remaining list. If there are fewer than $k$ nodes remaining, we leave them unchanged. -![BST construction from sorted array showing how middle element becomes root] +![Linked list reversal in groups showing how k nodes are reversed at a time] **1.3 Brute force vs. optimized strategy** -* **Brute Force:** Try all possible tree structures and check if they're balanced. This is exponential in complexity. -* **Optimized (Divide and Conquer):** Always choose the middle element as root, ensuring the tree is balanced. This achieves $O(n)$ time and creates an optimal height-balanced tree. +* **Brute Force:** Convert the linked list to an array, reverse groups in the array, then rebuild the list. This uses $O(n)$ extra space. +* **Optimized (In-Place Reversal):** Reverse groups of $k$ nodes in-place using pointer manipulation. This uses $O(1)$ extra space (excluding recursion stack) and maintains the linked list structure. **1.4 Decomposition** -1. **Choose Root:** Select the middle element of the current range as the root. -2. **Build Left Subtree:** Recursively build BST from elements before the middle. -3. **Build Right Subtree:** Recursively build BST from elements after the middle. -4. **Return Root:** Connect subtrees and return the root node. +1. Check if there are at least $k$ nodes remaining. +2. If yes, reverse the first $k$ nodes. +3. Recursively process the remaining list. +4. Connect the reversed group with the result of the recursive call. +5. If fewer than $k$ nodes remain, return the list as is. ### Steps (The "How") **2.1 Initialization & Example Setup** -Let's use the example $nums = [-10,-3,0,5,9]$. +Let's use the example $head = [1,2,3,4,5]$, $k = 2$. -We initialize: -* `left = 0`, `right = 4` -* Middle index: $mid = (0 + 4) // 2 = 2$ +The linked list: `1 -> 2 -> 3 -> 4 -> 5 -> None` -**2.2 Start Building** +**2.2 Start Checking/Processing** -Root is `nums[2] = 0`. +We first check if there are at least $k$ nodes. For the first call, we have 5 nodes, which is more than 2. **2.3 Trace Walkthrough** -| Level | left | right | mid | nums[mid] | Left Range | Right Range | Action | -|-------|------|-------|-----|-----------|------------|-------------|--------| -| 0 | 0 | 4 | 2 | 0 | [0,1] | [3,4] | Create root(0) | -| 1 (left) | 0 | 1 | 0 | -10 | [0,-1] | [1,1] | Create left(-10) | -| 1 (right) | 3 | 4 | 3 | 5 | [3,2] | [4,4] | Create right(5) | -| 2 (left) | 1 | 1 | 1 | -3 | [1,0] | [1,1] | Create right(-3) | -| 2 (right) | 4 | 4 | 4 | 9 | [4,3] | [4,4] | Create right(9) | +**First group (nodes 1-2):** +1. Count nodes: We have 5 nodes, so we can reverse a group of 2. +2. Reverse nodes 1-2: + - Before: `1 -> 2 -> 3 -> 4 -> 5` + - After: `2 -> 1 -> 3 -> 4 -> 5` +3. Recursively process remaining: `3 -> 4 -> 5` -**2.4 Recursive Building** +**Second group (nodes 3-4):** +1. Count nodes: We have 3 nodes, so we can reverse a group of 2. +2. Reverse nodes 3-4: + - Before: `3 -> 4 -> 5` + - After: `4 -> 3 -> 5` +3. Recursively process remaining: `5` -For each recursive call: -1. If `left > right`, return `None` (base case) -2. Calculate `mid = (left + right) // 2` -3. Create root with `nums[mid]` -4. Recursively build left subtree: `build(left, mid - 1)` -5. Recursively build right subtree: `build(mid + 1, right)` +**Remaining (node 5):** +1. Count nodes: We have 1 node, which is less than 2. +2. Return as is: `5` + +**Final result:** `2 -> 1 -> 4 -> 3 -> 5` + +**2.4 Increment and Loop** + +The reversal process: +1. Use a helper function to reverse a segment from `start` to `end` (exclusive). +2. The helper reverses the segment by: + - Setting `prev = None` + - For each node, save `next`, point `curr.next` to `prev`, move `prev` and `curr` forward +3. After reversing $k$ nodes, recursively call on the remaining list. +4. Connect the reversed head with the result of recursion. **2.5 Return Result** -The function returns the root of the balanced BST: `[0,-10,5,null,-3,null,9]`. +After processing all groups, the list becomes `[2,1,4,3,5]`: +* Group 1: `[1,2]` → `[2,1]` +* Group 2: `[3,4]` → `[4,3]` +* Remaining: `[5]` → `[5]` + +The final result is `2 -> 1 -> 4 -> 3 -> 5`. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right +# self.next = next +from typing import Optional + class Solution: - def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]: - def build(left, right): - if left > right: - return None - - # Choose middle element as root - mid = (left + right) // 2 - root = TreeNode(nums[mid]) - - # Recursively build left and right subtrees - root.left = build(left, mid - 1) - root.right = build(mid + 1, right) - - return root + def reverseKGroup(self, head: Optional[ListNode], k: int) -> Optional[ListNode]: + # Helper function to reverse a linked list segment + def reverse_segment(start, end): + prev = None + curr = start + while curr != end: + next_node = curr.next + curr.next = prev + prev = curr + curr = next_node + return prev - return build(0, len(nums) - 1) + # Count nodes to check if we have enough for a group + count = 0 + curr = head + while curr and count < k: + curr = curr.next + count += 1 + + # If we have k nodes, reverse them + if count == k: + # Reverse the first k nodes + reversed_head = reverse_segment(head, curr) + # Recursively reverse the rest + head.next = self.reverseKGroup(curr, k) + return reversed_head + + # Not enough nodes, return as is + return head ``` -## 148. Sort List [Medium] -https://leetcode.com/problems/sort-list/ +## 42. Trapping Rain Water [Hard] +https://leetcode.com/problems/trapping-rain-water/ ### Explanation -Given the `head` of a linked list, return *the list after sorting it in **ascending order***. - -**Example 1:** - -```tex -Input: head = [4,2,1,3] -Output: [1,2,3,4] -``` +## 42. Trapping Rain Water [Hard] -**Example 2:** +https://leetcode.com/problems/trapping-rain-water -```tex -Input: head = [-1,5,3,4,0] -Output: [-1,0,3,4,5] -``` +## Description +Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. -**Example 3:** +**Examples** -```tex -Input: head = [] -Output: [] -``` +```text +Example 1: +Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] +Output: 6 +Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. -**Constraints:** -- The number of nodes in the list is in the range `[0, 5 * 10^4]`. -- `-10^5 <= Node.val <= 10^5` +Example 2: +Input: height = [4,2,0,3,2,5] +Output: 9 +``` -**Follow up:** Can you sort the linked list in `O(n logn)` time and `O(1)` memory (i.e. constant space)? +**Constraints** +```text +- n == height.length +- 1 <= n <= 2 * 10^4 +- 0 <= height[i] <= 10^5 +``` ## Explanation ### Strategy +Let's restate the problem: You're given an array representing the heights of walls in a landscape. When it rains, water gets trapped between these walls. Your job is to calculate how much water can be trapped. -This is a **divide-and-conquer problem** that requires sorting a linked list in O(n log n) time and O(1) space. The key insight is to use merge sort, which naturally works well with linked lists and can be implemented in-place. +This is a **two-pointer and dynamic programming problem** that requires understanding how water trapping works in real life. -**Key observations:** -- We need O(n log n) time complexity for optimal sorting -- We need O(1) space complexity (no extra data structures) -- Merge sort is perfect for linked lists because we can split and merge in-place -- We can use the fast/slow pointer technique to find the middle +**What is given?** An array of non-negative integers representing wall heights. -**High-level approach:** -1. **Find the middle**: Use fast/slow pointers to split the list -2. **Recursively sort**: Sort the left and right halves -3. **Merge sorted lists**: Merge the two sorted halves -4. **Return result**: Return the merged sorted list +**What is being asked?** Calculate the total amount of water that can be trapped between the walls. -### Steps +**Constraints:** The array can be quite large (up to 20,000 elements), so we need an efficient solution. All heights are non-negative. -Let's break down the solution step by step: +**Edge cases:** +- If the array has less than 3 elements, no water can be trapped (need at least 3 walls to form a container) +- If all heights are the same, no water can be trapped +- If heights are strictly increasing or decreasing, no water can be trapped -**Step 1: Handle base cases** -- If head is null or head.next is null, return head (already sorted) +**High-level approach:** +The key insight is that for any position, the amount of water that can be trapped depends on the **minimum** of the highest wall to its left and the highest wall to its right. Water can only be trapped up to the height of the shorter of these two walls. -**Step 2: Find the middle of the list** -- Use fast/slow pointer technique -- Slow pointer moves 1 step, fast pointer moves 2 steps -- When fast reaches end, slow is at middle +Think of it like this: at any point, water will rise to the level of the lower "dam" on either side. If you're in a valley between two mountains, the water level is limited by the shorter mountain. -**Step 3: Split the list** -- Set `mid = slow.next` -- Set `slow.next = None` to split the list +**Decomposition:** +1. **Precompute left and right maximums**: For each position, find the highest wall to its left and right +2. **Calculate trapped water**: For each position, the trapped water is the minimum of left and right max, minus the current height (if positive) +3. **Sum up all trapped water**: Add up the water trapped at each position -**Step 4: Recursively sort halves** +**Brute force vs. optimized strategy:** +- **Brute force**: For each position, scan left and right to find maximums. This takes O(n²) time. +- **Optimized**: Precompute left and right maximums in two passes, then calculate water in one pass. This takes O(n) time. -- Sort the left half: `left = sortList(head)` -- Sort the right half: `right = sortList(mid)` +### Steps +Let's walk through the solution step by step using the first example: `height = [0,1,0,2,1,0,1,3,2,1,2,1]` -**Step 5: Merge the sorted halves** +**Step 1: Understand the visualization** +Imagine this array as a landscape: +``` + ■ + ■ ■ ■ + ■ ■ ■ ■ ■ ■ ■ ■ +■ ■ ■ ■ ■ ■ ■ ■ ■ ■ +0 1 0 2 1 0 1 3 2 1 2 1 +``` -- Use a dummy node to simplify merging -- Compare nodes from both lists and link them in order +**Step 2: Precompute left maximums** +We'll create an array `left_max` where `left_max[i]` is the highest wall to the left of position `i` (including position `i` itself). -**Example walkthrough:** +``` +height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] +left_max: [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3] +``` -Let's trace through the first example: +How we calculate this: +- `left_max[0] = height[0] = 0` (no walls to the left) +- `left_max[1] = max(left_max[0], height[1]) = max(0, 1) = 1` +- `left_max[2] = max(left_max[1], height[2]) = max(1, 0) = 1` +- `left_max[3] = max(left_max[2], height[3]) = max(1, 2) = 2` +- And so on... -```tex -head = [4,2,1,3] +**Step 3: Precompute right maximums** +Similarly, create `right_max` where `right_max[i]` is the highest wall to the right of position `i` (including position `i` itself). -Step 1: Find middle -slow = 4, fast = 4 -slow = 2, fast = 1 -slow = 1, fast = 3 -slow = 3, fast = null -middle = 3 +``` +height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] +right_max: [3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1] +``` -Step 2: Split list -left = [4,2,1], right = [3] +How we calculate this (from right to left): +- `right_max[11] = height[11] = 1` (no walls to the right) +- `right_max[10] = max(right_max[11], height[10]) = max(1, 2) = 2` +- `right_max[9] = max(right_max[10], height[9]) = max(2, 1) = 2` +- And so on... -Step 3: Recursively sort left -left = [4,2,1] → [1,2,4] +**Step 4: Calculate trapped water at each position** +For each position `i`, the water trapped is: +``` +water[i] = min(left_max[i], right_max[i]) - height[i] +``` -Step 4: Recursively sort right -right = [3] → [3] +But only if this value is positive (we can't have negative water). -Step 5: Merge [1,2,4] and [3] -result = [1,2,3,4] +Let's calculate for a few positions: +- Position 0: `min(0, 3) - 0 = 0` (no water trapped) +- Position 1: `min(1, 3) - 1 = 0` (no water trapped) +- Position 2: `min(1, 3) - 0 = 1` (1 unit of water trapped) +- Position 3: `min(2, 3) - 2 = 0` (no water trapped) +- Position 4: `min(2, 3) - 1 = 1` (1 unit of water trapped) +- Position 5: `min(2, 3) - 0 = 2` (2 units of water trapped) + +**Step 5: Sum up all trapped water** +``` +water = [0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 0] +total = 0 + 0 + 1 + 0 + 1 + 2 + 1 + 0 + 0 + 1 + 0 + 0 = 6 ``` -> **Note:** Merge sort is ideal for linked lists because we can split and merge in-place without extra space. The fast/slow pointer technique efficiently finds the middle, and the merge step can be done by simply relinking nodes. +> **Note:** The key insight is that water can only be trapped up to the height of the lower "dam" on either side. This is why we take the minimum of the left and right maximums. -**Time Complexity:** O(n log n) - merge sort time complexity -**Space Complexity:** O(log n) - recursion stack space (not O(1) due to recursion) +**Time Complexity:** O(n) - we make three passes through the array +**Space Complexity:** O(n) - we store two additional arrays of size n ### Solution ```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next +def trap(height): + """ + Calculate the amount of water that can be trapped between walls. + + Args: + height: List[int] - Array representing wall heights + + Returns: + int - Total amount of water trapped + """ + # Handle edge cases + if not height or len(height) < 3: + return 0 + + n = len(height) + + # Step 1: Precompute left maximums + # left_max[i] = highest wall to the left of position i (including i) + left_max = [0] * n + left_max[0] = height[0] + + for i in range(1, n): + left_max[i] = max(left_max[i-1], height[i]) + + # Step 2: Precompute right maximums + # right_max[i] = highest wall to the right of position i (including i) + right_max = [0] * n + right_max[n-1] = height[n-1] + + for i in range(n-2, -1, -1): + right_max[i] = max(right_max[i+1], height[i]) + + # Step 3: Calculate trapped water at each position + res = 0 + for i in range(n): + # Water trapped = min(left_max, right_max) - current_height + # But only if positive (can't have negative water) + water = min(left_max[i], right_max[i]) - height[i] + if water > 0: + res += water + + return res +``` +## 124. Binary Tree Maximum Path Sum [Hard] +https://leetcode.com/problems/binary-tree-maximum-path-sum/ -class Solution: - def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: - if not head or not head.next: - return head +### Explanation - # Find the middle of the list - slow = head - fast = head.next +## Explanation - while fast and fast.next: - slow = slow.next - fast = fast.next.next +### Strategy (The "Why") - # Split the list - mid = slow.next - slow.next = None +**1.1 Constraints & Complexity** - left = self.sortList(head) - right = self.sortList(mid) +* **Input Size:** The tree has $1 \leq n \leq 3 \times 10^4$ nodes, with values in $[-1000, 1000]$. +* **Time Complexity:** $O(n)$ - We visit each node exactly once during DFS traversal. +* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +* **Edge Case:** A single-node tree returns the node's value. All negative values require careful handling (we use `max(0, ...)` to avoid negative contributions). - return self.merge(left, right) +**1.2 High-level approach** - def merge( - self, left: Optional[ListNode], right: Optional[ListNode] - ) -> Optional[ListNode]: - # Create a dummy node to simplify merging - dummy = ListNode(0) - current = dummy +The goal is to find the maximum path sum in a binary tree, where a path can start and end at any nodes (not necessarily root or leaf). We use DFS to calculate the maximum path sum that can be extended upward from each node, while tracking the global maximum. - # Merge the two sorted lists - while left and right: - if left.val <= right.val: - current.next = left - left = left.next - else: - current.next = right - right = right.next - current = current.next +![Maximum path sum visualization showing paths that can go through any node] - # Attach remaining nodes - if left: - current.next = left - if right: - current.next = right +**1.3 Brute force vs. optimized strategy** - # Return the merged list (skip dummy node) - return dummy.next -``` +* **Brute Force:** Try all possible paths in the tree. This is exponential in complexity. +* **Optimized (DFS with Global Tracking):** For each node, calculate the maximum path sum that can be extended upward (for parent) and the maximum path sum through the node (for global maximum). This achieves $O(n)$ time. -## 427. Construct Quad Tree [Medium] -https://leetcode.com/problems/construct-quad-tree/ +**1.4 Decomposition** -### Explanation +1. **DFS Traversal:** Recursively visit each node. +2. **Calculate Contributions:** For each node, get maximum contributions from left and right subtrees (non-negative only). +3. **Update Global Maximum:** Calculate path sum through current node and update global maximum. +4. **Return Upward Contribution:** Return the maximum path sum that can be extended to parent. -## Explanation +### Steps (The "How") -### Strategy (The "Why") +**2.1 Initialization & Example Setup** -**1.1 Constraints & Complexity:** -- **Input Size:** `n == grid.length == grid[i].length`, `n == 2^x` where `0 <= x <= 6`. -- **Time Complexity:** O(n²) - we process each cell, but with divide-and-conquer optimization. -- **Space Complexity:** O(log n) - recursion depth. -- **Edge Case:** All cells have the same value, single leaf node. +Let's use the example $root = [-10,9,20,null,null,15,7]$. -**1.2 High-level approach:** -The goal is to construct a Quad-Tree from a binary grid. We use divide-and-conquer: if all values in a region are the same, create a leaf; otherwise, divide into 4 quadrants and recurse. +We initialize: +* `res = -inf` (global maximum path sum) +* Start DFS from root node (-10) -**1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Same as optimized - divide-and-conquer is the natural approach. -- **Optimized Strategy:** Recursively divide grid into quadrants until uniform or single cell. +**2.2 Start Processing** -**1.4 Decomposition:** -1. Check if all values in current region are the same. -2. If yes, create a leaf node with that value. -3. If no, divide into 4 quadrants (top-left, top-right, bottom-left, bottom-right). -4. Recursively construct each quadrant. -5. Create internal node with 4 children. +We call `dfs(root)`. -### Steps (The "How") +**2.3 Trace Walkthrough** -**2.1 Initialization & Example Setup:** -Let's use `grid = [[0,1],[1,0]]`. We start with the entire 2x2 grid. +| Node | left_sum | right_sum | Path Through Node | Return Value | res (after) | +|------|----------|-----------|-------------------|--------------|-------------| +| -10 | max(0, dfs(9)) | max(0, dfs(20)) | -10 + 0 + 0 = -10 | -10 + max(0,0) = -10 | -10 | +| 9 | 0 | 0 | 9 + 0 + 0 = 9 | 9 + 0 = 9 | 9 | +| 20 | max(0, dfs(15)) | max(0, dfs(7)) | 20 + 15 + 7 = 42 | 20 + max(15,7) = 35 | 42 | +| 15 | 0 | 0 | 15 + 0 + 0 = 15 | 15 + 0 = 15 | 42 | +| 7 | 0 | 0 | 7 + 0 + 0 = 7 | 7 + 0 = 7 | 42 | -**2.2 Start Checking:** -We check if all values are the same. +**2.4 Recursive Processing** -**2.3 Trace Walkthrough:** +For each node: +1. If `not node`, return 0 (base case) +2. Recursively get `left_sum = max(0, dfs(node.left))` (non-negative only) +3. Recursively get `right_sum = max(0, dfs(node.right))` (non-negative only) +4. Update global: `res = max(res, node.val + left_sum + right_sum)` +5. Return: `node.val + max(left_sum, right_sum)` (for parent) -| Region | All Same? | Action | Result | -|--------|-----------|--------|--------| -| [[0,1],[1,0]] | No | Divide | Internal node | -| Top-left [0] | Yes | Leaf | Node(val=0, isLeaf=True) | -| Top-right [1] | Yes | Leaf | Node(val=1, isLeaf=True) | -| Bottom-left [1] | Yes | Leaf | Node(val=1, isLeaf=True) | -| Bottom-right [0] | Yes | Leaf | Node(val=0, isLeaf=True) | +**2.5 Return Result** -**2.4 Increment and Loop:** -After processing each quadrant, we combine results. +After processing all nodes, `res = 42`, which is the maximum path sum from the path $15 \to 20 \to 7$. -**2.5 Return Result:** -Return root node with 4 leaf children. +> **Note:** We use `max(0, ...)` to ensure we only consider positive contributions from subtrees. If a subtree contributes negatively, we ignore it (treat as 0). ### Solution ```python -def __init__(self, val, isLeaf, topLeft, topRight, bottomLeft, bottomRight): - self.val = val - self.isLeaf = isLeaf - self.topLeft = topLeft - self.topRight = topRight - self.bottomLeft = bottomLeft - self.bottomRight = bottomRight -""" - +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right class Solution: - def construct(self, grid: List[List[int]]) -> 'Node': - def build(r1, c1, r2, c2): - # Check if all values in the grid are the same - all_same = True - first_val = grid[r1][c1] - - for i in range(r1, r2 + 1): - for j in range(c1, c2 + 1): - if grid[i][j] != first_val: - all_same = False - break - if not all_same: - break - - if all_same: - return Node(first_val == 1, True, None, None, None, None) + def maxPathSum(self, root: Optional[TreeNode]) -> int: + res = float('-inf') + + def dfs(node): + nonlocal res + if not node: + return 0 - # Divide into four quadrants - mid_r = (r1 + r2) // 2 - mid_c = (c1 + c2) // 2 + # Get max path sum from left and right subtrees + left_sum = max(0, dfs(node.left)) + right_sum = max(0, dfs(node.right)) - top_left = build(r1, c1, mid_r, mid_c) - top_right = build(r1, mid_c + 1, mid_r, c2) - bottom_left = build(mid_r + 1, c1, r2, mid_c) - bottom_right = build(mid_r + 1, mid_c + 1, r2, c2) + # Update global maximum (path through current node) + res = max(res, node.val + left_sum + right_sum) - return Node(False, False, top_left, top_right, bottom_left, bottom_right) + # Return max path sum that can be extended upward + return node.val + max(left_sum, right_sum) - n = len(grid) - res = build(0, 0, n - 1, n - 1) + dfs(root) return res ``` -## 23. Merge k Sorted Lists [Hard] -https://leetcode.com/problems/merge-k-sorted-lists/ +## 212. Word Search II [Hard] +https://leetcode.com/problems/word-search-ii/ ### Explanation @@ -5777,108 +5772,113 @@ https://leetcode.com/problems/merge-k-sorted-lists/ ### Strategy (The "Why") -Given an array of $k$ sorted linked lists, we need to merge all of them into one sorted linked list and return it. - **1.1 Constraints & Complexity:** - -- **Input Size:** $k$ can be between $0$ and $10^4$, and the total number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-10^4$ and $10^4$. -- **Time Complexity:** $O(n \log k)$ where $n$ is the total number of nodes. We use a heap of size $k$, and each insertion/extraction takes $O(\log k)$ time. We do this for $n$ nodes. -- **Space Complexity:** $O(k)$ - We maintain a heap of size $k$. -- **Edge Case:** If the array is empty, return null. If all lists are empty, return null. +- **Constraints:** Board size is up to 12x12, word length is 1 to 10, and there are up to 3*10^4 words. +- **Time Complexity:** O(M * N * 4^L) where M and N are board dimensions and L is the maximum word length. With trie optimization, we can prune early. +- **Space Complexity:** O(AL) where A is the alphabet size and L is the total length of all words for the trie, plus O(L) for recursion stack. +- **Edge Case:** If no words can be formed, return an empty list. **1.2 High-level approach:** - -The goal is to merge $k$ sorted linked lists into one sorted list. - -We use a min heap to always get the smallest node among all lists. We add the first node from each list to the heap, then repeatedly extract the minimum, add it to the result, and add the next node from that list to the heap. +The goal is to find all words from a list that can be formed on the board by moving to adjacent cells. We use a trie to store words and backtracking to explore the board. **1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** Merge lists one by one. This takes $O(kn)$ time where $n$ is the average list length. -- **Optimized Strategy (Min Heap):** Use a min heap to efficiently get the minimum node at each step. This takes $O(n \log k)$ time. -- **Why it's better:** The heap approach reduces time complexity by maintaining only $k$ nodes in the heap instead of comparing all $k$ lists at each step. +- **Brute Force:** For each word, use DFS to search the board. This is O(W * M * N * 4^L) where W is the number of words. +- **Optimized Strategy:** Build a trie from all words, then use backtracking with the trie to search all words simultaneously. Prune branches when the current path doesn't match any word prefix. +- **Why optimized is better:** The trie allows us to search all words in parallel and prune early when no words match the current path. **1.4 Decomposition:** - -1. Create a min heap and add the first node from each non-empty list. -2. Create a dummy node to simplify edge cases. -3. While the heap is not empty: - - Extract the minimum node from the heap. - - Add it to the result list. - - If that node has a next node, add the next node to the heap. -4. Return the head of the merged list. +1. Build a trie from all words, storing the complete word at the end node. +2. For each cell on the board, start DFS if the cell's character matches a trie root child. +3. During DFS, mark the cell as visited, check if we found a word, explore neighbors, and restore the cell. +4. Prune the trie by removing nodes with no children after processing. +5. Collect all found words and return them. ### Steps (The "How") **2.1 Initialization & Example Setup:** +Board: `[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]]` +Words: `["oath","pea","eat","rain"]` -Let's use the example: $lists = [[1,4,5],[1,3,4],[2,6]]$ - -We initialize: -- `heap = [(1,0,node1), (1,1,node1), (2,2,node2)]` -- `dummy = ListNode(0)` -- `current = dummy` - -**2.2 Start Merging:** +Build trie with all words. -We begin extracting from the heap. +**2.2 Start Checking:** +Start DFS from each cell that matches a trie root child. **2.3 Trace Walkthrough:** -| Step | Extract | current.next | Add to heap | heap After | -|------|---------|--------------|-------------|------------| -| 1 | (1,0) | 1 | (4,0) | [(1,1), (2,2), (4,0)] | -| 2 | (1,1) | 1 | (3,1) | [(2,2), (3,1), (4,0)] | -| 3 | (2,2) | 2 | (6,2) | [(3,1), (4,0), (6,2)] | -| 4 | (3,1) | 3 | (4,1) | [(4,0), (4,1), (6,2)] | -| ... | ... | ... | ... | ... | - -**2.4 Final Result:** +Starting from (0,0) with 'o': +- 'o' matches trie root child +- Mark (0,0) as '#' +- Explore neighbors: (0,1)='a', (1,0)='e' +- From (0,1): 'a' matches, continue to 't', then 'h' +- Found "oath", add to result +- Continue exploring... -After merging: $[1,1,2,3,4,4,5,6]$ +**2.4 Increment and Loop:** +For each cell (i, j): +- If board[i][j] matches a trie child, start DFS +- During DFS: mark visited, check for word, explore neighbors, restore cell +- Prune trie nodes with no children **2.5 Return Result:** - -We return the head of the merged list: $[1,1,2,3,4,4,5,6]$. - -> **Note:** The key insight is to use a min heap to efficiently get the minimum node among all lists at each step. By maintaining only the current head of each list in the heap, we avoid storing all nodes and achieve $O(n \log k)$ time complexity. +After processing all cells, `res = ["eat","oath"]`. Return this list. ### Solution ```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next +def __init__(self): + self.children = {} + self.word = None from typing import List -import heapq class Solution: - def mergeKLists(self, lists: List[ListNode]) -> ListNode: - # Create a min heap - heap = [] - - # Add first node from each list to heap - for i, node in enumerate(lists): - if node: - heapq.heappush(heap, (node.val, i, node)) + def findWords(self, board: List[List[str]], words: List[str]) -> List[str]: + # Build trie + root = TrieNode() + for word in words: + node = root + for char in word: + if char not in node.children: + node.children[char] = TrieNode() + node = node.children[char] + node.word = word - # Create dummy node - dummy = ListNode(0) - current = dummy + res = [] + rows, cols = len(board), len(board[0]) - # Merge lists - while heap: - val, idx, node = heapq.heappop(heap) - current.next = node - current = current.next + def dfs(row, col, node): + char = board[row][col] + curr_node = node.children[char] - # Add next node from the same list if it exists - if node.next: - heapq.heappush(heap, (node.next.val, idx, node.next)) + # Check if we found a word + if curr_node.word: + res.append(curr_node.word) + curr_node.word = None # Avoid duplicates + + # Mark as visited + board[row][col] = '#' + + # Explore neighbors + for dr, dc in [(0, 1), (0, -1), (1, 0), (-1, 0)]: + new_row, new_col = row + dr, col + dc + if (0 <= new_row < rows and 0 <= new_col < cols and + board[new_row][new_col] in curr_node.children): + dfs(new_row, new_col, curr_node) + + # Restore character + board[row][col] = char + + # Prune if node has no children + if not curr_node.children: + node.children.pop(char) - return dummy.next + for i in range(rows): + for j in range(cols): + if board[i][j] in root.children: + dfs(i, j, root) + + return res ``` ## 295. Find Median from Data Stream [Hard] diff --git a/books/Top_100_Liked_Questions.md b/books/Top_100_Liked_Questions.md index 516b58f..36044e2 100644 --- a/books/Top_100_Liked_Questions.md +++ b/books/Top_100_Liked_Questions.md @@ -34,168 +34,6 @@ def two_sum(nums, target): return [] ``` -## 2. Add Two Numbers [Medium] -https://leetcode.com/problems/add-two-numbers/ - -### Explanation - -You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. - -You may assume the two numbers do not contain any leading zero, except the number 0 itself. - -Example: -```text -Input: l1 = [2,4,3], l2 = [5,6,4] -Output: [7,0,8] -Explanation: 342 + 465 = 807. - -Input: l1 = [0], l2 = [0] -Output: [0] - -Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] -Output: [8,9,9,9,0,0,0,1] -``` - -Constraints: -```text -The number of nodes in each linked list is in the range [1, 100]. -0 <= Node.val <= 9 -It is guaranteed that the list represents a number that does not have leading zeros. -``` - -## Explanation - -The Add Two Numbers problem involves adding two numbers represented by linked lists, where each node contains a single digit and the digits are stored in reverse order. To solve this, we iterate through both linked lists, adding corresponding digits along with any carry from the previous addition. We create a new linked list to store the result. If one list is shorter, treat missing digits as 0. If there is a carry left after processing both lists, add a new node with the carry value. - -## Hint - -Use a dummy head node to simplify the code for building the result list. Remember to handle the carry at the end. - -## Points - -- Time complexity: O(max(m, n)), where m and n are the lengths of the two lists. -- Handle different lengths of input lists. -- Don’t forget to add a node if there is a carry left after the main loop. -- Each node contains a single digit (0-9). - -### Solution - -```python -def __init__(self, val=0, next=None): - self.val = val - self.next = next -``` - -## 19. Remove Nth Node From End of List [Medium] -https://leetcode.com/problems/remove-nth-node-from-end-of-list/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -Given the head of a linked list and an integer $n$, we need to remove the $n$-th node from the end of the list and return the head. - -**1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes $N$ can be between $1$ and $30$. -- **Value Range:** Node values are between $1$ and $100$. -- **Time Complexity:** $O(L)$ where $L$ is the length of the list. We make one pass through the list. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If we need to remove the head node ($n$ equals the list length), we need special handling. Using a dummy node simplifies this. - -**1.2 High-level approach:** - -The goal is to remove the $n$-th node from the end of a linked list. - -![Remove Nth Node](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg) - -We use two pointers: a fast pointer and a slow pointer. We move the fast pointer $n+1$ steps ahead, then move both pointers together. When fast reaches the end, slow will be at the node before the one to remove. - -**1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** First pass to count the length, second pass to find and remove the $(L-n+1)$-th node from the beginning. This takes two passes. -- **Optimized Strategy (Two Pointers):** Use two pointers with a gap of $n+1$ nodes. Move both together until the fast pointer reaches the end. This takes one pass. -- **Why it's better:** The two-pointer approach is more elegant and requires only one pass through the list, though both approaches have the same time complexity. - -**1.4 Decomposition:** - -1. Create a dummy node pointing to the head (to handle edge cases). -2. Initialize two pointers (fast and slow) at the dummy node. -3. Move the fast pointer $n+1$ steps ahead. -4. Move both pointers together until fast reaches the end. -5. Remove the node after slow (which is the $n$-th node from the end). -6. Return the head (via dummy.next). - -### Steps (The "How") - -**2.1 Initialization & Example Setup:** - -Let's use the example: head = $[1,2,3,4,5]$, $n = 2$ - -We initialize: -- `dummy = ListNode(0)`, `dummy.next = head` -- `fast = dummy`, `slow = dummy` - -**2.2 Start Processing:** - -We move the fast pointer $n+1 = 3$ steps ahead. - -**2.3 Trace Walkthrough:** - -| Step | Fast Position | Slow Position | Action | -|------|---------------|---------------|--------| -| Initial | dummy | dummy | - | -| After moving fast 3 steps | node 4 | dummy | Fast is 3 steps ahead | -| Move both together | node 5 | node 1 | Continue... | -| Move both together | null | node 3 | Fast reached end | - -When fast is null, slow is at node 3 (the node before node 4, which is the 2nd from end). - -**2.4 Remove Node:** - -- `slow.next = slow.next.next` removes node 4 -- Result: $[1,2,3,5]$ - -**2.5 Return Result:** - -We return `dummy.next` which points to the new head $[1,2,3,5]$. - -> **Note:** The dummy node is crucial because it handles the edge case where we need to remove the head node. Without it, we'd need special handling for that case. - -### Solution - -```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next - -class Solution: - def removeNthFromEnd(self, head, n: int): - # Create a dummy node to handle edge cases - dummy = ListNode(0) - dummy.next = head - - # Two pointers: fast and slow - fast = dummy - slow = dummy - - # Move fast pointer n+1 steps ahead - for _ in range(n + 1): - fast = fast.next - - # Move both pointers until fast reaches the end - while fast: - fast = fast.next - slow = slow.next - - # Remove the nth node from end - slow.next = slow.next.next - - return dummy.next -``` - ## 21. Merge Two Sorted Lists [Easy] https://leetcode.com/problems/merge-two-sorted-lists/ @@ -300,8 +138,8 @@ class Solution: return dummy.next ``` -## 23. Merge k Sorted Lists [Hard] -https://leetcode.com/problems/merge-k-sorted-lists/ +## 94. Binary Tree Inorder Traversal [Easy] +https://leetcode.com/problems/binary-tree-inorder-traversal/ ### Explanation @@ -309,292 +147,220 @@ https://leetcode.com/problems/merge-k-sorted-lists/ ### Strategy (The "Why") -Given an array of $k$ sorted linked lists, we need to merge all of them into one sorted linked list and return it. +Given the root of a binary tree, we need to return the inorder traversal of its nodes' values. **1.1 Constraints & Complexity:** -- **Input Size:** $k$ can be between $0$ and $10^4$, and the total number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-10^4$ and $10^4$. -- **Time Complexity:** $O(n \log k)$ where $n$ is the total number of nodes. We use a heap of size $k$, and each insertion/extraction takes $O(\log k)$ time. We do this for $n$ nodes. -- **Space Complexity:** $O(k)$ - We maintain a heap of size $k$. -- **Edge Case:** If the array is empty, return null. If all lists are empty, return null. +- **Input Size:** The number of nodes can be up to $100$. +- **Value Range:** Node values are between $-100$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. **1.2 High-level approach:** -The goal is to merge $k$ sorted linked lists into one sorted list. +The goal is to traverse the tree in inorder (left, root, right) order. -We use a min heap to always get the smallest node among all lists. We add the first node from each list to the heap, then repeatedly extract the minimum, add it to the result, and add the next node from that list to the heap. +We use recursion to implement inorder traversal. We recursively traverse the left subtree, visit the root, then recursively traverse the right subtree. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Merge lists one by one. This takes $O(kn)$ time where $n$ is the average list length. -- **Optimized Strategy (Min Heap):** Use a min heap to efficiently get the minimum node at each step. This takes $O(n \log k)$ time. -- **Why it's better:** The heap approach reduces time complexity by maintaining only $k$ nodes in the heap instead of comparing all $k$ lists at each step. +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. +- **Optimized Strategy (Recursion):** Use recursion to naturally implement inorder traversal. This is the standard and efficient approach. +- **Why it's better:** Recursion naturally follows the tree structure and implements inorder traversal efficiently. An iterative approach using a stack is also possible but more complex. **1.4 Decomposition:** -1. Create a min heap and add the first node from each non-empty list. -2. Create a dummy node to simplify edge cases. -3. While the heap is not empty: - - Extract the minimum node from the heap. - - Add it to the result list. - - If that node has a next node, add the next node to the heap. -4. Return the head of the merged list. +1. Define a recursive function that takes a node. +2. Base case: if node is null, return. +3. Recursively traverse left subtree. +4. Visit current node (add value to result). +5. Recursively traverse right subtree. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: $lists = [[1,4,5],[1,3,4],[2,6]]$ +Let's use the example: root = $[1,null,2,3]$ + +The tree structure: +``` + 1 + \ + 2 + / + 3 +``` We initialize: -- `heap = [(1,0,node1), (1,1,node1), (2,2,node2)]` -- `dummy = ListNode(0)` -- `current = dummy` +- `res = []` -**2.2 Start Merging:** +**2.2 Start Traversal:** -We begin extracting from the heap. +We begin from the root. **2.3 Trace Walkthrough:** -| Step | Extract | current.next | Add to heap | heap After | -|------|---------|--------------|-------------|------------| -| 1 | (1,0) | 1 | (4,0) | [(1,1), (2,2), (4,0)] | -| 2 | (1,1) | 1 | (3,1) | [(2,2), (3,1), (4,0)] | -| 3 | (2,2) | 2 | (6,2) | [(3,1), (4,0), (6,2)] | -| 4 | (3,1) | 3 | (4,1) | [(4,0), (4,1), (6,2)] | -| ... | ... | ... | ... | ... | +| Node | Action | res After | +|------|--------|-----------| +| 1 | Go left (null) | [] | +| 1 | Visit 1 | [1] | +| 1 | Go right (2) | [1] | +| 2 | Go left (3) | [1] | +| 3 | Go left (null) | [1] | +| 3 | Visit 3 | [1,3] | +| 3 | Go right (null) | [1,3] | +| 2 | Visit 2 | [1,3,2] | +| 2 | Go right (null) | [1,3,2] | **2.4 Final Result:** -After merging: $[1,1,2,3,4,4,5,6]$ +After traversal: `res = [1,3,2]` **2.5 Return Result:** -We return the head of the merged list: $[1,1,2,3,4,4,5,6]$. +We return `[1,3,2]`, which is the inorder traversal. -> **Note:** The key insight is to use a min heap to efficiently get the minimum node among all lists at each step. By maintaining only the current head of each list in the heap, we avoid storing all nodes and achieve $O(n \log k)$ time complexity. +> **Note:** The key is to follow the inorder order: left subtree first, then root, then right subtree. Recursion naturally implements this by processing the left subtree before the root, and the root before the right subtree. ### Solution ```python -def __init__(self, val=0, next=None): +def __init__(self, val=0, left=None, right=None): # self.val = val -# self.next = next +# self.left = left +# self.right = right from typing import List -import heapq class Solution: - def mergeKLists(self, lists: List[ListNode]) -> ListNode: - # Create a min heap - heap = [] + def inorderTraversal(self, root) -> List[int]: + res = [] - # Add first node from each list to heap - for i, node in enumerate(lists): - if node: - heapq.heappush(heap, (node.val, i, node)) - - # Create dummy node - dummy = ListNode(0) - current = dummy - - # Merge lists - while heap: - val, idx, node = heapq.heappop(heap) - current.next = node - current = current.next - - # Add next node from the same list if it exists - if node.next: - heapq.heappush(heap, (node.next.val, idx, node.next)) + def inorder(node): + if not node: + return + inorder(node.left) + res.append(node.val) + inorder(node.right) - return dummy.next + inorder(root) + return res ``` -## 42. Trapping Rain Water [Hard] -https://leetcode.com/problems/trapping-rain-water/ +## 101. Symmetric Tree [Easy] +https://leetcode.com/problems/symmetric-tree/ ### Explanation -## 42. Trapping Rain Water [Hard] - -https://leetcode.com/problems/trapping-rain-water - -## Description -Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. - -**Examples** - -```text -Example 1: -Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] -Output: 6 -Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. - -Example 2: -Input: height = [4,2,0,3,2,5] -Output: 9 -``` - -**Constraints** -```text -- n == height.length -- 1 <= n <= 2 * 10^4 -- 0 <= height[i] <= 10^5 -``` - ## Explanation -### Strategy -Let's restate the problem: You're given an array representing the heights of walls in a landscape. When it rains, water gets trapped between these walls. Your job is to calculate how much water can be trapped. +### Strategy (The "Why") -This is a **two-pointer and dynamic programming problem** that requires understanding how water trapping works in real life. +Given the root of a binary tree, we need to check whether it is a mirror of itself (symmetric around its center). -**What is given?** An array of non-negative integers representing wall heights. +**1.1 Constraints & Complexity:** -**What is being asked?** Calculate the total amount of water that can be trapped between the walls. +- **Input Size:** The number of nodes can be up to $1000$. +- **Value Range:** Node values are between $-100$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. +- **Edge Case:** An empty tree is symmetric. A tree with only one node is symmetric. -**Constraints:** The array can be quite large (up to 20,000 elements), so we need an efficient solution. All heights are non-negative. +**1.2 High-level approach:** -**Edge cases:** -- If the array has less than 3 elements, no water can be trapped (need at least 3 walls to form a container) -- If all heights are the same, no water can be trapped -- If heights are strictly increasing or decreasing, no water can be trapped +The goal is to determine if a binary tree is symmetric (mirror of itself). -**High-level approach:** -The key insight is that for any position, the amount of water that can be trapped depends on the **minimum** of the highest wall to its left and the highest wall to its right. Water can only be trapped up to the height of the shorter of these two walls. +We use recursion to check if the left and right subtrees are mirrors of each other. Two trees are mirrors if their roots have the same value, and the left subtree of one is a mirror of the right subtree of the other, and vice versa. -Think of it like this: at any point, water will rise to the level of the lower "dam" on either side. If you're in a valley between two mountains, the water level is limited by the shorter mountain. +**1.3 Brute force vs. optimized strategy:** -**Decomposition:** -1. **Precompute left and right maximums**: For each position, find the highest wall to its left and right -2. **Calculate trapped water**: For each position, the trapped water is the minimum of left and right max, minus the current height (if positive) -3. **Sum up all trapped water**: Add up the water trapped at each position +- **Brute Force:** There isn't really a brute force approach - we must check the mirror property. +- **Optimized Strategy (Recursion):** Use recursion to check if left and right subtrees are mirrors. This is the standard and efficient approach. +- **Why it's better:** Recursion naturally checks the mirror property by comparing corresponding nodes in the left and right subtrees. -**Brute force vs. optimized strategy:** -- **Brute force**: For each position, scan left and right to find maximums. This takes O(n²) time. -- **Optimized**: Precompute left and right maximums in two passes, then calculate water in one pass. This takes O(n) time. +**1.4 Decomposition:** -### Steps -Let's walk through the solution step by step using the first example: `height = [0,1,0,2,1,0,1,3,2,1,2,1]` +1. Define a helper function that checks if two trees are mirrors. +2. Two trees are mirrors if: + - Both are null (base case: true). + - One is null and the other is not (false). + - Both roots have the same value, and: + - Left subtree of first is mirror of right subtree of second. + - Right subtree of first is mirror of left subtree of second. +3. Check if root's left and right subtrees are mirrors. -**Step 1: Understand the visualization** -Imagine this array as a landscape: -``` - ■ - ■ ■ ■ - ■ ■ ■ ■ ■ ■ ■ ■ -■ ■ ■ ■ ■ ■ ■ ■ ■ ■ -0 1 0 2 1 0 1 3 2 1 2 1 -``` +### Steps (The "How") -**Step 2: Precompute left maximums** -We'll create an array `left_max` where `left_max[i]` is the highest wall to the left of position `i` (including position `i` itself). +**2.1 Initialization & Example Setup:** + +Let's use the example: root = $[1,2,2,3,4,4,3]$ +The tree structure: ``` -height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -left_max: [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3] + 1 + / \ + 2 2 + / \ / \ + 3 4 4 3 ``` -How we calculate this: -- `left_max[0] = height[0] = 0` (no walls to the left) -- `left_max[1] = max(left_max[0], height[1]) = max(0, 1) = 1` -- `left_max[2] = max(left_max[1], height[2]) = max(1, 0) = 1` -- `left_max[3] = max(left_max[2], height[3]) = max(1, 2) = 2` -- And so on... +We initialize: +- Call `is_mirror(root.left, root.right)` -**Step 3: Precompute right maximums** -Similarly, create `right_max` where `right_max[i]` is the highest wall to the right of position `i` (including position `i` itself). +**2.2 Start Checking:** -``` -height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] -right_max: [3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1] -``` +We begin checking if left and right subtrees are mirrors. -How we calculate this (from right to left): -- `right_max[11] = height[11] = 1` (no walls to the right) -- `right_max[10] = max(right_max[11], height[10]) = max(1, 2) = 2` -- `right_max[9] = max(right_max[10], height[9]) = max(2, 1) = 2` -- And so on... +**2.3 Trace Walkthrough:** -**Step 4: Calculate trapped water at each position** -For each position `i`, the water trapped is: -``` -water[i] = min(left_max[i], right_max[i]) - height[i] -``` +| left | right | left.val | right.val | Check | Result | +|------|-------|----------|-----------|-------|--------| +| 2 | 2 | 2 | 2 | Equal ✓ | Check children | +| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | +| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | +| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | +| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | -But only if this value is positive (we can't have negative water). +**2.4 Explanation:** -Let's calculate for a few positions: -- Position 0: `min(0, 3) - 0 = 0` (no water trapped) -- Position 1: `min(1, 3) - 1 = 0` (no water trapped) -- Position 2: `min(1, 3) - 0 = 1` (1 unit of water trapped) -- Position 3: `min(2, 3) - 2 = 0` (no water trapped) -- Position 4: `min(2, 3) - 1 = 1` (1 unit of water trapped) -- Position 5: `min(2, 3) - 0 = 2` (2 units of water trapped) +- Root's left (2) and right (2) have same value ✓ +- Left's left (3) and right's right (3) are mirrors ✓ +- Left's right (4) and right's left (4) are mirrors ✓ -**Step 5: Sum up all trapped water** -``` -water = [0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 0] -total = 0 + 0 + 1 + 0 + 1 + 2 + 1 + 0 + 0 + 1 + 0 + 0 = 6 -``` +**2.5 Return Result:** -> **Note:** The key insight is that water can only be trapped up to the height of the lower "dam" on either side. This is why we take the minimum of the left and right maximums. +We return `True` because the tree is symmetric. -**Time Complexity:** O(n) - we make three passes through the array -**Space Complexity:** O(n) - we store two additional arrays of size n +> **Note:** The key insight is that a tree is symmetric if its left and right subtrees are mirrors. Two trees are mirrors if their roots match and the left of one mirrors the right of the other (and vice versa). ### Solution ```python -def trap(height): - """ - Calculate the amount of water that can be trapped between walls. - - Args: - height: List[int] - Array representing wall heights +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def isSymmetric(self, root) -> bool: + def is_mirror(left, right): + if not left and not right: + return True + if not left or not right: + return False + return (left.val == right.val and + is_mirror(left.left, right.right) and + is_mirror(left.right, right.left)) - Returns: - int - Total amount of water trapped - """ - # Handle edge cases - if not height or len(height) < 3: - return 0 - - n = len(height) - - # Step 1: Precompute left maximums - # left_max[i] = highest wall to the left of position i (including i) - left_max = [0] * n - left_max[0] = height[0] - - for i in range(1, n): - left_max[i] = max(left_max[i-1], height[i]) - - # Step 2: Precompute right maximums - # right_max[i] = highest wall to the right of position i (including i) - right_max = [0] * n - right_max[n-1] = height[n-1] - - for i in range(n-2, -1, -1): - right_max[i] = max(right_max[i+1], height[i]) - - # Step 3: Calculate trapped water at each position - res = 0 - for i in range(n): - # Water trapped = min(left_max, right_max) - current_height - # But only if positive (can't have negative water) - water = min(left_max[i], right_max[i]) - height[i] - if water > 0: - res += water - - return res + if not root: + return True + + return is_mirror(root.left, root.right) ``` -## 94. Binary Tree Inorder Traversal [Easy] -https://leetcode.com/problems/binary-tree-inorder-traversal/ +## 104. Maximum Depth of Binary Tree [Easy] +https://leetcode.com/problems/maximum-depth-of-binary-tree/ ### Explanation @@ -602,81 +368,79 @@ https://leetcode.com/problems/binary-tree-inorder-traversal/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the inorder traversal of its nodes' values. +Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be up to $100$. +- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. - **Value Range:** Node values are between $-100$ and $100$. - **Time Complexity:** $O(n)$ - We visit each node exactly once. - **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. +- **Edge Case:** If the tree is empty (root is null), return 0. **1.2 High-level approach:** -The goal is to traverse the tree in inorder (left, root, right) order. +The goal is to find the maximum depth of a binary tree. -We use recursion to implement inorder traversal. We recursively traverse the left subtree, visit the root, then recursively traverse the right subtree. +![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) + +We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (Recursion):** Use recursion to naturally implement inorder traversal. This is the standard and efficient approach. -- **Why it's better:** Recursion naturally follows the tree structure and implements inorder traversal efficiently. An iterative approach using a stack is also possible but more complex. +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. +- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. +- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. **1.4 Decomposition:** -1. Define a recursive function that takes a node. -2. Base case: if node is null, return. -3. Recursively traverse left subtree. -4. Visit current node (add value to result). -5. Recursively traverse right subtree. +1. Base case: if the root is null, return 0. +2. Recursively find the maximum depth of the left subtree. +3. Recursively find the maximum depth of the right subtree. +4. Return 1 (for current node) plus the maximum of the two subtree depths. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,null,2,3]$ +Let's use the example: root = $[3,9,20,null,null,15,7]$ The tree structure: ``` - 1 - \ - 2 - / 3 + / \ + 9 20 + / \ + 15 7 ``` -We initialize: -- `res = []` - -**2.2 Start Traversal:** +**2.2 Start Recursion:** -We begin from the root. +We begin from the root node (value 3). **2.3 Trace Walkthrough:** -| Node | Action | res After | -|------|--------|-----------| -| 1 | Go left (null) | [] | -| 1 | Visit 1 | [1] | -| 1 | Go right (2) | [1] | -| 2 | Go left (3) | [1] | -| 3 | Go left (null) | [1] | -| 3 | Visit 3 | [1,3] | -| 3 | Go right (null) | [1,3] | -| 2 | Visit 2 | [1,3,2] | -| 2 | Go right (null) | [1,3,2] | +| Node | Left Depth | Right Depth | Max Depth | Return Value | +|------|------------|--------------|-----------|--------------| +| 3 | ? | ? | - | Compute... | +| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | ? | ? | - | Compute... | +| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | +| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | +| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | -**2.4 Final Result:** +**2.4 Recursion Flow:** -After traversal: `res = [1,3,2]` +- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ +- Node 9: both children null, return $0 + 1 = 1$ +- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ **2.5 Return Result:** -We return `[1,3,2]`, which is the inorder traversal. +We return 3, which is the maximum depth of the tree. -> **Note:** The key is to follow the inorder order: left subtree first, then root, then right subtree. Recursion naturally implements this by processing the left subtree before the root, and the root before the right subtree. +> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. ### Solution @@ -686,133 +450,136 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right -from typing import List - class Solution: - def inorderTraversal(self, root) -> List[int]: - res = [] + def maxDepth(self, root) -> int: + if not root: + return 0 - def inorder(node): - if not node: - return - inorder(node.left) - res.append(node.val) - inorder(node.right) + # Recursively find max depth of left and right subtrees + left_depth = self.maxDepth(root.left) + right_depth = self.maxDepth(root.right) - inorder(root) - return res + # Return max depth plus 1 for current node + return max(left_depth, right_depth) + 1 ``` -## 98. Validate Binary Search Tree [Medium] -https://leetcode.com/problems/validate-binary-search-tree/ +## 141. Linked List Cycle [Easy] +https://leetcode.com/problems/linked-list-cycle/ ### Explanation -## Explanation +# 141. Linked List Cycle [Easy] -### Strategy (The "Why") +https://leetcode.com/problems/linked-list-cycle -Given the root of a binary tree, we need to determine if it is a valid binary search tree (BST). A BST is valid if for every node, all nodes in its left subtree are less than it, and all nodes in its right subtree are greater than it. +## Description -**1.1 Constraints & Complexity:** +Given `head`, the head of a linked list, determine if the linked list has a cycle in it. -- **Input Size:** The number of nodes can be up to $10^4$. -- **Value Range:** Node values are between $-2^{31}$ and $2^{31} - 1$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** An empty tree is a valid BST. A tree with only one node is a valid BST. +There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is connected to. **Note that `pos` is not passed as a parameter**. -**1.2 High-level approach:** +Return `true` *if there is a cycle in the linked list*. Otherwise, return `false`. -The goal is to validate that a binary tree satisfies the BST property. +**Example 1:** +```text +Input: head = [3,2,0,-4], pos = 1 +Output: true +Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed). +``` -We use recursion with range validation. For each node, we check if its value is within the valid range (min_val, max_val). The range is updated as we traverse: left children must be less than the parent, right children must be greater than the parent. +**Example 2:** +```text +Input: head = [1,2], pos = 0 +Output: true +Explanation: There is a cycle in the linked list, where the tail connects to the 0th node. +``` -**1.3 Brute force vs. optimized strategy:** +**Example 3:** +```text +Input: head = [1], pos = -1 +Output: false +Explanation: There is no cycle in the linked list. +``` -- **Brute Force:** For each node, check if all nodes in its left subtree are less and all nodes in its right subtree are greater. This would be $O(n^2)$ time. -- **Optimized Strategy (Range Validation):** Use recursion with min and max bounds. Each node must be within its allowed range. This takes $O(n)$ time. -- **Why it's better:** The range validation approach reduces time complexity from $O(n^2)$ to $O(n)$ by passing down constraints instead of checking all descendants for each node. +**Constraints:** -**1.4 Decomposition:** +- The number of the nodes in the list is in the range `[0, 10^4]`. +- `-10^5 <= Node.val <= 10^5` +- `pos` is `-1` or a **valid index** in the linked-list. -1. Define a recursive function that takes a node and its allowed range (min_val, max_val). -2. If the node is null, return true (base case). -3. Check if the node's value is within the range (strictly greater than min_val and strictly less than max_val). -4. Recursively validate left subtree with range (min_val, node.val). -5. Recursively validate right subtree with range (node.val, max_val). -6. Return true only if all checks pass. -### Steps (The "How") +**Follow up:** Can you solve it using `O(1)` (i.e. constant) memory? -**2.1 Initialization & Example Setup:** +## Explanation -Let's use the example: root = $[5,1,4,null,null,3,6]$ +### Strategy -The tree structure: -``` - 5 - / \ - 1 4 - / \ - 3 6 -``` +This is a **two-pointer problem** that requires detecting a cycle in a linked list. The key insight is to use Floyd's Cycle-Finding Algorithm (also known as the "tortoise and hare" algorithm), which uses two pointers moving at different speeds. -We initialize: -- Call `validate(root, -∞, +∞)` +**Key observations:** +- If there's a cycle, a fast pointer will eventually catch up to a slow pointer +- If there's no cycle, the fast pointer will reach the end (null) +- The fast pointer moves twice as fast as the slow pointer +- This approach uses O(1) space, which is optimal -**2.2 Start Validation:** +**High-level approach:** +1. **Use two pointers**: Slow pointer (tortoise) and fast pointer (hare) +2. **Move pointers**: Slow moves 1 step, fast moves 2 steps +3. **Check for cycle**: If fast catches slow, there's a cycle +4. **Check for end**: If fast reaches null, there's no cycle -We begin validating from the root. +### Steps -**2.3 Trace Walkthrough:** +Let's break down the solution step by step: -| Node | min_val | max_val | node.val | Check | Result | -|------|---------|---------|----------|-------|--------| -| 5 | -∞ | +∞ | 5 | $-∞ < 5 < +∞$ | ✓ | -| 1 | -∞ | 5 | 1 | $-∞ < 1 < 5$ | ✓ | -| 4 | 5 | +∞ | 4 | $5 < 4 < +∞$ | ✗ | +**Step 1: Handle edge cases** +- If head is null or head.next is null, return false -**2.4 Explanation:** +**Step 2: Initialize pointers** +- `slow = head` (moves 1 step at a time) +- `fast = head.next` (moves 2 steps at a time) -- Root (5): Valid, within range (-∞, +∞) -- Left child (1): Valid, within range (-∞, 5) -- Right child (4): Invalid! It should be greater than 5, but 4 < 5 +**Step 3: Move pointers until they meet or reach end** +While `fast` is not null and `fast.next` is not null: +- Move slow pointer: `slow = slow.next` +- Move fast pointer: `fast = fast.next.next` +- If slow and fast meet, return true (cycle detected) -**2.5 Return Result:** +**Step 4: Return result** +- If you exit the loop, return false (no cycle) -We return `False` because node 4 violates the BST property (it's in the right subtree of 5 but is less than 5). +**Example walkthrough:** +Let's trace through the first example: -> **Note:** The key insight is to pass down the allowed range for each node. A node's value must be strictly within its range, and we update the range for children: left children get (min_val, node.val) and right children get (node.val, max_val). +```text +head = [3,2,0,-4], pos = 1 (cycle from -4 back to 2) + +Initial state: +slow = 3, fast = 2 + +Step 1: slow = 2, fast = 0 +Step 2: slow = 0, fast = 2 +Step 3: slow = -4, fast = 0 +Step 4: slow = 2, fast = 2 (they meet!) + +Result: Return true (cycle detected) +``` + +> **Note:** Floyd's Cycle-Finding Algorithm is optimal because it uses O(1) space and O(n) time. The mathematical proof shows that if there's a cycle, the fast pointer will eventually catch the slow pointer within one cycle length. + +**Time Complexity:** O(n) - in the worst case, you visit each node at most twice +**Space Complexity:** O(1) - you only use two pointers regardless of input size ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right - -class Solution: - def isValidBST(self, root) -> bool: - def validate(node, min_val, max_val): - # Empty tree is valid - if not node: - return True - - # Check if current node value is within valid range - if node.val <= min_val or node.val >= max_val: - return False - - # Recursively validate left and right subtrees - return (validate(node.left, min_val, node.val) and - validate(node.right, node.val, max_val)) - - return validate(root, float('-inf'), float('inf')) +def __init__(self, x): +# self.val = x +# self.next = None ``` -## 101. Symmetric Tree [Easy] -https://leetcode.com/problems/symmetric-tree/ +## 160. Intersection of Two Linked Lists [Easy] +https://leetcode.com/problems/intersection-of-two-linked-lists/ ### Explanation @@ -820,110 +587,93 @@ https://leetcode.com/problems/symmetric-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to check whether it is a mirror of itself (symmetric around its center). - **1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes can be up to $1000$. -- **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. -- **Edge Case:** An empty tree is symmetric. A tree with only one node is symmetric. +- **Constraints:** We have two linked lists with `m` and `n` nodes respectively, where `1 <= m, n <= 3 * 10^4`. Each node value is between `1` and `10^5`. +- **Time Complexity:** O(m + n) - In the worst case, we traverse both lists once before finding the intersection or determining there is none. +- **Space Complexity:** O(1) - We only use two pointer variables, no additional data structures. +- **Edge Case:** When the two lists have no intersection, both pointers will eventually become `None` and the loop will terminate, returning `None`. **1.2 High-level approach:** +The goal is to find the node where two linked lists intersect, or return `None` if they don't intersect. The key insight is that if we traverse both lists simultaneously, switching to the other list when we reach the end, both pointers will eventually meet at the intersection point (if it exists) after traversing the same total distance. -The goal is to determine if a binary tree is symmetric (mirror of itself). - -We use recursion to check if the left and right subtrees are mirrors of each other. Two trees are mirrors if their roots have the same value, and the left subtree of one is a mirror of the right subtree of the other, and vice versa. +![Two linked lists intersecting](https://assets.leetcode.com/uploads/2021/03/05/160_statement.png) **1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** There isn't really a brute force approach - we must check the mirror property. -- **Optimized Strategy (Recursion):** Use recursion to check if left and right subtrees are mirrors. This is the standard and efficient approach. -- **Why it's better:** Recursion naturally checks the mirror property by comparing corresponding nodes in the left and right subtrees. +- **Brute Force:** For each node in list A, check if it exists in list B by traversing list B. This would take O(m * n) time complexity. +- **Optimized Strategy (Two Pointers):** Use two pointers that traverse both lists, switching lists when reaching the end. This ensures both pointers cover the same total distance and will meet at the intersection. Time complexity is O(m + n) with O(1) space. **1.4 Decomposition:** - -1. Define a helper function that checks if two trees are mirrors. -2. Two trees are mirrors if: - - Both are null (base case: true). - - One is null and the other is not (false). - - Both roots have the same value, and: - - Left subtree of first is mirror of right subtree of second. - - Right subtree of first is mirror of left subtree of second. -3. Check if root's left and right subtrees are mirrors. +1. Initialize two pointers, one for each list. +2. Traverse both lists simultaneously, moving each pointer forward. +3. When a pointer reaches the end of its list, switch it to the head of the other list. +4. Continue until both pointers point to the same node (intersection found) or both are `None` (no intersection). ### Steps (The "How") **2.1 Initialization & Example Setup:** +Let's use an example: `headA = [4,1,8,4,5]` and `headB = [5,6,1,8,4,5]`, where the lists intersect at node with value 8. -Let's use the example: root = $[1,2,2,3,4,4,3]$ - -The tree structure: -``` - 1 - / \ - 2 2 - / \ / \ - 3 4 4 3 -``` - -We initialize: -- Call `is_mirror(root.left, root.right)` +Initialize: +- `p1 = headA` (points to node 4) +- `p2 = headB` (points to node 5) **2.2 Start Checking:** - -We begin checking if left and right subtrees are mirrors. +We enter a loop that continues while `p1 != p2`. **2.3 Trace Walkthrough:** -| left | right | left.val | right.val | Check | Result | -|------|-------|----------|-----------|-------|--------| -| 2 | 2 | 2 | 2 | Equal ✓ | Check children | -| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | -| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | -| 4 | 4 | 4 | 4 | Equal ✓ | Both null ✓ | -| 3 | 3 | 3 | 3 | Equal ✓ | Both null ✓ | - -**2.4 Explanation:** +| Step | p1 position | p2 position | p1 value | p2 value | Action | +|------|-------------|--------------|----------|----------|--------| +| 1 | headA[0] | headB[0] | 4 | 5 | Both advance | +| 2 | headA[1] | headB[1] | 1 | 6 | Both advance | +| 3 | headA[2] | headB[2] | 8 | 1 | Both advance | +| 4 | headA[3] | headB[3] | 4 | 8 | Both advance | +| 5 | headA[4] | headB[4] | 5 | 4 | Both advance | +| 6 | None | headB[5] | - | 5 | p1 switches to headB | +| 7 | headB[0] | None | 5 | - | p2 switches to headA | +| 8 | headB[1] | headA[0] | 6 | 4 | Both advance | +| 9 | headB[2] | headA[1] | 1 | 1 | Both advance | +| 10 | headB[3] | headA[2] | 8 | 8 | **Match!** Intersection found | -- Root's left (2) and right (2) have same value ✓ -- Left's left (3) and right's right (3) are mirrors ✓ -- Left's right (4) and right's left (4) are mirrors ✓ +**2.4 Increment and Loop:** +At each iteration: +- If `p1` is not `None`, move it to `p1.next`; otherwise, set it to `headB`. +- If `p2` is not `None`, move it to `p2.next`; otherwise, set it to `headA`. **2.5 Return Result:** +When `p1 == p2`, the loop exits. This happens either: +- When both point to the intersection node (return that node) +- When both are `None` (no intersection, return `None`) -We return `True` because the tree is symmetric. - -> **Note:** The key insight is that a tree is symmetric if its left and right subtrees are mirrors. Two trees are mirrors if their roots match and the left of one mirrors the right of the other (and vice versa). +In our example, both pointers meet at the node with value 8, which is the intersection point. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self, x): +# self.val = x +# self.next = None class Solution: - def isSymmetric(self, root) -> bool: - def is_mirror(left, right): - if not left and not right: - return True - if not left or not right: - return False - return (left.val == right.val and - is_mirror(left.left, right.right) and - is_mirror(left.right, right.left)) + def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> Optional[ListNode]: + # Two pointer approach: traverse both lists + # When one pointer reaches end, switch to other list + # This way both pointers will meet at intersection (if exists) + # or both will be None (if no intersection) - if not root: - return True + p1, p2 = headA, headB - return is_mirror(root.left, root.right) + while p1 != p2: + # If p1 reaches end, switch to headB + p1 = p1.next if p1 else headB + # If p2 reaches end, switch to headA + p2 = p2.next if p2 else headA + + return p1 ``` -## 102. Binary Tree Level Order Traversal [Medium] -https://leetcode.com/problems/binary-tree-level-order-traversal/ +## 206. Reverse Linked List [Easy] +https://leetcode.com/problems/reverse-linked-list/ ### Explanation @@ -931,122 +681,99 @@ https://leetcode.com/problems/binary-tree-level-order-traversal/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the level-order traversal of its nodes' values (i.e., from left to right, level by level). +Given the head of a singly linked list, we need to reverse the list and return the reversed list's head. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $2000$. -- **Value Range:** Node values are between $-1000$ and $1000$. +- **Input Size:** The number of nodes can be between $0$ and $5000$. +- **Value Range:** Node values are between $-5000$ and $5000$. - **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level, which is $O(n)$ in the worst case. -- **Edge Case:** If the tree is empty, return an empty list. +- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. +- **Edge Case:** If the list is empty (head is null), return null. If the list has only one node, return that node. **1.2 High-level approach:** -The goal is to traverse the tree level by level, collecting values at each level. - -![Level Order Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) +The goal is to reverse the links between nodes in a linked list. -We use BFS (breadth-first search) with a queue. We process nodes level by level, adding all nodes at the current level to a list before moving to the next level. +We use an iterative approach with three pointers: `prev` (previous node), `current` (current node), and `next_node` (next node). We traverse the list, reversing each link as we go. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS with Queue):** Use a queue to process nodes level by level. For each level, process all nodes in the queue (which represents the current level), then add their children for the next level. -- **Why it's better:** BFS naturally processes nodes level by level. Using a queue ensures we process all nodes at one level before moving to the next. +- **Brute Force:** Convert the list to an array, reverse the array, then convert back to a linked list. This takes $O(n)$ time and $O(n)$ space. +- **Optimized Strategy (Iterative):** Use pointers to reverse links in-place. This takes $O(n)$ time and $O(1)$ space. +- **Why it's better:** The iterative approach uses $O(1)$ extra space instead of $O(n)$ for an array, while maintaining the same time complexity. **1.4 Decomposition:** -1. If the tree is empty, return an empty list. -2. Initialize a queue with the root node. -3. While the queue is not empty: - - Get the number of nodes at the current level (queue size). - - Process all nodes at this level, adding their values to a level list. - - Add all children of these nodes to the queue for the next level. - - Add the level list to the result. -4. Return the result. +1. Initialize `prev = None` and `current = head`. +2. While `current` is not null: + - Store the next node. + - Reverse the link: `current.next = prev`. + - Move pointers forward: `prev = current`, `current = next_node`. +3. Return `prev` (which is the new head). ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3,9,20,null,null,15,7]$ - -The tree structure: -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` +Let's use the example: $head = [1,2,3,4,5]$ We initialize: -- `queue = deque([3])` -- `res = []` +- `prev = None` +- `current = 1` -**2.2 Start BFS:** +**2.2 Start Reversing:** -We begin processing level by level. +We begin reversing links. **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process Nodes | Level List | Queue After | -|-------|--------------|------------|---------------|------------|-------------| -| 0 | [3] | 1 | 3 | [3] | [9, 20] | -| 1 | [9, 20] | 2 | 9, 20 | [9, 20] | [15, 7] | -| 2 | [15, 7] | 2 | 15, 7 | [15, 7] | [] | +| Step | current | next_node | current.next | prev After | current After | +|------|---------|-----------|--------------|------------|---------------| +| 1 | 1 | 2 | None | 1 | 2 | +| 2 | 2 | 3 | 1 | 2 | 3 | +| 3 | 3 | 4 | 2 | 3 | 4 | +| 4 | 4 | 5 | 3 | 4 | 5 | +| 5 | 5 | None | 4 | 5 | None | -**2.4 Final Result:** +**2.4 Final State:** -After processing all levels: -- `res = [[3], [9, 20], [15, 7]]` +After reversing: +- Original: $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5 \rightarrow null$ +- Reversed: $5 \rightarrow 4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow null$ **2.5 Return Result:** -We return `[[3], [9, 20], [15, 7]]`, which represents the level-order traversal. +We return the node with value 5, which is the new head of the reversed list. -> **Note:** The key is to process all nodes at the current level before moving to the next. We do this by getting the queue size at the start of each iteration, which represents the number of nodes at the current level. +> **Note:** The key insight is to maintain three pointers: previous, current, and next. We reverse the link from current to previous, then move all pointers forward. The previous pointer becomes the new head at the end. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right - -from typing import List -from collections import deque +# self.next = next class Solution: - def levelOrder(self, root) -> List[List[int]]: - if not root: - return [] - - res = [] - queue = deque([root]) + def reverseList(self, head): + prev = None + current = head - while queue: - level_size = len(queue) - level = [] - - for _ in range(level_size): - node = queue.popleft() - level.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) - - res.append(level) + while current: + # Store next node + next_node = current.next + # Reverse the link + current.next = prev + # Move pointers forward + prev = current + current = next_node - return res + return prev ``` -## 104. Maximum Depth of Binary Tree [Easy] -https://leetcode.com/problems/maximum-depth-of-binary-tree/ +## 234. Palindrome Linked List [Easy] +https://leetcode.com/problems/palindrome-linked-list/ ### Explanation @@ -1054,210 +781,223 @@ https://leetcode.com/problems/maximum-depth-of-binary-tree/ ### Strategy (The "Why") -Given the root of a binary tree, we need to find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. +The problem asks us to determine if a singly linked list is a palindrome (reads the same forwards and backwards). **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ in the tree can be between $0$ and $10^4$. -- **Value Range:** Node values are between $-100$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. -- **Edge Case:** If the tree is empty (root is null), return 0. +- **Input Constraints:** The list has $1 \leq n \leq 10^5$ nodes, with values in $[0, 9]$. +- **Time Complexity:** $O(n)$ - We traverse the list once to collect values, then compare them. +- **Space Complexity:** $O(n)$ - We store all node values in an array for comparison. +- **Edge Case:** A single-node list is always a palindrome. **1.2 High-level approach:** -The goal is to find the maximum depth of a binary tree. - -![Maximum Depth](https://assets.leetcode.com/uploads/2020/11/26/tmp-tree.jpg) +The goal is to check if the linked list values form a palindrome. We convert the list to an array, then use two pointers to compare values from both ends. -We use recursion: the maximum depth of a tree is 1 plus the maximum of the depths of its left and right subtrees. +![Palindrome Linked List](https://assets.leetcode.com/uploads/2021/03/03/pal1linked-list.jpg) **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree to find the depth. -- **Optimized Strategy (Recursion):** Recursively compute the depth of left and right subtrees, then return 1 plus the maximum. This is the natural and efficient approach. -- **Why it's better:** Recursion naturally follows the tree structure. Each node's depth depends only on its children's depths, creating optimal substructure. +- **Brute Force:** Reverse the entire list, then compare with original. This requires $O(n)$ time and $O(n)$ space for the reversed list. +- **Optimized (Array Conversion):** Convert list to array, then use two pointers. This takes $O(n)$ time and $O(n)$ space. +- **Emphasize the optimization:** While both approaches have similar complexity, the array approach is simpler and more intuitive. For $O(1)$ space, we could reverse half the list, but that's more complex. **1.4 Decomposition:** -1. Base case: if the root is null, return 0. -2. Recursively find the maximum depth of the left subtree. -3. Recursively find the maximum depth of the right subtree. -4. Return 1 (for current node) plus the maximum of the two subtree depths. +1. **Convert to Array:** Traverse the list and store all values in an array. +2. **Two-Pointer Comparison:** Use left and right pointers to compare values from both ends. +3. **Check Match:** If any pair doesn't match, return `False`. If all pairs match, return `True`. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3,9,20,null,null,15,7]$ +Let's trace through an example: `head = [1,2,2,1]`. -The tree structure: -``` - 3 - / \ - 9 20 - / \ - 15 7 -``` +After conversion: `values = [1, 2, 2, 1]` -**2.2 Start Recursion:** +**2.2 Start Checking:** -We begin from the root node (value 3). +Initialize `left = 0` and `right = len(values) - 1 = 3`. **2.3 Trace Walkthrough:** -| Node | Left Depth | Right Depth | Max Depth | Return Value | -|------|------------|--------------|-----------|--------------| -| 3 | ? | ? | - | Compute... | -| 9 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | ? | ? | - | Compute... | -| 15 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 7 | 0 (null) | 0 (null) | 0 | $0 + 1 = 1$ | -| 20 | 1 | 1 | 1 | $1 + 1 = 2$ | -| 3 | 1 | 2 | 2 | $2 + 1 = 3$ | +| Step | left | right | values[left] | values[right] | Match? | Action | +|------|------|-------|--------------|----------------|--------|--------| +| 1 | 0 | 3 | 1 | 1 | Yes | Continue | +| 2 | 1 | 2 | 2 | 2 | Yes | Continue | +| 3 | 2 | 1 | - | - | - | Stop (left >= right) | -**2.4 Recursion Flow:** +**2.4 Complete Comparison:** -- Root (3): left depth = 1, right depth = 2, return $max(1, 2) + 1 = 3$ -- Node 9: both children null, return $0 + 1 = 1$ -- Node 20: left depth = 1, right depth = 1, return $max(1, 1) + 1 = 2$ +All pairs matched: (1,1) and (2,2). **2.5 Return Result:** -We return 3, which is the maximum depth of the tree. +Since all comparisons passed, the function returns `True`. -> **Note:** The recursive approach naturally handles the tree structure. The depth of each node is computed from its children's depths, working from the leaves upward to the root. +> **Note:** The two-pointer technique efficiently checks palindromes by comparing symmetric positions without needing to reverse the list. ### Solution ```python -def __init__(self, val=0, left=None, right=None): +def __init__(self, val=0, next=None): # self.val = val -# self.left = left -# self.right = right - +# self.next = next class Solution: - def maxDepth(self, root) -> int: - if not root: - return 0 + def isPalindrome(self, head: Optional[ListNode]) -> bool: + # Convert linked list to array + values = [] + current = head + while current: + values.append(current.val) + current = current.next - # Recursively find max depth of left and right subtrees - left_depth = self.maxDepth(root.left) - right_depth = self.maxDepth(root.right) + # Check if array is palindrome + left, right = 0, len(values) - 1 + while left < right: + if values[left] != values[right]: + return False + left += 1 + right -= 1 - # Return max depth plus 1 for current node - return max(left_depth, right_depth) + 1 + return True ``` -## 105. Construct Binary Tree from Preorder and Inorder Traversal [Medium] -https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ +## 242. Valid Anagram [Easy] +https://leetcode.com/problems/valid-anagram/ ### Explanation -## Explanation +Given two strings `s` and `t`, return `true` if `t` is an [anagram](https://en.wikipedia.org/wiki/Anagram) of `s`, and `false` otherwise. -### Strategy (The "Why") +**Examples** -The problem asks us to construct a binary tree from its preorder and inorder traversal arrays. +```tex +Example 1: +Input: s = "anagram", t = "nagaram" +Output: true -**1.1 Constraints & Complexity:** +Example 2: +Input: s = "rat", t = "car" +Output: false +``` -- **Input Constraints:** $1 \leq n \leq 3000$, values in $[-3000, 3000]$, all values are unique. -- **Time Complexity:** $O(n)$ - We visit each node once. The hash map lookup is $O(1)$. -- **Space Complexity:** $O(n)$ - Hash map for inorder indices takes $O(n)$, recursion stack takes $O(h)$ where $h$ is tree height. -- **Edge Case:** Empty arrays return `None`. +**Constraints** +```tex +- 1 <= s.length, t.length <= 5 * 10^4 +- s and t consist of lowercase English letters +``` -**1.2 High-level approach:** +**Follow up:** What if the inputs contain Unicode characters? How would you adapt your solution to such a case? -The goal is to reconstruct the tree using the property that in preorder, the root comes first, and in inorder, the root separates left and right subtrees. +## Explanation -![Tree Construction](https://assets.leetcode.com/uploads/2021/02/19/tree.jpg) +### Strategy +Let's restate the problem: You're given two strings, and you need to determine if one is an anagram of the other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. -**1.3 Brute force vs. optimized strategy:** +This is a **character counting problem** that can be solved using hash tables to track the frequency of each character in both strings. -- **Brute Force:** For each root, search for it in inorder array linearly. This takes $O(n^2)$ time. -- **Optimized (Hash Map):** Use a hash map to store inorder indices for $O(1)$ lookup. This takes $O(n)$ time. -- **Emphasize the optimization:** The hash map reduces the time complexity from $O(n^2)$ to $O(n)$ by eliminating linear searches. +**What is given?** Two strings `s` and `t` of potentially different lengths. -**1.4 Decomposition:** +**What is being asked?** Determine if `t` is an anagram of `s`. -1. **Build Hash Map:** Create a map from values to their inorder indices. -2. **Recursive Build:** Use preorder to get root, use inorder to split left/right subtrees. -3. **Calculate Ranges:** Determine preorder and inorder ranges for left and right subtrees. -4. **Return Root:** Build and return the root node. +**Constraints:** The strings can be up to 50,000 characters long and contain only lowercase English letters. -### Steps (The "How") +**Edge cases:** +- Strings of different lengths +- Empty strings +- Strings with repeated characters +- Strings with all identical characters -**2.1 Initialization & Example Setup:** +**High-level approach:** +The solution involves counting the frequency of each character in both strings and comparing them. If the character counts match exactly, the strings are anagrams. -Let's trace through an example: `preorder = [3,9,20,15,7]`, `inorder = [9,3,15,20,7]`. +**Decomposition:** +1. **Check length equality**: If strings have different lengths, they can't be anagrams +2. **Count characters in first string**: Use a hash table to track character frequencies +3. **Decrement counts for second string**: For each character in the second string, decrement its count +4. **Verify all counts are zero**: If any count is not zero, the strings are not anagrams -Hash map: `{9:0, 3:1, 15:2, 20:3, 7:4}` +**Brute force vs. optimized strategy:** +- **Brute force**: Try all possible permutations of one string. This takes O(n!) time. +- **Optimized**: Use character counting with hash tables. This takes O(n) time. -**2.2 Start Building:** +### Steps +Let's walk through the solution step by step using the first example: `s = "anagram"`, `t = "nagaram"` -Root is `preorder[0] = 3`. Find its position in inorder: `inorder[1] = 3`. +**Step 1: Check string lengths** +- `s.length = 7`, `t.length = 7` +- Lengths match ✓ -**2.3 Trace Walkthrough:** +**Step 2: Initialize character count dictionary** +- `char_count = {}` -| Root | Preorder Range | Inorder Range | Left Size | Left Subtree | Right Subtree | -|------|----------------|---------------|-----------|--------------|---------------| -| 3 | [0:4] | [0:4] | 1 | pre[1:2], in[0:0] | pre[2:5], in[2:4] | -| 9 | [1:2] | [0:0] | 0 | None | None | -| 20 | [2:5] | [2:4] | 1 | pre[3:4], in[2:2] | pre[4:5], in[3:4] | -| 15 | [3:4] | [2:2] | 0 | None | None | -| 7 | [4:5] | [3:4] | 0 | None | None | +**Step 3: Count characters in first string (s)** +- `s = "anagram"` +- `char_count['a'] = 3` (appears 3 times) +- `char_count['n'] = 1` (appears 1 time) +- `char_count['g'] = 1` (appears 1 time) +- `char_count['r'] = 1` (appears 1 time) +- `char_count['m'] = 1` (appears 1 time) -**2.4 Complete Construction:** +**Step 4: Decrement counts for second string (t)** +- `t = "nagaram"` +- `t[0] = 'n'`: `char_count['n'] = 1 - 1 = 0` +- `t[1] = 'a'`: `char_count['a'] = 3 - 1 = 2` +- `t[2] = 'g'`: `char_count['g'] = 1 - 1 = 0` +- `t[3] = 'a'`: `char_count['a'] = 2 - 1 = 1` +- `t[4] = 'r'`: `char_count['r'] = 1 - 1 = 0` +- `t[5] = 'a'`: `char_count['a'] = 1 - 1 = 0` +- `t[6] = 'm'`: `char_count['m'] = 1 - 1 = 0` -Tree structure: `3` (root) with left child `9` and right child `20`. `20` has left child `15` and right child `7`. +**Step 5: Verify all counts are zero** +- All character counts are now 0 +- The strings are anagrams: `true` -**2.5 Return Result:** +**Why this works:** +By counting characters in the first string and then decrementing for the second string, we ensure that: +1. Both strings contain the same characters +2. Each character appears the same number of times in both strings +3. The final count of 0 for all characters confirms the anagram property -The function returns the root node of the constructed tree. +> **Note:** The key insight is using character frequency counting to verify that both strings contain exactly the same characters with the same frequencies. This is much more efficient than trying to find permutations. -> **Note:** The key insight is that preorder gives us the root, and inorder tells us how many nodes are in the left subtree, allowing us to split the preorder array correctly. +**Time Complexity:** O(n) - we visit each character once in each string +**Space Complexity:** O(k) - where k is the number of unique characters (bounded by the character set size) ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def buildTree(self, preorder: List[int], inorder: List[int]) -> Optional[TreeNode]: - if not preorder or not inorder: - return None - - # Create a map for O(1) lookup of inorder indices - inorder_map = {val: idx for idx, val in enumerate(inorder)} +def isAnagram(s, t): + if len(s) != len(t): + return False + + char_count = {} + + for char in s: + char_count[char] = char_count.get(char, 0) + 1 + + for char in t: + if char not in char_count: + return False - def build(pre_start, pre_end, in_start, in_end): - if pre_start > pre_end: - return None - - # Root is the first element in preorder - root_val = preorder[pre_start] - root = TreeNode(root_val) - - # Find root position in inorder - root_idx = inorder_map[root_val] - - # Calculate sizes of left and right subtrees - left_size = root_idx - in_start - - # Recursively build left and right subtrees - root.left = build(pre_start + 1, pre_start + left_size, in_start, root_idx - 1) - root.right = build(pre_start + left_size + 1, pre_end, root_idx + 1, in_end) - - return root + char_count[char] -= 1 - return build(0, len(preorder) - 1, 0, len(inorder) - 1) + # If count becomes negative, strings are not anagrams + if char_count[char] < 0: + return False + + # Check if all counts are zero + for count in char_count.values(): + if count != 0: + return False + + return True ``` -## 114. Flatten Binary Tree to Linked List [Medium] -https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ +## 543. Diameter of Binary Tree [Easy] +https://leetcode.com/problems/diameter-of-binary-tree/ ### Explanation @@ -1265,82 +1005,52 @@ https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ ### Strategy (The "Why") -**1.1 Constraints & Complexity** - -* **Input Size:** The tree has $0 \leq n \leq 2000$ nodes, with values in $[-100, 100]$. -* **Time Complexity:** $O(n)$ - We visit each node exactly once during the flattening process. -* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -* **Edge Case:** An empty tree requires no modification. A single-node tree remains unchanged. - -**1.2 High-level approach** - -The goal is to flatten a binary tree into a linked list in pre-order traversal order. We recursively flatten subtrees, then rearrange pointers to form a linear structure. - -![Tree flattening visualization showing how tree nodes are rearranged into a linked list] +**1.1 Constraints & Complexity:** +- **Constraints:** Tree has between 1 and 10^4 nodes, and node values are between -100 and 100. +- **Time Complexity:** O(n) - We visit each node exactly once during DFS, where n is the number of nodes. +- **Space Complexity:** O(h) - The recursion stack depth is at most the height h of the tree. In the worst case (skewed tree), h = n, giving O(n) space. +- **Edge Case:** If the tree has only one node, the diameter is 0 (no edges). -**1.3 Brute force vs. optimized strategy** +**1.2 High-level approach:** +The goal is to find the diameter (longest path between any two nodes) of a binary tree. The diameter may or may not pass through the root. We use DFS to calculate the depth of each subtree and track the maximum diameter found so far. -* **Brute Force:** Store pre-order traversal in a list, then rebuild the tree as a linked list. This uses $O(n)$ extra space. -* **Optimized (In-Place):** Flatten subtrees recursively, then rearrange pointers in-place. This uses $O(h)$ space for recursion stack. +![Diameter of Binary Tree](https://assets.leetcode.com/uploads/2021/03/06/diamtree.jpg) -**1.4 Decomposition** +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** For each node, find the longest path passing through it by calculating depths of left and right subtrees. This still requires visiting each node once, so it's O(n) but with redundant calculations. +- **Optimized Strategy (DFS with Global Tracking):** Perform a single DFS pass, calculating subtree depths and updating the maximum diameter as we go. This takes O(n) time with a single traversal. +- **Emphasize the optimization:** By tracking the maximum diameter during a single DFS pass, we avoid multiple traversals and redundant calculations. -1. **Flatten Subtrees:** Recursively flatten left and right subtrees. -2. **Save Right:** Store the right subtree before modifying pointers. -3. **Move Left to Right:** Set `root.right = root.left` and `root.left = None`. -4. **Attach Saved Right:** Find the end of the flattened left subtree and attach the saved right subtree. +**1.4 Decomposition:** +1. Perform DFS traversal of the tree. +2. For each node, calculate the depth of its left and right subtrees. +3. The diameter passing through this node is left_depth + right_depth. +4. Update the global maximum diameter if this is larger. +5. Return the depth of the current subtree (1 + max(left_depth, right_depth)). ### Steps (The "How") -**2.1 Initialization & Example Setup** - -Let's use the example $root = [1,2,5,3,4,null,6]$. - -We start at the root node with value 1. - -**2.2 Start Processing** - -We call `flatten(root)`. - -**2.3 Trace Walkthrough** - -The flattening process happens bottom-up: - -**Step 1: Flatten leaf nodes** -- Node 3: Already flat (no children) -- Node 4: Already flat (no children) -- Node 6: Already flat (no children) - -**Step 2: Flatten node 2** -- Left subtree [3,4] is already flat -- Right subtree is None -- Move left to right: `2.right = 2.left = [3,4]`, `2.left = None` - -**Step 3: Flatten node 5** -- Left subtree is None -- Right subtree [6] is already flat -- No change needed +**2.1 Initialization & Example Setup:** +Let's use an example: `root = [1,2,3,4,5]` -**Step 4: Flatten root 1** -- Left subtree [2,3,4] is flattened -- Right subtree [5,6] is flattened -- Save right: `right = [5,6]` -- Move left to right: `1.right = [2,3,4]`, `1.left = None` -- Find end of [2,3,4] (node 4) and attach: `4.right = [5,6]` +Initialize: +- `res = 0` (global maximum diameter) -**2.4 Recursive Processing** +**2.2 Start Processing:** +We perform DFS starting from the root. -For each node: -1. If `not root`, return (base case) -2. Recursively flatten `root.left` -3. Recursively flatten `root.right` -4. Save `right = root.right` -5. Set `root.right = root.left` and `root.left = None` -6. Traverse to end of new right subtree and set `curr.right = right` +**2.3 Trace Walkthrough:** -**2.5 Return Result** +| Node | Left Depth | Right Depth | Diameter Through Node | Max Diameter | Return Depth | +|------|------------|-------------|----------------------|--------------|--------------| +| 4 (leaf) | 0 | 0 | 0 | 0 | 1 | +| 5 (leaf) | 0 | 0 | 0 | 0 | 1 | +| 2 | 1 | 1 | 2 | 2 | 2 | +| 3 (leaf) | 0 | 0 | 0 | 2 | 1 | +| 1 (root) | 2 | 1 | 3 | 3 | 3 | -After flattening, the tree becomes a linked list: `[1,null,2,null,3,null,4,null,5,null,6]`, which matches the pre-order traversal. +**2.4 Return Result:** +The maximum diameter found is 3, which is the path [4,2,1,3] or [5,2,1,3]. ### Solution @@ -1350,33 +1060,29 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right class Solution: - def flatten(self, root: Optional[TreeNode]) -> None: - """ - Do not return anything, modify root in-place instead. - """ - if not root: - return - - # Flatten left and right subtrees - self.flatten(root.left) - self.flatten(root.right) - - # Save right subtree - right = root.right + def diameterOfBinaryTree(self, root: Optional[TreeNode]) -> int: + res = 0 - # Move left subtree to right - root.right = root.left - root.left = None + def dfs(node): + nonlocal res + if not node: + return 0 + + left_depth = dfs(node.left) + right_depth = dfs(node.right) + + # Diameter passing through this node + res = max(res, left_depth + right_depth) + + # Return depth of this subtree + return 1 + max(left_depth, right_depth) - # Find the end of the new right subtree and attach saved right - curr = root - while curr.right: - curr = curr.right - curr.right = right + dfs(root) + return res ``` -## 124. Binary Tree Maximum Path Sum [Hard] -https://leetcode.com/problems/binary-tree-maximum-path-sum/ +## 617. Merge Two Binary Trees [Easy] +https://leetcode.com/problems/merge-two-binary-trees/ ### Explanation @@ -1384,69 +1090,75 @@ https://leetcode.com/problems/binary-tree-maximum-path-sum/ ### Strategy (The "Why") -**1.1 Constraints & Complexity** +**1.1 Constraints & Complexity:** -* **Input Size:** The tree has $1 \leq n \leq 3 \times 10^4$ nodes, with values in $[-1000, 1000]$. -* **Time Complexity:** $O(n)$ - We visit each node exactly once during DFS traversal. -* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -* **Edge Case:** A single-node tree returns the node's value. All negative values require careful handling (we use `max(0, ...)` to avoid negative contributions). +- **Input Size:** The number of nodes in both trees is in the range `[0, 2000]`. +- **Value Range:** `-10^4 <= Node.val <= 10^4`. +- **Time Complexity:** O(min(m, n)) where m and n are the number of nodes in the two trees. We visit each node at most once. +- **Space Complexity:** O(min(m, n)) for the recursion stack in the worst case (skewed tree). +- **Edge Case:** If one tree is null, return the other tree. If both are null, return null. -**1.2 High-level approach** +**1.2 High-level approach:** -The goal is to find the maximum path sum in a binary tree, where a path can start and end at any nodes (not necessarily root or leaf). We use DFS to calculate the maximum path sum that can be extended upward from each node, while tracking the global maximum. +The goal is to merge two binary trees by summing overlapping nodes and using non-null nodes when one tree has a node and the other doesn't. We use recursion to traverse both trees simultaneously, creating new nodes for the merged tree. -![Maximum path sum visualization showing paths that can go through any node] +![Visualization showing how two binary trees are merged node by node, with overlapping nodes summed and non-overlapping nodes preserved] -**1.3 Brute force vs. optimized strategy** +**1.3 Brute force vs. optimized strategy:** -* **Brute Force:** Try all possible paths in the tree. This is exponential in complexity. -* **Optimized (DFS with Global Tracking):** For each node, calculate the maximum path sum that can be extended upward (for parent) and the maximum path sum through the node (for global maximum). This achieves $O(n)$ time. +- **Brute Force:** There isn't really a brute force approach - we must traverse both trees to merge them. +- **Optimized Strategy:** Use recursive depth-first search to traverse both trees simultaneously, creating merged nodes as we go. +- **Why it's better:** Recursion naturally handles the tree structure and allows us to process each node exactly once. -**1.4 Decomposition** +**1.4 Decomposition:** -1. **DFS Traversal:** Recursively visit each node. -2. **Calculate Contributions:** For each node, get maximum contributions from left and right subtrees (non-negative only). -3. **Update Global Maximum:** Calculate path sum through current node and update global maximum. -4. **Return Upward Contribution:** Return the maximum path sum that can be extended to parent. +1. If both nodes are null, return null. +2. If one node is null, return the other node (no merging needed). +3. If both nodes exist, create a new node with the sum of their values. +4. Recursively merge the left subtrees. +5. Recursively merge the right subtrees. +6. Return the merged node. ### Steps (The "How") -**2.1 Initialization & Example Setup** - -Let's use the example $root = [-10,9,20,null,null,15,7]$. - -We initialize: -* `res = -inf` (global maximum path sum) -* Start DFS from root node (-10) +**2.1 Initialization & Example Setup:** -**2.2 Start Processing** +Let's use the example: +- `root1 = [1, 3, 2, 5]` (tree structure: 1 has left=3, right=2; 3 has left=5) +- `root2 = [2, 1, 3, null, 4, null, 7]` (tree structure: 2 has left=1, right=3; 1 has right=4; 3 has right=7) -We call `dfs(root)`. +**2.2 Start Checking:** -**2.3 Trace Walkthrough** +We start from the root nodes of both trees. -| Node | left_sum | right_sum | Path Through Node | Return Value | res (after) | -|------|----------|-----------|-------------------|--------------|-------------| -| -10 | max(0, dfs(9)) | max(0, dfs(20)) | -10 + 0 + 0 = -10 | -10 + max(0,0) = -10 | -10 | -| 9 | 0 | 0 | 9 + 0 + 0 = 9 | 9 + 0 = 9 | 9 | -| 20 | max(0, dfs(15)) | max(0, dfs(7)) | 20 + 15 + 7 = 42 | 20 + max(15,7) = 35 | 42 | -| 15 | 0 | 0 | 15 + 0 + 0 = 15 | 15 + 0 = 15 | 42 | -| 7 | 0 | 0 | 7 + 0 + 0 = 7 | 7 + 0 = 7 | 42 | +**2.3 Trace Walkthrough:** -**2.4 Recursive Processing** +| Step | root1 node | root2 node | Action | Merged value | Left child | Right child | +|------|------------|------------|--------|--------------|------------|-------------| +| 1 | 1 | 2 | Both exist | 1 + 2 = 3 | Merge(3, 1) | Merge(2, 3) | +| 2 | 3 | 1 | Both exist | 3 + 1 = 4 | Merge(5, null) | Merge(null, 4) | +| 3 | 5 | null | root2 is null | 5 | null | null | +| 4 | null | 4 | root1 is null | 4 | null | null | +| 5 | 2 | 3 | Both exist | 2 + 3 = 5 | Merge(null, null) | Merge(null, 7) | +| 6 | null | null | Both null | null | - | - | +| 7 | null | 7 | root1 is null | 7 | null | null | + +The merged tree structure: +- Root: 3 (1 + 2) + - Left: 4 (3 + 1) + - Left: 5 (5 + null) + - Right: 4 (null + 4) + - Right: 5 (2 + 3) + - Left: null + - Right: 7 (null + 7) -For each node: -1. If `not node`, return 0 (base case) -2. Recursively get `left_sum = max(0, dfs(node.left))` (non-negative only) -3. Recursively get `right_sum = max(0, dfs(node.right))` (non-negative only) -4. Update global: `res = max(res, node.val + left_sum + right_sum)` -5. Return: `node.val + max(left_sum, right_sum)` (for parent) +**2.4 Increment and Loop:** -**2.5 Return Result** +Recursion handles the traversal automatically. -After processing all nodes, `res = 42`, which is the maximum path sum from the path $15 \to 20 \to 7$. +**2.5 Return Result:** -> **Note:** We use `max(0, ...)` to ensure we only consider positive contributions from subtrees. If a subtree contributes negatively, we ignore it (treat as 0). +Return the merged tree root: `[3, 4, 5, 5, 4, null, 7]`. ### Solution @@ -1456,282 +1168,876 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right class Solution: - def maxPathSum(self, root: Optional[TreeNode]) -> int: - res = float('-inf') + def mergeTrees(self, root1: Optional[TreeNode], root2: Optional[TreeNode]) -> Optional[TreeNode]: + if not root1 and not root2: + return None - def dfs(node): - nonlocal res - if not node: - return 0 - - # Get max path sum from left and right subtrees - left_sum = max(0, dfs(node.left)) - right_sum = max(0, dfs(node.right)) - - # Update global maximum (path through current node) - res = max(res, node.val + left_sum + right_sum) - - # Return max path sum that can be extended upward - return node.val + max(left_sum, right_sum) + if not root1: + return root2 - dfs(root) - return res + if not root2: + return root1 + + # Merge values + merged = TreeNode(root1.val + root2.val) + + # Recursively merge left and right subtrees + merged.left = self.mergeTrees(root1.left, root2.left) + merged.right = self.mergeTrees(root1.right, root2.right) + + return merged ``` -## 128. Longest Consecutive Sequence [Medium] -https://leetcode.com/problems/longest-consecutive-sequence/ +## 876. Middle of the Linked List [Easy] +https://leetcode.com/problems/middle-of-the-linked-list/ ### Explanation -## 128. Longest Consecutive Sequence [Medium] +## Explanation -https://leetcode.com/problems/longest-consecutive-sequence +### Strategy (The "Why") -## Description -Given an unsorted array of integers `nums`, return *the length of the longest consecutive elements sequence.* +Given the head of a singly linked list, we need to return the middle node of the linked list. If there are two middle nodes, return the second one. -You must write an algorithm that runs in `O(n)` time. +**1.1 Constraints & Complexity:** -**Examples** +- **Input Size:** The number of nodes can be between $1$ and $100$. +- **Value Range:** Node values are between $1$ and $100$. +- **Time Complexity:** $O(n)$ - We traverse the list once with two pointers. +- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. +- **Edge Case:** If the list has only one node, return that node. If the list has two nodes, return the second one. -```tex -Example 1: -Input: nums = [100,4,200,1,3,2] -Output: 4 -Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. +**1.2 High-level approach:** -Example 2: -Input: nums = [0,3,7,2,5,8,4,6,0,1] -Output: 9 +The goal is to find the middle node of a linked list. -Example 3: -Input: nums = [1,0,1,2] -Output: 3 -``` +We use the "tortoise and hare" approach: one pointer moves one step at a time (slow), and another moves two steps at a time (fast). When the fast pointer reaches the end, the slow pointer is at the middle. -**Constraints** -```tex -- 0 <= nums.length <= 10^5 -- -10^9 <= nums[i] <= 10^9 -``` +**1.3 Brute force vs. optimized strategy:** -## Explanation +- **Brute Force:** First pass to count nodes, second pass to find the middle node. This takes $O(n)$ time but requires two passes. +- **Optimized Strategy (Two Pointers):** Use two pointers moving at different speeds. This takes $O(n)$ time in a single pass. +- **Why it's better:** The two-pointer approach finds the middle in one pass instead of two, making it more efficient and elegant. -### Strategy -Let's restate the problem: You're given an unsorted array of integers, and you need to find the length of the longest sequence of consecutive integers. The challenge is to do this in O(n) time, which means we can't sort the array (as sorting takes O(n log n) time). +**1.4 Decomposition:** -This is a **hash table problem** that requires finding sequences of consecutive numbers efficiently by using the properties of consecutive sequences. - -**What is given?** An unsorted array of integers that can be very large (up to 100,000 elements). - -**What is being asked?** Find the length of the longest sequence of consecutive integers. +1. Initialize two pointers (slow and fast) at the head. +2. Move slow one step and fast two steps at a time. +3. When fast reaches the end (null or last node), slow is at the middle. +4. Return the slow pointer. -**Constraints:** The array can be up to 100,000 elements long, with values ranging from -10⁹ to 10⁹. +### Steps (The "How") -**Edge cases:** -- Empty array -- Array with single element -- Array with all identical elements -- Array with no consecutive sequences +**2.1 Initialization & Example Setup:** -**High-level approach:** -The solution involves using a hash set to quickly check if numbers exist, then for each number, expanding in both directions to find the complete consecutive sequence. +Let's use the example: $head = [1,2,3,4,5]$ -**Decomposition:** -1. **Convert array to hash set**: For O(1) lookup time -2. **Find sequence starting points**: Look for numbers that are the start of a consecutive sequence -3. **Expand sequences**: For each starting point, expand in both directions to find the complete sequence -4. **Track maximum length**: Keep track of the longest sequence found +We initialize: +- `slow = 1` +- `fast = 1` -**Brute force vs. optimized strategy:** -- **Brute force**: Sort the array and find consecutive sequences. This takes O(n log n) time. -- **Optimized**: Use hash set and expand sequences from starting points. This takes O(n) time. +**2.2 Start Processing:** -### Steps -Let's walk through the solution step by step using the first example: `nums = [100,4,200,1,3,2]` +We begin moving the pointers. -**Step 1: Convert array to hash set** -- `nums = [100,4,200,1,3,2]` -- `num_set = {100, 4, 200, 1, 3, 2}` +**2.3 Trace Walkthrough:** -**Step 2: Find sequence starting points** -- For each number, check if it's the start of a consecutive sequence -- A number is a starting point if `num - 1` is NOT in the set -- Starting points: `[100, 200, 1]` (because 99, 199, and 0 are not in the set) +| Step | slow position | fast position | Action | +|------|---------------|---------------|--------| +| 0 | 1 | 1 | Start | +| 1 | 2 | 3 | Move slow 1, fast 2 | +| 2 | 3 | 5 | Move slow 1, fast 2 | +| 3 | 3 | null | fast.next is null, stop | -**Step 3: Expand sequences from starting points** -- **Starting point 100**: - - Check if 101 exists: No - - Sequence length: 1 -- **Starting point 200**: - - Check if 201 exists: No - - Sequence length: 1 -- **Starting point 1**: - - Check if 2 exists: Yes - - Check if 3 exists: Yes - - Check if 4 exists: Yes - - Check if 5 exists: No - - Sequence: [1, 2, 3, 4] - - Sequence length: 4 +**2.4 Explanation:** -**Step 4: Track maximum length** -- Maximum sequence length found: 4 -- Result: 4 +- When fast reaches the end (node 5, where fast.next is null), slow is at node 3, which is the middle node. -**Why this works:** -By identifying starting points (numbers that don't have a predecessor in the set), we ensure that we only expand each sequence once. This gives us O(n) time complexity because: -1. We visit each number at most twice (once when checking if it's a starting point, once when expanding sequences) -2. Each number is part of at most one sequence -3. The total work is bounded by O(n) +**2.5 Return Result:** -> **Note:** The key insight is identifying starting points of consecutive sequences and expanding from there. This avoids redundant work and ensures O(n) time complexity. +We return the node with value 3, which is the middle node. -**Time Complexity:** O(n) - we visit each number at most twice -**Space Complexity:** O(n) - we need to store the hash set +> **Note:** The key insight is that when the fast pointer moves twice as fast, it covers twice the distance. When it reaches the end, the slow pointer has covered half the distance, which is exactly the middle. ### Solution ```python -def longestConsecutive(nums): - if not nums: - return 0 - - # Convert array to hash set for O(1) lookup - num_set = set(nums) - max_length = 0 - - # For each number, check if it's the start of a consecutive sequence - for num in num_set: - # A number is a starting point if num - 1 is NOT in the set - if num - 1 not in num_set: - current_length = 1 - current_num = num - - # Expand the sequence by checking consecutive numbers - while current_num + 1 in num_set: - current_length += 1 - current_num += 1 - - # Update maximum length if current sequence is longer - max_length = max(max_length, current_length) - - return max_length +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next + +class Solution: + def middleNode(self, head): + slow = head + fast = head + + # Move fast pointer twice as fast as slow pointer + while fast and fast.next: + slow = slow.next + fast = fast.next.next + + # When fast reaches the end, slow is at the middle + return slow ``` -## 141. Linked List Cycle [Easy] -https://leetcode.com/problems/linked-list-cycle/ +## 2. Add Two Numbers [Medium] +https://leetcode.com/problems/add-two-numbers/ ### Explanation -# 141. Linked List Cycle [Easy] - -https://leetcode.com/problems/linked-list-cycle - -## Description +You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. -Given `head`, the head of a linked list, determine if the linked list has a cycle in it. +You may assume the two numbers do not contain any leading zero, except the number 0 itself. -There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the `next` pointer. Internally, `pos` is used to denote the index of the node that tail's `next` pointer is connected to. **Note that `pos` is not passed as a parameter**. +Example: +```text +Input: l1 = [2,4,3], l2 = [5,6,4] +Output: [7,0,8] +Explanation: 342 + 465 = 807. -Return `true` *if there is a cycle in the linked list*. Otherwise, return `false`. +Input: l1 = [0], l2 = [0] +Output: [0] -**Example 1:** -```text -Input: head = [3,2,0,-4], pos = 1 -Output: true -Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed). +Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9] +Output: [8,9,9,9,0,0,0,1] ``` -**Example 2:** +Constraints: ```text -Input: head = [1,2], pos = 0 -Output: true -Explanation: There is a cycle in the linked list, where the tail connects to the 0th node. +The number of nodes in each linked list is in the range [1, 100]. +0 <= Node.val <= 9 +It is guaranteed that the list represents a number that does not have leading zeros. ``` -**Example 3:** -```text -Input: head = [1], pos = -1 -Output: false -Explanation: There is no cycle in the linked list. -``` +## Explanation -**Constraints:** +The Add Two Numbers problem involves adding two numbers represented by linked lists, where each node contains a single digit and the digits are stored in reverse order. To solve this, we iterate through both linked lists, adding corresponding digits along with any carry from the previous addition. We create a new linked list to store the result. If one list is shorter, treat missing digits as 0. If there is a carry left after processing both lists, add a new node with the carry value. -- The number of the nodes in the list is in the range `[0, 10^4]`. -- `-10^5 <= Node.val <= 10^5` -- `pos` is `-1` or a **valid index** in the linked-list. +## Hint +Use a dummy head node to simplify the code for building the result list. Remember to handle the carry at the end. -**Follow up:** Can you solve it using `O(1)` (i.e. constant) memory? +## Points -## Explanation +- Time complexity: O(max(m, n)), where m and n are the lengths of the two lists. +- Handle different lengths of input lists. +- Don’t forget to add a node if there is a carry left after the main loop. +- Each node contains a single digit (0-9). -### Strategy +### Solution -This is a **two-pointer problem** that requires detecting a cycle in a linked list. The key insight is to use Floyd's Cycle-Finding Algorithm (also known as the "tortoise and hare" algorithm), which uses two pointers moving at different speeds. +```python +def __init__(self, val=0, next=None): + self.val = val + self.next = next +``` -**Key observations:** -- If there's a cycle, a fast pointer will eventually catch up to a slow pointer -- If there's no cycle, the fast pointer will reach the end (null) -- The fast pointer moves twice as fast as the slow pointer -- This approach uses O(1) space, which is optimal +## 19. Remove Nth Node From End of List [Medium] +https://leetcode.com/problems/remove-nth-node-from-end-of-list/ -**High-level approach:** -1. **Use two pointers**: Slow pointer (tortoise) and fast pointer (hare) -2. **Move pointers**: Slow moves 1 step, fast moves 2 steps -3. **Check for cycle**: If fast catches slow, there's a cycle -4. **Check for end**: If fast reaches null, there's no cycle +### Explanation -### Steps +## Explanation -Let's break down the solution step by step: +### Strategy (The "Why") -**Step 1: Handle edge cases** -- If head is null or head.next is null, return false +Given the head of a linked list and an integer $n$, we need to remove the $n$-th node from the end of the list and return the head. -**Step 2: Initialize pointers** -- `slow = head` (moves 1 step at a time) -- `fast = head.next` (moves 2 steps at a time) +**1.1 Constraints & Complexity:** -**Step 3: Move pointers until they meet or reach end** -While `fast` is not null and `fast.next` is not null: -- Move slow pointer: `slow = slow.next` -- Move fast pointer: `fast = fast.next.next` -- If slow and fast meet, return true (cycle detected) +- **Input Size:** The number of nodes $N$ can be between $1$ and $30$. +- **Value Range:** Node values are between $1$ and $100$. +- **Time Complexity:** $O(L)$ where $L$ is the length of the list. We make one pass through the list. +- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. +- **Edge Case:** If we need to remove the head node ($n$ equals the list length), we need special handling. Using a dummy node simplifies this. -**Step 4: Return result** -- If you exit the loop, return false (no cycle) +**1.2 High-level approach:** -**Example walkthrough:** -Let's trace through the first example: +The goal is to remove the $n$-th node from the end of a linked list. -```text -head = [3,2,0,-4], pos = 1 (cycle from -4 back to 2) +![Remove Nth Node](https://assets.leetcode.com/uploads/2020/10/03/remove_ex1.jpg) -Initial state: -slow = 3, fast = 2 +We use two pointers: a fast pointer and a slow pointer. We move the fast pointer $n+1$ steps ahead, then move both pointers together. When fast reaches the end, slow will be at the node before the one to remove. -Step 1: slow = 2, fast = 0 -Step 2: slow = 0, fast = 2 -Step 3: slow = -4, fast = 0 -Step 4: slow = 2, fast = 2 (they meet!) +**1.3 Brute force vs. optimized strategy:** -Result: Return true (cycle detected) -``` +- **Brute Force:** First pass to count the length, second pass to find and remove the $(L-n+1)$-th node from the beginning. This takes two passes. +- **Optimized Strategy (Two Pointers):** Use two pointers with a gap of $n+1$ nodes. Move both together until the fast pointer reaches the end. This takes one pass. +- **Why it's better:** The two-pointer approach is more elegant and requires only one pass through the list, though both approaches have the same time complexity. -> **Note:** Floyd's Cycle-Finding Algorithm is optimal because it uses O(1) space and O(n) time. The mathematical proof shows that if there's a cycle, the fast pointer will eventually catch the slow pointer within one cycle length. +**1.4 Decomposition:** -**Time Complexity:** O(n) - in the worst case, you visit each node at most twice -**Space Complexity:** O(1) - you only use two pointers regardless of input size +1. Create a dummy node pointing to the head (to handle edge cases). +2. Initialize two pointers (fast and slow) at the dummy node. +3. Move the fast pointer $n+1$ steps ahead. +4. Move both pointers together until fast reaches the end. +5. Remove the node after slow (which is the $n$-th node from the end). +6. Return the head (via dummy.next). -### Solution +### Steps (The "How") -```python -def __init__(self, x): -# self.val = x -# self.next = None -``` +**2.1 Initialization & Example Setup:** + +Let's use the example: head = $[1,2,3,4,5]$, $n = 2$ + +We initialize: +- `dummy = ListNode(0)`, `dummy.next = head` +- `fast = dummy`, `slow = dummy` + +**2.2 Start Processing:** + +We move the fast pointer $n+1 = 3$ steps ahead. + +**2.3 Trace Walkthrough:** + +| Step | Fast Position | Slow Position | Action | +|------|---------------|---------------|--------| +| Initial | dummy | dummy | - | +| After moving fast 3 steps | node 4 | dummy | Fast is 3 steps ahead | +| Move both together | node 5 | node 1 | Continue... | +| Move both together | null | node 3 | Fast reached end | + +When fast is null, slow is at node 3 (the node before node 4, which is the 2nd from end). + +**2.4 Remove Node:** + +- `slow.next = slow.next.next` removes node 4 +- Result: $[1,2,3,5]$ + +**2.5 Return Result:** + +We return `dummy.next` which points to the new head $[1,2,3,5]$. + +> **Note:** The dummy node is crucial because it handles the edge case where we need to remove the head node. Without it, we'd need special handling for that case. + +### Solution + +```python +def __init__(self, val=0, next=None): +# self.val = val +# self.next = next + +class Solution: + def removeNthFromEnd(self, head, n: int): + # Create a dummy node to handle edge cases + dummy = ListNode(0) + dummy.next = head + + # Two pointers: fast and slow + fast = dummy + slow = dummy + + # Move fast pointer n+1 steps ahead + for _ in range(n + 1): + fast = fast.next + + # Move both pointers until fast reaches the end + while fast: + fast = fast.next + slow = slow.next + + # Remove the nth node from end + slow.next = slow.next.next + + return dummy.next +``` + +## 98. Validate Binary Search Tree [Medium] +https://leetcode.com/problems/validate-binary-search-tree/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +Given the root of a binary tree, we need to determine if it is a valid binary search tree (BST). A BST is valid if for every node, all nodes in its left subtree are less than it, and all nodes in its right subtree are greater than it. + +**1.1 Constraints & Complexity:** + +- **Input Size:** The number of nodes can be up to $10^4$. +- **Value Range:** Node values are between $-2^{31}$ and $2^{31} - 1$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(h)$ where $h$ is the height of the tree. In the worst case (skewed tree), $h = n$, so $O(n)$. In the average case (balanced tree), $h = \log n$, so $O(\log n)$. +- **Edge Case:** An empty tree is a valid BST. A tree with only one node is a valid BST. + +**1.2 High-level approach:** + +The goal is to validate that a binary tree satisfies the BST property. + +We use recursion with range validation. For each node, we check if its value is within the valid range (min_val, max_val). The range is updated as we traverse: left children must be less than the parent, right children must be greater than the parent. + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** For each node, check if all nodes in its left subtree are less and all nodes in its right subtree are greater. This would be $O(n^2)$ time. +- **Optimized Strategy (Range Validation):** Use recursion with min and max bounds. Each node must be within its allowed range. This takes $O(n)$ time. +- **Why it's better:** The range validation approach reduces time complexity from $O(n^2)$ to $O(n)$ by passing down constraints instead of checking all descendants for each node. + +**1.4 Decomposition:** + +1. Define a recursive function that takes a node and its allowed range (min_val, max_val). +2. If the node is null, return true (base case). +3. Check if the node's value is within the range (strictly greater than min_val and strictly less than max_val). +4. Recursively validate left subtree with range (min_val, node.val). +5. Recursively validate right subtree with range (node.val, max_val). +6. Return true only if all checks pass. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = $[5,1,4,null,null,3,6]$ + +The tree structure: +``` + 5 + / \ + 1 4 + / \ + 3 6 +``` + +We initialize: +- Call `validate(root, -∞, +∞)` + +**2.2 Start Validation:** + +We begin validating from the root. + +**2.3 Trace Walkthrough:** + +| Node | min_val | max_val | node.val | Check | Result | +|------|---------|---------|----------|-------|--------| +| 5 | -∞ | +∞ | 5 | $-∞ < 5 < +∞$ | ✓ | +| 1 | -∞ | 5 | 1 | $-∞ < 1 < 5$ | ✓ | +| 4 | 5 | +∞ | 4 | $5 < 4 < +∞$ | ✗ | + +**2.4 Explanation:** + +- Root (5): Valid, within range (-∞, +∞) +- Left child (1): Valid, within range (-∞, 5) +- Right child (4): Invalid! It should be greater than 5, but 4 < 5 + +**2.5 Return Result:** + +We return `False` because node 4 violates the BST property (it's in the right subtree of 5 but is less than 5). + +> **Note:** The key insight is to pass down the allowed range for each node. A node's value must be strictly within its range, and we update the range for children: left children get (min_val, node.val) and right children get (node.val, max_val). + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def isValidBST(self, root) -> bool: + def validate(node, min_val, max_val): + # Empty tree is valid + if not node: + return True + + # Check if current node value is within valid range + if node.val <= min_val or node.val >= max_val: + return False + + # Recursively validate left and right subtrees + return (validate(node.left, min_val, node.val) and + validate(node.right, node.val, max_val)) + + return validate(root, float('-inf'), float('inf')) +``` + +## 102. Binary Tree Level Order Traversal [Medium] +https://leetcode.com/problems/binary-tree-level-order-traversal/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +Given the root of a binary tree, we need to return the level-order traversal of its nodes' values (i.e., from left to right, level by level). + +**1.1 Constraints & Complexity:** + +- **Input Size:** The number of nodes $N$ can be up to $2000$. +- **Value Range:** Node values are between $-1000$ and $1000$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level, which is $O(n)$ in the worst case. +- **Edge Case:** If the tree is empty, return an empty list. + +**1.2 High-level approach:** + +The goal is to traverse the tree level by level, collecting values at each level. + +![Level Order Traversal](https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg) + +We use BFS (breadth-first search) with a queue. We process nodes level by level, adding all nodes at the current level to a list before moving to the next level. + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. +- **Optimized Strategy (BFS with Queue):** Use a queue to process nodes level by level. For each level, process all nodes in the queue (which represents the current level), then add their children for the next level. +- **Why it's better:** BFS naturally processes nodes level by level. Using a queue ensures we process all nodes at one level before moving to the next. + +**1.4 Decomposition:** + +1. If the tree is empty, return an empty list. +2. Initialize a queue with the root node. +3. While the queue is not empty: + - Get the number of nodes at the current level (queue size). + - Process all nodes at this level, adding their values to a level list. + - Add all children of these nodes to the queue for the next level. + - Add the level list to the result. +4. Return the result. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = $[3,9,20,null,null,15,7]$ + +The tree structure: +``` + 3 + / \ + 9 20 + / \ + 15 7 +``` + +We initialize: +- `queue = deque([3])` +- `res = []` + +**2.2 Start BFS:** + +We begin processing level by level. + +**2.3 Trace Walkthrough:** + +| Level | Queue Before | Level Size | Process Nodes | Level List | Queue After | +|-------|--------------|------------|---------------|------------|-------------| +| 0 | [3] | 1 | 3 | [3] | [9, 20] | +| 1 | [9, 20] | 2 | 9, 20 | [9, 20] | [15, 7] | +| 2 | [15, 7] | 2 | 15, 7 | [15, 7] | [] | + +**2.4 Final Result:** + +After processing all levels: +- `res = [[3], [9, 20], [15, 7]]` + +**2.5 Return Result:** + +We return `[[3], [9, 20], [15, 7]]`, which represents the level-order traversal. + +> **Note:** The key is to process all nodes at the current level before moving to the next. We do this by getting the queue size at the start of each iteration, which represents the number of nodes at the current level. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +from typing import List +from collections import deque + +class Solution: + def levelOrder(self, root) -> List[List[int]]: + if not root: + return [] + + res = [] + queue = deque([root]) + + while queue: + level_size = len(queue) + level = [] + + for _ in range(level_size): + node = queue.popleft() + level.append(node.val) + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + res.append(level) + + return res +``` + +## 105. Construct Binary Tree from Preorder and Inorder Traversal [Medium] +https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +The problem asks us to construct a binary tree from its preorder and inorder traversal arrays. + +**1.1 Constraints & Complexity:** + +- **Input Constraints:** $1 \leq n \leq 3000$, values in $[-3000, 3000]$, all values are unique. +- **Time Complexity:** $O(n)$ - We visit each node once. The hash map lookup is $O(1)$. +- **Space Complexity:** $O(n)$ - Hash map for inorder indices takes $O(n)$, recursion stack takes $O(h)$ where $h$ is tree height. +- **Edge Case:** Empty arrays return `None`. + +**1.2 High-level approach:** + +The goal is to reconstruct the tree using the property that in preorder, the root comes first, and in inorder, the root separates left and right subtrees. + +![Tree Construction](https://assets.leetcode.com/uploads/2021/02/19/tree.jpg) + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** For each root, search for it in inorder array linearly. This takes $O(n^2)$ time. +- **Optimized (Hash Map):** Use a hash map to store inorder indices for $O(1)$ lookup. This takes $O(n)$ time. +- **Emphasize the optimization:** The hash map reduces the time complexity from $O(n^2)$ to $O(n)$ by eliminating linear searches. + +**1.4 Decomposition:** + +1. **Build Hash Map:** Create a map from values to their inorder indices. +2. **Recursive Build:** Use preorder to get root, use inorder to split left/right subtrees. +3. **Calculate Ranges:** Determine preorder and inorder ranges for left and right subtrees. +4. **Return Root:** Build and return the root node. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's trace through an example: `preorder = [3,9,20,15,7]`, `inorder = [9,3,15,20,7]`. + +Hash map: `{9:0, 3:1, 15:2, 20:3, 7:4}` + +**2.2 Start Building:** + +Root is `preorder[0] = 3`. Find its position in inorder: `inorder[1] = 3`. + +**2.3 Trace Walkthrough:** + +| Root | Preorder Range | Inorder Range | Left Size | Left Subtree | Right Subtree | +|------|----------------|---------------|-----------|--------------|---------------| +| 3 | [0:4] | [0:4] | 1 | pre[1:2], in[0:0] | pre[2:5], in[2:4] | +| 9 | [1:2] | [0:0] | 0 | None | None | +| 20 | [2:5] | [2:4] | 1 | pre[3:4], in[2:2] | pre[4:5], in[3:4] | +| 15 | [3:4] | [2:2] | 0 | None | None | +| 7 | [4:5] | [3:4] | 0 | None | None | + +**2.4 Complete Construction:** + +Tree structure: `3` (root) with left child `9` and right child `20`. `20` has left child `15` and right child `7`. + +**2.5 Return Result:** + +The function returns the root node of the constructed tree. + +> **Note:** The key insight is that preorder gives us the root, and inorder tells us how many nodes are in the left subtree, allowing us to split the preorder array correctly. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def buildTree(self, preorder: List[int], inorder: List[int]) -> Optional[TreeNode]: + if not preorder or not inorder: + return None + + # Create a map for O(1) lookup of inorder indices + inorder_map = {val: idx for idx, val in enumerate(inorder)} + + def build(pre_start, pre_end, in_start, in_end): + if pre_start > pre_end: + return None + + # Root is the first element in preorder + root_val = preorder[pre_start] + root = TreeNode(root_val) + + # Find root position in inorder + root_idx = inorder_map[root_val] + + # Calculate sizes of left and right subtrees + left_size = root_idx - in_start + + # Recursively build left and right subtrees + root.left = build(pre_start + 1, pre_start + left_size, in_start, root_idx - 1) + root.right = build(pre_start + left_size + 1, pre_end, root_idx + 1, in_end) + + return root + + return build(0, len(preorder) - 1, 0, len(inorder) - 1) +``` + +## 114. Flatten Binary Tree to Linked List [Medium] +https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +**1.1 Constraints & Complexity** + +* **Input Size:** The tree has $0 \leq n \leq 2000$ nodes, with values in $[-100, 100]$. +* **Time Complexity:** $O(n)$ - We visit each node exactly once during the flattening process. +* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +* **Edge Case:** An empty tree requires no modification. A single-node tree remains unchanged. + +**1.2 High-level approach** + +The goal is to flatten a binary tree into a linked list in pre-order traversal order. We recursively flatten subtrees, then rearrange pointers to form a linear structure. + +![Tree flattening visualization showing how tree nodes are rearranged into a linked list] + +**1.3 Brute force vs. optimized strategy** + +* **Brute Force:** Store pre-order traversal in a list, then rebuild the tree as a linked list. This uses $O(n)$ extra space. +* **Optimized (In-Place):** Flatten subtrees recursively, then rearrange pointers in-place. This uses $O(h)$ space for recursion stack. + +**1.4 Decomposition** + +1. **Flatten Subtrees:** Recursively flatten left and right subtrees. +2. **Save Right:** Store the right subtree before modifying pointers. +3. **Move Left to Right:** Set `root.right = root.left` and `root.left = None`. +4. **Attach Saved Right:** Find the end of the flattened left subtree and attach the saved right subtree. + +### Steps (The "How") + +**2.1 Initialization & Example Setup** + +Let's use the example $root = [1,2,5,3,4,null,6]$. + +We start at the root node with value 1. + +**2.2 Start Processing** + +We call `flatten(root)`. + +**2.3 Trace Walkthrough** + +The flattening process happens bottom-up: + +**Step 1: Flatten leaf nodes** +- Node 3: Already flat (no children) +- Node 4: Already flat (no children) +- Node 6: Already flat (no children) + +**Step 2: Flatten node 2** +- Left subtree [3,4] is already flat +- Right subtree is None +- Move left to right: `2.right = 2.left = [3,4]`, `2.left = None` + +**Step 3: Flatten node 5** +- Left subtree is None +- Right subtree [6] is already flat +- No change needed + +**Step 4: Flatten root 1** +- Left subtree [2,3,4] is flattened +- Right subtree [5,6] is flattened +- Save right: `right = [5,6]` +- Move left to right: `1.right = [2,3,4]`, `1.left = None` +- Find end of [2,3,4] (node 4) and attach: `4.right = [5,6]` + +**2.4 Recursive Processing** + +For each node: +1. If `not root`, return (base case) +2. Recursively flatten `root.left` +3. Recursively flatten `root.right` +4. Save `right = root.right` +5. Set `root.right = root.left` and `root.left = None` +6. Traverse to end of new right subtree and set `curr.right = right` + +**2.5 Return Result** + +After flattening, the tree becomes a linked list: `[1,null,2,null,3,null,4,null,5,null,6]`, which matches the pre-order traversal. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def flatten(self, root: Optional[TreeNode]) -> None: + """ + Do not return anything, modify root in-place instead. + """ + if not root: + return + + # Flatten left and right subtrees + self.flatten(root.left) + self.flatten(root.right) + + # Save right subtree + right = root.right + + # Move left subtree to right + root.right = root.left + root.left = None + + # Find the end of the new right subtree and attach saved right + curr = root + while curr.right: + curr = curr.right + curr.right = right +``` + +## 128. Longest Consecutive Sequence [Medium] +https://leetcode.com/problems/longest-consecutive-sequence/ + +### Explanation + +## 128. Longest Consecutive Sequence [Medium] + +https://leetcode.com/problems/longest-consecutive-sequence + +## Description +Given an unsorted array of integers `nums`, return *the length of the longest consecutive elements sequence.* + +You must write an algorithm that runs in `O(n)` time. + +**Examples** + +```tex +Example 1: +Input: nums = [100,4,200,1,3,2] +Output: 4 +Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. + +Example 2: +Input: nums = [0,3,7,2,5,8,4,6,0,1] +Output: 9 + +Example 3: +Input: nums = [1,0,1,2] +Output: 3 +``` + +**Constraints** +```tex +- 0 <= nums.length <= 10^5 +- -10^9 <= nums[i] <= 10^9 +``` + +## Explanation + +### Strategy +Let's restate the problem: You're given an unsorted array of integers, and you need to find the length of the longest sequence of consecutive integers. The challenge is to do this in O(n) time, which means we can't sort the array (as sorting takes O(n log n) time). + +This is a **hash table problem** that requires finding sequences of consecutive numbers efficiently by using the properties of consecutive sequences. + +**What is given?** An unsorted array of integers that can be very large (up to 100,000 elements). + +**What is being asked?** Find the length of the longest sequence of consecutive integers. + +**Constraints:** The array can be up to 100,000 elements long, with values ranging from -10⁹ to 10⁹. + +**Edge cases:** +- Empty array +- Array with single element +- Array with all identical elements +- Array with no consecutive sequences + +**High-level approach:** +The solution involves using a hash set to quickly check if numbers exist, then for each number, expanding in both directions to find the complete consecutive sequence. + +**Decomposition:** +1. **Convert array to hash set**: For O(1) lookup time +2. **Find sequence starting points**: Look for numbers that are the start of a consecutive sequence +3. **Expand sequences**: For each starting point, expand in both directions to find the complete sequence +4. **Track maximum length**: Keep track of the longest sequence found + +**Brute force vs. optimized strategy:** +- **Brute force**: Sort the array and find consecutive sequences. This takes O(n log n) time. +- **Optimized**: Use hash set and expand sequences from starting points. This takes O(n) time. + +### Steps +Let's walk through the solution step by step using the first example: `nums = [100,4,200,1,3,2]` + +**Step 1: Convert array to hash set** +- `nums = [100,4,200,1,3,2]` +- `num_set = {100, 4, 200, 1, 3, 2}` + +**Step 2: Find sequence starting points** +- For each number, check if it's the start of a consecutive sequence +- A number is a starting point if `num - 1` is NOT in the set +- Starting points: `[100, 200, 1]` (because 99, 199, and 0 are not in the set) + +**Step 3: Expand sequences from starting points** +- **Starting point 100**: + - Check if 101 exists: No + - Sequence length: 1 +- **Starting point 200**: + - Check if 201 exists: No + - Sequence length: 1 +- **Starting point 1**: + - Check if 2 exists: Yes + - Check if 3 exists: Yes + - Check if 4 exists: Yes + - Check if 5 exists: No + - Sequence: [1, 2, 3, 4] + - Sequence length: 4 + +**Step 4: Track maximum length** +- Maximum sequence length found: 4 +- Result: 4 + +**Why this works:** +By identifying starting points (numbers that don't have a predecessor in the set), we ensure that we only expand each sequence once. This gives us O(n) time complexity because: +1. We visit each number at most twice (once when checking if it's a starting point, once when expanding sequences) +2. Each number is part of at most one sequence +3. The total work is bounded by O(n) + +> **Note:** The key insight is identifying starting points of consecutive sequences and expanding from there. This avoids redundant work and ensures O(n) time complexity. + +**Time Complexity:** O(n) - we visit each number at most twice +**Space Complexity:** O(n) - we need to store the hash set + +### Solution + +```python +def longestConsecutive(nums): + if not nums: + return 0 + + # Convert array to hash set for O(1) lookup + num_set = set(nums) + max_length = 0 + + # For each number, check if it's the start of a consecutive sequence + for num in num_set: + # A number is a starting point if num - 1 is NOT in the set + if num - 1 not in num_set: + current_length = 1 + current_num = num + + # Expand the sequence by checking consecutive numbers + while current_num + 1 in num_set: + current_length += 1 + current_num += 1 + + # Update maximum length if current sequence is longer + max_length = max(max_length, current_length) + + return max_length +``` ## 146. LRU Cache [Medium] https://leetcode.com/problems/lru-cache/ @@ -2203,8 +2509,132 @@ def __init__(self): # param_4 = obj.getMin() ``` -## 160. Intersection of Two Linked Lists [Easy] -https://leetcode.com/problems/intersection-of-two-linked-lists/ +## 199. Binary Tree Right Side View [Medium] +https://leetcode.com/problems/binary-tree-right-side-view/ + +### Explanation + +## Explanation + +### Strategy (The "Why") + +Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. + +**1.1 Constraints & Complexity:** + +- **Input Size:** The number of nodes $N$ can be up to $100$. +- **Value Range:** Node values are between $0$ and $100$. +- **Time Complexity:** $O(n)$ - We visit each node exactly once. +- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. +- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. + +**1.2 High-level approach:** + +The goal is to find the rightmost node at each level of the tree. + +![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) + +We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. + +**1.3 Brute force vs. optimized strategy:** + +- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. +- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. +- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. + +**1.4 Decomposition:** + +1. If the tree is empty, return an empty list. +2. Initialize a queue with the root node. +3. While the queue is not empty: + - Get the number of nodes at the current level. + - Process all nodes at this level. + - For the last node at each level (rightmost), add its value to the result. + - Add all children to the queue for the next level. +4. Return the result. + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** + +Let's use the example: root = $[1,2,3,null,5,null,4]$ + +The tree structure: +``` + 1 + / \ + 2 3 + \ \ + 5 4 +``` + +We initialize: +- `queue = deque([1])` +- `res = []` + +**2.2 Start BFS:** + +We begin processing level by level. + +**2.3 Trace Walkthrough:** + +| Level | Queue Before | Level Size | Process | Rightmost Node | res | +|-------|--------------|------------|---------|----------------|-----| +| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | +| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | +| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | + +**2.4 Explanation:** + +- Level 0: Only node 1 → add 1 +- Level 1: Nodes 2 and 3 → add 3 (rightmost) +- Level 2: Nodes 5 and 4 → add 4 (rightmost) + +**2.5 Return Result:** + +We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. + +> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +from typing import List +from collections import deque + +class Solution: + def rightSideView(self, root) -> List[int]: + if not root: + return [] + + res = [] + queue = deque([root]) + + while queue: + level_size = len(queue) + + for i in range(level_size): + node = queue.popleft() + + # Add the rightmost node of each level + if i == level_size - 1: + res.append(node.val) + + if node.left: + queue.append(node.left) + if node.right: + queue.append(node.right) + + return res +``` + +## 208. Implement Trie (Prefix Tree) [Medium] +https://leetcode.com/problems/implement-trie-prefix-tree/ ### Explanation @@ -2212,93 +2642,147 @@ https://leetcode.com/problems/intersection-of-two-linked-lists/ ### Strategy (The "Why") +We need to implement a Trie (prefix tree) data structure that supports inserting words, searching for complete words, and checking if any word starts with a given prefix. + **1.1 Constraints & Complexity:** -- **Constraints:** We have two linked lists with `m` and `n` nodes respectively, where `1 <= m, n <= 3 * 10^4`. Each node value is between `1` and `10^5`. -- **Time Complexity:** O(m + n) - In the worst case, we traverse both lists once before finding the intersection or determining there is none. -- **Space Complexity:** O(1) - We only use two pointer variables, no additional data structures. -- **Edge Case:** When the two lists have no intersection, both pointers will eventually become `None` and the loop will terminate, returning `None`. + +- **Input Size:** The number of operations $N$ can be up to $3 \times 10^4$. +- **Value Range:** Words and prefixes consist of lowercase English letters only, with length between 1 and 2000. +- **Time Complexity:** + - `insert`: $O(m)$ where $m$ is the length of the word + - `search`: $O(m)$ where $m$ is the length of the word + - `startsWith`: $O(m)$ where $m$ is the length of the prefix +- **Space Complexity:** $O(ALPHABET\_SIZE \times N \times M)$ where $N$ is the number of words and $M$ is the average length. In practice, this is $O(\text{total characters in all words})$. +- **Edge Case:** Searching for an empty string should return false (unless an empty word was inserted). Checking prefix of empty string should return true if any word exists. **1.2 High-level approach:** -The goal is to find the node where two linked lists intersect, or return `None` if they don't intersect. The key insight is that if we traverse both lists simultaneously, switching to the other list when we reach the end, both pointers will eventually meet at the intersection point (if it exists) after traversing the same total distance. -![Two linked lists intersecting](https://assets.leetcode.com/uploads/2021/03/05/160_statement.png) +The goal is to implement a Trie data structure that efficiently stores and retrieves words. + +![Trie Structure](https://assets.leetcode.com/uploads/2021/04/28/trie-1.png) + +A Trie is a tree-like data structure where each node represents a character. Words that share common prefixes share the same path in the tree. This makes prefix searches very efficient. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** For each node in list A, check if it exists in list B by traversing list B. This would take O(m * n) time complexity. -- **Optimized Strategy (Two Pointers):** Use two pointers that traverse both lists, switching lists when reaching the end. This ensures both pointers cover the same total distance and will meet at the intersection. Time complexity is O(m + n) with O(1) space. + +- **Brute Force:** Store all words in a list. For search and prefix operations, iterate through all words checking each one. This takes $O(n \times m)$ time where $n$ is the number of words. +- **Optimized Strategy (Trie):** Use a tree structure where each node has children representing possible next characters. This allows us to search in $O(m)$ time regardless of how many words are stored. +- **Why it's better:** The Trie structure eliminates the need to check every word. We only traverse the path relevant to the word or prefix we're looking for, making it much more efficient for large datasets. **1.4 Decomposition:** -1. Initialize two pointers, one for each list. -2. Traverse both lists simultaneously, moving each pointer forward. -3. When a pointer reaches the end of its list, switch it to the head of the other list. -4. Continue until both pointers point to the same node (intersection found) or both are `None` (no intersection). + +1. Create a `TrieNode` class with a dictionary of children and a flag indicating if it's the end of a word. +2. Initialize the Trie with a root `TrieNode`. +3. For `insert`: Traverse the tree, creating nodes as needed, and mark the final node as an end-of-word. +4. For `search`: Traverse the tree following the word's characters. Return true only if we reach the end and the final node is marked as end-of-word. +5. For `startsWith`: Similar to search, but return true if we can traverse the entire prefix, regardless of whether it's a complete word. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use an example: `headA = [4,1,8,4,5]` and `headB = [5,6,1,8,4,5]`, where the lists intersect at node with value 8. -Initialize: -- `p1 = headA` (points to node 4) -- `p2 = headB` (points to node 5) +Let's use the example operations: +- `insert("apple")` +- `search("apple")` → returns true +- `search("app")` → returns false +- `startsWith("app")` → returns true +- `insert("app")` +- `search("app")` → returns true -**2.2 Start Checking:** -We enter a loop that continues while `p1 != p2`. +We initialize: +- A root `TrieNode` with empty children dictionary +- `is_end = False` for all nodes initially + +**2.2 Start Inserting:** + +We begin by inserting "apple". **2.3 Trace Walkthrough:** -| Step | p1 position | p2 position | p1 value | p2 value | Action | -|------|-------------|--------------|----------|----------|--------| -| 1 | headA[0] | headB[0] | 4 | 5 | Both advance | -| 2 | headA[1] | headB[1] | 1 | 6 | Both advance | -| 3 | headA[2] | headB[2] | 8 | 1 | Both advance | -| 4 | headA[3] | headB[3] | 4 | 8 | Both advance | -| 5 | headA[4] | headB[4] | 5 | 4 | Both advance | -| 6 | None | headB[5] | - | 5 | p1 switches to headB | -| 7 | headB[0] | None | 5 | - | p2 switches to headA | -| 8 | headB[1] | headA[0] | 6 | 4 | Both advance | -| 9 | headB[2] | headA[1] | 1 | 1 | Both advance | -| 10 | headB[3] | headA[2] | 8 | 8 | **Match!** Intersection found | +**Insert "apple":** -**2.4 Increment and Loop:** -At each iteration: -- If `p1` is not `None`, move it to `p1.next`; otherwise, set it to `headB`. -- If `p2` is not `None`, move it to `p2.next`; otherwise, set it to `headA`. +| Step | Current Node | Character | Action | New Node Created? | +|------|--------------|-----------|--------|-------------------| +| 1 | root | 'a' | Create node for 'a' | Yes | +| 2 | a-node | 'p' | Create node for 'p' | Yes | +| 3 | p-node | 'p' | Create node for 'p' | Yes | +| 4 | p-node | 'l' | Create node for 'l' | Yes | +| 5 | l-node | 'e' | Create node for 'e', mark as end | Yes | + +**Search "apple":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | Move to 'p' node | +| 4 | p-node | 'l' | Yes | Move to 'l' node | +| 5 | l-node | 'e' | Yes | Check is_end → true → Return true | + +**Search "app":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | Check is_end → false → Return false | + +**startsWith "app":** + +| Step | Current Node | Character | Found? | Action | +|------|--------------|-----------|--------|--------| +| 1 | root | 'a' | Yes | Move to 'a' node | +| 2 | a-node | 'p' | Yes | Move to 'p' node | +| 3 | p-node | 'p' | Yes | All characters found → Return true | + +**2.4 Insert "app" and Search Again:** + +After inserting "app", the second 'p' node now has `is_end = true`. So searching "app" will now return true. **2.5 Return Result:** -When `p1 == p2`, the loop exits. This happens either: -- When both point to the intersection node (return that node) -- When both are `None` (no intersection, return `None`) -In our example, both pointers meet at the node with value 8, which is the intersection point. +The Trie correctly handles all operations, allowing efficient word storage and prefix matching. + +> **Note:** The key difference between `search` and `startsWith` is that `search` requires the final node to be marked as an end-of-word, while `startsWith` only requires that the path exists. ### Solution ```python -def __init__(self, x): -# self.val = x -# self.next = None +def __init__(self): + self.children = {} + self.is_end = False -class Solution: - def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> Optional[ListNode]: - # Two pointer approach: traverse both lists - # When one pointer reaches end, switch to other list - # This way both pointers will meet at intersection (if exists) - # or both will be None (if no intersection) - - p1, p2 = headA, headB - - while p1 != p2: - # If p1 reaches end, switch to headB - p1 = p1.next if p1 else headB - # If p2 reaches end, switch to headA - p2 = p2.next if p2 else headA - - return p1 +class Trie: + def __init__(self): + self.root = TrieNode() + + def insert(self, word: str) -> None: + node = self.root + for char in word: + if char not in node.children: + node.children[char] = TrieNode() + node = node.children[char] + node.is_end = True + + def search(self, word: str) -> bool: + node = self.root + for char in word: + if char not in node.children: + return False + node = node.children[char] + return node.is_end + + def startsWith(self, prefix: str) -> bool: + node = self.root + for char in prefix: + if char not in node.children: + return False + node = node.children[char] + return True ``` -## 199. Binary Tree Right Side View [Medium] -https://leetcode.com/problems/binary-tree-right-side-view/ +## 230. Kth Smallest Element in a BST [Medium] +https://leetcode.com/problems/kth-smallest-element-in-a-bst/ ### Explanation @@ -2306,83 +2790,93 @@ https://leetcode.com/problems/binary-tree-right-side-view/ ### Strategy (The "Why") -Given the root of a binary tree, we need to return the values of the nodes you can see when standing on the right side of the tree, ordered from top to bottom. +Given the root of a binary search tree (BST) and an integer $k$, we need to find the $k$-th smallest element in the BST. **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ can be up to $100$. -- **Value Range:** Node values are between $0$ and $100$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(n)$ - The queue can contain at most all nodes at the widest level. -- **Edge Case:** If the tree is empty, return an empty list. If the tree has only one node, return that node's value. +- **Input Size:** The number of nodes $N$ in the BST can be up to $10^4$. +- **Value Range:** Node values are between $1$ and $10^4$. +- **Time Complexity:** $O(n)$ - We traverse all nodes in the BST using in-order traversal, which visits each node exactly once. +- **Space Complexity:** $O(n)$ - In the worst case (a skewed tree), the recursion stack can be $O(n)$ deep. Additionally, we store all node values in a list, which requires $O(n)$ space. +- **Edge Case:** If $k$ is 1, we return the smallest element. If $k$ equals the number of nodes, we return the largest element. **1.2 High-level approach:** -The goal is to find the rightmost node at each level of the tree. +The goal is to find the $k$-th smallest element in a BST. -![Right Side View](https://assets.leetcode.com/uploads/2021/02/14/tree.jpg) +![BST In-order Traversal](https://assets.leetcode.com/uploads/2021/01/28/kthtree1.jpg) -We use BFS (breadth-first search) level by level. For each level, we add the rightmost node (the last node processed at that level) to our result. +A key property of a BST is that an in-order traversal (left → root → right) visits nodes in ascending order. Therefore, the $k$-th element visited during an in-order traversal is the $k$-th smallest element. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** There isn't really a brute force approach - we must traverse the tree. -- **Optimized Strategy (BFS):** Use BFS to process nodes level by level. For each level, track the last node processed, which is the rightmost node. This is the same as level-order traversal, but we only keep the last element of each level. -- **Why it's better:** BFS naturally processes nodes level by level from left to right, so the last node at each level is the rightmost node. +- **Brute Force:** Perform an in-order traversal to collect all node values in a list, then return the element at index $k-1$. This approach is straightforward and works correctly. +- **Optimized Strategy:** We can optimize by stopping the traversal once we've found the $k$-th element, using an iterative approach or early termination in recursion. However, for clarity and beginner-friendliness, we'll use the complete traversal approach. +- **Why it's better:** The brute force approach is actually quite efficient for this problem. A more optimized version would use iterative in-order traversal with early termination, but the complete traversal approach is easier to understand. **1.4 Decomposition:** -1. If the tree is empty, return an empty list. -2. Initialize a queue with the root node. -3. While the queue is not empty: - - Get the number of nodes at the current level. - - Process all nodes at this level. - - For the last node at each level (rightmost), add its value to the result. - - Add all children to the queue for the next level. -4. Return the result. +1. Perform an in-order traversal of the BST (visit left subtree, then root, then right subtree). +2. Collect all node values in a list during the traversal. +3. Since in-order traversal of a BST produces values in sorted order, the list will be sorted. +4. Return the element at index $k-1$ (since $k$ is 1-indexed). ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[1,2,3,null,5,null,4]$ +Let's use the example: root = $[3, 1, 4, null, 2]$, $k = 1$ -The tree structure: +The BST structure: ``` - 1 + 3 / \ - 2 3 - \ \ - 5 4 + 1 4 + \ + 2 ``` We initialize: -- `queue = deque([1])` -- `res = []` +- An empty list `res = []` to store node values +- We'll perform in-order traversal starting from the root -**2.2 Start BFS:** +**2.2 Start Traversing:** -We begin processing level by level. +We begin the in-order traversal from the root node (value 3). **2.3 Trace Walkthrough:** -| Level | Queue Before | Level Size | Process | Rightmost Node | res | -|-------|--------------|------------|---------|----------------|-----| -| 0 | [1] | 1 | Node 1 (last) | 1 | [1] | -| 1 | [2, 3] | 2 | Node 2, Node 3 (last) | 3 | [1, 3] | -| 2 | [5, 4] | 2 | Node 5, Node 4 (last) | 4 | [1, 3, 4] | +The in-order traversal visits nodes in this order: + +| Step | Current Node | Action | List State | +|------|--------------|--------|------------| +| 1 | 3 (root) | Go to left child (1) | [] | +| 2 | 1 | Go to left child (null) | [] | +| 3 | null | Return (base case) | [] | +| 4 | 1 | Add 1 to list | [1] | +| 5 | 1 | Go to right child (2) | [1] | +| 6 | 2 | Go to left child (null) | [1] | +| 7 | null | Return (base case) | [1] | +| 8 | 2 | Add 2 to list | [1, 2] | +| 9 | 2 | Go to right child (null) | [1, 2] | +| 10 | null | Return (base case) | [1, 2] | +| 11 | 3 | Add 3 to list | [1, 2, 3] | +| 12 | 3 | Go to right child (4) | [1, 2, 3] | +| 13 | 4 | Go to left child (null) | [1, 2, 3] | +| 14 | null | Return (base case) | [1, 2, 3] | +| 15 | 4 | Add 4 to list | [1, 2, 3, 4] | +| 16 | 4 | Go to right child (null) | [1, 2, 3, 4] | +| 17 | null | Return (base case) | [1, 2, 3, 4] | -**2.4 Explanation:** +After traversal: `res = [1, 2, 3, 4]` -- Level 0: Only node 1 → add 1 -- Level 1: Nodes 2 and 3 → add 3 (rightmost) -- Level 2: Nodes 5 and 4 → add 4 (rightmost) +**2.4 Return Result:** -**2.5 Return Result:** +Since $k = 1$ (1-indexed), we return `res[0] = 1`, which is the 1st smallest element. -We return `[1, 3, 4]`, which are the values of the rightmost nodes at each level. +For $k = 3$, we would return `res[2] = 3`, which is the 3rd smallest element. -> **Note:** The key is to identify the last node processed at each level during BFS. Since BFS processes nodes from left to right, the last node at each level is the rightmost node visible from the right side. +> **Note:** In-order traversal of a BST always produces values in ascending order because of the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. ### Solution @@ -2392,37 +2886,26 @@ def __init__(self, val=0, left=None, right=None): # self.left = left # self.right = right -from typing import List -from collections import deque - class Solution: - def rightSideView(self, root) -> List[int]: - if not root: - return [] - + def kthSmallest(self, root, k: int) -> int: + # In-order traversal to get elements in sorted order res = [] - queue = deque([root]) - while queue: - level_size = len(queue) - - for i in range(level_size): - node = queue.popleft() - - # Add the rightmost node of each level - if i == level_size - 1: - res.append(node.val) - - if node.left: - queue.append(node.left) - if node.right: - queue.append(node.right) + def inorder(node): + if not node: + return + inorder(node.left) + res.append(node.val) + inorder(node.right) - return res + inorder(root) + + # Return the k-th smallest element (1-indexed) + return res[k - 1] ``` -## 206. Reverse Linked List [Easy] -https://leetcode.com/problems/reverse-linked-list/ +## 236. Lowest Common Ancestor of a Binary Tree [Medium] +https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ ### Explanation @@ -2430,99 +2913,91 @@ https://leetcode.com/problems/reverse-linked-list/ ### Strategy (The "Why") -Given the head of a singly linked list, we need to reverse the list and return the reversed list's head. +The problem asks us to find the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA is the deepest node that has both nodes as descendants (a node can be a descendant of itself). **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes can be between $0$ and $5000$. -- **Value Range:** Node values are between $-5000$ and $5000$. -- **Time Complexity:** $O(n)$ - We visit each node exactly once. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If the list is empty (head is null), return null. If the list has only one node, return that node. +- **Input Constraints:** The tree has $2 \leq n \leq 10^5$ nodes with unique values in $[-10^9, 10^9]$. +- **Time Complexity:** $O(n)$ - We may need to visit all nodes in the worst case. +- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +- **Edge Case:** If one node is an ancestor of the other, return that ancestor node. **1.2 High-level approach:** -The goal is to reverse the links between nodes in a linked list. +The goal is to find the deepest node that is an ancestor of both target nodes. We use recursive DFS: if we find both nodes in a subtree, the current root is the LCA. -We use an iterative approach with three pointers: `prev` (previous node), `current` (current node), and `next_node` (next node). We traverse the list, reversing each link as we go. +![Binary Tree LCA](https://assets.leetcode.com/uploads/2018/12/14/binarytree.png) **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Convert the list to an array, reverse the array, then convert back to a linked list. This takes $O(n)$ time and $O(n)$ space. -- **Optimized Strategy (Iterative):** Use pointers to reverse links in-place. This takes $O(n)$ time and $O(1)$ space. -- **Why it's better:** The iterative approach uses $O(1)$ extra space instead of $O(n)$ for an array, while maintaining the same time complexity. +- **Brute Force:** Find paths to both nodes, then find the last common node in both paths. This requires storing paths and takes $O(n)$ time and $O(n)$ space. +- **Optimized (Recursive DFS):** Recursively search both subtrees. If both subtrees return non-null, the current root is the LCA. This takes $O(n)$ time and $O(h)$ space. +- **Emphasize the optimization:** The recursive approach finds the LCA in a single pass without storing paths, making it more space-efficient. **1.4 Decomposition:** -1. Initialize `prev = None` and `current = head`. -2. While `current` is not null: - - Store the next node. - - Reverse the link: `current.next = prev`. - - Move pointers forward: `prev = current`, `current = next_node`. -3. Return `prev` (which is the new head). +1. **Base Case:** If root is `None` or equals `p` or `q`, return root. +2. **Recursive Search:** Recursively search left and right subtrees for `p` and `q`. +3. **Combine Results:** If both subtrees return non-null, root is the LCA. Otherwise, return whichever subtree found a node. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: $head = [1,2,3,4,5]$ - -We initialize: -- `prev = None` -- `current = 1` +Let's trace through an example: `root = [3,5,1,6,2,0,8,null,null,7,4]`, `p = 5`, `q = 1`. -**2.2 Start Reversing:** +**2.2 Start Searching:** -We begin reversing links. +Begin at root node `3`. **2.3 Trace Walkthrough:** -| Step | current | next_node | current.next | prev After | current After | -|------|---------|-----------|--------------|------------|---------------| -| 1 | 1 | 2 | None | 1 | 2 | -| 2 | 2 | 3 | 1 | 2 | 3 | -| 3 | 3 | 4 | 2 | 3 | 4 | -| 4 | 4 | 5 | 3 | 4 | 5 | -| 5 | 5 | None | 4 | 5 | None | +| Node | Left Result | Right Result | Action | +|------|-------------|--------------|---------| +| 3 | Search left (5) | Search right (1) | Both found → Return 3 | +| 5 | Search left (6) | Search right (2) | Found p → Return 5 | +| 1 | Search left (0) | Search right (8) | Found q → Return 1 | -**2.4 Final State:** +**2.4 Recursive Unwinding:** -After reversing: -- Original: $1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5 \rightarrow null$ -- Reversed: $5 \rightarrow 4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow null$ +- Node `5` returns itself (found `p`). +- Node `1` returns itself (found `q`). +- Node `3` receives both results, so it's the LCA. **2.5 Return Result:** -We return the node with value 5, which is the new head of the reversed list. +The function returns node `3`, which is the LCA of nodes `5` and `1`. -> **Note:** The key insight is to maintain three pointers: previous, current, and next. We reverse the link from current to previous, then move all pointers forward. The previous pointer becomes the new head at the end. +> **Note:** The key insight is that if both left and right subtrees return non-null, the current root must be the LCA. If only one subtree returns non-null, that subtree contains the LCA. ### Solution ```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next +def __init__(self, x): +# self.val = x +# self.left = None +# self.right = None class Solution: - def reverseList(self, head): - prev = None - current = head + def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': + # Base case: if root is None or root is p or q, return root + if not root or root == p or root == q: + return root - while current: - # Store next node - next_node = current.next - # Reverse the link - current.next = prev - # Move pointers forward - prev = current - current = next_node + # Recursively search in left and right subtrees + left = self.lowestCommonAncestor(root.left, p, q) + right = self.lowestCommonAncestor(root.right, p, q) - return prev + # If both left and right return non-None, root is the LCA + if left and right: + return root + + # Otherwise, return whichever side found p or q + return left if left else right ``` -## 208. Implement Trie (Prefix Tree) [Medium] -https://leetcode.com/problems/implement-trie-prefix-tree/ +## 337. House Robber III [Medium] +https://leetcode.com/problems/house-robber-iii/ ### Explanation @@ -2530,147 +3005,143 @@ https://leetcode.com/problems/implement-trie-prefix-tree/ ### Strategy (The "Why") -We need to implement a Trie (prefix tree) data structure that supports inserting words, searching for complete words, and checking if any word starts with a given prefix. - **1.1 Constraints & Complexity:** - -- **Input Size:** The number of operations $N$ can be up to $3 \times 10^4$. -- **Value Range:** Words and prefixes consist of lowercase English letters only, with length between 1 and 2000. -- **Time Complexity:** - - `insert`: $O(m)$ where $m$ is the length of the word - - `search`: $O(m)$ where $m$ is the length of the word - - `startsWith`: $O(m)$ where $m$ is the length of the prefix -- **Space Complexity:** $O(ALPHABET\_SIZE \times N \times M)$ where $N$ is the number of words and $M$ is the average length. In practice, this is $O(\text{total characters in all words})$. -- **Edge Case:** Searching for an empty string should return false (unless an empty word was inserted). Checking prefix of empty string should return true if any word exists. +- **Constraints:** The tree has at most 10^4 nodes, and each node value is between 0 and 10^4. +- **Time Complexity:** O(n) - We visit each node exactly once, where n is the number of nodes. +- **Space Complexity:** O(h) - The recursion stack depth is at most the height h of the tree. In the worst case (skewed tree), h = n, giving O(n) space. +- **Edge Case:** If the tree is empty (root is None), return 0. **1.2 High-level approach:** +The goal is to find the maximum amount of money we can rob from a binary tree without robbing two directly connected nodes. We use dynamic programming with a post-order traversal, where for each node we calculate two values: the maximum if we rob this node, and the maximum if we don't rob this node. -The goal is to implement a Trie data structure that efficiently stores and retrieves words. - -![Trie Structure](https://assets.leetcode.com/uploads/2021/04/28/trie-1.png) - -A Trie is a tree-like data structure where each node represents a character. Words that share common prefixes share the same path in the tree. This makes prefix searches very efficient. +![House Robber III tree](https://assets.leetcode.com/uploads/2021/03/10/rob1-tree.jpg) **1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** Store all words in a list. For search and prefix operations, iterate through all words checking each one. This takes $O(n \times m)$ time where $n$ is the number of words. -- **Optimized Strategy (Trie):** Use a tree structure where each node has children representing possible next characters. This allows us to search in $O(m)$ time regardless of how many words are stored. -- **Why it's better:** The Trie structure eliminates the need to check every word. We only traverse the path relevant to the word or prefix we're looking for, making it much more efficient for large datasets. +- **Brute Force:** Try all possible combinations of robbing/not robbing each node, checking constraints. This would be exponential time O(2^n). +- **Optimized Strategy (DP with DFS):** For each node, calculate the maximum profit for two cases: robbing this node (can't rob children) and not robbing this node (can rob children). This takes O(n) time. +- **Emphasize the optimization:** By storing both possibilities at each node, we avoid recalculating subproblems and reduce time complexity from exponential to linear. **1.4 Decomposition:** - -1. Create a `TrieNode` class with a dictionary of children and a flag indicating if it's the end of a word. -2. Initialize the Trie with a root `TrieNode`. -3. For `insert`: Traverse the tree, creating nodes as needed, and mark the final node as an end-of-word. -4. For `search`: Traverse the tree following the word's characters. Return true only if we reach the end and the final node is marked as end-of-word. -5. For `startsWith`: Similar to search, but return true if we can traverse the entire prefix, regardless of whether it's a complete word. +1. Perform a post-order traversal of the tree. +2. For each node, return a tuple: (rob_this, dont_rob_this). +3. If we rob this node, we can't rob its children, so we take children's "don't rob" values. +4. If we don't rob this node, we can choose the maximum from each child's two options. +5. Return the maximum of the root's two options. ### Steps (The "How") **2.1 Initialization & Example Setup:** +Let's use an example: `root = [3,2,3,null,3,null,1]` -Let's use the example operations: -- `insert("apple")` -- `search("apple")` → returns true -- `search("app")` → returns false -- `startsWith("app")` → returns true -- `insert("app")` -- `search("app")` → returns true +Initialize: +- Start DFS from root node with value 3. -We initialize: -- A root `TrieNode` with empty children dictionary -- `is_end = False` for all nodes initially +**2.2 Start Processing:** +We traverse the tree using post-order DFS (process children before parent). -**2.2 Start Inserting:** +**2.3 Trace Walkthrough:** -We begin by inserting "apple". +| Node | Left Child Result | Right Child Result | Rob This | Don't Rob This | Max | +|------|-------------------|-------------------|----------|----------------|-----| +| 1 (leaf) | (0,0) | (0,0) | 1 + 0 + 0 = 1 | 0 + 0 = 0 | 1 | +| 3 (leaf) | (0,0) | (0,0) | 3 + 0 + 0 = 3 | 0 + 0 = 0 | 3 | +| 2 | (0,0) | (3,0) | 2 + 0 + 0 = 2 | 0 + 3 = 3 | 3 | +| 3 (root) | (2,3) | (1,0) | 3 + 3 + 0 = 6 | 3 + 1 = 4 | 7 | -**2.3 Trace Walkthrough:** +**2.4 Return Result:** +The final result is max(rob_root, dont_rob_root) = max(6, 4) = 7. + +### Solution + +```python +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def rob(self, root: Optional[TreeNode]) -> int: + def dfs(node): + if not node: + return (0, 0) # (rob this node, don't rob this node) + + left = dfs(node.left) + right = dfs(node.right) + + # If we rob this node, we can't rob children + rob_this = node.val + left[1] + right[1] + + # If we don't rob this node, we can choose to rob or not rob children + dont_rob_this = max(left) + max(right) + + return (rob_this, dont_rob_this) + + return max(dfs(root)) +``` -**Insert "apple":** +## 647. Palindromic Substrings [Medium] +https://leetcode.com/problems/palindromic-substrings/ -| Step | Current Node | Character | Action | New Node Created? | -|------|--------------|-----------|--------|-------------------| -| 1 | root | 'a' | Create node for 'a' | Yes | -| 2 | a-node | 'p' | Create node for 'p' | Yes | -| 3 | p-node | 'p' | Create node for 'p' | Yes | -| 4 | p-node | 'l' | Create node for 'l' | Yes | -| 5 | l-node | 'e' | Create node for 'e', mark as end | Yes | +### Explanation -**Search "apple":** +## 647. Longest Subarray of 1's After Deleting One Element [Medium] -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | Move to 'p' node | -| 4 | p-node | 'l' | Yes | Move to 'l' node | -| 5 | l-node | 'e' | Yes | Check is_end → true → Return true | +https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element -**Search "app":** +## Description +Given a binary array nums, you should delete one element from it. -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | Check is_end → false → Return false | +Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray. -**startsWith "app":** +**Examples** +```text +Input: nums = [1,1,0,1] +Output: 3 +Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. -| Step | Current Node | Character | Found? | Action | -|------|--------------|-----------|--------|--------| -| 1 | root | 'a' | Yes | Move to 'a' node | -| 2 | a-node | 'p' | Yes | Move to 'p' node | -| 3 | p-node | 'p' | Yes | All characters found → Return true | +Input: nums = [0,1,1,1,0,1,1,0,1] +Output: 5 +Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. -**2.4 Insert "app" and Search Again:** +Input: nums = [1,1,1] +Output: 2 +Explanation: You must delete one element. +``` +**Constraints** +```text +- 1 <= nums.length <= 10^5 +- nums[i] is either 0 or 1. +``` -After inserting "app", the second 'p' node now has `is_end = true`. So searching "app" will now return true. +## Hint +Use a sliding window to keep at most one zero in the window. -**2.5 Return Result:** +## Explanation +We want the longest run of 1's after deleting one element. That means we can have at most one zero in our current window, since deleting it would leave only 1's. -The Trie correctly handles all operations, allowing efficient word storage and prefix matching. +We use a sliding window to keep track of the current sequence. Every time we have more than one zero, we move the left end of the window forward until we're back to at most one zero. -> **Note:** The key difference between `search` and `startsWith` is that `search` requires the final node to be marked as an end-of-word, while `startsWith` only requires that the path exists. +We do this because it lets us efficiently find the longest possible sequence without checking every possible subarray. By only moving the window when needed, we keep our solution fast and memory-efficient, especially for large arrays. ### Solution ```python -def __init__(self): - self.children = {} - self.is_end = False - -class Trie: - def __init__(self): - self.root = TrieNode() - - def insert(self, word: str) -> None: - node = self.root - for char in word: - if char not in node.children: - node.children[char] = TrieNode() - node = node.children[char] - node.is_end = True - - def search(self, word: str) -> bool: - node = self.root - for char in word: - if char not in node.children: - return False - node = node.children[char] - return node.is_end - - def startsWith(self, prefix: str) -> bool: - node = self.root - for char in prefix: - if char not in node.children: - return False - node = node.children[char] - return True +def longestSubarray(nums): + left = 0 + zeros = 0 + max_len = 0 + for right in range(len(nums)): + if nums[right] == 0: + zeros += 1 + while zeros > 1: + if nums[left] == 0: + zeros -= 1 + left += 1 + max_len = max(max_len, right - left) + return max_len ``` -## 230. Kth Smallest Element in a BST [Medium] -https://leetcode.com/problems/kth-smallest-element-in-a-bst/ +## 981. Time Based Key-Value Store [Medium] +https://leetcode.com/problems/time-based-key-value-store/ ### Explanation @@ -2678,122 +3149,114 @@ https://leetcode.com/problems/kth-smallest-element-in-a-bst/ ### Strategy (The "Why") -Given the root of a binary search tree (BST) and an integer $k$, we need to find the $k$-th smallest element in the BST. - **1.1 Constraints & Complexity:** -- **Input Size:** The number of nodes $N$ in the BST can be up to $10^4$. -- **Value Range:** Node values are between $1$ and $10^4$. -- **Time Complexity:** $O(n)$ - We traverse all nodes in the BST using in-order traversal, which visits each node exactly once. -- **Space Complexity:** $O(n)$ - In the worst case (a skewed tree), the recursion stack can be $O(n)$ deep. Additionally, we store all node values in a list, which requires $O(n)$ space. -- **Edge Case:** If $k$ is 1, we return the smallest element. If $k$ equals the number of nodes, we return the largest element. +- **Input Size:** `1 <= key.length, value.length <= 100`, `1 <= timestamp <= 10^7`, at most `2 * 10^5` calls to set and get. +- **Time Complexity:** + - `set`: O(1) - append to list. + - `get`: O(log m) where m is the number of timestamps for the key (binary search). +- **Space Complexity:** O(n) where n is the total number of set operations. +- **Edge Case:** If a key doesn't exist or no timestamp <= given timestamp exists, return empty string. **1.2 High-level approach:** -The goal is to find the $k$-th smallest element in a BST. - -![BST In-order Traversal](https://assets.leetcode.com/uploads/2021/01/28/kthtree1.jpg) +The goal is to design a time-based key-value store that can store multiple values for the same key at different timestamps and retrieve the value associated with the largest timestamp that is <= the given timestamp. We use a dictionary to map keys to lists of (timestamp, value) pairs, and use binary search to efficiently find the correct value. -A key property of a BST is that an in-order traversal (left → root → right) visits nodes in ascending order. Therefore, the $k$-th element visited during an in-order traversal is the $k$-th smallest element. +![Visualization showing how timestamps are stored and retrieved using binary search to find the largest timestamp <= target] **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Perform an in-order traversal to collect all node values in a list, then return the element at index $k-1$. This approach is straightforward and works correctly. -- **Optimized Strategy:** We can optimize by stopping the traversal once we've found the $k$-th element, using an iterative approach or early termination in recursion. However, for clarity and beginner-friendliness, we'll use the complete traversal approach. -- **Why it's better:** The brute force approach is actually quite efficient for this problem. A more optimized version would use iterative in-order traversal with early termination, but the complete traversal approach is easier to understand. +- **Brute Force:** For `get`, iterate through all timestamps for a key to find the largest one <= target. This takes O(m) time where m is the number of timestamps. +- **Optimized Strategy:** Since timestamps are strictly increasing, we can use binary search to find the answer in O(log m) time. +- **Why it's better:** Binary search reduces the time complexity from O(m) to O(log m), which is crucial when there are many timestamps for a key. **1.4 Decomposition:** -1. Perform an in-order traversal of the BST (visit left subtree, then root, then right subtree). -2. Collect all node values in a list during the traversal. -3. Since in-order traversal of a BST produces values in sorted order, the list will be sorted. -4. Return the element at index $k-1$ (since $k$ is 1-indexed). +1. Initialize a dictionary to store key -> list of (timestamp, value) pairs. +2. For `set`: Append (timestamp, value) to the list for the key. +3. For `get`: Use binary search to find the largest timestamp <= target timestamp. +4. Return the corresponding value, or empty string if not found. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's use the example: root = $[3, 1, 4, null, 2]$, $k = 1$ - -The BST structure: -``` - 3 - / \ - 1 4 - \ - 2 -``` - -We initialize: -- An empty list `res = []` to store node values -- We'll perform in-order traversal starting from the root +Let's trace through the example operations: +- `set("foo", "bar", 1)` +- `get("foo", 1)` -> should return "bar" +- `get("foo", 3)` -> should return "bar" (largest timestamp <= 3 is 1) +- `set("foo", "bar2", 4)` +- `get("foo", 4)` -> should return "bar2" +- `get("foo", 5)` -> should return "bar2" (largest timestamp <= 5 is 4) -**2.2 Start Traversing:** +**2.2 Start Checking:** -We begin the in-order traversal from the root node (value 3). +Initialize: `store = {}` **2.3 Trace Walkthrough:** -The in-order traversal visits nodes in this order: - -| Step | Current Node | Action | List State | -|------|--------------|--------|------------| -| 1 | 3 (root) | Go to left child (1) | [] | -| 2 | 1 | Go to left child (null) | [] | -| 3 | null | Return (base case) | [] | -| 4 | 1 | Add 1 to list | [1] | -| 5 | 1 | Go to right child (2) | [1] | -| 6 | 2 | Go to left child (null) | [1] | -| 7 | null | Return (base case) | [1] | -| 8 | 2 | Add 2 to list | [1, 2] | -| 9 | 2 | Go to right child (null) | [1, 2] | -| 10 | null | Return (base case) | [1, 2] | -| 11 | 3 | Add 3 to list | [1, 2, 3] | -| 12 | 3 | Go to right child (4) | [1, 2, 3] | -| 13 | 4 | Go to left child (null) | [1, 2, 3] | -| 14 | null | Return (base case) | [1, 2, 3] | -| 15 | 4 | Add 4 to list | [1, 2, 3, 4] | -| 16 | 4 | Go to right child (null) | [1, 2, 3, 4] | -| 17 | null | Return (base case) | [1, 2, 3, 4] | - -After traversal: `res = [1, 2, 3, 4]` +| Operation | Key | Timestamp/Value | Store state | Action | +|-----------|-----|-----------------|-------------|--------| +| set | "foo" | ("bar", 1) | {"foo": [(1, "bar")]} | Append to list | +| get | "foo" | 1 | - | Binary search: find timestamp <= 1 | +| - | - | - | - | Found (1, "bar"), return "bar" | +| get | "foo" | 3 | - | Binary search: find timestamp <= 3 | +| - | - | - | - | Found (1, "bar"), return "bar" | +| set | "foo" | ("bar2", 4) | {"foo": [(1, "bar"), (4, "bar2")]} | Append to list | +| get | "foo" | 4 | - | Binary search: find timestamp <= 4 | +| - | - | - | - | Found (4, "bar2"), return "bar2" | +| get | "foo" | 5 | - | Binary search: find timestamp <= 5 | +| - | - | - | - | Found (4, "bar2"), return "bar2" | + +Binary search details for `get("foo", 3)`: +- List: `[(1, "bar"), (4, "bar2")]` +- left = 0, right = 1 +- mid = 0, values[0][0] = 1 <= 3, so res = "bar", left = 1 +- left = 1, right = 1, mid = 1, values[1][0] = 4 > 3, so right = 0 +- left = 1 > right = 0, exit loop +- Return "bar" -**2.4 Return Result:** +**2.4 Increment and Loop:** -Since $k = 1$ (1-indexed), we return `res[0] = 1`, which is the 1st smallest element. +Binary search continues until left > right. -For $k = 3$, we would return `res[2] = 3`, which is the 3rd smallest element. +**2.5 Return Result:** -> **Note:** In-order traversal of a BST always produces values in ascending order because of the BST property: all values in the left subtree are less than the root, and all values in the right subtree are greater than the root. +Return the value associated with the largest timestamp <= target, or "" if not found. ### Solution ```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right +def __init__(self): + self.store = {} # key -> list of (timestamp, value) pairs -class Solution: - def kthSmallest(self, root, k: int) -> int: - # In-order traversal to get elements in sorted order - res = [] + def set(self, key: str, value: str, timestamp: int) -> None: + if key not in self.store: + self.store[key] = [] + self.store[key].append((timestamp, value)) + + def get(self, key: str, timestamp: int) -> str: + if key not in self.store: + return "" - def inorder(node): - if not node: - return - inorder(node.left) - res.append(node.val) - inorder(node.right) + # Binary search for the largest timestamp <= given timestamp + values = self.store[key] + left, right = 0, len(values) - 1 + res = "" - inorder(root) + while left <= right: + mid = (left + right) // 2 + if values[mid][0] <= timestamp: + res = values[mid][1] + left = mid + 1 + else: + right = mid - 1 - # Return the k-th smallest element (1-indexed) - return res[k - 1] + return res ``` -## 234. Palindrome Linked List [Easy] -https://leetcode.com/problems/palindrome-linked-list/ +## 23. Merge k Sorted Lists [Hard] +https://leetcode.com/problems/merge-k-sorted-lists/ ### Explanation @@ -2801,62 +3264,72 @@ https://leetcode.com/problems/palindrome-linked-list/ ### Strategy (The "Why") -The problem asks us to determine if a singly linked list is a palindrome (reads the same forwards and backwards). +Given an array of $k$ sorted linked lists, we need to merge all of them into one sorted linked list and return it. **1.1 Constraints & Complexity:** -- **Input Constraints:** The list has $1 \leq n \leq 10^5$ nodes, with values in $[0, 9]$. -- **Time Complexity:** $O(n)$ - We traverse the list once to collect values, then compare them. -- **Space Complexity:** $O(n)$ - We store all node values in an array for comparison. -- **Edge Case:** A single-node list is always a palindrome. +- **Input Size:** $k$ can be between $0$ and $10^4$, and the total number of nodes can be up to $10^4$. +- **Value Range:** Node values are between $-10^4$ and $10^4$. +- **Time Complexity:** $O(n \log k)$ where $n$ is the total number of nodes. We use a heap of size $k$, and each insertion/extraction takes $O(\log k)$ time. We do this for $n$ nodes. +- **Space Complexity:** $O(k)$ - We maintain a heap of size $k$. +- **Edge Case:** If the array is empty, return null. If all lists are empty, return null. **1.2 High-level approach:** -The goal is to check if the linked list values form a palindrome. We convert the list to an array, then use two pointers to compare values from both ends. +The goal is to merge $k$ sorted linked lists into one sorted list. -![Palindrome Linked List](https://assets.leetcode.com/uploads/2021/03/03/pal1linked-list.jpg) +We use a min heap to always get the smallest node among all lists. We add the first node from each list to the heap, then repeatedly extract the minimum, add it to the result, and add the next node from that list to the heap. **1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Reverse the entire list, then compare with original. This requires $O(n)$ time and $O(n)$ space for the reversed list. -- **Optimized (Array Conversion):** Convert list to array, then use two pointers. This takes $O(n)$ time and $O(n)$ space. -- **Emphasize the optimization:** While both approaches have similar complexity, the array approach is simpler and more intuitive. For $O(1)$ space, we could reverse half the list, but that's more complex. +- **Brute Force:** Merge lists one by one. This takes $O(kn)$ time where $n$ is the average list length. +- **Optimized Strategy (Min Heap):** Use a min heap to efficiently get the minimum node at each step. This takes $O(n \log k)$ time. +- **Why it's better:** The heap approach reduces time complexity by maintaining only $k$ nodes in the heap instead of comparing all $k$ lists at each step. **1.4 Decomposition:** -1. **Convert to Array:** Traverse the list and store all values in an array. -2. **Two-Pointer Comparison:** Use left and right pointers to compare values from both ends. -3. **Check Match:** If any pair doesn't match, return `False`. If all pairs match, return `True`. +1. Create a min heap and add the first node from each non-empty list. +2. Create a dummy node to simplify edge cases. +3. While the heap is not empty: + - Extract the minimum node from the heap. + - Add it to the result list. + - If that node has a next node, add the next node to the heap. +4. Return the head of the merged list. ### Steps (The "How") **2.1 Initialization & Example Setup:** -Let's trace through an example: `head = [1,2,2,1]`. +Let's use the example: $lists = [[1,4,5],[1,3,4],[2,6]]$ -After conversion: `values = [1, 2, 2, 1]` +We initialize: +- `heap = [(1,0,node1), (1,1,node1), (2,2,node2)]` +- `dummy = ListNode(0)` +- `current = dummy` -**2.2 Start Checking:** +**2.2 Start Merging:** -Initialize `left = 0` and `right = len(values) - 1 = 3`. +We begin extracting from the heap. **2.3 Trace Walkthrough:** -| Step | left | right | values[left] | values[right] | Match? | Action | -|------|------|-------|--------------|----------------|--------|--------| -| 1 | 0 | 3 | 1 | 1 | Yes | Continue | -| 2 | 1 | 2 | 2 | 2 | Yes | Continue | -| 3 | 2 | 1 | - | - | - | Stop (left >= right) | +| Step | Extract | current.next | Add to heap | heap After | +|------|---------|--------------|-------------|------------| +| 1 | (1,0) | 1 | (4,0) | [(1,1), (2,2), (4,0)] | +| 2 | (1,1) | 1 | (3,1) | [(2,2), (3,1), (4,0)] | +| 3 | (2,2) | 2 | (6,2) | [(3,1), (4,0), (6,2)] | +| 4 | (3,1) | 3 | (4,1) | [(4,0), (4,1), (6,2)] | +| ... | ... | ... | ... | ... | -**2.4 Complete Comparison:** +**2.4 Final Result:** -All pairs matched: (1,1) and (2,2). +After merging: $[1,1,2,3,4,4,5,6]$ **2.5 Return Result:** -Since all comparisons passed, the function returns `True`. +We return the head of the merged list: $[1,1,2,3,4,4,5,6]$. -> **Note:** The two-pointer technique efficiently checks palindromes by comparing symmetric positions without needing to reverse the list. +> **Note:** The key insight is to use a min heap to efficiently get the minimum node among all lists at each step. By maintaining only the current head of each list in the heap, we avoid storing all nodes and achieve $O(n \log k)$ time complexity. ### Solution @@ -2864,248 +3337,318 @@ Since all comparisons passed, the function returns `True`. def __init__(self, val=0, next=None): # self.val = val # self.next = next + +from typing import List +import heapq + class Solution: - def isPalindrome(self, head: Optional[ListNode]) -> bool: - # Convert linked list to array - values = [] - current = head - while current: - values.append(current.val) - current = current.next + def mergeKLists(self, lists: List[ListNode]) -> ListNode: + # Create a min heap + heap = [] - # Check if array is palindrome - left, right = 0, len(values) - 1 - while left < right: - if values[left] != values[right]: - return False - left += 1 - right -= 1 + # Add first node from each list to heap + for i, node in enumerate(lists): + if node: + heapq.heappush(heap, (node.val, i, node)) - return True + # Create dummy node + dummy = ListNode(0) + current = dummy + + # Merge lists + while heap: + val, idx, node = heapq.heappop(heap) + current.next = node + current = current.next + + # Add next node from the same list if it exists + if node.next: + heapq.heappush(heap, (node.next.val, idx, node.next)) + + return dummy.next ``` -## 236. Lowest Common Ancestor of a Binary Tree [Medium] -https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ +## 42. Trapping Rain Water [Hard] +https://leetcode.com/problems/trapping-rain-water/ ### Explanation +## 42. Trapping Rain Water [Hard] + +https://leetcode.com/problems/trapping-rain-water + +## Description +Given `n` non-negative integers representing an elevation map where the width of each bar is `1`, compute how much water it can trap after raining. + +**Examples** + +```text +Example 1: +Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] +Output: 6 +Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. + +Example 2: +Input: height = [4,2,0,3,2,5] +Output: 9 +``` + +**Constraints** +```text +- n == height.length +- 1 <= n <= 2 * 10^4 +- 0 <= height[i] <= 10^5 +``` + ## Explanation -### Strategy (The "Why") +### Strategy +Let's restate the problem: You're given an array representing the heights of walls in a landscape. When it rains, water gets trapped between these walls. Your job is to calculate how much water can be trapped. -The problem asks us to find the lowest common ancestor (LCA) of two nodes in a binary tree. The LCA is the deepest node that has both nodes as descendants (a node can be a descendant of itself). +This is a **two-pointer and dynamic programming problem** that requires understanding how water trapping works in real life. -**1.1 Constraints & Complexity:** +**What is given?** An array of non-negative integers representing wall heights. -- **Input Constraints:** The tree has $2 \leq n \leq 10^5$ nodes with unique values in $[-10^9, 10^9]$. -- **Time Complexity:** $O(n)$ - We may need to visit all nodes in the worst case. -- **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. -- **Edge Case:** If one node is an ancestor of the other, return that ancestor node. +**What is being asked?** Calculate the total amount of water that can be trapped between the walls. -**1.2 High-level approach:** +**Constraints:** The array can be quite large (up to 20,000 elements), so we need an efficient solution. All heights are non-negative. -The goal is to find the deepest node that is an ancestor of both target nodes. We use recursive DFS: if we find both nodes in a subtree, the current root is the LCA. +**Edge cases:** +- If the array has less than 3 elements, no water can be trapped (need at least 3 walls to form a container) +- If all heights are the same, no water can be trapped +- If heights are strictly increasing or decreasing, no water can be trapped -![Binary Tree LCA](https://assets.leetcode.com/uploads/2018/12/14/binarytree.png) +**High-level approach:** +The key insight is that for any position, the amount of water that can be trapped depends on the **minimum** of the highest wall to its left and the highest wall to its right. Water can only be trapped up to the height of the shorter of these two walls. -**1.3 Brute force vs. optimized strategy:** +Think of it like this: at any point, water will rise to the level of the lower "dam" on either side. If you're in a valley between two mountains, the water level is limited by the shorter mountain. -- **Brute Force:** Find paths to both nodes, then find the last common node in both paths. This requires storing paths and takes $O(n)$ time and $O(n)$ space. -- **Optimized (Recursive DFS):** Recursively search both subtrees. If both subtrees return non-null, the current root is the LCA. This takes $O(n)$ time and $O(h)$ space. -- **Emphasize the optimization:** The recursive approach finds the LCA in a single pass without storing paths, making it more space-efficient. +**Decomposition:** +1. **Precompute left and right maximums**: For each position, find the highest wall to its left and right +2. **Calculate trapped water**: For each position, the trapped water is the minimum of left and right max, minus the current height (if positive) +3. **Sum up all trapped water**: Add up the water trapped at each position -**1.4 Decomposition:** +**Brute force vs. optimized strategy:** +- **Brute force**: For each position, scan left and right to find maximums. This takes O(n²) time. +- **Optimized**: Precompute left and right maximums in two passes, then calculate water in one pass. This takes O(n) time. -1. **Base Case:** If root is `None` or equals `p` or `q`, return root. -2. **Recursive Search:** Recursively search left and right subtrees for `p` and `q`. -3. **Combine Results:** If both subtrees return non-null, root is the LCA. Otherwise, return whichever subtree found a node. +### Steps +Let's walk through the solution step by step using the first example: `height = [0,1,0,2,1,0,1,3,2,1,2,1]` -### Steps (The "How") +**Step 1: Understand the visualization** +Imagine this array as a landscape: +``` + ■ + ■ ■ ■ + ■ ■ ■ ■ ■ ■ ■ ■ +■ ■ ■ ■ ■ ■ ■ ■ ■ ■ +0 1 0 2 1 0 1 3 2 1 2 1 +``` -**2.1 Initialization & Example Setup:** +**Step 2: Precompute left maximums** +We'll create an array `left_max` where `left_max[i]` is the highest wall to the left of position `i` (including position `i` itself). -Let's trace through an example: `root = [3,5,1,6,2,0,8,null,null,7,4]`, `p = 5`, `q = 1`. +``` +height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] +left_max: [0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3] +``` -**2.2 Start Searching:** +How we calculate this: +- `left_max[0] = height[0] = 0` (no walls to the left) +- `left_max[1] = max(left_max[0], height[1]) = max(0, 1) = 1` +- `left_max[2] = max(left_max[1], height[2]) = max(1, 0) = 1` +- `left_max[3] = max(left_max[2], height[3]) = max(1, 2) = 2` +- And so on... -Begin at root node `3`. +**Step 3: Precompute right maximums** +Similarly, create `right_max` where `right_max[i]` is the highest wall to the right of position `i` (including position `i` itself). -**2.3 Trace Walkthrough:** +``` +height: [0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1] +right_max: [3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1] +``` -| Node | Left Result | Right Result | Action | -|------|-------------|--------------|---------| -| 3 | Search left (5) | Search right (1) | Both found → Return 3 | -| 5 | Search left (6) | Search right (2) | Found p → Return 5 | -| 1 | Search left (0) | Search right (8) | Found q → Return 1 | +How we calculate this (from right to left): +- `right_max[11] = height[11] = 1` (no walls to the right) +- `right_max[10] = max(right_max[11], height[10]) = max(1, 2) = 2` +- `right_max[9] = max(right_max[10], height[9]) = max(2, 1) = 2` +- And so on... -**2.4 Recursive Unwinding:** +**Step 4: Calculate trapped water at each position** +For each position `i`, the water trapped is: +``` +water[i] = min(left_max[i], right_max[i]) - height[i] +``` -- Node `5` returns itself (found `p`). -- Node `1` returns itself (found `q`). -- Node `3` receives both results, so it's the LCA. +But only if this value is positive (we can't have negative water). -**2.5 Return Result:** +Let's calculate for a few positions: +- Position 0: `min(0, 3) - 0 = 0` (no water trapped) +- Position 1: `min(1, 3) - 1 = 0` (no water trapped) +- Position 2: `min(1, 3) - 0 = 1` (1 unit of water trapped) +- Position 3: `min(2, 3) - 2 = 0` (no water trapped) +- Position 4: `min(2, 3) - 1 = 1` (1 unit of water trapped) +- Position 5: `min(2, 3) - 0 = 2` (2 units of water trapped) -The function returns node `3`, which is the LCA of nodes `5` and `1`. +**Step 5: Sum up all trapped water** +``` +water = [0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 0] +total = 0 + 0 + 1 + 0 + 1 + 2 + 1 + 0 + 0 + 1 + 0 + 0 = 6 +``` -> **Note:** The key insight is that if both left and right subtrees return non-null, the current root must be the LCA. If only one subtree returns non-null, that subtree contains the LCA. +> **Note:** The key insight is that water can only be trapped up to the height of the lower "dam" on either side. This is why we take the minimum of the left and right maximums. + +**Time Complexity:** O(n) - we make three passes through the array +**Space Complexity:** O(n) - we store two additional arrays of size n ### Solution ```python -def __init__(self, x): -# self.val = x -# self.left = None -# self.right = None - -class Solution: - def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': - # Base case: if root is None or root is p or q, return root - if not root or root == p or root == q: - return root - - # Recursively search in left and right subtrees - left = self.lowestCommonAncestor(root.left, p, q) - right = self.lowestCommonAncestor(root.right, p, q) - - # If both left and right return non-None, root is the LCA - if left and right: - return root +def trap(height): + """ + Calculate the amount of water that can be trapped between walls. + + Args: + height: List[int] - Array representing wall heights - # Otherwise, return whichever side found p or q - return left if left else right + Returns: + int - Total amount of water trapped + """ + # Handle edge cases + if not height or len(height) < 3: + return 0 + + n = len(height) + + # Step 1: Precompute left maximums + # left_max[i] = highest wall to the left of position i (including i) + left_max = [0] * n + left_max[0] = height[0] + + for i in range(1, n): + left_max[i] = max(left_max[i-1], height[i]) + + # Step 2: Precompute right maximums + # right_max[i] = highest wall to the right of position i (including i) + right_max = [0] * n + right_max[n-1] = height[n-1] + + for i in range(n-2, -1, -1): + right_max[i] = max(right_max[i+1], height[i]) + + # Step 3: Calculate trapped water at each position + res = 0 + for i in range(n): + # Water trapped = min(left_max, right_max) - current_height + # But only if positive (can't have negative water) + water = min(left_max[i], right_max[i]) - height[i] + if water > 0: + res += water + + return res ``` -## 242. Valid Anagram [Easy] -https://leetcode.com/problems/valid-anagram/ +## 124. Binary Tree Maximum Path Sum [Hard] +https://leetcode.com/problems/binary-tree-maximum-path-sum/ ### Explanation -Given two strings `s` and `t`, return `true` if `t` is an [anagram](https://en.wikipedia.org/wiki/Anagram) of `s`, and `false` otherwise. - -**Examples** +## Explanation -```tex -Example 1: -Input: s = "anagram", t = "nagaram" -Output: true +### Strategy (The "Why") -Example 2: -Input: s = "rat", t = "car" -Output: false -``` +**1.1 Constraints & Complexity** -**Constraints** -```tex -- 1 <= s.length, t.length <= 5 * 10^4 -- s and t consist of lowercase English letters -``` +* **Input Size:** The tree has $1 \leq n \leq 3 \times 10^4$ nodes, with values in $[-1000, 1000]$. +* **Time Complexity:** $O(n)$ - We visit each node exactly once during DFS traversal. +* **Space Complexity:** $O(h)$ - The recursion stack depth is at most the height $h$ of the tree. In worst case (skewed tree), $h = n$. +* **Edge Case:** A single-node tree returns the node's value. All negative values require careful handling (we use `max(0, ...)` to avoid negative contributions). -**Follow up:** What if the inputs contain Unicode characters? How would you adapt your solution to such a case? +**1.2 High-level approach** -## Explanation +The goal is to find the maximum path sum in a binary tree, where a path can start and end at any nodes (not necessarily root or leaf). We use DFS to calculate the maximum path sum that can be extended upward from each node, while tracking the global maximum. -### Strategy -Let's restate the problem: You're given two strings, and you need to determine if one is an anagram of the other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. +![Maximum path sum visualization showing paths that can go through any node] -This is a **character counting problem** that can be solved using hash tables to track the frequency of each character in both strings. +**1.3 Brute force vs. optimized strategy** -**What is given?** Two strings `s` and `t` of potentially different lengths. +* **Brute Force:** Try all possible paths in the tree. This is exponential in complexity. +* **Optimized (DFS with Global Tracking):** For each node, calculate the maximum path sum that can be extended upward (for parent) and the maximum path sum through the node (for global maximum). This achieves $O(n)$ time. -**What is being asked?** Determine if `t` is an anagram of `s`. +**1.4 Decomposition** -**Constraints:** The strings can be up to 50,000 characters long and contain only lowercase English letters. +1. **DFS Traversal:** Recursively visit each node. +2. **Calculate Contributions:** For each node, get maximum contributions from left and right subtrees (non-negative only). +3. **Update Global Maximum:** Calculate path sum through current node and update global maximum. +4. **Return Upward Contribution:** Return the maximum path sum that can be extended to parent. -**Edge cases:** -- Strings of different lengths -- Empty strings -- Strings with repeated characters -- Strings with all identical characters +### Steps (The "How") -**High-level approach:** -The solution involves counting the frequency of each character in both strings and comparing them. If the character counts match exactly, the strings are anagrams. +**2.1 Initialization & Example Setup** -**Decomposition:** -1. **Check length equality**: If strings have different lengths, they can't be anagrams -2. **Count characters in first string**: Use a hash table to track character frequencies -3. **Decrement counts for second string**: For each character in the second string, decrement its count -4. **Verify all counts are zero**: If any count is not zero, the strings are not anagrams +Let's use the example $root = [-10,9,20,null,null,15,7]$. -**Brute force vs. optimized strategy:** -- **Brute force**: Try all possible permutations of one string. This takes O(n!) time. -- **Optimized**: Use character counting with hash tables. This takes O(n) time. +We initialize: +* `res = -inf` (global maximum path sum) +* Start DFS from root node (-10) -### Steps -Let's walk through the solution step by step using the first example: `s = "anagram"`, `t = "nagaram"` +**2.2 Start Processing** -**Step 1: Check string lengths** -- `s.length = 7`, `t.length = 7` -- Lengths match ✓ +We call `dfs(root)`. -**Step 2: Initialize character count dictionary** -- `char_count = {}` +**2.3 Trace Walkthrough** -**Step 3: Count characters in first string (s)** -- `s = "anagram"` -- `char_count['a'] = 3` (appears 3 times) -- `char_count['n'] = 1` (appears 1 time) -- `char_count['g'] = 1` (appears 1 time) -- `char_count['r'] = 1` (appears 1 time) -- `char_count['m'] = 1` (appears 1 time) +| Node | left_sum | right_sum | Path Through Node | Return Value | res (after) | +|------|----------|-----------|-------------------|--------------|-------------| +| -10 | max(0, dfs(9)) | max(0, dfs(20)) | -10 + 0 + 0 = -10 | -10 + max(0,0) = -10 | -10 | +| 9 | 0 | 0 | 9 + 0 + 0 = 9 | 9 + 0 = 9 | 9 | +| 20 | max(0, dfs(15)) | max(0, dfs(7)) | 20 + 15 + 7 = 42 | 20 + max(15,7) = 35 | 42 | +| 15 | 0 | 0 | 15 + 0 + 0 = 15 | 15 + 0 = 15 | 42 | +| 7 | 0 | 0 | 7 + 0 + 0 = 7 | 7 + 0 = 7 | 42 | -**Step 4: Decrement counts for second string (t)** -- `t = "nagaram"` -- `t[0] = 'n'`: `char_count['n'] = 1 - 1 = 0` -- `t[1] = 'a'`: `char_count['a'] = 3 - 1 = 2` -- `t[2] = 'g'`: `char_count['g'] = 1 - 1 = 0` -- `t[3] = 'a'`: `char_count['a'] = 2 - 1 = 1` -- `t[4] = 'r'`: `char_count['r'] = 1 - 1 = 0` -- `t[5] = 'a'`: `char_count['a'] = 1 - 1 = 0` -- `t[6] = 'm'`: `char_count['m'] = 1 - 1 = 0` +**2.4 Recursive Processing** -**Step 5: Verify all counts are zero** -- All character counts are now 0 -- The strings are anagrams: `true` +For each node: +1. If `not node`, return 0 (base case) +2. Recursively get `left_sum = max(0, dfs(node.left))` (non-negative only) +3. Recursively get `right_sum = max(0, dfs(node.right))` (non-negative only) +4. Update global: `res = max(res, node.val + left_sum + right_sum)` +5. Return: `node.val + max(left_sum, right_sum)` (for parent) -**Why this works:** -By counting characters in the first string and then decrementing for the second string, we ensure that: -1. Both strings contain the same characters -2. Each character appears the same number of times in both strings -3. The final count of 0 for all characters confirms the anagram property +**2.5 Return Result** -> **Note:** The key insight is using character frequency counting to verify that both strings contain exactly the same characters with the same frequencies. This is much more efficient than trying to find permutations. +After processing all nodes, `res = 42`, which is the maximum path sum from the path $15 \to 20 \to 7$. -**Time Complexity:** O(n) - we visit each character once in each string -**Space Complexity:** O(k) - where k is the number of unique characters (bounded by the character set size) +> **Note:** We use `max(0, ...)` to ensure we only consider positive contributions from subtrees. If a subtree contributes negatively, we ignore it (treat as 0). ### Solution ```python -def isAnagram(s, t): - if len(s) != len(t): - return False - - char_count = {} - - for char in s: - char_count[char] = char_count.get(char, 0) + 1 - - for char in t: - if char not in char_count: - return False +def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def maxPathSum(self, root: Optional[TreeNode]) -> int: + res = float('-inf') - char_count[char] -= 1 + def dfs(node): + nonlocal res + if not node: + return 0 + + # Get max path sum from left and right subtrees + left_sum = max(0, dfs(node.left)) + right_sum = max(0, dfs(node.right)) + + # Update global maximum (path through current node) + res = max(res, node.val + left_sum + right_sum) + + # Return max path sum that can be extended upward + return node.val + max(left_sum, right_sum) - # If count becomes negative, strings are not anagrams - if char_count[char] < 0: - return False - - # Check if all counts are zero - for count in char_count.values(): - if count != 0: - return False - - return True + dfs(root) + return res ``` ## 297. Serialize and Deserialize Binary Tree [Hard] @@ -3229,104 +3772,22 @@ class Codec: values = data.split(",") root = TreeNode(int(values[0])) queue = [root] - i = 1 - - while queue and i < len(values): - node = queue.pop(0) - - if values[i] != "null": - node.left = TreeNode(int(values[i])) - queue.append(node.left) - i += 1 - - if i < len(values) and values[i] != "null": - node.right = TreeNode(int(values[i])) - queue.append(node.right) - i += 1 - - return root -``` - -## 337. House Robber III [Medium] -https://leetcode.com/problems/house-robber-iii/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -**1.1 Constraints & Complexity:** -- **Constraints:** The tree has at most 10^4 nodes, and each node value is between 0 and 10^4. -- **Time Complexity:** O(n) - We visit each node exactly once, where n is the number of nodes. -- **Space Complexity:** O(h) - The recursion stack depth is at most the height h of the tree. In the worst case (skewed tree), h = n, giving O(n) space. -- **Edge Case:** If the tree is empty (root is None), return 0. - -**1.2 High-level approach:** -The goal is to find the maximum amount of money we can rob from a binary tree without robbing two directly connected nodes. We use dynamic programming with a post-order traversal, where for each node we calculate two values: the maximum if we rob this node, and the maximum if we don't rob this node. - -![House Robber III tree](https://assets.leetcode.com/uploads/2021/03/10/rob1-tree.jpg) - -**1.3 Brute force vs. optimized strategy:** -- **Brute Force:** Try all possible combinations of robbing/not robbing each node, checking constraints. This would be exponential time O(2^n). -- **Optimized Strategy (DP with DFS):** For each node, calculate the maximum profit for two cases: robbing this node (can't rob children) and not robbing this node (can rob children). This takes O(n) time. -- **Emphasize the optimization:** By storing both possibilities at each node, we avoid recalculating subproblems and reduce time complexity from exponential to linear. - -**1.4 Decomposition:** -1. Perform a post-order traversal of the tree. -2. For each node, return a tuple: (rob_this, dont_rob_this). -3. If we rob this node, we can't rob its children, so we take children's "don't rob" values. -4. If we don't rob this node, we can choose the maximum from each child's two options. -5. Return the maximum of the root's two options. - -### Steps (The "How") - -**2.1 Initialization & Example Setup:** -Let's use an example: `root = [3,2,3,null,3,null,1]` - -Initialize: -- Start DFS from root node with value 3. - -**2.2 Start Processing:** -We traverse the tree using post-order DFS (process children before parent). - -**2.3 Trace Walkthrough:** - -| Node | Left Child Result | Right Child Result | Rob This | Don't Rob This | Max | -|------|-------------------|-------------------|----------|----------------|-----| -| 1 (leaf) | (0,0) | (0,0) | 1 + 0 + 0 = 1 | 0 + 0 = 0 | 1 | -| 3 (leaf) | (0,0) | (0,0) | 3 + 0 + 0 = 3 | 0 + 0 = 0 | 3 | -| 2 | (0,0) | (3,0) | 2 + 0 + 0 = 2 | 0 + 3 = 3 | 3 | -| 3 (root) | (2,3) | (1,0) | 3 + 3 + 0 = 6 | 3 + 1 = 4 | 7 | - -**2.4 Return Result:** -The final result is max(rob_root, dont_rob_root) = max(6, 4) = 7. - -### Solution - -```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def rob(self, root: Optional[TreeNode]) -> int: - def dfs(node): - if not node: - return (0, 0) # (rob this node, don't rob this node) - - left = dfs(node.left) - right = dfs(node.right) - - # If we rob this node, we can't rob children - rob_this = node.val + left[1] + right[1] + i = 1 + + while queue and i < len(values): + node = queue.pop(0) - # If we don't rob this node, we can choose to rob or not rob children - dont_rob_this = max(left) + max(right) + if values[i] != "null": + node.left = TreeNode(int(values[i])) + queue.append(node.left) + i += 1 - return (rob_this, dont_rob_this) + if i < len(values) and values[i] != "null": + node.right = TreeNode(int(values[i])) + queue.append(node.right) + i += 1 - return max(dfs(root)) + return root ``` ## 460. LFU Cache [Hard] @@ -3440,242 +3901,3 @@ def __init__(self, capacity: int): self.freq_to_keys[1][key] = None self.min_freq = 1 ``` - -## 543. Diameter of Binary Tree [Easy] -https://leetcode.com/problems/diameter-of-binary-tree/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -**1.1 Constraints & Complexity:** -- **Constraints:** Tree has between 1 and 10^4 nodes, and node values are between -100 and 100. -- **Time Complexity:** O(n) - We visit each node exactly once during DFS, where n is the number of nodes. -- **Space Complexity:** O(h) - The recursion stack depth is at most the height h of the tree. In the worst case (skewed tree), h = n, giving O(n) space. -- **Edge Case:** If the tree has only one node, the diameter is 0 (no edges). - -**1.2 High-level approach:** -The goal is to find the diameter (longest path between any two nodes) of a binary tree. The diameter may or may not pass through the root. We use DFS to calculate the depth of each subtree and track the maximum diameter found so far. - -![Diameter of Binary Tree](https://assets.leetcode.com/uploads/2021/03/06/diamtree.jpg) - -**1.3 Brute force vs. optimized strategy:** -- **Brute Force:** For each node, find the longest path passing through it by calculating depths of left and right subtrees. This still requires visiting each node once, so it's O(n) but with redundant calculations. -- **Optimized Strategy (DFS with Global Tracking):** Perform a single DFS pass, calculating subtree depths and updating the maximum diameter as we go. This takes O(n) time with a single traversal. -- **Emphasize the optimization:** By tracking the maximum diameter during a single DFS pass, we avoid multiple traversals and redundant calculations. - -**1.4 Decomposition:** -1. Perform DFS traversal of the tree. -2. For each node, calculate the depth of its left and right subtrees. -3. The diameter passing through this node is left_depth + right_depth. -4. Update the global maximum diameter if this is larger. -5. Return the depth of the current subtree (1 + max(left_depth, right_depth)). - -### Steps (The "How") - -**2.1 Initialization & Example Setup:** -Let's use an example: `root = [1,2,3,4,5]` - -Initialize: -- `res = 0` (global maximum diameter) - -**2.2 Start Processing:** -We perform DFS starting from the root. - -**2.3 Trace Walkthrough:** - -| Node | Left Depth | Right Depth | Diameter Through Node | Max Diameter | Return Depth | -|------|------------|-------------|----------------------|--------------|--------------| -| 4 (leaf) | 0 | 0 | 0 | 0 | 1 | -| 5 (leaf) | 0 | 0 | 0 | 0 | 1 | -| 2 | 1 | 1 | 2 | 2 | 2 | -| 3 (leaf) | 0 | 0 | 0 | 2 | 1 | -| 1 (root) | 2 | 1 | 3 | 3 | 3 | - -**2.4 Return Result:** -The maximum diameter found is 3, which is the path [4,2,1,3] or [5,2,1,3]. - -### Solution - -```python -def __init__(self, val=0, left=None, right=None): -# self.val = val -# self.left = left -# self.right = right -class Solution: - def diameterOfBinaryTree(self, root: Optional[TreeNode]) -> int: - res = 0 - - def dfs(node): - nonlocal res - if not node: - return 0 - - left_depth = dfs(node.left) - right_depth = dfs(node.right) - - # Diameter passing through this node - res = max(res, left_depth + right_depth) - - # Return depth of this subtree - return 1 + max(left_depth, right_depth) - - dfs(root) - return res -``` - -## 647. Palindromic Substrings [Medium] -https://leetcode.com/problems/palindromic-substrings/ - -### Explanation - -## 647. Longest Subarray of 1's After Deleting One Element [Medium] - -https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element - -## Description -Given a binary array nums, you should delete one element from it. - -Return the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray. - -**Examples** -```text -Input: nums = [1,1,0,1] -Output: 3 -Explanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's. - -Input: nums = [0,1,1,1,0,1,1,0,1] -Output: 5 -Explanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1]. - -Input: nums = [1,1,1] -Output: 2 -Explanation: You must delete one element. -``` -**Constraints** -```text -- 1 <= nums.length <= 10^5 -- nums[i] is either 0 or 1. -``` - -## Hint -Use a sliding window to keep at most one zero in the window. - -## Explanation -We want the longest run of 1's after deleting one element. That means we can have at most one zero in our current window, since deleting it would leave only 1's. - -We use a sliding window to keep track of the current sequence. Every time we have more than one zero, we move the left end of the window forward until we're back to at most one zero. - -We do this because it lets us efficiently find the longest possible sequence without checking every possible subarray. By only moving the window when needed, we keep our solution fast and memory-efficient, especially for large arrays. - -### Solution - -```python -def longestSubarray(nums): - left = 0 - zeros = 0 - max_len = 0 - for right in range(len(nums)): - if nums[right] == 0: - zeros += 1 - while zeros > 1: - if nums[left] == 0: - zeros -= 1 - left += 1 - max_len = max(max_len, right - left) - return max_len -``` - -## 876. Middle of the Linked List [Easy] -https://leetcode.com/problems/middle-of-the-linked-list/ - -### Explanation - -## Explanation - -### Strategy (The "Why") - -Given the head of a singly linked list, we need to return the middle node of the linked list. If there are two middle nodes, return the second one. - -**1.1 Constraints & Complexity:** - -- **Input Size:** The number of nodes can be between $1$ and $100$. -- **Value Range:** Node values are between $1$ and $100$. -- **Time Complexity:** $O(n)$ - We traverse the list once with two pointers. -- **Space Complexity:** $O(1)$ - We only use a constant amount of extra space for pointers. -- **Edge Case:** If the list has only one node, return that node. If the list has two nodes, return the second one. - -**1.2 High-level approach:** - -The goal is to find the middle node of a linked list. - -We use the "tortoise and hare" approach: one pointer moves one step at a time (slow), and another moves two steps at a time (fast). When the fast pointer reaches the end, the slow pointer is at the middle. - -**1.3 Brute force vs. optimized strategy:** - -- **Brute Force:** First pass to count nodes, second pass to find the middle node. This takes $O(n)$ time but requires two passes. -- **Optimized Strategy (Two Pointers):** Use two pointers moving at different speeds. This takes $O(n)$ time in a single pass. -- **Why it's better:** The two-pointer approach finds the middle in one pass instead of two, making it more efficient and elegant. - -**1.4 Decomposition:** - -1. Initialize two pointers (slow and fast) at the head. -2. Move slow one step and fast two steps at a time. -3. When fast reaches the end (null or last node), slow is at the middle. -4. Return the slow pointer. - -### Steps (The "How") - -**2.1 Initialization & Example Setup:** - -Let's use the example: $head = [1,2,3,4,5]$ - -We initialize: -- `slow = 1` -- `fast = 1` - -**2.2 Start Processing:** - -We begin moving the pointers. - -**2.3 Trace Walkthrough:** - -| Step | slow position | fast position | Action | -|------|---------------|---------------|--------| -| 0 | 1 | 1 | Start | -| 1 | 2 | 3 | Move slow 1, fast 2 | -| 2 | 3 | 5 | Move slow 1, fast 2 | -| 3 | 3 | null | fast.next is null, stop | - -**2.4 Explanation:** - -- When fast reaches the end (node 5, where fast.next is null), slow is at node 3, which is the middle node. - -**2.5 Return Result:** - -We return the node with value 3, which is the middle node. - -> **Note:** The key insight is that when the fast pointer moves twice as fast, it covers twice the distance. When it reaches the end, the slow pointer has covered half the distance, which is exactly the middle. - -### Solution - -```python -def __init__(self, val=0, next=None): -# self.val = val -# self.next = next - -class Solution: - def middleNode(self, head): - slow = head - fast = head - - # Move fast pointer twice as fast as slow pointer - while fast and fast.next: - slow = slow.next - fast = fast.next.next - - # When fast reaches the end, slow is at the middle - return slow -``` diff --git a/data/book-sets.json b/data/book-sets.json index 4e5f4cf..e7a9ed1 100644 --- a/data/book-sets.json +++ b/data/book-sets.json @@ -53,25 +53,20 @@ 1, 2, 3, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 33, 34, 35, 36, 39, 42, 45, 46, 48, 49, 50, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 84, 86, 88, 89, 92, 94, 97, 98, 100, 101, 102, 103, 104, 105, 106, 108, 112, 114, 116, 117, 120, 121, 122, 123, 124, 125, 127, 128, 129, 130, 133, 134, 135, 136, 137, 138, 139, 141, 142, - 146, 148, 149, 150, 151, 152, 153, 155, 160, 162, 167, 169, 172, 173, 188, 189, 190, 191, 198, 199, 200, 201, 202, 205, 206, 207, 208, 209, 210, - 211, 212, 215, 216, 217, 219, 221, 222, 224, 226, 228, 230, 234, 235, 236, 238, 240, 242, 268, 274, 278, 283, 287, 289, 290, 295, 297, 300, 322, - 328, 334, 337, 338, 344, 345, 347, 373, 374, 378, 380, 383, 392, 394, 399, 409, 412, 427, 433, 435, 437, 438, 443, 448, 450, 452, 460, 494, 502, - 509, 530, 543, 547, 560, 581, 605, 617, 637, 643, 647, 649, 695, 700, 701, 704, 714, 724, 733, 735, 739, 746, 790, 841, 872, 875, 876, 901, 909, - 918, 933, 973, 981, 994, 997, 1004, 1029, 1046, 1071, 1127, 1137, 1143, 1161, 1167, 1207, 1249, 1268, 1288, 1304, 1318, 1337, 1372, 1423, 1431, - 1448, 1456, 1466, 1480, 1493, 1515, 1523, 1528, 1557, 1584, 1657, 1672, 1679, 1704, 1732, 1768, 1798, 1920, 1925, 1926, 1929, 1957, 1963, 2011, - 2095, 2119, 2130, 2211, 2215, 2300, 2336, 2352, 2390, 2419, 2462, 2542, 2627, 2703, 2723, 2769, 2807, 2862, 2879, 2884, 2888, 2894, 2942, 3100, - 3110, 3133, 3164, 3190, 3197, 3228, 3291, 3320, 3351, 3380, 3381, 3413, 3424, 3432, 3444, 3471, 3512, 3522, 3602, 3603, 3606, 3607, 3608, 3622, - 3623, 3625, 3663, 3668, 3678, 3683, 3688, 3692, 3697, 3701, 3707, 3712, 3718, 3722, 3723, 3724, 3726, 3727, 3728, 3731, 3736, 3737, 3738, 3739, - 3740, 3741, 3742, 3743, 3745, 3747, 3748, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3759, 3760, 3761, 3762, 3764, 3765, 3766, 3767, 3768, - 3769, 3770, 3771, 3772 + 146, 148, 149, 150, 151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 162, 163, 167, 169, 170, 172, 173, 188, 189, 190, 191, 198, 199, 200, 201, + 202, 205, 206, 207, 208, 209, 210, 211, 212, 215, 216, 217, 219, 221, 222, 224, 226, 228, 230, 234, 235, 236, 238, 240, 242, 268, 274, 278, 283, + 287, 289, 290, 295, 297, 300, 322, 328, 334, 337, 338, 344, 345, 347, 373, 374, 378, 380, 383, 392, 394, 399, 409, 412, 427, 433, 435, 437, 438, + 443, 448, 450, 452, 460, 494, 502, 509, 530, 543, 547, 560, 581, 605, 617, 637, 643, 647, 649, 695, 700, 701, 704, 714, 724, 733, 735, 739, 746, + 790, 841, 872, 875, 876, 901, 909, 918, 933, 973, 981, 994, 997, 1004, 1029, 1046, 1071, 1127, 1137, 1143, 1161, 1167, 1207, 1249, 1268, 1288, + 1304, 1318, 1337, 1372, 1423, 1431, 1448, 1456, 1466, 1480, 1493, 1515, 1523, 1528, 1557, 1584, 1657, 1672, 1679, 1704, 1732, 1768, 1798, 1920, + 1925, 1926, 1929, 1957, 1963, 2011, 2095, 2119, 2130, 2211, 2215, 2300, 2336, 2352, 2390, 2419, 2462, 2542, 2627, 2703, 2723, 2769, 2807, 2862, + 2879, 2884, 2888, 2894, 2942, 3100, 3110, 3133, 3164, 3190, 3197, 3228, 3291, 3320, 3351, 3380, 3381, 3413, 3424, 3432, 3444, 3471, 3512, 3522, + 3602, 3603, 3606, 3607, 3608, 3622, 3623, 3625, 3663, 3668, 3678, 3683, 3688, 3692, 3697, 3701, 3707, 3712, 3718, 3722, 3723, 3724, 3726, 3727, + 3728, 3731, 3736, 3737, 3738, 3739, 3740, 3741, 3742, 3743, 3745, 3747, 3748, 3750, 3751, 3752, 3753, 3754, 3755, 3756, 3757, 3759, 3760, 3761, + 3762, 3764, 3765, 3766, 3767, 3768, 3769, 3770, 3771, 3772 ] }, - { - "title": "Visualization", - "description": "", - "tags": [], - "problems": [1, 2, 11, 1431, 1679, 1768, 1798, 2215, 3603, 3622, 3623] - }, + {"title": "Visualization", "description": "", "tags": [], "problems": [1, 2, 11, 1431, 1679, 1768, 1798, 2215, 3603, 3622, 3623]}, { "title": "All-TODO", "description": "", diff --git a/data/leetcode-problems.json b/data/leetcode-problems.json index 2029af6..d4b1819 100644 --- a/data/leetcode-problems.json +++ b/data/leetcode-problems.json @@ -1,26416 +1,25828 @@ { - "1": { - "id": 1, - "category": "Array & Hashing", - "title": "Two Sum", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-sum/" - }, + "1": {"category": "Array & Hashing", "difficulty": "Easy", "id": 1, "link": "https://leetcode.com/problems/two-sum/", "title": "Two Sum"}, "2": { - "id": 2, "category": "Linked List", - "title": "Add Two Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-two-numbers/" + "id": 2, + "link": "https://leetcode.com/problems/add-two-numbers/", + "title": "Add Two Numbers" }, "3": { - "id": 3, "category": "Sliding Window", - "title": "Longest Substring Without Repeating Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-substring-without-repeating-characters/" + "id": 3, + "link": "https://leetcode.com/problems/longest-substring-without-repeating-characters/", + "title": "Longest Substring Without Repeating Characters" }, "4": { - "id": 4, "category": "Binary Search", - "title": "Median of Two Sorted Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/median-of-two-sorted-arrays/" + "id": 4, + "link": "https://leetcode.com/problems/median-of-two-sorted-arrays/", + "title": "Median of Two Sorted Arrays" }, "5": { - "id": 5, "category": "Dynamic Programming", - "title": "Longest Palindromic Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindromic-substring/" + "id": 5, + "link": "https://leetcode.com/problems/longest-palindromic-substring/", + "title": "Longest Palindromic Substring" }, "6": { - "id": 6, "category": "Array & Hashing", - "title": "Zigzag Conversion", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zigzag-conversion/" + "id": 6, + "link": "https://leetcode.com/problems/zigzag-conversion/", + "title": "Zigzag Conversion" }, "7": { - "id": 7, "category": "Math & Geometry", - "title": "Reverse Integer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-integer/" + "id": 7, + "link": "https://leetcode.com/problems/reverse-integer/", + "title": "Reverse Integer" }, "8": { - "id": 8, "category": "Array & Hashing", - "title": "String to Integer (atoi)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/string-to-integer-atoi/" + "id": 8, + "link": "https://leetcode.com/problems/string-to-integer-atoi/", + "title": "String to Integer (atoi)" }, "9": { - "id": 9, "category": "Math & Geometry", - "title": "Palindrome Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/palindrome-number/" + "id": 9, + "link": "https://leetcode.com/problems/palindrome-number/", + "title": "Palindrome Number" }, "10": { - "id": 10, "category": "Dynamic Programming", - "title": "Regular Expression Matching", "difficulty": "Hard", - "link": "https://leetcode.com/problems/regular-expression-matching/" + "id": 10, + "link": "https://leetcode.com/problems/regular-expression-matching/", + "title": "Regular Expression Matching" }, "11": { - "id": 11, "category": "Greedy", - "title": "Container With Most Water", "difficulty": "Medium", - "link": "https://leetcode.com/problems/container-with-most-water/" + "id": 11, + "link": "https://leetcode.com/problems/container-with-most-water/", + "title": "Container With Most Water" }, "12": { - "id": 12, "category": "Math & Geometry", - "title": "Integer to Roman", "difficulty": "Medium", - "link": "https://leetcode.com/problems/integer-to-roman/" + "id": 12, + "link": "https://leetcode.com/problems/integer-to-roman/", + "title": "Integer to Roman" }, "13": { - "id": 13, "category": "Math & Geometry", - "title": "Roman to Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/roman-to-integer/" + "id": 13, + "link": "https://leetcode.com/problems/roman-to-integer/", + "title": "Roman to Integer" }, "14": { - "id": 14, "category": "Trie", - "title": "Longest Common Prefix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-common-prefix/" - }, - "15": { - "id": 15, - "category": "Two Pointers", - "title": "3Sum", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/3sum/" + "id": 14, + "link": "https://leetcode.com/problems/longest-common-prefix/", + "title": "Longest Common Prefix" }, + "15": {"category": "Two Pointers", "difficulty": "Medium", "id": 15, "link": "https://leetcode.com/problems/3sum/", "title": "3Sum"}, "16": { - "id": 16, "category": "Two Pointers", - "title": "3Sum Closest", "difficulty": "Medium", - "link": "https://leetcode.com/problems/3sum-closest/" + "id": 16, + "link": "https://leetcode.com/problems/3sum-closest/", + "title": "3Sum Closest" }, "17": { - "id": 17, "category": "Backtracking", - "title": "Letter Combinations of a Phone Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/letter-combinations-of-a-phone-number/" - }, - "18": { - "id": 18, - "category": "Two Pointers", - "title": "4Sum", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/4sum/" + "id": 17, + "link": "https://leetcode.com/problems/letter-combinations-of-a-phone-number/", + "title": "Letter Combinations of a Phone Number" }, + "18": {"category": "Two Pointers", "difficulty": "Medium", "id": 18, "link": "https://leetcode.com/problems/4sum/", "title": "4Sum"}, "19": { - "id": 19, "category": "Linked List", - "title": "Remove Nth Node From End of List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-nth-node-from-end-of-list/" + "id": 19, + "link": "https://leetcode.com/problems/remove-nth-node-from-end-of-list/", + "title": "Remove Nth Node From End of List" }, "20": { - "id": 20, "category": "Stack", - "title": "Valid Parentheses", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-parentheses/" + "id": 20, + "link": "https://leetcode.com/problems/valid-parentheses/", + "title": "Valid Parentheses" }, "21": { - "id": 21, "category": "Linked List", - "title": "Merge Two Sorted Lists", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-two-sorted-lists/" + "id": 21, + "link": "https://leetcode.com/problems/merge-two-sorted-lists/", + "title": "Merge Two Sorted Lists" }, "22": { - "id": 22, "category": "Dynamic Programming", - "title": "Generate Parentheses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generate-parentheses/" + "id": 22, + "link": "https://leetcode.com/problems/generate-parentheses/", + "title": "Generate Parentheses" }, "23": { - "id": 23, "category": "Heap (Priority Queue)", - "title": "Merge k Sorted Lists", "difficulty": "Hard", - "link": "https://leetcode.com/problems/merge-k-sorted-lists/" + "id": 23, + "link": "https://leetcode.com/problems/merge-k-sorted-lists/", + "title": "Merge k Sorted Lists" }, "24": { - "id": 24, "category": "Linked List", - "title": "Swap Nodes in Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/swap-nodes-in-pairs/" + "id": 24, + "link": "https://leetcode.com/problems/swap-nodes-in-pairs/", + "title": "Swap Nodes in Pairs" }, "25": { - "id": 25, "category": "Linked List", - "title": "Reverse Nodes in k-Group", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reverse-nodes-in-k-group/" + "id": 25, + "link": "https://leetcode.com/problems/reverse-nodes-in-k-group/", + "title": "Reverse Nodes in k-Group" }, "26": { - "id": 26, "category": "Two Pointers", - "title": "Remove Duplicates from Sorted Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-array/" + "id": 26, + "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-array/", + "title": "Remove Duplicates from Sorted Array" }, "27": { - "id": 27, "category": "Two Pointers", - "title": "Remove Element", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-element/" + "id": 27, + "link": "https://leetcode.com/problems/remove-element/", + "title": "Remove Element" }, "28": { - "id": 28, "category": "Two Pointers", - "title": "Find the Index of the First Occurrence in a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/" + "id": 28, + "link": "https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/", + "title": "Find the Index of the First Occurrence in a String" }, "29": { - "id": 29, "category": "Bit Manipulation", - "title": "Divide Two Integers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/divide-two-integers/" + "id": 29, + "link": "https://leetcode.com/problems/divide-two-integers/", + "title": "Divide Two Integers" }, "30": { - "id": 30, "category": "Sliding Window", - "title": "Substring with Concatenation of All Words", "difficulty": "Hard", - "link": "https://leetcode.com/problems/substring-with-concatenation-of-all-words/" + "id": 30, + "link": "https://leetcode.com/problems/substring-with-concatenation-of-all-words/", + "title": "Substring with Concatenation of All Words" }, "31": { - "id": 31, "category": "Two Pointers", - "title": "Next Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-permutation/" + "id": 31, + "link": "https://leetcode.com/problems/next-permutation/", + "title": "Next Permutation" }, "32": { - "id": 32, "category": "Dynamic Programming", - "title": "Longest Valid Parentheses", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-valid-parentheses/" + "id": 32, + "link": "https://leetcode.com/problems/longest-valid-parentheses/", + "title": "Longest Valid Parentheses" }, "33": { - "id": 33, "category": "Binary Search", - "title": "Search in Rotated Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-in-rotated-sorted-array/" + "id": 33, + "link": "https://leetcode.com/problems/search-in-rotated-sorted-array/", + "title": "Search in Rotated Sorted Array" }, "34": { - "id": 34, "category": "Binary Search", - "title": "Find First and Last Position of Element in Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/" + "id": 34, + "link": "https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/", + "title": "Find First and Last Position of Element in Sorted Array" }, "35": { - "id": 35, "category": "Binary Search", - "title": "Search Insert Position", "difficulty": "Easy", - "link": "https://leetcode.com/problems/search-insert-position/" + "id": 35, + "link": "https://leetcode.com/problems/search-insert-position/", + "title": "Search Insert Position" }, "36": { - "id": 36, "category": "Array & Hashing", - "title": "Valid Sudoku", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-sudoku/" + "id": 36, + "link": "https://leetcode.com/problems/valid-sudoku/", + "title": "Valid Sudoku" }, "37": { - "id": 37, "category": "Backtracking", - "title": "Sudoku Solver", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sudoku-solver/" + "id": 37, + "link": "https://leetcode.com/problems/sudoku-solver/", + "title": "Sudoku Solver" }, "38": { - "id": 38, "category": "Array & Hashing", - "title": "Count and Say", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-and-say/" + "id": 38, + "link": "https://leetcode.com/problems/count-and-say/", + "title": "Count and Say" }, "39": { - "id": 39, "category": "Backtracking", - "title": "Combination Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/combination-sum/" + "id": 39, + "link": "https://leetcode.com/problems/combination-sum/", + "title": "Combination Sum" }, "40": { - "id": 40, "category": "Backtracking", - "title": "Combination Sum II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/combination-sum-ii/" + "id": 40, + "link": "https://leetcode.com/problems/combination-sum-ii/", + "title": "Combination Sum II" }, "41": { - "id": 41, "category": "Array & Hashing", - "title": "First Missing Positive", "difficulty": "Hard", - "link": "https://leetcode.com/problems/first-missing-positive/" + "id": 41, + "link": "https://leetcode.com/problems/first-missing-positive/", + "title": "First Missing Positive" }, "42": { - "id": 42, "category": "Dynamic Programming", - "title": "Trapping Rain Water", "difficulty": "Hard", - "link": "https://leetcode.com/problems/trapping-rain-water/" + "id": 42, + "link": "https://leetcode.com/problems/trapping-rain-water/", + "title": "Trapping Rain Water" }, "43": { - "id": 43, "category": "Math & Geometry", - "title": "Multiply Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/multiply-strings/" + "id": 43, + "link": "https://leetcode.com/problems/multiply-strings/", + "title": "Multiply Strings" }, "44": { - "id": 44, "category": "Dynamic Programming", - "title": "Wildcard Matching", "difficulty": "Hard", - "link": "https://leetcode.com/problems/wildcard-matching/" + "id": 44, + "link": "https://leetcode.com/problems/wildcard-matching/", + "title": "Wildcard Matching" }, "45": { - "id": 45, "category": "Dynamic Programming", - "title": "Jump Game II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-ii/" + "id": 45, + "link": "https://leetcode.com/problems/jump-game-ii/", + "title": "Jump Game II" }, "46": { - "id": 46, "category": "Backtracking", - "title": "Permutations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/permutations/" + "id": 46, + "link": "https://leetcode.com/problems/permutations/", + "title": "Permutations" }, "47": { - "id": 47, "category": "Backtracking", - "title": "Permutations II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/permutations-ii/" + "id": 47, + "link": "https://leetcode.com/problems/permutations-ii/", + "title": "Permutations II" }, "48": { - "id": 48, "category": "Math & Geometry", - "title": "Rotate Image", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotate-image/" + "id": 48, + "link": "https://leetcode.com/problems/rotate-image/", + "title": "Rotate Image" }, "49": { - "id": 49, "category": "Array & Hashing", - "title": "Group Anagrams", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/group-anagrams/" - }, - "50": { - "id": 50, - "category": "Math & Geometry", - "title": "Pow(x, n)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/powx-n/" - }, - "51": { - "id": 51, - "category": "Backtracking", - "title": "N-Queens", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/n-queens/" - }, - "52": { - "id": 52, - "category": "Backtracking", - "title": "N-Queens II", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/n-queens-ii/" + "id": 49, + "link": "https://leetcode.com/problems/group-anagrams/", + "title": "Group Anagrams" }, + "50": {"category": "Math & Geometry", "difficulty": "Medium", "id": 50, "link": "https://leetcode.com/problems/powx-n/", "title": "Pow(x, n)"}, + "51": {"category": "Backtracking", "difficulty": "Hard", "id": 51, "link": "https://leetcode.com/problems/n-queens/", "title": "N-Queens"}, + "52": {"category": "Backtracking", "difficulty": "Hard", "id": 52, "link": "https://leetcode.com/problems/n-queens-ii/", "title": "N-Queens II"}, "53": { - "id": 53, "category": "Dynamic Programming", - "title": "Maximum Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subarray/" + "id": 53, + "link": "https://leetcode.com/problems/maximum-subarray/", + "title": "Maximum Subarray" }, "54": { - "id": 54, "category": "Array & Hashing", - "title": "Spiral Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/spiral-matrix/" + "id": 54, + "link": "https://leetcode.com/problems/spiral-matrix/", + "title": "Spiral Matrix" }, "55": { - "id": 55, "category": "Dynamic Programming", - "title": "Jump Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game/" + "id": 55, + "link": "https://leetcode.com/problems/jump-game/", + "title": "Jump Game" }, "56": { - "id": 56, "category": "Array & Hashing", - "title": "Merge Intervals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/merge-intervals/" + "id": 56, + "link": "https://leetcode.com/problems/merge-intervals/", + "title": "Merge Intervals" }, "57": { - "id": 57, "category": "Array & Hashing", - "title": "Insert Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insert-interval/" + "id": 57, + "link": "https://leetcode.com/problems/insert-interval/", + "title": "Insert Interval" }, "58": { - "id": 58, "category": "Array & Hashing", - "title": "Length of Last Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/length-of-last-word/" + "id": 58, + "link": "https://leetcode.com/problems/length-of-last-word/", + "title": "Length of Last Word" }, "59": { - "id": 59, "category": "Array & Hashing", - "title": "Spiral Matrix II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/spiral-matrix-ii/" + "id": 59, + "link": "https://leetcode.com/problems/spiral-matrix-ii/", + "title": "Spiral Matrix II" }, "60": { - "id": 60, "category": "Math & Geometry", - "title": "Permutation Sequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/permutation-sequence/" - }, - "61": { - "id": 61, - "category": "Linked List", - "title": "Rotate List", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotate-list/" + "id": 60, + "link": "https://leetcode.com/problems/permutation-sequence/", + "title": "Permutation Sequence" }, + "61": {"category": "Linked List", "difficulty": "Medium", "id": 61, "link": "https://leetcode.com/problems/rotate-list/", "title": "Rotate List"}, "62": { - "id": 62, "category": "Dynamic Programming", - "title": "Unique Paths", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-paths/" + "id": 62, + "link": "https://leetcode.com/problems/unique-paths/", + "title": "Unique Paths" }, "63": { - "id": 63, "category": "Dynamic Programming", - "title": "Unique Paths II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-paths-ii/" + "id": 63, + "link": "https://leetcode.com/problems/unique-paths-ii/", + "title": "Unique Paths II" }, "64": { - "id": 64, "category": "Dynamic Programming", - "title": "Minimum Path Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-path-sum/" + "id": 64, + "link": "https://leetcode.com/problems/minimum-path-sum/", + "title": "Minimum Path Sum" }, "65": { - "id": 65, "category": "Array & Hashing", - "title": "Valid Number", "difficulty": "Hard", - "link": "https://leetcode.com/problems/valid-number/" - }, - "66": { - "id": 66, - "category": "Math & Geometry", - "title": "Plus One", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/plus-one/" - }, - "67": { - "id": 67, - "category": "Bit Manipulation", - "title": "Add Binary", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-binary/" + "id": 65, + "link": "https://leetcode.com/problems/valid-number/", + "title": "Valid Number" }, + "66": {"category": "Math & Geometry", "difficulty": "Easy", "id": 66, "link": "https://leetcode.com/problems/plus-one/", "title": "Plus One"}, + "67": {"category": "Bit Manipulation", "difficulty": "Easy", "id": 67, "link": "https://leetcode.com/problems/add-binary/", "title": "Add Binary"}, "68": { - "id": 68, "category": "Array & Hashing", - "title": "Text Justification", "difficulty": "Hard", - "link": "https://leetcode.com/problems/text-justification/" - }, - "69": { - "id": 69, - "category": "Binary Search", - "title": "Sqrt(x)", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/sqrtx/" + "id": 68, + "link": "https://leetcode.com/problems/text-justification/", + "title": "Text Justification" }, + "69": {"category": "Binary Search", "difficulty": "Easy", "id": 69, "link": "https://leetcode.com/problems/sqrtx/", "title": "Sqrt(x)"}, "70": { - "id": 70, "category": "Dynamic Programming", - "title": "Climbing Stairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/climbing-stairs/" - }, - "71": { - "id": 71, - "category": "Stack", - "title": "Simplify Path", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/simplify-path/" + "id": 70, + "link": "https://leetcode.com/problems/climbing-stairs/", + "title": "Climbing Stairs" }, + "71": {"category": "Stack", "difficulty": "Medium", "id": 71, "link": "https://leetcode.com/problems/simplify-path/", "title": "Simplify Path"}, "72": { - "id": 72, "category": "Dynamic Programming", - "title": "Edit Distance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/edit-distance/" + "id": 72, + "link": "https://leetcode.com/problems/edit-distance/", + "title": "Edit Distance" }, "73": { - "id": 73, "category": "Array & Hashing", - "title": "Set Matrix Zeroes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/set-matrix-zeroes/" + "id": 73, + "link": "https://leetcode.com/problems/set-matrix-zeroes/", + "title": "Set Matrix Zeroes" }, "74": { - "id": 74, "category": "Binary Search", - "title": "Search a 2D Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-a-2d-matrix/" - }, - "75": { - "id": 75, - "category": "Two Pointers", - "title": "Sort Colors", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-colors/" + "id": 74, + "link": "https://leetcode.com/problems/search-a-2d-matrix/", + "title": "Search a 2D Matrix" }, + "75": {"category": "Two Pointers", "difficulty": "Medium", "id": 75, "link": "https://leetcode.com/problems/sort-colors/", "title": "Sort Colors"}, "76": { - "id": 76, "category": "Sliding Window", - "title": "Minimum Window Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-window-substring/" + "id": 76, + "link": "https://leetcode.com/problems/minimum-window-substring/", + "title": "Minimum Window Substring" }, "77": { - "id": 77, - "category": "Backtracking", - "title": "Combinations", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/combinations/" - }, - "78": { - "id": 78, "category": "Backtracking", - "title": "Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subsets/" + "id": 77, + "link": "https://leetcode.com/problems/combinations/", + "title": "Combinations" }, + "78": {"category": "Backtracking", "difficulty": "Medium", "id": 78, "link": "https://leetcode.com/problems/subsets/", "title": "Subsets"}, "79": { - "id": 79, "category": "Graph Traversal", - "title": "Word Search", "difficulty": "Medium", - "link": "https://leetcode.com/problems/word-search/" + "id": 79, + "link": "https://leetcode.com/problems/word-search/", + "title": "Word Search" }, "80": { - "id": 80, "category": "Two Pointers", - "title": "Remove Duplicates from Sorted Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/" + "id": 80, + "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/", + "title": "Remove Duplicates from Sorted Array II" }, "81": { - "id": 81, "category": "Binary Search", - "title": "Search in Rotated Sorted Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-in-rotated-sorted-array-ii/" + "id": 81, + "link": "https://leetcode.com/problems/search-in-rotated-sorted-array-ii/", + "title": "Search in Rotated Sorted Array II" }, "82": { - "id": 82, "category": "Linked List", - "title": "Remove Duplicates from Sorted List II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/" + "id": 82, + "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/", + "title": "Remove Duplicates from Sorted List II" }, "83": { - "id": 83, "category": "Linked List", - "title": "Remove Duplicates from Sorted List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-list/" + "id": 83, + "link": "https://leetcode.com/problems/remove-duplicates-from-sorted-list/", + "title": "Remove Duplicates from Sorted List" }, "84": { - "id": 84, "category": "Stack", - "title": "Largest Rectangle in Histogram", "difficulty": "Hard", - "link": "https://leetcode.com/problems/largest-rectangle-in-histogram/" + "id": 84, + "link": "https://leetcode.com/problems/largest-rectangle-in-histogram/", + "title": "Largest Rectangle in Histogram" }, "85": { - "id": 85, "category": "Dynamic Programming", - "title": "Maximal Rectangle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximal-rectangle/" + "id": 85, + "link": "https://leetcode.com/problems/maximal-rectangle/", + "title": "Maximal Rectangle" }, "86": { - "id": 86, "category": "Linked List", - "title": "Partition List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-list/" + "id": 86, + "link": "https://leetcode.com/problems/partition-list/", + "title": "Partition List" }, "87": { - "id": 87, "category": "Dynamic Programming", - "title": "Scramble String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/scramble-string/" + "id": 87, + "link": "https://leetcode.com/problems/scramble-string/", + "title": "Scramble String" }, "88": { - "id": 88, "category": "Two Pointers", - "title": "Merge Sorted Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-sorted-array/" - }, - "89": { - "id": 89, - "category": "Backtracking", - "title": "Gray Code", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/gray-code/" - }, - "90": { - "id": 90, - "category": "Backtracking", - "title": "Subsets II", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/subsets-ii/" + "id": 88, + "link": "https://leetcode.com/problems/merge-sorted-array/", + "title": "Merge Sorted Array" }, + "89": {"category": "Backtracking", "difficulty": "Medium", "id": 89, "link": "https://leetcode.com/problems/gray-code/", "title": "Gray Code"}, + "90": {"category": "Backtracking", "difficulty": "Medium", "id": 90, "link": "https://leetcode.com/problems/subsets-ii/", "title": "Subsets II"}, "91": { - "id": 91, "category": "Dynamic Programming", - "title": "Decode Ways", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decode-ways/" + "id": 91, + "link": "https://leetcode.com/problems/decode-ways/", + "title": "Decode Ways" }, "92": { - "id": 92, "category": "Linked List", - "title": "Reverse Linked List II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-linked-list-ii/" + "id": 92, + "link": "https://leetcode.com/problems/reverse-linked-list-ii/", + "title": "Reverse Linked List II" }, "93": { - "id": 93, "category": "Backtracking", - "title": "Restore IP Addresses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/restore-ip-addresses/" + "id": 93, + "link": "https://leetcode.com/problems/restore-ip-addresses/", + "title": "Restore IP Addresses" }, "94": { - "id": 94, "category": "Tree", - "title": "Binary Tree Inorder Traversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-tree-inorder-traversal/" + "id": 94, + "link": "https://leetcode.com/problems/binary-tree-inorder-traversal/", + "title": "Binary Tree Inorder Traversal" }, "95": { - "id": 95, "category": "Tree", - "title": "Unique Binary Search Trees II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-binary-search-trees-ii/" + "id": 95, + "link": "https://leetcode.com/problems/unique-binary-search-trees-ii/", + "title": "Unique Binary Search Trees II" }, "96": { - "id": 96, "category": "Tree", - "title": "Unique Binary Search Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-binary-search-trees/" + "id": 96, + "link": "https://leetcode.com/problems/unique-binary-search-trees/", + "title": "Unique Binary Search Trees" }, "97": { - "id": 97, "category": "Dynamic Programming", - "title": "Interleaving String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/interleaving-string/" + "id": 97, + "link": "https://leetcode.com/problems/interleaving-string/", + "title": "Interleaving String" }, "98": { - "id": 98, "category": "Tree", - "title": "Validate Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/validate-binary-search-tree/" + "id": 98, + "link": "https://leetcode.com/problems/validate-binary-search-tree/", + "title": "Validate Binary Search Tree" }, "99": { - "id": 99, "category": "Tree", - "title": "Recover Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/recover-binary-search-tree/" - }, - "100": { - "id": 100, - "category": "Tree", - "title": "Same Tree", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/same-tree/" - }, - "101": { - "id": 101, - "category": "Tree", - "title": "Symmetric Tree", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/symmetric-tree/" + "id": 99, + "link": "https://leetcode.com/problems/recover-binary-search-tree/", + "title": "Recover Binary Search Tree" }, + "100": {"category": "Tree", "difficulty": "Easy", "id": 100, "link": "https://leetcode.com/problems/same-tree/", "title": "Same Tree"}, + "101": {"category": "Tree", "difficulty": "Easy", "id": 101, "link": "https://leetcode.com/problems/symmetric-tree/", "title": "Symmetric Tree"}, "102": { - "id": 102, "category": "Tree", - "title": "Binary Tree Level Order Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-level-order-traversal/" + "id": 102, + "link": "https://leetcode.com/problems/binary-tree-level-order-traversal/", + "title": "Binary Tree Level Order Traversal" }, "103": { - "id": 103, "category": "Tree", - "title": "Binary Tree Zigzag Level Order Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/" + "id": 103, + "link": "https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/", + "title": "Binary Tree Zigzag Level Order Traversal" }, "104": { - "id": 104, "category": "Tree", - "title": "Maximum Depth of Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-depth-of-binary-tree/" + "id": 104, + "link": "https://leetcode.com/problems/maximum-depth-of-binary-tree/", + "title": "Maximum Depth of Binary Tree" }, "105": { - "id": 105, "category": "Tree", - "title": "Construct Binary Tree from Preorder and Inorder Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/" + "id": 105, + "link": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/", + "title": "Construct Binary Tree from Preorder and Inorder Traversal" }, "106": { - "id": 106, "category": "Tree", - "title": "Construct Binary Tree from Inorder and Postorder Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/" + "id": 106, + "link": "https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/", + "title": "Construct Binary Tree from Inorder and Postorder Traversal" }, "107": { - "id": 107, "category": "Tree", - "title": "Binary Tree Level Order Traversal II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-level-order-traversal-ii/" + "id": 107, + "link": "https://leetcode.com/problems/binary-tree-level-order-traversal-ii/", + "title": "Binary Tree Level Order Traversal II" }, "108": { - "id": 108, "category": "Tree", - "title": "Convert Sorted Array to Binary Search Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/" + "id": 108, + "link": "https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/", + "title": "Convert Sorted Array to Binary Search Tree" }, "109": { - "id": 109, "category": "Tree", - "title": "Convert Sorted List to Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/" + "id": 109, + "link": "https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/", + "title": "Convert Sorted List to Binary Search Tree" }, "110": { - "id": 110, "category": "Tree", - "title": "Balanced Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/balanced-binary-tree/" + "id": 110, + "link": "https://leetcode.com/problems/balanced-binary-tree/", + "title": "Balanced Binary Tree" }, "111": { - "id": 111, "category": "Tree", - "title": "Minimum Depth of Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-depth-of-binary-tree/" - }, - "112": { - "id": 112, - "category": "Tree", - "title": "Path Sum", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/path-sum/" - }, - "113": { - "id": 113, - "category": "Tree", - "title": "Path Sum II", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-sum-ii/" + "id": 111, + "link": "https://leetcode.com/problems/minimum-depth-of-binary-tree/", + "title": "Minimum Depth of Binary Tree" }, + "112": {"category": "Tree", "difficulty": "Easy", "id": 112, "link": "https://leetcode.com/problems/path-sum/", "title": "Path Sum"}, + "113": {"category": "Tree", "difficulty": "Medium", "id": 113, "link": "https://leetcode.com/problems/path-sum-ii/", "title": "Path Sum II"}, "114": { - "id": 114, "category": "Tree", - "title": "Flatten Binary Tree to Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flatten-binary-tree-to-linked-list/" + "id": 114, + "link": "https://leetcode.com/problems/flatten-binary-tree-to-linked-list/", + "title": "Flatten Binary Tree to Linked List" }, "115": { - "id": 115, "category": "Dynamic Programming", - "title": "Distinct Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distinct-subsequences/" + "id": 115, + "link": "https://leetcode.com/problems/distinct-subsequences/", + "title": "Distinct Subsequences" }, "116": { - "id": 116, "category": "Tree", - "title": "Populating Next Right Pointers in Each Node", "difficulty": "Medium", - "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node/" + "id": 116, + "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node/", + "title": "Populating Next Right Pointers in Each Node" }, "117": { - "id": 117, "category": "Tree", - "title": "Populating Next Right Pointers in Each Node II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/" + "id": 117, + "link": "https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/", + "title": "Populating Next Right Pointers in Each Node II" }, "118": { - "id": 118, "category": "Dynamic Programming", - "title": "Pascal's Triangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/pascals-triangle/" + "id": 118, + "link": "https://leetcode.com/problems/pascals-triangle/", + "title": "Pascal's Triangle" }, "119": { - "id": 119, "category": "Dynamic Programming", - "title": "Pascal's Triangle II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/pascals-triangle-ii/" + "id": 119, + "link": "https://leetcode.com/problems/pascals-triangle-ii/", + "title": "Pascal's Triangle II" }, "120": { - "id": 120, "category": "Dynamic Programming", - "title": "Triangle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/triangle/" + "id": 120, + "link": "https://leetcode.com/problems/triangle/", + "title": "Triangle" }, "121": { - "id": 121, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock", "difficulty": "Easy", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock/" + "id": 121, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock/", + "title": "Best Time to Buy and Sell Stock" }, "122": { - "id": 122, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/" + "id": 122, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/", + "title": "Best Time to Buy and Sell Stock II" }, "123": { - "id": 123, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/" + "id": 123, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/", + "title": "Best Time to Buy and Sell Stock III" }, "124": { - "id": 124, "category": "Tree", - "title": "Binary Tree Maximum Path Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/binary-tree-maximum-path-sum/" + "id": 124, + "link": "https://leetcode.com/problems/binary-tree-maximum-path-sum/", + "title": "Binary Tree Maximum Path Sum" }, "125": { - "id": 125, "category": "Two Pointers", - "title": "Valid Palindrome", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-palindrome/" + "id": 125, + "link": "https://leetcode.com/problems/valid-palindrome/", + "title": "Valid Palindrome" }, "126": { - "id": 126, "category": "Graph Traversal", - "title": "Word Ladder II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-ladder-ii/" + "id": 126, + "link": "https://leetcode.com/problems/word-ladder-ii/", + "title": "Word Ladder II" }, "127": { - "id": 127, "category": "Graph Traversal", - "title": "Word Ladder", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-ladder/" + "id": 127, + "link": "https://leetcode.com/problems/word-ladder/", + "title": "Word Ladder" }, "128": { - "id": 128, "category": "Graph Traversal", - "title": "Longest Consecutive Sequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-consecutive-sequence/" + "id": 128, + "link": "https://leetcode.com/problems/longest-consecutive-sequence/", + "title": "Longest Consecutive Sequence" }, "129": { - "id": 129, "category": "Tree", - "title": "Sum Root to Leaf Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-root-to-leaf-numbers/" + "id": 129, + "link": "https://leetcode.com/problems/sum-root-to-leaf-numbers/", + "title": "Sum Root to Leaf Numbers" }, "130": { - "id": 130, "category": "Graph Traversal", - "title": "Surrounded Regions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/surrounded-regions/" + "id": 130, + "link": "https://leetcode.com/problems/surrounded-regions/", + "title": "Surrounded Regions" }, "131": { - "id": 131, "category": "Dynamic Programming", - "title": "Palindrome Partitioning", "difficulty": "Medium", - "link": "https://leetcode.com/problems/palindrome-partitioning/" + "id": 131, + "link": "https://leetcode.com/problems/palindrome-partitioning/", + "title": "Palindrome Partitioning" }, "132": { - "id": 132, "category": "Dynamic Programming", - "title": "Palindrome Partitioning II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-partitioning-ii/" + "id": 132, + "link": "https://leetcode.com/problems/palindrome-partitioning-ii/", + "title": "Palindrome Partitioning II" }, "133": { - "id": 133, "category": "Graph Traversal", - "title": "Clone Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/clone-graph/" - }, - "134": { - "id": 134, - "category": "Greedy", - "title": "Gas Station", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/gas-station/" - }, - "135": { - "id": 135, - "category": "Greedy", - "title": "Candy", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/candy/" + "id": 133, + "link": "https://leetcode.com/problems/clone-graph/", + "title": "Clone Graph" }, + "134": {"category": "Greedy", "difficulty": "Medium", "id": 134, "link": "https://leetcode.com/problems/gas-station/", "title": "Gas Station"}, + "135": {"category": "Greedy", "difficulty": "Hard", "id": 135, "link": "https://leetcode.com/problems/candy/", "title": "Candy"}, "136": { - "id": 136, "category": "Bit Manipulation", - "title": "Single Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/single-number/" + "id": 136, + "link": "https://leetcode.com/problems/single-number/", + "title": "Single Number" }, "137": { - "id": 137, "category": "Bit Manipulation", - "title": "Single Number II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/single-number-ii/" + "id": 137, + "link": "https://leetcode.com/problems/single-number-ii/", + "title": "Single Number II" }, "138": { - "id": 138, "category": "Linked List", - "title": "Copy List with Random Pointer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/copy-list-with-random-pointer/" + "id": 138, + "link": "https://leetcode.com/problems/copy-list-with-random-pointer/", + "title": "Copy List with Random Pointer" }, "139": { - "id": 139, "category": "Dynamic Programming", - "title": "Word Break", "difficulty": "Medium", - "link": "https://leetcode.com/problems/word-break/" + "id": 139, + "link": "https://leetcode.com/problems/word-break/", + "title": "Word Break" }, "140": { - "id": 140, "category": "Dynamic Programming", - "title": "Word Break II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-break-ii/" + "id": 140, + "link": "https://leetcode.com/problems/word-break-ii/", + "title": "Word Break II" }, "141": { - "id": 141, "category": "Linked List", - "title": "Linked List Cycle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/linked-list-cycle/" + "id": 141, + "link": "https://leetcode.com/problems/linked-list-cycle/", + "title": "Linked List Cycle" }, "142": { - "id": 142, "category": "Linked List", - "title": "Linked List Cycle II", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/linked-list-cycle-ii/" - }, - "143": { - "id": 143, - "category": "Stack", - "title": "Reorder List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reorder-list/" + "id": 142, + "link": "https://leetcode.com/problems/linked-list-cycle-ii/", + "title": "Linked List Cycle II" }, + "143": {"category": "Stack", "difficulty": "Medium", "id": 143, "link": "https://leetcode.com/problems/reorder-list/", "title": "Reorder List"}, "144": { - "id": 144, "category": "Tree", - "title": "Binary Tree Preorder Traversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-tree-preorder-traversal/" + "id": 144, + "link": "https://leetcode.com/problems/binary-tree-preorder-traversal/", + "title": "Binary Tree Preorder Traversal" }, "145": { - "id": 145, "category": "Tree", - "title": "Binary Tree Postorder Traversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-tree-postorder-traversal/" - }, - "146": { - "id": 146, - "category": "Linked List", - "title": "LRU Cache", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/lru-cache/" + "id": 145, + "link": "https://leetcode.com/problems/binary-tree-postorder-traversal/", + "title": "Binary Tree Postorder Traversal" }, + "146": {"category": "Linked List", "difficulty": "Medium", "id": 146, "link": "https://leetcode.com/problems/lru-cache/", "title": "LRU Cache"}, "147": { - "id": 147, - "category": "Linked List", - "title": "Insertion Sort List", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/insertion-sort-list/" - }, - "148": { - "id": 148, "category": "Linked List", - "title": "Sort List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-list/" + "id": 147, + "link": "https://leetcode.com/problems/insertion-sort-list/", + "title": "Insertion Sort List" }, + "148": {"category": "Linked List", "difficulty": "Medium", "id": 148, "link": "https://leetcode.com/problems/sort-list/", "title": "Sort List"}, "149": { - "id": 149, "category": "Math & Geometry", - "title": "Max Points on a Line", "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-points-on-a-line/" + "id": 149, + "link": "https://leetcode.com/problems/max-points-on-a-line/", + "title": "Max Points on a Line" }, "150": { - "id": 150, "category": "Stack", - "title": "Evaluate Reverse Polish Notation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/evaluate-reverse-polish-notation/" + "id": 150, + "link": "https://leetcode.com/problems/evaluate-reverse-polish-notation/", + "title": "Evaluate Reverse Polish Notation" }, "151": { - "id": 151, "category": "Two Pointers", - "title": "Reverse Words in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-words-in-a-string/" + "id": 151, + "link": "https://leetcode.com/problems/reverse-words-in-a-string/", + "title": "Reverse Words in a String" }, "152": { - "id": 152, "category": "Dynamic Programming", - "title": "Maximum Product Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-subarray/" + "id": 152, + "link": "https://leetcode.com/problems/maximum-product-subarray/", + "title": "Maximum Product Subarray" }, "153": { - "id": 153, "category": "Binary Search", - "title": "Find Minimum in Rotated Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/" + "id": 153, + "link": "https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/", + "title": "Find Minimum in Rotated Sorted Array" }, "154": { - "id": 154, "category": "Binary Search", - "title": "Find Minimum in Rotated Sorted Array II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/" - }, - "155": { - "id": 155, - "category": "Stack", - "title": "Min Stack", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/min-stack/" + "id": 154, + "link": "https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/", + "title": "Find Minimum in Rotated Sorted Array II" }, + "155": {"category": "Stack", "difficulty": "Medium", "id": 155, "link": "https://leetcode.com/problems/min-stack/", "title": "Min Stack"}, "156": { - "id": 156, "category": "Tree", - "title": "Binary Tree Upside Down", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-upside-down/" + "id": 156, + "link": "https://leetcode.com/problems/binary-tree-upside-down/", + "title": "Binary Tree Upside Down" }, "157": { - "id": 157, "category": "Array & Hashing", - "title": "Read N Characters Given Read4", "difficulty": "Easy", - "link": "https://leetcode.com/problems/read-n-characters-given-read4/" + "id": 157, + "link": "https://leetcode.com/problems/read-n-characters-given-read4/", + "title": "Read N Characters Given Read4" }, "158": { - "id": 158, "category": "Array & Hashing", - "title": "Read N Characters Given read4 II - Call Multiple Times", "difficulty": "Hard", - "link": "https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/" + "id": 158, + "link": "https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/", + "title": "Read N Characters Given read4 II - Call Multiple Times" }, "159": { - "id": 159, "category": "Sliding Window", - "title": "Longest Substring with At Most Two Distinct Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/" + "id": 159, + "link": "https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/", + "title": "Longest Substring with At Most Two Distinct Characters" }, "160": { - "id": 160, "category": "Linked List", - "title": "Intersection of Two Linked Lists", "difficulty": "Easy", - "link": "https://leetcode.com/problems/intersection-of-two-linked-lists/" + "id": 160, + "link": "https://leetcode.com/problems/intersection-of-two-linked-lists/", + "title": "Intersection of Two Linked Lists" }, "161": { - "id": 161, "category": "Two Pointers", - "title": "One Edit Distance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/one-edit-distance/" + "id": 161, + "link": "https://leetcode.com/problems/one-edit-distance/", + "title": "One Edit Distance" }, "162": { - "id": 162, "category": "Binary Search", - "title": "Find Peak Element", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-peak-element/" + "id": 162, + "link": "https://leetcode.com/problems/find-peak-element/", + "title": "Find Peak Element" }, "163": { - "id": 163, "category": "Array & Hashing", - "title": "Missing Ranges", "difficulty": "Easy", - "link": "https://leetcode.com/problems/missing-ranges/" + "id": 163, + "link": "https://leetcode.com/problems/missing-ranges/", + "title": "Missing Ranges" }, "164": { - "id": 164, "category": "Array & Hashing", - "title": "Maximum Gap", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-gap/" + "id": 164, + "link": "https://leetcode.com/problems/maximum-gap/", + "title": "Maximum Gap" }, "165": { - "id": 165, "category": "Two Pointers", - "title": "Compare Version Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/compare-version-numbers/" + "id": 165, + "link": "https://leetcode.com/problems/compare-version-numbers/", + "title": "Compare Version Numbers" }, "166": { - "id": 166, "category": "Math & Geometry", - "title": "Fraction to Recurring Decimal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fraction-to-recurring-decimal/" + "id": 166, + "link": "https://leetcode.com/problems/fraction-to-recurring-decimal/", + "title": "Fraction to Recurring Decimal" }, "167": { - "id": 167, "category": "Binary Search", - "title": "Two Sum II - Input Array Is Sorted", "difficulty": "Medium", - "link": "https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/" + "id": 167, + "link": "https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/", + "title": "Two Sum II - Input Array Is Sorted" }, "168": { - "id": 168, "category": "Math & Geometry", - "title": "Excel Sheet Column Title", "difficulty": "Easy", - "link": "https://leetcode.com/problems/excel-sheet-column-title/" + "id": 168, + "link": "https://leetcode.com/problems/excel-sheet-column-title/", + "title": "Excel Sheet Column Title" }, "169": { - "id": 169, "category": "Array & Hashing", - "title": "Majority Element", "difficulty": "Easy", - "link": "https://leetcode.com/problems/majority-element/" + "id": 169, + "link": "https://leetcode.com/problems/majority-element/", + "title": "Majority Element" }, "170": { - "id": 170, "category": "Two Pointers", - "title": "Two Sum III - Data structure design", "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-sum-iii-data-structure-design/" + "id": 170, + "link": "https://leetcode.com/problems/two-sum-iii-data-structure-design/", + "title": "Two Sum III - Data structure design" }, "171": { - "id": 171, "category": "Math & Geometry", - "title": "Excel Sheet Column Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/excel-sheet-column-number/" + "id": 171, + "link": "https://leetcode.com/problems/excel-sheet-column-number/", + "title": "Excel Sheet Column Number" }, "172": { - "id": 172, "category": "Math & Geometry", - "title": "Factorial Trailing Zeroes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/factorial-trailing-zeroes/" + "id": 172, + "link": "https://leetcode.com/problems/factorial-trailing-zeroes/", + "title": "Factorial Trailing Zeroes" }, "173": { - "id": 173, "category": "Tree", - "title": "Binary Search Tree Iterator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-search-tree-iterator/" + "id": 173, + "link": "https://leetcode.com/problems/binary-search-tree-iterator/", + "title": "Binary Search Tree Iterator" }, "174": { - "id": 174, "category": "Dynamic Programming", - "title": "Dungeon Game", "difficulty": "Hard", - "link": "https://leetcode.com/problems/dungeon-game/" + "id": 174, + "link": "https://leetcode.com/problems/dungeon-game/", + "title": "Dungeon Game" }, "175": { - "id": 175, "category": "Database", - "title": "Combine Two Tables", "difficulty": "Easy", - "link": "https://leetcode.com/problems/combine-two-tables/" + "id": 175, + "link": "https://leetcode.com/problems/combine-two-tables/", + "title": "Combine Two Tables" }, "176": { - "id": 176, "category": "Database", - "title": "Second Highest Salary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/second-highest-salary/" + "id": 176, + "link": "https://leetcode.com/problems/second-highest-salary/", + "title": "Second Highest Salary" }, "177": { - "id": 177, "category": "Database", - "title": "Nth Highest Salary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/nth-highest-salary/" - }, - "178": { - "id": 178, - "category": "Database", - "title": "Rank Scores", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/rank-scores/" + "id": 177, + "link": "https://leetcode.com/problems/nth-highest-salary/", + "title": "Nth Highest Salary" }, + "178": {"category": "Database", "difficulty": "Medium", "id": 178, "link": "https://leetcode.com/problems/rank-scores/", "title": "Rank Scores"}, "179": { - "id": 179, "category": "Greedy", - "title": "Largest Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-number/" + "id": 179, + "link": "https://leetcode.com/problems/largest-number/", + "title": "Largest Number" }, "180": { - "id": 180, "category": "Database", - "title": "Consecutive Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/consecutive-numbers/" + "id": 180, + "link": "https://leetcode.com/problems/consecutive-numbers/", + "title": "Consecutive Numbers" }, "181": { - "id": 181, "category": "Database", - "title": "Employees Earning More Than Their Managers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/employees-earning-more-than-their-managers/" + "id": 181, + "link": "https://leetcode.com/problems/employees-earning-more-than-their-managers/", + "title": "Employees Earning More Than Their Managers" }, "182": { - "id": 182, "category": "Database", - "title": "Duplicate Emails", "difficulty": "Easy", - "link": "https://leetcode.com/problems/duplicate-emails/" + "id": 182, + "link": "https://leetcode.com/problems/duplicate-emails/", + "title": "Duplicate Emails" }, "183": { - "id": 183, "category": "Database", - "title": "Customers Who Never Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/customers-who-never-order/" + "id": 183, + "link": "https://leetcode.com/problems/customers-who-never-order/", + "title": "Customers Who Never Order" }, "184": { - "id": 184, "category": "Database", - "title": "Department Highest Salary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/department-highest-salary/" + "id": 184, + "link": "https://leetcode.com/problems/department-highest-salary/", + "title": "Department Highest Salary" }, "185": { - "id": 185, "category": "Database", - "title": "Department Top Three Salaries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/department-top-three-salaries/" + "id": 185, + "link": "https://leetcode.com/problems/department-top-three-salaries/", + "title": "Department Top Three Salaries" }, "186": { - "id": 186, "category": "Two Pointers", - "title": "Reverse Words in a String II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-words-in-a-string-ii/" + "id": 186, + "link": "https://leetcode.com/problems/reverse-words-in-a-string-ii/", + "title": "Reverse Words in a String II" }, "187": { - "id": 187, "category": "Sliding Window", - "title": "Repeated DNA Sequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/repeated-dna-sequences/" + "id": 187, + "link": "https://leetcode.com/problems/repeated-dna-sequences/", + "title": "Repeated DNA Sequences" }, "188": { - "id": 188, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/" + "id": 188, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/", + "title": "Best Time to Buy and Sell Stock IV" }, "189": { - "id": 189, "category": "Math & Geometry", - "title": "Rotate Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotate-array/" + "id": 189, + "link": "https://leetcode.com/problems/rotate-array/", + "title": "Rotate Array" }, "190": { - "id": 190, "category": "Bit Manipulation", - "title": "Reverse Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-bits/" + "id": 190, + "link": "https://leetcode.com/problems/reverse-bits/", + "title": "Reverse Bits" }, "191": { - "id": 191, "category": "Bit Manipulation", - "title": "Number of 1 Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-1-bits/" + "id": 191, + "link": "https://leetcode.com/problems/number-of-1-bits/", + "title": "Number of 1 Bits" }, "192": { - "id": 192, "category": "Array & Hashing", - "title": "Word Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/word-frequency/" + "id": 192, + "link": "https://leetcode.com/problems/word-frequency/", + "title": "Word Frequency" }, "193": { - "id": 193, "category": "Array & Hashing", - "title": "Valid Phone Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-phone-numbers/" + "id": 193, + "link": "https://leetcode.com/problems/valid-phone-numbers/", + "title": "Valid Phone Numbers" }, "194": { - "id": 194, "category": "Array & Hashing", - "title": "Transpose File", "difficulty": "Medium", - "link": "https://leetcode.com/problems/transpose-file/" - }, - "195": { - "id": 195, - "category": "Array & Hashing", - "title": "Tenth Line", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/tenth-line/" + "id": 194, + "link": "https://leetcode.com/problems/transpose-file/", + "title": "Transpose File" }, + "195": {"category": "Array & Hashing", "difficulty": "Easy", "id": 195, "link": "https://leetcode.com/problems/tenth-line/", "title": "Tenth Line"}, "196": { - "id": 196, "category": "Database", - "title": "Delete Duplicate Emails", "difficulty": "Easy", - "link": "https://leetcode.com/problems/delete-duplicate-emails/" + "id": 196, + "link": "https://leetcode.com/problems/delete-duplicate-emails/", + "title": "Delete Duplicate Emails" }, "197": { - "id": 197, "category": "Database", - "title": "Rising Temperature", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rising-temperature/" + "id": 197, + "link": "https://leetcode.com/problems/rising-temperature/", + "title": "Rising Temperature" }, "198": { - "id": 198, "category": "Dynamic Programming", - "title": "House Robber", "difficulty": "Medium", - "link": "https://leetcode.com/problems/house-robber/" + "id": 198, + "link": "https://leetcode.com/problems/house-robber/", + "title": "House Robber" }, "199": { - "id": 199, "category": "Tree", - "title": "Binary Tree Right Side View", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-right-side-view/" + "id": 199, + "link": "https://leetcode.com/problems/binary-tree-right-side-view/", + "title": "Binary Tree Right Side View" }, "200": { - "id": 200, "category": "Graph Traversal", - "title": "Number of Islands", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-islands/" + "id": 200, + "link": "https://leetcode.com/problems/number-of-islands/", + "title": "Number of Islands" }, "201": { - "id": 201, "category": "Bit Manipulation", - "title": "Bitwise AND of Numbers Range", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bitwise-and-of-numbers-range/" + "id": 201, + "link": "https://leetcode.com/problems/bitwise-and-of-numbers-range/", + "title": "Bitwise AND of Numbers Range" }, "202": { - "id": 202, "category": "Math & Geometry", - "title": "Happy Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/happy-number/" + "id": 202, + "link": "https://leetcode.com/problems/happy-number/", + "title": "Happy Number" }, "203": { - "id": 203, "category": "Linked List", - "title": "Remove Linked List Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-linked-list-elements/" + "id": 203, + "link": "https://leetcode.com/problems/remove-linked-list-elements/", + "title": "Remove Linked List Elements" }, "204": { - "id": 204, "category": "Math & Geometry", - "title": "Count Primes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-primes/" + "id": 204, + "link": "https://leetcode.com/problems/count-primes/", + "title": "Count Primes" }, "205": { - "id": 205, "category": "Array & Hashing", - "title": "Isomorphic Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/isomorphic-strings/" + "id": 205, + "link": "https://leetcode.com/problems/isomorphic-strings/", + "title": "Isomorphic Strings" }, "206": { - "id": 206, "category": "Linked List", - "title": "Reverse Linked List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-linked-list/" + "id": 206, + "link": "https://leetcode.com/problems/reverse-linked-list/", + "title": "Reverse Linked List" }, "207": { - "id": 207, "category": "Graph Traversal", - "title": "Course Schedule", "difficulty": "Medium", - "link": "https://leetcode.com/problems/course-schedule/" + "id": 207, + "link": "https://leetcode.com/problems/course-schedule/", + "title": "Course Schedule" }, "208": { - "id": 208, "category": "Trie", - "title": "Implement Trie (Prefix Tree)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/implement-trie-prefix-tree/" + "id": 208, + "link": "https://leetcode.com/problems/implement-trie-prefix-tree/", + "title": "Implement Trie (Prefix Tree)" }, "209": { - "id": 209, "category": "Sliding Window", - "title": "Minimum Size Subarray Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-size-subarray-sum/" + "id": 209, + "link": "https://leetcode.com/problems/minimum-size-subarray-sum/", + "title": "Minimum Size Subarray Sum" }, "210": { - "id": 210, "category": "Graph Traversal", - "title": "Course Schedule II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/course-schedule-ii/" + "id": 210, + "link": "https://leetcode.com/problems/course-schedule-ii/", + "title": "Course Schedule II" }, "211": { - "id": 211, "category": "Graph Traversal", - "title": "Design Add and Search Words Data Structure", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-add-and-search-words-data-structure/" + "id": 211, + "link": "https://leetcode.com/problems/design-add-and-search-words-data-structure/", + "title": "Design Add and Search Words Data Structure" }, "212": { - "id": 212, "category": "Backtracking", - "title": "Word Search II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-search-ii/" + "id": 212, + "link": "https://leetcode.com/problems/word-search-ii/", + "title": "Word Search II" }, "213": { - "id": 213, "category": "Dynamic Programming", - "title": "House Robber II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/house-robber-ii/" + "id": 213, + "link": "https://leetcode.com/problems/house-robber-ii/", + "title": "House Robber II" }, "214": { - "id": 214, "category": "Array & Hashing", - "title": "Shortest Palindrome", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-palindrome/" + "id": 214, + "link": "https://leetcode.com/problems/shortest-palindrome/", + "title": "Shortest Palindrome" }, "215": { - "id": 215, "category": "Heap (Priority Queue)", - "title": "Kth Largest Element in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kth-largest-element-in-an-array/" + "id": 215, + "link": "https://leetcode.com/problems/kth-largest-element-in-an-array/", + "title": "Kth Largest Element in an Array" }, "216": { - "id": 216, "category": "Backtracking", - "title": "Combination Sum III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/combination-sum-iii/" + "id": 216, + "link": "https://leetcode.com/problems/combination-sum-iii/", + "title": "Combination Sum III" }, "217": { - "id": 217, "category": "Array & Hashing", - "title": "Contains Duplicate", "difficulty": "Easy", - "link": "https://leetcode.com/problems/contains-duplicate/" + "id": 217, + "link": "https://leetcode.com/problems/contains-duplicate/", + "title": "Contains Duplicate" }, "218": { - "id": 218, "category": "Tree", - "title": "The Skyline Problem", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-skyline-problem/" + "id": 218, + "link": "https://leetcode.com/problems/the-skyline-problem/", + "title": "The Skyline Problem" }, "219": { - "id": 219, "category": "Sliding Window", - "title": "Contains Duplicate II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/contains-duplicate-ii/" + "id": 219, + "link": "https://leetcode.com/problems/contains-duplicate-ii/", + "title": "Contains Duplicate II" }, "220": { - "id": 220, "category": "Sliding Window", - "title": "Contains Duplicate III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/contains-duplicate-iii/" + "id": 220, + "link": "https://leetcode.com/problems/contains-duplicate-iii/", + "title": "Contains Duplicate III" }, "221": { - "id": 221, "category": "Dynamic Programming", - "title": "Maximal Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximal-square/" + "id": 221, + "link": "https://leetcode.com/problems/maximal-square/", + "title": "Maximal Square" }, "222": { - "id": 222, "category": "Tree", - "title": "Count Complete Tree Nodes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-complete-tree-nodes/" + "id": 222, + "link": "https://leetcode.com/problems/count-complete-tree-nodes/", + "title": "Count Complete Tree Nodes" }, "223": { - "id": 223, "category": "Math & Geometry", - "title": "Rectangle Area", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rectangle-area/" + "id": 223, + "link": "https://leetcode.com/problems/rectangle-area/", + "title": "Rectangle Area" }, "224": { - "id": 224, "category": "Stack", - "title": "Basic Calculator", "difficulty": "Hard", - "link": "https://leetcode.com/problems/basic-calculator/" + "id": 224, + "link": "https://leetcode.com/problems/basic-calculator/", + "title": "Basic Calculator" }, "225": { - "id": 225, "category": "Stack", - "title": "Implement Stack using Queues", "difficulty": "Easy", - "link": "https://leetcode.com/problems/implement-stack-using-queues/" + "id": 225, + "link": "https://leetcode.com/problems/implement-stack-using-queues/", + "title": "Implement Stack using Queues" }, "226": { - "id": 226, "category": "Tree", - "title": "Invert Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/invert-binary-tree/" + "id": 226, + "link": "https://leetcode.com/problems/invert-binary-tree/", + "title": "Invert Binary Tree" }, "227": { - "id": 227, "category": "Stack", - "title": "Basic Calculator II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/basic-calculator-ii/" + "id": 227, + "link": "https://leetcode.com/problems/basic-calculator-ii/", + "title": "Basic Calculator II" }, "228": { - "id": 228, "category": "Array & Hashing", - "title": "Summary Ranges", "difficulty": "Easy", - "link": "https://leetcode.com/problems/summary-ranges/" + "id": 228, + "link": "https://leetcode.com/problems/summary-ranges/", + "title": "Summary Ranges" }, "229": { - "id": 229, "category": "Array & Hashing", - "title": "Majority Element II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/majority-element-ii/" + "id": 229, + "link": "https://leetcode.com/problems/majority-element-ii/", + "title": "Majority Element II" }, "230": { - "id": 230, "category": "Tree", - "title": "Kth Smallest Element in a BST", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kth-smallest-element-in-a-bst/" + "id": 230, + "link": "https://leetcode.com/problems/kth-smallest-element-in-a-bst/", + "title": "Kth Smallest Element in a BST" }, "231": { - "id": 231, "category": "Bit Manipulation", - "title": "Power of Two", "difficulty": "Easy", - "link": "https://leetcode.com/problems/power-of-two/" + "id": 231, + "link": "https://leetcode.com/problems/power-of-two/", + "title": "Power of Two" }, "232": { - "id": 232, "category": "Stack", - "title": "Implement Queue using Stacks", "difficulty": "Easy", - "link": "https://leetcode.com/problems/implement-queue-using-stacks/" + "id": 232, + "link": "https://leetcode.com/problems/implement-queue-using-stacks/", + "title": "Implement Queue using Stacks" }, "233": { - "id": 233, "category": "Dynamic Programming", - "title": "Number of Digit One", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-digit-one/" + "id": 233, + "link": "https://leetcode.com/problems/number-of-digit-one/", + "title": "Number of Digit One" }, "234": { - "id": 234, "category": "Stack", - "title": "Palindrome Linked List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/palindrome-linked-list/" + "id": 234, + "link": "https://leetcode.com/problems/palindrome-linked-list/", + "title": "Palindrome Linked List" }, "235": { - "id": 235, "category": "Tree", - "title": "Lowest Common Ancestor of a Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/" + "id": 235, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/", + "title": "Lowest Common Ancestor of a Binary Search Tree" }, "236": { - "id": 236, "category": "Tree", - "title": "Lowest Common Ancestor of a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/" + "id": 236, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/", + "title": "Lowest Common Ancestor of a Binary Tree" }, "237": { - "id": 237, "category": "Linked List", - "title": "Delete Node in a Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-node-in-a-linked-list/" + "id": 237, + "link": "https://leetcode.com/problems/delete-node-in-a-linked-list/", + "title": "Delete Node in a Linked List" }, "238": { - "id": 238, "category": "Array & Hashing", - "title": "Product of Array Except Self", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-of-array-except-self/" + "id": 238, + "link": "https://leetcode.com/problems/product-of-array-except-self/", + "title": "Product of Array Except Self" }, "239": { - "id": 239, "category": "Sliding Window", - "title": "Sliding Window Maximum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sliding-window-maximum/" + "id": 239, + "link": "https://leetcode.com/problems/sliding-window-maximum/", + "title": "Sliding Window Maximum" }, "240": { - "id": 240, "category": "Binary Search", - "title": "Search a 2D Matrix II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-a-2d-matrix-ii/" + "id": 240, + "link": "https://leetcode.com/problems/search-a-2d-matrix-ii/", + "title": "Search a 2D Matrix II" }, "241": { - "id": 241, "category": "Dynamic Programming", - "title": "Different Ways to Add Parentheses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/different-ways-to-add-parentheses/" + "id": 241, + "link": "https://leetcode.com/problems/different-ways-to-add-parentheses/", + "title": "Different Ways to Add Parentheses" }, "242": { - "id": 242, "category": "Array & Hashing", - "title": "Valid Anagram", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-anagram/" + "id": 242, + "link": "https://leetcode.com/problems/valid-anagram/", + "title": "Valid Anagram" }, "243": { - "id": 243, "category": "Array & Hashing", - "title": "Shortest Word Distance", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-word-distance/" + "id": 243, + "link": "https://leetcode.com/problems/shortest-word-distance/", + "title": "Shortest Word Distance" }, "244": { - "id": 244, "category": "Two Pointers", - "title": "Shortest Word Distance II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-word-distance-ii/" + "id": 244, + "link": "https://leetcode.com/problems/shortest-word-distance-ii/", + "title": "Shortest Word Distance II" }, "245": { - "id": 245, "category": "Array & Hashing", - "title": "Shortest Word Distance III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-word-distance-iii/" + "id": 245, + "link": "https://leetcode.com/problems/shortest-word-distance-iii/", + "title": "Shortest Word Distance III" }, "246": { - "id": 246, "category": "Two Pointers", - "title": "Strobogrammatic Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/strobogrammatic-number/" + "id": 246, + "link": "https://leetcode.com/problems/strobogrammatic-number/", + "title": "Strobogrammatic Number" }, "247": { - "id": 247, "category": "Array & Hashing", - "title": "Strobogrammatic Number II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/strobogrammatic-number-ii/" + "id": 247, + "link": "https://leetcode.com/problems/strobogrammatic-number-ii/", + "title": "Strobogrammatic Number II" }, "248": { - "id": 248, "category": "Array & Hashing", - "title": "Strobogrammatic Number III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/strobogrammatic-number-iii/" + "id": 248, + "link": "https://leetcode.com/problems/strobogrammatic-number-iii/", + "title": "Strobogrammatic Number III" }, "249": { - "id": 249, "category": "Array & Hashing", - "title": "Group Shifted Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/group-shifted-strings/" + "id": 249, + "link": "https://leetcode.com/problems/group-shifted-strings/", + "title": "Group Shifted Strings" }, "250": { - "id": 250, "category": "Tree", - "title": "Count Univalue Subtrees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-univalue-subtrees/" + "id": 250, + "link": "https://leetcode.com/problems/count-univalue-subtrees/", + "title": "Count Univalue Subtrees" }, "251": { - "id": 251, "category": "Two Pointers", - "title": "Flatten 2D Vector", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flatten-2d-vector/" + "id": 251, + "link": "https://leetcode.com/problems/flatten-2d-vector/", + "title": "Flatten 2D Vector" }, "252": { - "id": 252, "category": "Array & Hashing", - "title": "Meeting Rooms", "difficulty": "Easy", - "link": "https://leetcode.com/problems/meeting-rooms/" + "id": 252, + "link": "https://leetcode.com/problems/meeting-rooms/", + "title": "Meeting Rooms" }, "253": { - "id": 253, "category": "Heap (Priority Queue)", - "title": "Meeting Rooms II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/meeting-rooms-ii/" + "id": 253, + "link": "https://leetcode.com/problems/meeting-rooms-ii/", + "title": "Meeting Rooms II" }, "254": { - "id": 254, "category": "Backtracking", - "title": "Factor Combinations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/factor-combinations/" + "id": 254, + "link": "https://leetcode.com/problems/factor-combinations/", + "title": "Factor Combinations" }, "255": { - "id": 255, "category": "Tree", - "title": "Verify Preorder Sequence in Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/" + "id": 255, + "link": "https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/", + "title": "Verify Preorder Sequence in Binary Search Tree" }, "256": { - "id": 256, "category": "Dynamic Programming", - "title": "Paint House", "difficulty": "Medium", - "link": "https://leetcode.com/problems/paint-house/" + "id": 256, + "link": "https://leetcode.com/problems/paint-house/", + "title": "Paint House" }, "257": { - "id": 257, "category": "Tree", - "title": "Binary Tree Paths", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-tree-paths/" - }, - "258": { - "id": 258, - "category": "Math & Geometry", - "title": "Add Digits", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-digits/" + "id": 257, + "link": "https://leetcode.com/problems/binary-tree-paths/", + "title": "Binary Tree Paths" }, + "258": {"category": "Math & Geometry", "difficulty": "Easy", "id": 258, "link": "https://leetcode.com/problems/add-digits/", "title": "Add Digits"}, "259": { - "id": 259, "category": "Binary Search", - "title": "3Sum Smaller", "difficulty": "Medium", - "link": "https://leetcode.com/problems/3sum-smaller/" + "id": 259, + "link": "https://leetcode.com/problems/3sum-smaller/", + "title": "3Sum Smaller" }, "260": { - "id": 260, "category": "Bit Manipulation", - "title": "Single Number III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/single-number-iii/" + "id": 260, + "link": "https://leetcode.com/problems/single-number-iii/", + "title": "Single Number III" }, "261": { - "id": 261, "category": "Graph Traversal", - "title": "Graph Valid Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/graph-valid-tree/" + "id": 261, + "link": "https://leetcode.com/problems/graph-valid-tree/", + "title": "Graph Valid Tree" }, "262": { - "id": 262, "category": "Database", - "title": "Trips and Users", "difficulty": "Hard", - "link": "https://leetcode.com/problems/trips-and-users/" + "id": 262, + "link": "https://leetcode.com/problems/trips-and-users/", + "title": "Trips and Users" }, "263": { - "id": 263, "category": "Math & Geometry", - "title": "Ugly Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/ugly-number/" + "id": 263, + "link": "https://leetcode.com/problems/ugly-number/", + "title": "Ugly Number" }, "264": { - "id": 264, "category": "Dynamic Programming", - "title": "Ugly Number II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ugly-number-ii/" + "id": 264, + "link": "https://leetcode.com/problems/ugly-number-ii/", + "title": "Ugly Number II" }, "265": { - "id": 265, "category": "Dynamic Programming", - "title": "Paint House II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/paint-house-ii/" + "id": 265, + "link": "https://leetcode.com/problems/paint-house-ii/", + "title": "Paint House II" }, "266": { - "id": 266, "category": "Bit Manipulation", - "title": "Palindrome Permutation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/palindrome-permutation/" + "id": 266, + "link": "https://leetcode.com/problems/palindrome-permutation/", + "title": "Palindrome Permutation" }, "267": { - "id": 267, "category": "Backtracking", - "title": "Palindrome Permutation II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/palindrome-permutation-ii/" + "id": 267, + "link": "https://leetcode.com/problems/palindrome-permutation-ii/", + "title": "Palindrome Permutation II" }, "268": { - "id": 268, "category": "Binary Search", - "title": "Missing Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/missing-number/" + "id": 268, + "link": "https://leetcode.com/problems/missing-number/", + "title": "Missing Number" }, "269": { - "id": 269, "category": "Graph Traversal", - "title": "Alien Dictionary", "difficulty": "Hard", - "link": "https://leetcode.com/problems/alien-dictionary/" + "id": 269, + "link": "https://leetcode.com/problems/alien-dictionary/", + "title": "Alien Dictionary" }, "270": { - "id": 270, "category": "Tree", - "title": "Closest Binary Search Tree Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/closest-binary-search-tree-value/" + "id": 270, + "link": "https://leetcode.com/problems/closest-binary-search-tree-value/", + "title": "Closest Binary Search Tree Value" }, "271": { - "id": 271, "category": "Array & Hashing", - "title": "Encode and Decode Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/encode-and-decode-strings/" + "id": 271, + "link": "https://leetcode.com/problems/encode-and-decode-strings/", + "title": "Encode and Decode Strings" }, "272": { - "id": 272, "category": "Tree", - "title": "Closest Binary Search Tree Value II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/closest-binary-search-tree-value-ii/" + "id": 272, + "link": "https://leetcode.com/problems/closest-binary-search-tree-value-ii/", + "title": "Closest Binary Search Tree Value II" }, "273": { - "id": 273, "category": "Math & Geometry", - "title": "Integer to English Words", "difficulty": "Hard", - "link": "https://leetcode.com/problems/integer-to-english-words/" - }, - "274": { - "id": 274, - "category": "Array & Hashing", - "title": "H-Index", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/h-index/" - }, - "275": { - "id": 275, - "category": "Binary Search", - "title": "H-Index II", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/h-index-ii/" + "id": 273, + "link": "https://leetcode.com/problems/integer-to-english-words/", + "title": "Integer to English Words" }, + "274": {"category": "Array & Hashing", "difficulty": "Medium", "id": 274, "link": "https://leetcode.com/problems/h-index/", "title": "H-Index"}, + "275": {"category": "Binary Search", "difficulty": "Medium", "id": 275, "link": "https://leetcode.com/problems/h-index-ii/", "title": "H-Index II"}, "276": { - "id": 276, "category": "Dynamic Programming", - "title": "Paint Fence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/paint-fence/" + "id": 276, + "link": "https://leetcode.com/problems/paint-fence/", + "title": "Paint Fence" }, "277": { - "id": 277, "category": "Graph Traversal", - "title": "Find the Celebrity", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-celebrity/" + "id": 277, + "link": "https://leetcode.com/problems/find-the-celebrity/", + "title": "Find the Celebrity" }, "278": { - "id": 278, "category": "Binary Search", - "title": "First Bad Version", "difficulty": "Easy", - "link": "https://leetcode.com/problems/first-bad-version/" + "id": 278, + "link": "https://leetcode.com/problems/first-bad-version/", + "title": "First Bad Version" }, "279": { - "id": 279, "category": "Graph Traversal", - "title": "Perfect Squares", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/perfect-squares/" - }, - "280": { - "id": 280, - "category": "Greedy", - "title": "Wiggle Sort", "difficulty": "Medium", - "link": "https://leetcode.com/problems/wiggle-sort/" + "id": 279, + "link": "https://leetcode.com/problems/perfect-squares/", + "title": "Perfect Squares" }, + "280": {"category": "Greedy", "difficulty": "Medium", "id": 280, "link": "https://leetcode.com/problems/wiggle-sort/", "title": "Wiggle Sort"}, "281": { - "id": 281, "category": "Array & Hashing", - "title": "Zigzag Iterator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zigzag-iterator/" + "id": 281, + "link": "https://leetcode.com/problems/zigzag-iterator/", + "title": "Zigzag Iterator" }, "282": { - "id": 282, "category": "Backtracking", - "title": "Expression Add Operators", "difficulty": "Hard", - "link": "https://leetcode.com/problems/expression-add-operators/" - }, - "283": { - "id": 283, - "category": "Two Pointers", - "title": "Move Zeroes", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/move-zeroes/" + "id": 282, + "link": "https://leetcode.com/problems/expression-add-operators/", + "title": "Expression Add Operators" }, + "283": {"category": "Two Pointers", "difficulty": "Easy", "id": 283, "link": "https://leetcode.com/problems/move-zeroes/", "title": "Move Zeroes"}, "284": { - "id": 284, "category": "Array & Hashing", - "title": "Peeking Iterator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/peeking-iterator/" + "id": 284, + "link": "https://leetcode.com/problems/peeking-iterator/", + "title": "Peeking Iterator" }, "285": { - "id": 285, "category": "Tree", - "title": "Inorder Successor in BST", "difficulty": "Medium", - "link": "https://leetcode.com/problems/inorder-successor-in-bst/" + "id": 285, + "link": "https://leetcode.com/problems/inorder-successor-in-bst/", + "title": "Inorder Successor in BST" }, "286": { - "id": 286, "category": "Graph Traversal", - "title": "Walls and Gates", "difficulty": "Medium", - "link": "https://leetcode.com/problems/walls-and-gates/" + "id": 286, + "link": "https://leetcode.com/problems/walls-and-gates/", + "title": "Walls and Gates" }, "287": { - "id": 287, "category": "Binary Search", - "title": "Find the Duplicate Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-duplicate-number/" + "id": 287, + "link": "https://leetcode.com/problems/find-the-duplicate-number/", + "title": "Find the Duplicate Number" }, "288": { - "id": 288, "category": "Array & Hashing", - "title": "Unique Word Abbreviation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-word-abbreviation/" + "id": 288, + "link": "https://leetcode.com/problems/unique-word-abbreviation/", + "title": "Unique Word Abbreviation" }, "289": { - "id": 289, "category": "Array & Hashing", - "title": "Game of Life", "difficulty": "Medium", - "link": "https://leetcode.com/problems/game-of-life/" + "id": 289, + "link": "https://leetcode.com/problems/game-of-life/", + "title": "Game of Life" }, "290": { - "id": 290, "category": "Array & Hashing", - "title": "Word Pattern", "difficulty": "Easy", - "link": "https://leetcode.com/problems/word-pattern/" + "id": 290, + "link": "https://leetcode.com/problems/word-pattern/", + "title": "Word Pattern" }, "291": { - "id": 291, "category": "Backtracking", - "title": "Word Pattern II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/word-pattern-ii/" - }, - "292": { - "id": 292, - "category": "Math & Geometry", - "title": "Nim Game", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/nim-game/" - }, - "293": { - "id": 293, - "category": "Array & Hashing", - "title": "Flip Game", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/flip-game/" + "id": 291, + "link": "https://leetcode.com/problems/word-pattern-ii/", + "title": "Word Pattern II" }, + "292": {"category": "Math & Geometry", "difficulty": "Easy", "id": 292, "link": "https://leetcode.com/problems/nim-game/", "title": "Nim Game"}, + "293": {"category": "Array & Hashing", "difficulty": "Easy", "id": 293, "link": "https://leetcode.com/problems/flip-game/", "title": "Flip Game"}, "294": { - "id": 294, "category": "Dynamic Programming", - "title": "Flip Game II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flip-game-ii/" + "id": 294, + "link": "https://leetcode.com/problems/flip-game-ii/", + "title": "Flip Game II" }, "295": { - "id": 295, "category": "Heap (Priority Queue)", - "title": "Find Median from Data Stream", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-median-from-data-stream/" + "id": 295, + "link": "https://leetcode.com/problems/find-median-from-data-stream/", + "title": "Find Median from Data Stream" }, "296": { - "id": 296, "category": "Math & Geometry", - "title": "Best Meeting Point", "difficulty": "Hard", - "link": "https://leetcode.com/problems/best-meeting-point/" + "id": 296, + "link": "https://leetcode.com/problems/best-meeting-point/", + "title": "Best Meeting Point" }, "297": { - "id": 297, "category": "Tree", - "title": "Serialize and Deserialize Binary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/serialize-and-deserialize-binary-tree/" + "id": 297, + "link": "https://leetcode.com/problems/serialize-and-deserialize-binary-tree/", + "title": "Serialize and Deserialize Binary Tree" }, "298": { - "id": 298, "category": "Tree", - "title": "Binary Tree Longest Consecutive Sequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/" + "id": 298, + "link": "https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/", + "title": "Binary Tree Longest Consecutive Sequence" }, "299": { - "id": 299, "category": "Array & Hashing", - "title": "Bulls and Cows", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bulls-and-cows/" + "id": 299, + "link": "https://leetcode.com/problems/bulls-and-cows/", + "title": "Bulls and Cows" }, "300": { - "id": 300, "category": "Dynamic Programming", - "title": "Longest Increasing Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-increasing-subsequence/" + "id": 300, + "link": "https://leetcode.com/problems/longest-increasing-subsequence/", + "title": "Longest Increasing Subsequence" }, "301": { - "id": 301, "category": "Graph Traversal", - "title": "Remove Invalid Parentheses", "difficulty": "Hard", - "link": "https://leetcode.com/problems/remove-invalid-parentheses/" + "id": 301, + "link": "https://leetcode.com/problems/remove-invalid-parentheses/", + "title": "Remove Invalid Parentheses" }, "302": { - "id": 302, "category": "Graph Traversal", - "title": "Smallest Rectangle Enclosing Black Pixels", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/" + "id": 302, + "link": "https://leetcode.com/problems/smallest-rectangle-enclosing-black-pixels/", + "title": "Smallest Rectangle Enclosing Black Pixels" }, "303": { - "id": 303, "category": "Array & Hashing", - "title": "Range Sum Query - Immutable", "difficulty": "Easy", - "link": "https://leetcode.com/problems/range-sum-query-immutable/" + "id": 303, + "link": "https://leetcode.com/problems/range-sum-query-immutable/", + "title": "Range Sum Query - Immutable" }, "304": { - "id": 304, "category": "Array & Hashing", - "title": "Range Sum Query 2D - Immutable", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-sum-query-2d-immutable/" + "id": 304, + "link": "https://leetcode.com/problems/range-sum-query-2d-immutable/", + "title": "Range Sum Query 2D - Immutable" }, "305": { - "id": 305, "category": "Graph Traversal", - "title": "Number of Islands II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-islands-ii/" + "id": 305, + "link": "https://leetcode.com/problems/number-of-islands-ii/", + "title": "Number of Islands II" }, "306": { - "id": 306, "category": "Backtracking", - "title": "Additive Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/additive-number/" + "id": 306, + "link": "https://leetcode.com/problems/additive-number/", + "title": "Additive Number" }, "307": { - "id": 307, "category": "Tree", - "title": "Range Sum Query - Mutable", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-sum-query-mutable/" + "id": 307, + "link": "https://leetcode.com/problems/range-sum-query-mutable/", + "title": "Range Sum Query - Mutable" }, "308": { - "id": 308, "category": "Tree", - "title": "Range Sum Query 2D - Mutable", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-sum-query-2d-mutable/" + "id": 308, + "link": "https://leetcode.com/problems/range-sum-query-2d-mutable/", + "title": "Range Sum Query 2D - Mutable" }, "309": { - "id": 309, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock with Cooldown", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/" + "id": 309, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/", + "title": "Best Time to Buy and Sell Stock with Cooldown" }, "310": { - "id": 310, "category": "Graph Traversal", - "title": "Minimum Height Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-height-trees/" + "id": 310, + "link": "https://leetcode.com/problems/minimum-height-trees/", + "title": "Minimum Height Trees" }, "311": { - "id": 311, "category": "Array & Hashing", - "title": "Sparse Matrix Multiplication", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sparse-matrix-multiplication/" + "id": 311, + "link": "https://leetcode.com/problems/sparse-matrix-multiplication/", + "title": "Sparse Matrix Multiplication" }, "312": { - "id": 312, "category": "Dynamic Programming", - "title": "Burst Balloons", "difficulty": "Hard", - "link": "https://leetcode.com/problems/burst-balloons/" + "id": 312, + "link": "https://leetcode.com/problems/burst-balloons/", + "title": "Burst Balloons" }, "313": { - "id": 313, "category": "Dynamic Programming", - "title": "Super Ugly Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/super-ugly-number/" + "id": 313, + "link": "https://leetcode.com/problems/super-ugly-number/", + "title": "Super Ugly Number" }, "314": { - "id": 314, "category": "Tree", - "title": "Binary Tree Vertical Order Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-vertical-order-traversal/" + "id": 314, + "link": "https://leetcode.com/problems/binary-tree-vertical-order-traversal/", + "title": "Binary Tree Vertical Order Traversal" }, "315": { - "id": 315, "category": "Tree", - "title": "Count of Smaller Numbers After Self", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-of-smaller-numbers-after-self/" + "id": 315, + "link": "https://leetcode.com/problems/count-of-smaller-numbers-after-self/", + "title": "Count of Smaller Numbers After Self" }, "316": { - "id": 316, "category": "Stack", - "title": "Remove Duplicate Letters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-duplicate-letters/" + "id": 316, + "link": "https://leetcode.com/problems/remove-duplicate-letters/", + "title": "Remove Duplicate Letters" }, "317": { - "id": 317, "category": "Graph Traversal", - "title": "Shortest Distance from All Buildings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-distance-from-all-buildings/" + "id": 317, + "link": "https://leetcode.com/problems/shortest-distance-from-all-buildings/", + "title": "Shortest Distance from All Buildings" }, "318": { - "id": 318, "category": "Bit Manipulation", - "title": "Maximum Product of Word Lengths", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-word-lengths/" + "id": 318, + "link": "https://leetcode.com/problems/maximum-product-of-word-lengths/", + "title": "Maximum Product of Word Lengths" }, "319": { - "id": 319, "category": "Math & Geometry", - "title": "Bulb Switcher", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bulb-switcher/" + "id": 319, + "link": "https://leetcode.com/problems/bulb-switcher/", + "title": "Bulb Switcher" }, "320": { - "id": 320, "category": "Backtracking", - "title": "Generalized Abbreviation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generalized-abbreviation/" + "id": 320, + "link": "https://leetcode.com/problems/generalized-abbreviation/", + "title": "Generalized Abbreviation" }, "321": { - "id": 321, "category": "Stack", - "title": "Create Maximum Number", "difficulty": "Hard", - "link": "https://leetcode.com/problems/create-maximum-number/" + "id": 321, + "link": "https://leetcode.com/problems/create-maximum-number/", + "title": "Create Maximum Number" }, "322": { - "id": 322, "category": "Graph Traversal", - "title": "Coin Change", "difficulty": "Medium", - "link": "https://leetcode.com/problems/coin-change/" + "id": 322, + "link": "https://leetcode.com/problems/coin-change/", + "title": "Coin Change" }, "323": { - "id": 323, "category": "Graph Traversal", - "title": "Number of Connected Components in an Undirected Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/" + "id": 323, + "link": "https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/", + "title": "Number of Connected Components in an Undirected Graph" }, "324": { - "id": 324, "category": "Greedy", - "title": "Wiggle Sort II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/wiggle-sort-ii/" + "id": 324, + "link": "https://leetcode.com/problems/wiggle-sort-ii/", + "title": "Wiggle Sort II" }, "325": { - "id": 325, "category": "Array & Hashing", - "title": "Maximum Size Subarray Sum Equals k", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/" + "id": 325, + "link": "https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/", + "title": "Maximum Size Subarray Sum Equals k" }, "326": { - "id": 326, "category": "Math & Geometry", - "title": "Power of Three", "difficulty": "Easy", - "link": "https://leetcode.com/problems/power-of-three/" + "id": 326, + "link": "https://leetcode.com/problems/power-of-three/", + "title": "Power of Three" }, "327": { - "id": 327, "category": "Tree", - "title": "Count of Range Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-of-range-sum/" + "id": 327, + "link": "https://leetcode.com/problems/count-of-range-sum/", + "title": "Count of Range Sum" }, "328": { - "id": 328, "category": "Linked List", - "title": "Odd Even Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/odd-even-linked-list/" + "id": 328, + "link": "https://leetcode.com/problems/odd-even-linked-list/", + "title": "Odd Even Linked List" }, "329": { - "id": 329, "category": "Graph Traversal", - "title": "Longest Increasing Path in a Matrix", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-increasing-path-in-a-matrix/" - }, - "330": { - "id": 330, - "category": "Greedy", - "title": "Patching Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/patching-array/" + "id": 329, + "link": "https://leetcode.com/problems/longest-increasing-path-in-a-matrix/", + "title": "Longest Increasing Path in a Matrix" }, + "330": {"category": "Greedy", "difficulty": "Hard", "id": 330, "link": "https://leetcode.com/problems/patching-array/", "title": "Patching Array"}, "331": { - "id": 331, "category": "Tree", - "title": "Verify Preorder Serialization of a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/" + "id": 331, + "link": "https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/", + "title": "Verify Preorder Serialization of a Binary Tree" }, "332": { - "id": 332, "category": "Graph Traversal", - "title": "Reconstruct Itinerary", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reconstruct-itinerary/" + "id": 332, + "link": "https://leetcode.com/problems/reconstruct-itinerary/", + "title": "Reconstruct Itinerary" }, "333": { - "id": 333, "category": "Tree", - "title": "Largest BST Subtree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-bst-subtree/" + "id": 333, + "link": "https://leetcode.com/problems/largest-bst-subtree/", + "title": "Largest BST Subtree" }, "334": { - "id": 334, "category": "Greedy", - "title": "Increasing Triplet Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/increasing-triplet-subsequence/" + "id": 334, + "link": "https://leetcode.com/problems/increasing-triplet-subsequence/", + "title": "Increasing Triplet Subsequence" }, "335": { - "id": 335, "category": "Math & Geometry", - "title": "Self Crossing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/self-crossing/" + "id": 335, + "link": "https://leetcode.com/problems/self-crossing/", + "title": "Self Crossing" }, "336": { - "id": 336, "category": "Trie", - "title": "Palindrome Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-pairs/" + "id": 336, + "link": "https://leetcode.com/problems/palindrome-pairs/", + "title": "Palindrome Pairs" }, "337": { - "id": 337, "category": "Tree", - "title": "House Robber III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/house-robber-iii/" + "id": 337, + "link": "https://leetcode.com/problems/house-robber-iii/", + "title": "House Robber III" }, "338": { - "id": 338, "category": "Dynamic Programming", - "title": "Counting Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/counting-bits/" + "id": 338, + "link": "https://leetcode.com/problems/counting-bits/", + "title": "Counting Bits" }, "339": { - "id": 339, "category": "Graph Traversal", - "title": "Nested List Weight Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/nested-list-weight-sum/" + "id": 339, + "link": "https://leetcode.com/problems/nested-list-weight-sum/", + "title": "Nested List Weight Sum" }, "340": { - "id": 340, "category": "Sliding Window", - "title": "Longest Substring with At Most K Distinct Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/" + "id": 340, + "link": "https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/", + "title": "Longest Substring with At Most K Distinct Characters" }, "341": { - "id": 341, "category": "Tree", - "title": "Flatten Nested List Iterator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flatten-nested-list-iterator/" + "id": 341, + "link": "https://leetcode.com/problems/flatten-nested-list-iterator/", + "title": "Flatten Nested List Iterator" }, "342": { - "id": 342, "category": "Bit Manipulation", - "title": "Power of Four", "difficulty": "Easy", - "link": "https://leetcode.com/problems/power-of-four/" + "id": 342, + "link": "https://leetcode.com/problems/power-of-four/", + "title": "Power of Four" }, "343": { - "id": 343, "category": "Dynamic Programming", - "title": "Integer Break", "difficulty": "Medium", - "link": "https://leetcode.com/problems/integer-break/" + "id": 343, + "link": "https://leetcode.com/problems/integer-break/", + "title": "Integer Break" }, "344": { - "id": 344, "category": "Two Pointers", - "title": "Reverse String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-string/" + "id": 344, + "link": "https://leetcode.com/problems/reverse-string/", + "title": "Reverse String" }, "345": { - "id": 345, "category": "Two Pointers", - "title": "Reverse Vowels of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-vowels-of-a-string/" + "id": 345, + "link": "https://leetcode.com/problems/reverse-vowels-of-a-string/", + "title": "Reverse Vowels of a String" }, "346": { - "id": 346, "category": "Array & Hashing", - "title": "Moving Average from Data Stream", "difficulty": "Easy", - "link": "https://leetcode.com/problems/moving-average-from-data-stream/" + "id": 346, + "link": "https://leetcode.com/problems/moving-average-from-data-stream/", + "title": "Moving Average from Data Stream" }, "347": { - "id": 347, "category": "Heap (Priority Queue)", - "title": "Top K Frequent Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/top-k-frequent-elements/" + "id": 347, + "link": "https://leetcode.com/problems/top-k-frequent-elements/", + "title": "Top K Frequent Elements" }, "348": { - "id": 348, "category": "Array & Hashing", - "title": "Design Tic-Tac-Toe", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-tic-tac-toe/" + "id": 348, + "link": "https://leetcode.com/problems/design-tic-tac-toe/", + "title": "Design Tic-Tac-Toe" }, "349": { - "id": 349, "category": "Binary Search", - "title": "Intersection of Two Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/intersection-of-two-arrays/" + "id": 349, + "link": "https://leetcode.com/problems/intersection-of-two-arrays/", + "title": "Intersection of Two Arrays" }, "350": { - "id": 350, "category": "Binary Search", - "title": "Intersection of Two Arrays II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/intersection-of-two-arrays-ii/" + "id": 350, + "link": "https://leetcode.com/problems/intersection-of-two-arrays-ii/", + "title": "Intersection of Two Arrays II" }, "351": { - "id": 351, "category": "Dynamic Programming", - "title": "Android Unlock Patterns", "difficulty": "Medium", - "link": "https://leetcode.com/problems/android-unlock-patterns/" + "id": 351, + "link": "https://leetcode.com/problems/android-unlock-patterns/", + "title": "Android Unlock Patterns" }, "352": { - "id": 352, "category": "Graph Traversal", - "title": "Data Stream as Disjoint Intervals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/data-stream-as-disjoint-intervals/" + "id": 352, + "link": "https://leetcode.com/problems/data-stream-as-disjoint-intervals/", + "title": "Data Stream as Disjoint Intervals" }, "353": { - "id": 353, "category": "Array & Hashing", - "title": "Design Snake Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-snake-game/" + "id": 353, + "link": "https://leetcode.com/problems/design-snake-game/", + "title": "Design Snake Game" }, "354": { - "id": 354, "category": "Dynamic Programming", - "title": "Russian Doll Envelopes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/russian-doll-envelopes/" + "id": 354, + "link": "https://leetcode.com/problems/russian-doll-envelopes/", + "title": "Russian Doll Envelopes" }, "355": { - "id": 355, "category": "Heap (Priority Queue)", - "title": "Design Twitter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-twitter/" + "id": 355, + "link": "https://leetcode.com/problems/design-twitter/", + "title": "Design Twitter" }, "356": { - "id": 356, "category": "Math & Geometry", - "title": "Line Reflection", "difficulty": "Medium", - "link": "https://leetcode.com/problems/line-reflection/" + "id": 356, + "link": "https://leetcode.com/problems/line-reflection/", + "title": "Line Reflection" }, "357": { - "id": 357, "category": "Dynamic Programming", - "title": "Count Numbers with Unique Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-numbers-with-unique-digits/" + "id": 357, + "link": "https://leetcode.com/problems/count-numbers-with-unique-digits/", + "title": "Count Numbers with Unique Digits" }, "358": { - "id": 358, "category": "Heap (Priority Queue)", - "title": "Rearrange String k Distance Apart", "difficulty": "Hard", - "link": "https://leetcode.com/problems/rearrange-string-k-distance-apart/" + "id": 358, + "link": "https://leetcode.com/problems/rearrange-string-k-distance-apart/", + "title": "Rearrange String k Distance Apart" }, "359": { - "id": 359, "category": "Array & Hashing", - "title": "Logger Rate Limiter", "difficulty": "Easy", - "link": "https://leetcode.com/problems/logger-rate-limiter/" + "id": 359, + "link": "https://leetcode.com/problems/logger-rate-limiter/", + "title": "Logger Rate Limiter" }, "360": { - "id": 360, "category": "Math & Geometry", - "title": "Sort Transformed Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-transformed-array/" + "id": 360, + "link": "https://leetcode.com/problems/sort-transformed-array/", + "title": "Sort Transformed Array" }, "361": { - "id": 361, "category": "Dynamic Programming", - "title": "Bomb Enemy", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bomb-enemy/" + "id": 361, + "link": "https://leetcode.com/problems/bomb-enemy/", + "title": "Bomb Enemy" }, "362": { - "id": 362, "category": "Binary Search", - "title": "Design Hit Counter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-hit-counter/" + "id": 362, + "link": "https://leetcode.com/problems/design-hit-counter/", + "title": "Design Hit Counter" }, "363": { - "id": 363, "category": "Binary Search", - "title": "Max Sum of Rectangle No Larger Than K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/" + "id": 363, + "link": "https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/", + "title": "Max Sum of Rectangle No Larger Than K" }, "364": { - "id": 364, "category": "Graph Traversal", - "title": "Nested List Weight Sum II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/nested-list-weight-sum-ii/" + "id": 364, + "link": "https://leetcode.com/problems/nested-list-weight-sum-ii/", + "title": "Nested List Weight Sum II" }, "365": { - "id": 365, "category": "Graph Traversal", - "title": "Water and Jug Problem", "difficulty": "Medium", - "link": "https://leetcode.com/problems/water-and-jug-problem/" + "id": 365, + "link": "https://leetcode.com/problems/water-and-jug-problem/", + "title": "Water and Jug Problem" }, "366": { - "id": 366, "category": "Tree", - "title": "Find Leaves of Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-leaves-of-binary-tree/" + "id": 366, + "link": "https://leetcode.com/problems/find-leaves-of-binary-tree/", + "title": "Find Leaves of Binary Tree" }, "367": { - "id": 367, "category": "Binary Search", - "title": "Valid Perfect Square", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-perfect-square/" + "id": 367, + "link": "https://leetcode.com/problems/valid-perfect-square/", + "title": "Valid Perfect Square" }, "368": { - "id": 368, "category": "Dynamic Programming", - "title": "Largest Divisible Subset", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-divisible-subset/" + "id": 368, + "link": "https://leetcode.com/problems/largest-divisible-subset/", + "title": "Largest Divisible Subset" }, "369": { - "id": 369, "category": "Linked List", - "title": "Plus One Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/plus-one-linked-list/" + "id": 369, + "link": "https://leetcode.com/problems/plus-one-linked-list/", + "title": "Plus One Linked List" }, "370": { - "id": 370, "category": "Array & Hashing", - "title": "Range Addition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-addition/" + "id": 370, + "link": "https://leetcode.com/problems/range-addition/", + "title": "Range Addition" }, "371": { - "id": 371, "category": "Bit Manipulation", - "title": "Sum of Two Integers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-two-integers/" - }, - "372": { - "id": 372, - "category": "Math & Geometry", - "title": "Super Pow", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/super-pow/" + "id": 371, + "link": "https://leetcode.com/problems/sum-of-two-integers/", + "title": "Sum of Two Integers" }, + "372": {"category": "Math & Geometry", "difficulty": "Medium", "id": 372, "link": "https://leetcode.com/problems/super-pow/", "title": "Super Pow"}, "373": { - "id": 373, "category": "Heap (Priority Queue)", - "title": "Find K Pairs with Smallest Sums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-k-pairs-with-smallest-sums/" + "id": 373, + "link": "https://leetcode.com/problems/find-k-pairs-with-smallest-sums/", + "title": "Find K Pairs with Smallest Sums" }, "374": { - "id": 374, "category": "Binary Search", - "title": "Guess Number Higher or Lower", "difficulty": "Easy", - "link": "https://leetcode.com/problems/guess-number-higher-or-lower/" + "id": 374, + "link": "https://leetcode.com/problems/guess-number-higher-or-lower/", + "title": "Guess Number Higher or Lower" }, "375": { - "id": 375, "category": "Dynamic Programming", - "title": "Guess Number Higher or Lower II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/guess-number-higher-or-lower-ii/" + "id": 375, + "link": "https://leetcode.com/problems/guess-number-higher-or-lower-ii/", + "title": "Guess Number Higher or Lower II" }, "376": { - "id": 376, "category": "Dynamic Programming", - "title": "Wiggle Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/wiggle-subsequence/" + "id": 376, + "link": "https://leetcode.com/problems/wiggle-subsequence/", + "title": "Wiggle Subsequence" }, "377": { - "id": 377, "category": "Dynamic Programming", - "title": "Combination Sum IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/combination-sum-iv/" + "id": 377, + "link": "https://leetcode.com/problems/combination-sum-iv/", + "title": "Combination Sum IV" }, "378": { - "id": 378, "category": "Binary Search", - "title": "Kth Smallest Element in a Sorted Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/" + "id": 378, + "link": "https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/", + "title": "Kth Smallest Element in a Sorted Matrix" }, "379": { - "id": 379, "category": "Linked List", - "title": "Design Phone Directory", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-phone-directory/" + "id": 379, + "link": "https://leetcode.com/problems/design-phone-directory/", + "title": "Design Phone Directory" }, "380": { - "id": 380, "category": "Math & Geometry", - "title": "Insert Delete GetRandom O(1)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insert-delete-getrandom-o1/" + "id": 380, + "link": "https://leetcode.com/problems/insert-delete-getrandom-o1/", + "title": "Insert Delete GetRandom O(1)" }, "381": { - "id": 381, "category": "Math & Geometry", - "title": "Insert Delete GetRandom O(1) - Duplicates allowed", "difficulty": "Hard", - "link": "https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/" + "id": 381, + "link": "https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/", + "title": "Insert Delete GetRandom O(1) - Duplicates allowed" }, "382": { - "id": 382, "category": "Linked List", - "title": "Linked List Random Node", "difficulty": "Medium", - "link": "https://leetcode.com/problems/linked-list-random-node/" + "id": 382, + "link": "https://leetcode.com/problems/linked-list-random-node/", + "title": "Linked List Random Node" }, "383": { - "id": 383, "category": "Array & Hashing", - "title": "Ransom Note", "difficulty": "Easy", - "link": "https://leetcode.com/problems/ransom-note/" + "id": 383, + "link": "https://leetcode.com/problems/ransom-note/", + "title": "Ransom Note" }, "384": { - "id": 384, "category": "Math & Geometry", - "title": "Shuffle an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shuffle-an-array/" + "id": 384, + "link": "https://leetcode.com/problems/shuffle-an-array/", + "title": "Shuffle an Array" }, "385": { - "id": 385, "category": "Graph Traversal", - "title": "Mini Parser", "difficulty": "Medium", - "link": "https://leetcode.com/problems/mini-parser/" + "id": 385, + "link": "https://leetcode.com/problems/mini-parser/", + "title": "Mini Parser" }, "386": { - "id": 386, "category": "Graph Traversal", - "title": "Lexicographical Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographical-numbers/" + "id": 386, + "link": "https://leetcode.com/problems/lexicographical-numbers/", + "title": "Lexicographical Numbers" }, "387": { - "id": 387, "category": "Array & Hashing", - "title": "First Unique Character in a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/first-unique-character-in-a-string/" + "id": 387, + "link": "https://leetcode.com/problems/first-unique-character-in-a-string/", + "title": "First Unique Character in a String" }, "388": { - "id": 388, "category": "Graph Traversal", - "title": "Longest Absolute File Path", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-absolute-file-path/" + "id": 388, + "link": "https://leetcode.com/problems/longest-absolute-file-path/", + "title": "Longest Absolute File Path" }, "389": { - "id": 389, "category": "Bit Manipulation", - "title": "Find the Difference", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-difference/" + "id": 389, + "link": "https://leetcode.com/problems/find-the-difference/", + "title": "Find the Difference" }, "390": { - "id": 390, "category": "Math & Geometry", - "title": "Elimination Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/elimination-game/" + "id": 390, + "link": "https://leetcode.com/problems/elimination-game/", + "title": "Elimination Game" }, "391": { - "id": 391, "category": "Math & Geometry", - "title": "Perfect Rectangle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/perfect-rectangle/" + "id": 391, + "link": "https://leetcode.com/problems/perfect-rectangle/", + "title": "Perfect Rectangle" }, "392": { - "id": 392, "category": "Dynamic Programming", - "title": "Is Subsequence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/is-subsequence/" + "id": 392, + "link": "https://leetcode.com/problems/is-subsequence/", + "title": "Is Subsequence" }, "393": { - "id": 393, "category": "Bit Manipulation", - "title": "UTF-8 Validation", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/utf-8-validation/" - }, - "394": { - "id": 394, - "category": "Stack", - "title": "Decode String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decode-string/" + "id": 393, + "link": "https://leetcode.com/problems/utf-8-validation/", + "title": "UTF-8 Validation" }, + "394": {"category": "Stack", "difficulty": "Medium", "id": 394, "link": "https://leetcode.com/problems/decode-string/", "title": "Decode String"}, "395": { - "id": 395, "category": "Sliding Window", - "title": "Longest Substring with At Least K Repeating Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/" + "id": 395, + "link": "https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/", + "title": "Longest Substring with At Least K Repeating Characters" }, "396": { - "id": 396, "category": "Dynamic Programming", - "title": "Rotate Function", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotate-function/" + "id": 396, + "link": "https://leetcode.com/problems/rotate-function/", + "title": "Rotate Function" }, "397": { - "id": 397, "category": "Dynamic Programming", - "title": "Integer Replacement", "difficulty": "Medium", - "link": "https://leetcode.com/problems/integer-replacement/" + "id": 397, + "link": "https://leetcode.com/problems/integer-replacement/", + "title": "Integer Replacement" }, "398": { - "id": 398, "category": "Math & Geometry", - "title": "Random Pick Index", "difficulty": "Medium", - "link": "https://leetcode.com/problems/random-pick-index/" + "id": 398, + "link": "https://leetcode.com/problems/random-pick-index/", + "title": "Random Pick Index" }, "399": { - "id": 399, "category": "Graph Traversal", - "title": "Evaluate Division", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/evaluate-division/" - }, - "400": { - "id": 400, - "category": "Binary Search", - "title": "Nth Digit", "difficulty": "Medium", - "link": "https://leetcode.com/problems/nth-digit/" + "id": 399, + "link": "https://leetcode.com/problems/evaluate-division/", + "title": "Evaluate Division" }, + "400": {"category": "Binary Search", "difficulty": "Medium", "id": 400, "link": "https://leetcode.com/problems/nth-digit/", "title": "Nth Digit"}, "401": { - "id": 401, "category": "Backtracking", - "title": "Binary Watch", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-watch/" + "id": 401, + "link": "https://leetcode.com/problems/binary-watch/", + "title": "Binary Watch" }, "402": { - "id": 402, "category": "Stack", - "title": "Remove K Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-k-digits/" + "id": 402, + "link": "https://leetcode.com/problems/remove-k-digits/", + "title": "Remove K Digits" }, "403": { - "id": 403, "category": "Dynamic Programming", - "title": "Frog Jump", "difficulty": "Hard", - "link": "https://leetcode.com/problems/frog-jump/" + "id": 403, + "link": "https://leetcode.com/problems/frog-jump/", + "title": "Frog Jump" }, "404": { - "id": 404, "category": "Tree", - "title": "Sum of Left Leaves", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-left-leaves/" + "id": 404, + "link": "https://leetcode.com/problems/sum-of-left-leaves/", + "title": "Sum of Left Leaves" }, "405": { - "id": 405, "category": "Bit Manipulation", - "title": "Convert a Number to Hexadecimal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-a-number-to-hexadecimal/" + "id": 405, + "link": "https://leetcode.com/problems/convert-a-number-to-hexadecimal/", + "title": "Convert a Number to Hexadecimal" }, "406": { - "id": 406, "category": "Tree", - "title": "Queue Reconstruction by Height", "difficulty": "Medium", - "link": "https://leetcode.com/problems/queue-reconstruction-by-height/" + "id": 406, + "link": "https://leetcode.com/problems/queue-reconstruction-by-height/", + "title": "Queue Reconstruction by Height" }, "407": { - "id": 407, "category": "Graph Traversal", - "title": "Trapping Rain Water II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/trapping-rain-water-ii/" + "id": 407, + "link": "https://leetcode.com/problems/trapping-rain-water-ii/", + "title": "Trapping Rain Water II" }, "408": { - "id": 408, "category": "Two Pointers", - "title": "Valid Word Abbreviation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-word-abbreviation/" + "id": 408, + "link": "https://leetcode.com/problems/valid-word-abbreviation/", + "title": "Valid Word Abbreviation" }, "409": { - "id": 409, "category": "Greedy", - "title": "Longest Palindrome", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-palindrome/" + "id": 409, + "link": "https://leetcode.com/problems/longest-palindrome/", + "title": "Longest Palindrome" }, "410": { - "id": 410, "category": "Dynamic Programming", - "title": "Split Array Largest Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/split-array-largest-sum/" + "id": 410, + "link": "https://leetcode.com/problems/split-array-largest-sum/", + "title": "Split Array Largest Sum" }, "411": { - "id": 411, "category": "Backtracking", - "title": "Minimum Unique Word Abbreviation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-unique-word-abbreviation/" - }, - "412": { - "id": 412, - "category": "Math & Geometry", - "title": "Fizz Buzz", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/fizz-buzz/" + "id": 411, + "link": "https://leetcode.com/problems/minimum-unique-word-abbreviation/", + "title": "Minimum Unique Word Abbreviation" }, + "412": {"category": "Math & Geometry", "difficulty": "Easy", "id": 412, "link": "https://leetcode.com/problems/fizz-buzz/", "title": "Fizz Buzz"}, "413": { - "id": 413, "category": "Dynamic Programming", - "title": "Arithmetic Slices", "difficulty": "Medium", - "link": "https://leetcode.com/problems/arithmetic-slices/" + "id": 413, + "link": "https://leetcode.com/problems/arithmetic-slices/", + "title": "Arithmetic Slices" }, "414": { - "id": 414, "category": "Array & Hashing", - "title": "Third Maximum Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/third-maximum-number/" + "id": 414, + "link": "https://leetcode.com/problems/third-maximum-number/", + "title": "Third Maximum Number" }, "415": { - "id": 415, "category": "Math & Geometry", - "title": "Add Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-strings/" + "id": 415, + "link": "https://leetcode.com/problems/add-strings/", + "title": "Add Strings" }, "416": { - "id": 416, "category": "Dynamic Programming", - "title": "Partition Equal Subset Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-equal-subset-sum/" + "id": 416, + "link": "https://leetcode.com/problems/partition-equal-subset-sum/", + "title": "Partition Equal Subset Sum" }, "417": { - "id": 417, "category": "Graph Traversal", - "title": "Pacific Atlantic Water Flow", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pacific-atlantic-water-flow/" + "id": 417, + "link": "https://leetcode.com/problems/pacific-atlantic-water-flow/", + "title": "Pacific Atlantic Water Flow" }, "418": { - "id": 418, "category": "Dynamic Programming", - "title": "Sentence Screen Fitting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sentence-screen-fitting/" + "id": 418, + "link": "https://leetcode.com/problems/sentence-screen-fitting/", + "title": "Sentence Screen Fitting" }, "419": { - "id": 419, "category": "Graph Traversal", - "title": "Battleships in a Board", "difficulty": "Medium", - "link": "https://leetcode.com/problems/battleships-in-a-board/" + "id": 419, + "link": "https://leetcode.com/problems/battleships-in-a-board/", + "title": "Battleships in a Board" }, "420": { - "id": 420, "category": "Heap (Priority Queue)", - "title": "Strong Password Checker", "difficulty": "Hard", - "link": "https://leetcode.com/problems/strong-password-checker/" + "id": 420, + "link": "https://leetcode.com/problems/strong-password-checker/", + "title": "Strong Password Checker" }, "421": { - "id": 421, "category": "Trie", - "title": "Maximum XOR of Two Numbers in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/" + "id": 421, + "link": "https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/", + "title": "Maximum XOR of Two Numbers in an Array" }, "422": { - "id": 422, "category": "Array & Hashing", - "title": "Valid Word Square", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-word-square/" + "id": 422, + "link": "https://leetcode.com/problems/valid-word-square/", + "title": "Valid Word Square" }, "423": { - "id": 423, "category": "Math & Geometry", - "title": "Reconstruct Original Digits from English", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reconstruct-original-digits-from-english/" + "id": 423, + "link": "https://leetcode.com/problems/reconstruct-original-digits-from-english/", + "title": "Reconstruct Original Digits from English" }, "424": { - "id": 424, "category": "Sliding Window", - "title": "Longest Repeating Character Replacement", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-repeating-character-replacement/" + "id": 424, + "link": "https://leetcode.com/problems/longest-repeating-character-replacement/", + "title": "Longest Repeating Character Replacement" }, "425": { - "id": 425, "category": "Backtracking", - "title": "Word Squares", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-squares/" + "id": 425, + "link": "https://leetcode.com/problems/word-squares/", + "title": "Word Squares" }, "426": { - "id": 426, "category": "Tree", - "title": "Convert Binary Search Tree to Sorted Doubly Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/" + "id": 426, + "link": "https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/", + "title": "Convert Binary Search Tree to Sorted Doubly Linked List" }, "427": { - "id": 427, "category": "Tree", - "title": "Construct Quad Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-quad-tree/" + "id": 427, + "link": "https://leetcode.com/problems/construct-quad-tree/", + "title": "Construct Quad Tree" }, "428": { - "id": 428, "category": "Tree", - "title": "Serialize and Deserialize N-ary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree/" + "id": 428, + "link": "https://leetcode.com/problems/serialize-and-deserialize-n-ary-tree/", + "title": "Serialize and Deserialize N-ary Tree" }, "429": { - "id": 429, "category": "Tree", - "title": "N-ary Tree Level Order Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/n-ary-tree-level-order-traversal/" + "id": 429, + "link": "https://leetcode.com/problems/n-ary-tree-level-order-traversal/", + "title": "N-ary Tree Level Order Traversal" }, "430": { - "id": 430, "category": "Graph Traversal", - "title": "Flatten a Multilevel Doubly Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/" + "id": 430, + "link": "https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/", + "title": "Flatten a Multilevel Doubly Linked List" }, "431": { - "id": 431, "category": "Tree", - "title": "Encode N-ary Tree to Binary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree/" + "id": 431, + "link": "https://leetcode.com/problems/encode-n-ary-tree-to-binary-tree/", + "title": "Encode N-ary Tree to Binary Tree" }, "432": { - "id": 432, "category": "Linked List", - "title": "All O`one Data Structure", "difficulty": "Hard", - "link": "https://leetcode.com/problems/all-oone-data-structure/" + "id": 432, + "link": "https://leetcode.com/problems/all-oone-data-structure/", + "title": "All O`one Data Structure" }, "433": { - "id": 433, "category": "Graph Traversal", - "title": "Minimum Genetic Mutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-genetic-mutation/" + "id": 433, + "link": "https://leetcode.com/problems/minimum-genetic-mutation/", + "title": "Minimum Genetic Mutation" }, "434": { - "id": 434, "category": "Array & Hashing", - "title": "Number of Segments in a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-segments-in-a-string/" + "id": 434, + "link": "https://leetcode.com/problems/number-of-segments-in-a-string/", + "title": "Number of Segments in a String" }, "435": { - "id": 435, "category": "Dynamic Programming", - "title": "Non-overlapping Intervals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/non-overlapping-intervals/" + "id": 435, + "link": "https://leetcode.com/problems/non-overlapping-intervals/", + "title": "Non-overlapping Intervals" }, "436": { - "id": 436, "category": "Binary Search", - "title": "Find Right Interval", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-right-interval/" - }, - "437": { - "id": 437, - "category": "Tree", - "title": "Path Sum III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-sum-iii/" + "id": 436, + "link": "https://leetcode.com/problems/find-right-interval/", + "title": "Find Right Interval" }, + "437": {"category": "Tree", "difficulty": "Medium", "id": 437, "link": "https://leetcode.com/problems/path-sum-iii/", "title": "Path Sum III"}, "438": { - "id": 438, "category": "Sliding Window", - "title": "Find All Anagrams in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-anagrams-in-a-string/" + "id": 438, + "link": "https://leetcode.com/problems/find-all-anagrams-in-a-string/", + "title": "Find All Anagrams in a String" }, "439": { - "id": 439, "category": "Stack", - "title": "Ternary Expression Parser", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ternary-expression-parser/" + "id": 439, + "link": "https://leetcode.com/problems/ternary-expression-parser/", + "title": "Ternary Expression Parser" }, "440": { - "id": 440, "category": "Trie", - "title": "K-th Smallest in Lexicographical Order", "difficulty": "Hard", - "link": "https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/" + "id": 440, + "link": "https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/", + "title": "K-th Smallest in Lexicographical Order" }, "441": { - "id": 441, "category": "Binary Search", - "title": "Arranging Coins", "difficulty": "Easy", - "link": "https://leetcode.com/problems/arranging-coins/" + "id": 441, + "link": "https://leetcode.com/problems/arranging-coins/", + "title": "Arranging Coins" }, "442": { - "id": 442, "category": "Array & Hashing", - "title": "Find All Duplicates in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-duplicates-in-an-array/" + "id": 442, + "link": "https://leetcode.com/problems/find-all-duplicates-in-an-array/", + "title": "Find All Duplicates in an Array" }, "443": { - "id": 443, "category": "Two Pointers", - "title": "String Compression", "difficulty": "Medium", - "link": "https://leetcode.com/problems/string-compression/" + "id": 443, + "link": "https://leetcode.com/problems/string-compression/", + "title": "String Compression" }, "444": { - "id": 444, "category": "Graph Traversal", - "title": "Sequence Reconstruction", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sequence-reconstruction/" + "id": 444, + "link": "https://leetcode.com/problems/sequence-reconstruction/", + "title": "Sequence Reconstruction" }, "445": { - "id": 445, "category": "Stack", - "title": "Add Two Numbers II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-two-numbers-ii/" + "id": 445, + "link": "https://leetcode.com/problems/add-two-numbers-ii/", + "title": "Add Two Numbers II" }, "446": { - "id": 446, "category": "Dynamic Programming", - "title": "Arithmetic Slices II - Subsequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/arithmetic-slices-ii-subsequence/" + "id": 446, + "link": "https://leetcode.com/problems/arithmetic-slices-ii-subsequence/", + "title": "Arithmetic Slices II - Subsequence" }, "447": { - "id": 447, "category": "Math & Geometry", - "title": "Number of Boomerangs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-boomerangs/" + "id": 447, + "link": "https://leetcode.com/problems/number-of-boomerangs/", + "title": "Number of Boomerangs" }, "448": { - "id": 448, "category": "Array & Hashing", - "title": "Find All Numbers Disappeared in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/" + "id": 448, + "link": "https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/", + "title": "Find All Numbers Disappeared in an Array" }, "449": { - "id": 449, "category": "Tree", - "title": "Serialize and Deserialize BST", "difficulty": "Medium", - "link": "https://leetcode.com/problems/serialize-and-deserialize-bst/" + "id": 449, + "link": "https://leetcode.com/problems/serialize-and-deserialize-bst/", + "title": "Serialize and Deserialize BST" }, "450": { - "id": 450, "category": "Tree", - "title": "Delete Node in a BST", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-node-in-a-bst/" + "id": 450, + "link": "https://leetcode.com/problems/delete-node-in-a-bst/", + "title": "Delete Node in a BST" }, "451": { - "id": 451, "category": "Heap (Priority Queue)", - "title": "Sort Characters By Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-characters-by-frequency/" + "id": 451, + "link": "https://leetcode.com/problems/sort-characters-by-frequency/", + "title": "Sort Characters By Frequency" }, "452": { - "id": 452, "category": "Greedy", - "title": "Minimum Number of Arrows to Burst Balloons", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/" + "id": 452, + "link": "https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/", + "title": "Minimum Number of Arrows to Burst Balloons" }, "453": { - "id": 453, "category": "Math & Geometry", - "title": "Minimum Moves to Equal Array Elements", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements/" - }, - "454": { - "id": 454, - "category": "Array & Hashing", - "title": "4Sum II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/4sum-ii/" - }, - "455": { - "id": 455, - "category": "Greedy", - "title": "Assign Cookies", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/assign-cookies/" + "id": 453, + "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements/", + "title": "Minimum Moves to Equal Array Elements" }, + "454": {"category": "Array & Hashing", "difficulty": "Medium", "id": 454, "link": "https://leetcode.com/problems/4sum-ii/", "title": "4Sum II"}, + "455": {"category": "Greedy", "difficulty": "Easy", "id": 455, "link": "https://leetcode.com/problems/assign-cookies/", "title": "Assign Cookies"}, "456": { - "id": 456, "category": "Binary Search", - "title": "132 Pattern", "difficulty": "Medium", - "link": "https://leetcode.com/problems/132-pattern/" + "id": 456, + "link": "https://leetcode.com/problems/132-pattern/", + "title": "132 Pattern" }, "457": { - "id": 457, "category": "Two Pointers", - "title": "Circular Array Loop", "difficulty": "Medium", - "link": "https://leetcode.com/problems/circular-array-loop/" + "id": 457, + "link": "https://leetcode.com/problems/circular-array-loop/", + "title": "Circular Array Loop" }, "458": { - "id": 458, "category": "Dynamic Programming", - "title": "Poor Pigs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/poor-pigs/" + "id": 458, + "link": "https://leetcode.com/problems/poor-pigs/", + "title": "Poor Pigs" }, "459": { - "id": 459, "category": "Array & Hashing", - "title": "Repeated Substring Pattern", "difficulty": "Easy", - "link": "https://leetcode.com/problems/repeated-substring-pattern/" - }, - "460": { - "id": 460, - "category": "Linked List", - "title": "LFU Cache", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/lfu-cache/" + "id": 459, + "link": "https://leetcode.com/problems/repeated-substring-pattern/", + "title": "Repeated Substring Pattern" }, + "460": {"category": "Linked List", "difficulty": "Hard", "id": 460, "link": "https://leetcode.com/problems/lfu-cache/", "title": "LFU Cache"}, "461": { - "id": 461, "category": "Bit Manipulation", - "title": "Hamming Distance", "difficulty": "Easy", - "link": "https://leetcode.com/problems/hamming-distance/" + "id": 461, + "link": "https://leetcode.com/problems/hamming-distance/", + "title": "Hamming Distance" }, "462": { - "id": 462, "category": "Math & Geometry", - "title": "Minimum Moves to Equal Array Elements II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/" + "id": 462, + "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/", + "title": "Minimum Moves to Equal Array Elements II" }, "463": { - "id": 463, "category": "Graph Traversal", - "title": "Island Perimeter", "difficulty": "Easy", - "link": "https://leetcode.com/problems/island-perimeter/" + "id": 463, + "link": "https://leetcode.com/problems/island-perimeter/", + "title": "Island Perimeter" }, "464": { - "id": 464, "category": "Dynamic Programming", - "title": "Can I Win", "difficulty": "Medium", - "link": "https://leetcode.com/problems/can-i-win/" + "id": 464, + "link": "https://leetcode.com/problems/can-i-win/", + "title": "Can I Win" }, "465": { - "id": 465, "category": "Dynamic Programming", - "title": "Optimal Account Balancing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/optimal-account-balancing/" + "id": 465, + "link": "https://leetcode.com/problems/optimal-account-balancing/", + "title": "Optimal Account Balancing" }, "466": { - "id": 466, "category": "Dynamic Programming", - "title": "Count The Repetitions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-repetitions/" + "id": 466, + "link": "https://leetcode.com/problems/count-the-repetitions/", + "title": "Count The Repetitions" }, "467": { - "id": 467, "category": "Dynamic Programming", - "title": "Unique Substrings in Wraparound String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-substrings-in-wraparound-string/" + "id": 467, + "link": "https://leetcode.com/problems/unique-substrings-in-wraparound-string/", + "title": "Unique Substrings in Wraparound String" }, "468": { - "id": 468, "category": "Array & Hashing", - "title": "Validate IP Address", "difficulty": "Medium", - "link": "https://leetcode.com/problems/validate-ip-address/" + "id": 468, + "link": "https://leetcode.com/problems/validate-ip-address/", + "title": "Validate IP Address" }, "469": { - "id": 469, "category": "Math & Geometry", - "title": "Convex Polygon", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convex-polygon/" + "id": 469, + "link": "https://leetcode.com/problems/convex-polygon/", + "title": "Convex Polygon" }, "470": { - "id": 470, "category": "Math & Geometry", - "title": "Implement Rand10() Using Rand7()", "difficulty": "Medium", - "link": "https://leetcode.com/problems/implement-rand10-using-rand7/" + "id": 470, + "link": "https://leetcode.com/problems/implement-rand10-using-rand7/", + "title": "Implement Rand10() Using Rand7()" }, "471": { - "id": 471, "category": "Dynamic Programming", - "title": "Encode String with Shortest Length", "difficulty": "Hard", - "link": "https://leetcode.com/problems/encode-string-with-shortest-length/" + "id": 471, + "link": "https://leetcode.com/problems/encode-string-with-shortest-length/", + "title": "Encode String with Shortest Length" }, "472": { - "id": 472, "category": "Graph Traversal", - "title": "Concatenated Words", "difficulty": "Hard", - "link": "https://leetcode.com/problems/concatenated-words/" + "id": 472, + "link": "https://leetcode.com/problems/concatenated-words/", + "title": "Concatenated Words" }, "473": { - "id": 473, "category": "Dynamic Programming", - "title": "Matchsticks to Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/matchsticks-to-square/" + "id": 473, + "link": "https://leetcode.com/problems/matchsticks-to-square/", + "title": "Matchsticks to Square" }, "474": { - "id": 474, "category": "Dynamic Programming", - "title": "Ones and Zeroes", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/ones-and-zeroes/" - }, - "475": { - "id": 475, - "category": "Binary Search", - "title": "Heaters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/heaters/" + "id": 474, + "link": "https://leetcode.com/problems/ones-and-zeroes/", + "title": "Ones and Zeroes" }, + "475": {"category": "Binary Search", "difficulty": "Medium", "id": 475, "link": "https://leetcode.com/problems/heaters/", "title": "Heaters"}, "476": { - "id": 476, "category": "Bit Manipulation", - "title": "Number Complement", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-complement/" + "id": 476, + "link": "https://leetcode.com/problems/number-complement/", + "title": "Number Complement" }, "477": { - "id": 477, "category": "Bit Manipulation", - "title": "Total Hamming Distance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/total-hamming-distance/" + "id": 477, + "link": "https://leetcode.com/problems/total-hamming-distance/", + "title": "Total Hamming Distance" }, "478": { - "id": 478, "category": "Math & Geometry", - "title": "Generate Random Point in a Circle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generate-random-point-in-a-circle/" + "id": 478, + "link": "https://leetcode.com/problems/generate-random-point-in-a-circle/", + "title": "Generate Random Point in a Circle" }, "479": { - "id": 479, "category": "Math & Geometry", - "title": "Largest Palindrome Product", "difficulty": "Hard", - "link": "https://leetcode.com/problems/largest-palindrome-product/" + "id": 479, + "link": "https://leetcode.com/problems/largest-palindrome-product/", + "title": "Largest Palindrome Product" }, "480": { - "id": 480, "category": "Sliding Window", - "title": "Sliding Window Median", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sliding-window-median/" + "id": 480, + "link": "https://leetcode.com/problems/sliding-window-median/", + "title": "Sliding Window Median" }, "481": { - "id": 481, "category": "Two Pointers", - "title": "Magical String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/magical-string/" + "id": 481, + "link": "https://leetcode.com/problems/magical-string/", + "title": "Magical String" }, "482": { - "id": 482, "category": "Array & Hashing", - "title": "License Key Formatting", "difficulty": "Easy", - "link": "https://leetcode.com/problems/license-key-formatting/" + "id": 482, + "link": "https://leetcode.com/problems/license-key-formatting/", + "title": "License Key Formatting" }, "483": { - "id": 483, "category": "Binary Search", - "title": "Smallest Good Base", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-good-base/" + "id": 483, + "link": "https://leetcode.com/problems/smallest-good-base/", + "title": "Smallest Good Base" }, "484": { - "id": 484, "category": "Stack", - "title": "Find Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-permutation/" + "id": 484, + "link": "https://leetcode.com/problems/find-permutation/", + "title": "Find Permutation" }, "485": { - "id": 485, "category": "Array & Hashing", - "title": "Max Consecutive Ones", "difficulty": "Easy", - "link": "https://leetcode.com/problems/max-consecutive-ones/" + "id": 485, + "link": "https://leetcode.com/problems/max-consecutive-ones/", + "title": "Max Consecutive Ones" }, "486": { - "id": 486, "category": "Dynamic Programming", - "title": "Predict the Winner", "difficulty": "Medium", - "link": "https://leetcode.com/problems/predict-the-winner/" + "id": 486, + "link": "https://leetcode.com/problems/predict-the-winner/", + "title": "Predict the Winner" }, "487": { - "id": 487, "category": "Dynamic Programming", - "title": "Max Consecutive Ones II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-consecutive-ones-ii/" - }, - "488": { - "id": 488, - "category": "Graph Traversal", - "title": "Zuma Game", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/zuma-game/" + "id": 487, + "link": "https://leetcode.com/problems/max-consecutive-ones-ii/", + "title": "Max Consecutive Ones II" }, + "488": {"category": "Graph Traversal", "difficulty": "Hard", "id": 488, "link": "https://leetcode.com/problems/zuma-game/", "title": "Zuma Game"}, "489": { - "id": 489, "category": "Backtracking", - "title": "Robot Room Cleaner", "difficulty": "Hard", - "link": "https://leetcode.com/problems/robot-room-cleaner/" - }, - "490": { - "id": 490, - "category": "Graph Traversal", - "title": "The Maze", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-maze/" + "id": 489, + "link": "https://leetcode.com/problems/robot-room-cleaner/", + "title": "Robot Room Cleaner" }, + "490": {"category": "Graph Traversal", "difficulty": "Medium", "id": 490, "link": "https://leetcode.com/problems/the-maze/", "title": "The Maze"}, "491": { - "id": 491, "category": "Backtracking", - "title": "Non-decreasing Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/non-decreasing-subsequences/" + "id": 491, + "link": "https://leetcode.com/problems/non-decreasing-subsequences/", + "title": "Non-decreasing Subsequences" }, "492": { - "id": 492, "category": "Math & Geometry", - "title": "Construct the Rectangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/construct-the-rectangle/" - }, - "493": { - "id": 493, - "category": "Tree", - "title": "Reverse Pairs", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/reverse-pairs/" + "id": 492, + "link": "https://leetcode.com/problems/construct-the-rectangle/", + "title": "Construct the Rectangle" }, + "493": {"category": "Tree", "difficulty": "Hard", "id": 493, "link": "https://leetcode.com/problems/reverse-pairs/", "title": "Reverse Pairs"}, "494": { - "id": 494, "category": "Dynamic Programming", - "title": "Target Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/target-sum/" + "id": 494, + "link": "https://leetcode.com/problems/target-sum/", + "title": "Target Sum" }, "495": { - "id": 495, "category": "Array & Hashing", - "title": "Teemo Attacking", "difficulty": "Easy", - "link": "https://leetcode.com/problems/teemo-attacking/" + "id": 495, + "link": "https://leetcode.com/problems/teemo-attacking/", + "title": "Teemo Attacking" }, "496": { - "id": 496, "category": "Stack", - "title": "Next Greater Element I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/next-greater-element-i/" + "id": 496, + "link": "https://leetcode.com/problems/next-greater-element-i/", + "title": "Next Greater Element I" }, "497": { - "id": 497, "category": "Binary Search", - "title": "Random Point in Non-overlapping Rectangles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/" + "id": 497, + "link": "https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/", + "title": "Random Point in Non-overlapping Rectangles" }, "498": { - "id": 498, "category": "Array & Hashing", - "title": "Diagonal Traverse", "difficulty": "Medium", - "link": "https://leetcode.com/problems/diagonal-traverse/" + "id": 498, + "link": "https://leetcode.com/problems/diagonal-traverse/", + "title": "Diagonal Traverse" }, "499": { - "id": 499, "category": "Graph Traversal", - "title": "The Maze III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-maze-iii/" + "id": 499, + "link": "https://leetcode.com/problems/the-maze-iii/", + "title": "The Maze III" }, "500": { - "id": 500, "category": "Array & Hashing", - "title": "Keyboard Row", "difficulty": "Easy", - "link": "https://leetcode.com/problems/keyboard-row/" + "id": 500, + "link": "https://leetcode.com/problems/keyboard-row/", + "title": "Keyboard Row" }, "501": { - "id": 501, "category": "Tree", - "title": "Find Mode in Binary Search Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-mode-in-binary-search-tree/" - }, - "502": { - "id": 502, - "category": "Heap (Priority Queue)", - "title": "IPO", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/ipo/" + "id": 501, + "link": "https://leetcode.com/problems/find-mode-in-binary-search-tree/", + "title": "Find Mode in Binary Search Tree" }, + "502": {"category": "Heap (Priority Queue)", "difficulty": "Hard", "id": 502, "link": "https://leetcode.com/problems/ipo/", "title": "IPO"}, "503": { - "id": 503, "category": "Stack", - "title": "Next Greater Element II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-greater-element-ii/" - }, - "504": { - "id": 504, - "category": "Math & Geometry", - "title": "Base 7", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/base-7/" + "id": 503, + "link": "https://leetcode.com/problems/next-greater-element-ii/", + "title": "Next Greater Element II" }, + "504": {"category": "Math & Geometry", "difficulty": "Easy", "id": 504, "link": "https://leetcode.com/problems/base-7/", "title": "Base 7"}, "505": { - "id": 505, "category": "Graph Traversal", - "title": "The Maze II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-maze-ii/" + "id": 505, + "link": "https://leetcode.com/problems/the-maze-ii/", + "title": "The Maze II" }, "506": { - "id": 506, "category": "Heap (Priority Queue)", - "title": "Relative Ranks", "difficulty": "Easy", - "link": "https://leetcode.com/problems/relative-ranks/" + "id": 506, + "link": "https://leetcode.com/problems/relative-ranks/", + "title": "Relative Ranks" }, "507": { - "id": 507, "category": "Math & Geometry", - "title": "Perfect Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/perfect-number/" + "id": 507, + "link": "https://leetcode.com/problems/perfect-number/", + "title": "Perfect Number" }, "508": { - "id": 508, "category": "Tree", - "title": "Most Frequent Subtree Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-frequent-subtree-sum/" + "id": 508, + "link": "https://leetcode.com/problems/most-frequent-subtree-sum/", + "title": "Most Frequent Subtree Sum" }, "509": { - "id": 509, "category": "Dynamic Programming", - "title": "Fibonacci Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fibonacci-number/" + "id": 509, + "link": "https://leetcode.com/problems/fibonacci-number/", + "title": "Fibonacci Number" }, "510": { - "id": 510, "category": "Tree", - "title": "Inorder Successor in BST II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/inorder-successor-in-bst-ii/" + "id": 510, + "link": "https://leetcode.com/problems/inorder-successor-in-bst-ii/", + "title": "Inorder Successor in BST II" }, "511": { - "id": 511, "category": "Database", - "title": "Game Play Analysis I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/game-play-analysis-i/" + "id": 511, + "link": "https://leetcode.com/problems/game-play-analysis-i/", + "title": "Game Play Analysis I" }, "512": { - "id": 512, "category": "Database", - "title": "Game Play Analysis II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/game-play-analysis-ii/" + "id": 512, + "link": "https://leetcode.com/problems/game-play-analysis-ii/", + "title": "Game Play Analysis II" }, "513": { - "id": 513, "category": "Tree", - "title": "Find Bottom Left Tree Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-bottom-left-tree-value/" + "id": 513, + "link": "https://leetcode.com/problems/find-bottom-left-tree-value/", + "title": "Find Bottom Left Tree Value" }, "514": { - "id": 514, "category": "Graph Traversal", - "title": "Freedom Trail", "difficulty": "Hard", - "link": "https://leetcode.com/problems/freedom-trail/" + "id": 514, + "link": "https://leetcode.com/problems/freedom-trail/", + "title": "Freedom Trail" }, "515": { - "id": 515, "category": "Tree", - "title": "Find Largest Value in Each Tree Row", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-largest-value-in-each-tree-row/" + "id": 515, + "link": "https://leetcode.com/problems/find-largest-value-in-each-tree-row/", + "title": "Find Largest Value in Each Tree Row" }, "516": { - "id": 516, "category": "Dynamic Programming", - "title": "Longest Palindromic Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindromic-subsequence/" + "id": 516, + "link": "https://leetcode.com/problems/longest-palindromic-subsequence/", + "title": "Longest Palindromic Subsequence" }, "517": { - "id": 517, "category": "Greedy", - "title": "Super Washing Machines", "difficulty": "Hard", - "link": "https://leetcode.com/problems/super-washing-machines/" + "id": 517, + "link": "https://leetcode.com/problems/super-washing-machines/", + "title": "Super Washing Machines" }, "518": { - "id": 518, "category": "Dynamic Programming", - "title": "Coin Change II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/coin-change-ii/" + "id": 518, + "link": "https://leetcode.com/problems/coin-change-ii/", + "title": "Coin Change II" }, "519": { - "id": 519, "category": "Math & Geometry", - "title": "Random Flip Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/random-flip-matrix/" + "id": 519, + "link": "https://leetcode.com/problems/random-flip-matrix/", + "title": "Random Flip Matrix" }, "520": { - "id": 520, "category": "Array & Hashing", - "title": "Detect Capital", "difficulty": "Easy", - "link": "https://leetcode.com/problems/detect-capital/" + "id": 520, + "link": "https://leetcode.com/problems/detect-capital/", + "title": "Detect Capital" }, "521": { - "id": 521, "category": "Array & Hashing", - "title": "Longest Uncommon Subsequence I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-uncommon-subsequence-i/" + "id": 521, + "link": "https://leetcode.com/problems/longest-uncommon-subsequence-i/", + "title": "Longest Uncommon Subsequence I" }, "522": { - "id": 522, "category": "Two Pointers", - "title": "Longest Uncommon Subsequence II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-uncommon-subsequence-ii/" + "id": 522, + "link": "https://leetcode.com/problems/longest-uncommon-subsequence-ii/", + "title": "Longest Uncommon Subsequence II" }, "523": { - "id": 523, "category": "Math & Geometry", - "title": "Continuous Subarray Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/continuous-subarray-sum/" + "id": 523, + "link": "https://leetcode.com/problems/continuous-subarray-sum/", + "title": "Continuous Subarray Sum" }, "524": { - "id": 524, "category": "Two Pointers", - "title": "Longest Word in Dictionary through Deleting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/" + "id": 524, + "link": "https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/", + "title": "Longest Word in Dictionary through Deleting" }, "525": { - "id": 525, "category": "Array & Hashing", - "title": "Contiguous Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/contiguous-array/" + "id": 525, + "link": "https://leetcode.com/problems/contiguous-array/", + "title": "Contiguous Array" }, "526": { - "id": 526, "category": "Dynamic Programming", - "title": "Beautiful Arrangement", "difficulty": "Medium", - "link": "https://leetcode.com/problems/beautiful-arrangement/" + "id": 526, + "link": "https://leetcode.com/problems/beautiful-arrangement/", + "title": "Beautiful Arrangement" }, "527": { - "id": 527, "category": "Trie", - "title": "Word Abbreviation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/word-abbreviation/" + "id": 527, + "link": "https://leetcode.com/problems/word-abbreviation/", + "title": "Word Abbreviation" }, "528": { - "id": 528, "category": "Binary Search", - "title": "Random Pick with Weight", "difficulty": "Medium", - "link": "https://leetcode.com/problems/random-pick-with-weight/" + "id": 528, + "link": "https://leetcode.com/problems/random-pick-with-weight/", + "title": "Random Pick with Weight" }, "529": { - "id": 529, "category": "Graph Traversal", - "title": "Minesweeper", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minesweeper/" + "id": 529, + "link": "https://leetcode.com/problems/minesweeper/", + "title": "Minesweeper" }, "530": { - "id": 530, "category": "Tree", - "title": "Minimum Absolute Difference in BST", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-absolute-difference-in-bst/" + "id": 530, + "link": "https://leetcode.com/problems/minimum-absolute-difference-in-bst/", + "title": "Minimum Absolute Difference in BST" }, "531": { - "id": 531, "category": "Array & Hashing", - "title": "Lonely Pixel I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lonely-pixel-i/" + "id": 531, + "link": "https://leetcode.com/problems/lonely-pixel-i/", + "title": "Lonely Pixel I" }, "532": { - "id": 532, "category": "Binary Search", - "title": "K-diff Pairs in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-diff-pairs-in-an-array/" + "id": 532, + "link": "https://leetcode.com/problems/k-diff-pairs-in-an-array/", + "title": "K-diff Pairs in an Array" }, "533": { - "id": 533, "category": "Array & Hashing", - "title": "Lonely Pixel II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lonely-pixel-ii/" + "id": 533, + "link": "https://leetcode.com/problems/lonely-pixel-ii/", + "title": "Lonely Pixel II" }, "534": { - "id": 534, "category": "Database", - "title": "Game Play Analysis III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/game-play-analysis-iii/" + "id": 534, + "link": "https://leetcode.com/problems/game-play-analysis-iii/", + "title": "Game Play Analysis III" }, "535": { - "id": 535, "category": "Array & Hashing", - "title": "Encode and Decode TinyURL", "difficulty": "Medium", - "link": "https://leetcode.com/problems/encode-and-decode-tinyurl/" + "id": 535, + "link": "https://leetcode.com/problems/encode-and-decode-tinyurl/", + "title": "Encode and Decode TinyURL" }, "536": { - "id": 536, "category": "Tree", - "title": "Construct Binary Tree from String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-binary-tree-from-string/" + "id": 536, + "link": "https://leetcode.com/problems/construct-binary-tree-from-string/", + "title": "Construct Binary Tree from String" }, "537": { - "id": 537, "category": "Math & Geometry", - "title": "Complex Number Multiplication", "difficulty": "Medium", - "link": "https://leetcode.com/problems/complex-number-multiplication/" + "id": 537, + "link": "https://leetcode.com/problems/complex-number-multiplication/", + "title": "Complex Number Multiplication" }, "538": { - "id": 538, "category": "Tree", - "title": "Convert BST to Greater Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-bst-to-greater-tree/" + "id": 538, + "link": "https://leetcode.com/problems/convert-bst-to-greater-tree/", + "title": "Convert BST to Greater Tree" }, "539": { - "id": 539, "category": "Math & Geometry", - "title": "Minimum Time Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-difference/" + "id": 539, + "link": "https://leetcode.com/problems/minimum-time-difference/", + "title": "Minimum Time Difference" }, "540": { - "id": 540, "category": "Binary Search", - "title": "Single Element in a Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/single-element-in-a-sorted-array/" + "id": 540, + "link": "https://leetcode.com/problems/single-element-in-a-sorted-array/", + "title": "Single Element in a Sorted Array" }, "541": { - "id": 541, "category": "Two Pointers", - "title": "Reverse String II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-string-ii/" - }, - "542": { - "id": 542, - "category": "Graph Traversal", - "title": "01 Matrix", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/01-matrix/" + "id": 541, + "link": "https://leetcode.com/problems/reverse-string-ii/", + "title": "Reverse String II" }, + "542": {"category": "Graph Traversal", "difficulty": "Medium", "id": 542, "link": "https://leetcode.com/problems/01-matrix/", "title": "01 Matrix"}, "543": { - "id": 543, "category": "Tree", - "title": "Diameter of Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/diameter-of-binary-tree/" + "id": 543, + "link": "https://leetcode.com/problems/diameter-of-binary-tree/", + "title": "Diameter of Binary Tree" }, "544": { - "id": 544, "category": "Array & Hashing", - "title": "Output Contest Matches", "difficulty": "Medium", - "link": "https://leetcode.com/problems/output-contest-matches/" + "id": 544, + "link": "https://leetcode.com/problems/output-contest-matches/", + "title": "Output Contest Matches" }, "545": { - "id": 545, "category": "Tree", - "title": "Boundary of Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/boundary-of-binary-tree/" + "id": 545, + "link": "https://leetcode.com/problems/boundary-of-binary-tree/", + "title": "Boundary of Binary Tree" }, "546": { - "id": 546, "category": "Dynamic Programming", - "title": "Remove Boxes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/remove-boxes/" + "id": 546, + "link": "https://leetcode.com/problems/remove-boxes/", + "title": "Remove Boxes" }, "547": { - "id": 547, "category": "Graph Traversal", - "title": "Number of Provinces", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-provinces/" + "id": 547, + "link": "https://leetcode.com/problems/number-of-provinces/", + "title": "Number of Provinces" }, "548": { - "id": 548, "category": "Array & Hashing", - "title": "Split Array with Equal Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/split-array-with-equal-sum/" + "id": 548, + "link": "https://leetcode.com/problems/split-array-with-equal-sum/", + "title": "Split Array with Equal Sum" }, "549": { - "id": 549, "category": "Tree", - "title": "Binary Tree Longest Consecutive Sequence II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/" + "id": 549, + "link": "https://leetcode.com/problems/binary-tree-longest-consecutive-sequence-ii/", + "title": "Binary Tree Longest Consecutive Sequence II" }, "550": { - "id": 550, "category": "Database", - "title": "Game Play Analysis IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/game-play-analysis-iv/" + "id": 550, + "link": "https://leetcode.com/problems/game-play-analysis-iv/", + "title": "Game Play Analysis IV" }, "551": { - "id": 551, "category": "Array & Hashing", - "title": "Student Attendance Record I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/student-attendance-record-i/" + "id": 551, + "link": "https://leetcode.com/problems/student-attendance-record-i/", + "title": "Student Attendance Record I" }, "552": { - "id": 552, "category": "Dynamic Programming", - "title": "Student Attendance Record II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/student-attendance-record-ii/" + "id": 552, + "link": "https://leetcode.com/problems/student-attendance-record-ii/", + "title": "Student Attendance Record II" }, "553": { - "id": 553, "category": "Dynamic Programming", - "title": "Optimal Division", "difficulty": "Medium", - "link": "https://leetcode.com/problems/optimal-division/" + "id": 553, + "link": "https://leetcode.com/problems/optimal-division/", + "title": "Optimal Division" }, "554": { - "id": 554, "category": "Array & Hashing", - "title": "Brick Wall", "difficulty": "Medium", - "link": "https://leetcode.com/problems/brick-wall/" + "id": 554, + "link": "https://leetcode.com/problems/brick-wall/", + "title": "Brick Wall" }, "555": { - "id": 555, "category": "Greedy", - "title": "Split Concatenated Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-concatenated-strings/" + "id": 555, + "link": "https://leetcode.com/problems/split-concatenated-strings/", + "title": "Split Concatenated Strings" }, "556": { - "id": 556, "category": "Math & Geometry", - "title": "Next Greater Element III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-greater-element-iii/" + "id": 556, + "link": "https://leetcode.com/problems/next-greater-element-iii/", + "title": "Next Greater Element III" }, "557": { - "id": 557, "category": "Two Pointers", - "title": "Reverse Words in a String III", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-words-in-a-string-iii/" + "id": 557, + "link": "https://leetcode.com/problems/reverse-words-in-a-string-iii/", + "title": "Reverse Words in a String III" }, "558": { - "id": 558, "category": "Tree", - "title": "Logical OR of Two Binary Grids Represented as Quad-Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/" + "id": 558, + "link": "https://leetcode.com/problems/logical-or-of-two-binary-grids-represented-as-quad-trees/", + "title": "Logical OR of Two Binary Grids Represented as Quad-Trees" }, "559": { - "id": 559, "category": "Tree", - "title": "Maximum Depth of N-ary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-depth-of-n-ary-tree/" + "id": 559, + "link": "https://leetcode.com/problems/maximum-depth-of-n-ary-tree/", + "title": "Maximum Depth of N-ary Tree" }, "560": { - "id": 560, "category": "Array & Hashing", - "title": "Subarray Sum Equals K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subarray-sum-equals-k/" + "id": 560, + "link": "https://leetcode.com/problems/subarray-sum-equals-k/", + "title": "Subarray Sum Equals K" }, "561": { - "id": 561, "category": "Greedy", - "title": "Array Partition", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-partition/" + "id": 561, + "link": "https://leetcode.com/problems/array-partition/", + "title": "Array Partition" }, "562": { - "id": 562, "category": "Dynamic Programming", - "title": "Longest Line of Consecutive One in Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix/" + "id": 562, + "link": "https://leetcode.com/problems/longest-line-of-consecutive-one-in-matrix/", + "title": "Longest Line of Consecutive One in Matrix" }, "563": { - "id": 563, "category": "Tree", - "title": "Binary Tree Tilt", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-tree-tilt/" + "id": 563, + "link": "https://leetcode.com/problems/binary-tree-tilt/", + "title": "Binary Tree Tilt" }, "564": { - "id": 564, "category": "Math & Geometry", - "title": "Find the Closest Palindrome", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-closest-palindrome/" + "id": 564, + "link": "https://leetcode.com/problems/find-the-closest-palindrome/", + "title": "Find the Closest Palindrome" }, "565": { - "id": 565, "category": "Graph Traversal", - "title": "Array Nesting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/array-nesting/" + "id": 565, + "link": "https://leetcode.com/problems/array-nesting/", + "title": "Array Nesting" }, "566": { - "id": 566, "category": "Array & Hashing", - "title": "Reshape the Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reshape-the-matrix/" + "id": 566, + "link": "https://leetcode.com/problems/reshape-the-matrix/", + "title": "Reshape the Matrix" }, "567": { - "id": 567, "category": "Sliding Window", - "title": "Permutation in String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/permutation-in-string/" + "id": 567, + "link": "https://leetcode.com/problems/permutation-in-string/", + "title": "Permutation in String" }, "568": { - "id": 568, "category": "Dynamic Programming", - "title": "Maximum Vacation Days", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-vacation-days/" + "id": 568, + "link": "https://leetcode.com/problems/maximum-vacation-days/", + "title": "Maximum Vacation Days" }, "569": { - "id": 569, "category": "Database", - "title": "Median Employee Salary", "difficulty": "Hard", - "link": "https://leetcode.com/problems/median-employee-salary/" + "id": 569, + "link": "https://leetcode.com/problems/median-employee-salary/", + "title": "Median Employee Salary" }, "570": { - "id": 570, "category": "Database", - "title": "Managers with at Least 5 Direct Reports", "difficulty": "Medium", - "link": "https://leetcode.com/problems/managers-with-at-least-5-direct-reports/" + "id": 570, + "link": "https://leetcode.com/problems/managers-with-at-least-5-direct-reports/", + "title": "Managers with at Least 5 Direct Reports" }, "571": { - "id": 571, "category": "Database", - "title": "Find Median Given Frequency of Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-median-given-frequency-of-numbers/" + "id": 571, + "link": "https://leetcode.com/problems/find-median-given-frequency-of-numbers/", + "title": "Find Median Given Frequency of Numbers" }, "572": { - "id": 572, "category": "Tree", - "title": "Subtree of Another Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/subtree-of-another-tree/" + "id": 572, + "link": "https://leetcode.com/problems/subtree-of-another-tree/", + "title": "Subtree of Another Tree" }, "573": { - "id": 573, "category": "Math & Geometry", - "title": "Squirrel Simulation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/squirrel-simulation/" + "id": 573, + "link": "https://leetcode.com/problems/squirrel-simulation/", + "title": "Squirrel Simulation" }, "574": { - "id": 574, "category": "Database", - "title": "Winning Candidate", "difficulty": "Medium", - "link": "https://leetcode.com/problems/winning-candidate/" + "id": 574, + "link": "https://leetcode.com/problems/winning-candidate/", + "title": "Winning Candidate" }, "575": { - "id": 575, "category": "Array & Hashing", - "title": "Distribute Candies", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distribute-candies/" + "id": 575, + "link": "https://leetcode.com/problems/distribute-candies/", + "title": "Distribute Candies" }, "576": { - "id": 576, "category": "Dynamic Programming", - "title": "Out of Boundary Paths", "difficulty": "Medium", - "link": "https://leetcode.com/problems/out-of-boundary-paths/" + "id": 576, + "link": "https://leetcode.com/problems/out-of-boundary-paths/", + "title": "Out of Boundary Paths" }, "577": { - "id": 577, "category": "Database", - "title": "Employee Bonus", "difficulty": "Easy", - "link": "https://leetcode.com/problems/employee-bonus/" + "id": 577, + "link": "https://leetcode.com/problems/employee-bonus/", + "title": "Employee Bonus" }, "578": { - "id": 578, "category": "Database", - "title": "Get Highest Answer Rate Question", "difficulty": "Medium", - "link": "https://leetcode.com/problems/get-highest-answer-rate-question/" + "id": 578, + "link": "https://leetcode.com/problems/get-highest-answer-rate-question/", + "title": "Get Highest Answer Rate Question" }, "579": { - "id": 579, "category": "Database", - "title": "Find Cumulative Salary of an Employee", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-cumulative-salary-of-an-employee/" + "id": 579, + "link": "https://leetcode.com/problems/find-cumulative-salary-of-an-employee/", + "title": "Find Cumulative Salary of an Employee" }, "580": { - "id": 580, "category": "Database", - "title": "Count Student Number in Departments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-student-number-in-departments/" + "id": 580, + "link": "https://leetcode.com/problems/count-student-number-in-departments/", + "title": "Count Student Number in Departments" }, "581": { - "id": 581, "category": "Stack", - "title": "Shortest Unsorted Continuous Subarray", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-unsorted-continuous-subarray/" - }, - "582": { - "id": 582, - "category": "Tree", - "title": "Kill Process", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kill-process/" + "id": 581, + "link": "https://leetcode.com/problems/shortest-unsorted-continuous-subarray/", + "title": "Shortest Unsorted Continuous Subarray" }, + "582": {"category": "Tree", "difficulty": "Medium", "id": 582, "link": "https://leetcode.com/problems/kill-process/", "title": "Kill Process"}, "583": { - "id": 583, "category": "Dynamic Programming", - "title": "Delete Operation for Two Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-operation-for-two-strings/" + "id": 583, + "link": "https://leetcode.com/problems/delete-operation-for-two-strings/", + "title": "Delete Operation for Two Strings" }, "584": { - "id": 584, "category": "Database", - "title": "Find Customer Referee", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-customer-referee/" + "id": 584, + "link": "https://leetcode.com/problems/find-customer-referee/", + "title": "Find Customer Referee" }, "585": { - "id": 585, "category": "Database", - "title": "Investments in 2016", "difficulty": "Medium", - "link": "https://leetcode.com/problems/investments-in-2016/" + "id": 585, + "link": "https://leetcode.com/problems/investments-in-2016/", + "title": "Investments in 2016" }, "586": { - "id": 586, "category": "Database", - "title": "Customer Placing the Largest Number of Orders", "difficulty": "Easy", - "link": "https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/" + "id": 586, + "link": "https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/", + "title": "Customer Placing the Largest Number of Orders" }, "587": { - "id": 587, "category": "Math & Geometry", - "title": "Erect the Fence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/erect-the-fence/" + "id": 587, + "link": "https://leetcode.com/problems/erect-the-fence/", + "title": "Erect the Fence" }, "588": { - "id": 588, "category": "Trie", - "title": "Design In-Memory File System", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-in-memory-file-system/" + "id": 588, + "link": "https://leetcode.com/problems/design-in-memory-file-system/", + "title": "Design In-Memory File System" }, "589": { - "id": 589, "category": "Tree", - "title": "N-ary Tree Preorder Traversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/n-ary-tree-preorder-traversal/" + "id": 589, + "link": "https://leetcode.com/problems/n-ary-tree-preorder-traversal/", + "title": "N-ary Tree Preorder Traversal" }, "590": { - "id": 590, "category": "Tree", - "title": "N-ary Tree Postorder Traversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/n-ary-tree-postorder-traversal/" - }, - "591": { - "id": 591, - "category": "Stack", - "title": "Tag Validator", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/tag-validator/" + "id": 590, + "link": "https://leetcode.com/problems/n-ary-tree-postorder-traversal/", + "title": "N-ary Tree Postorder Traversal" }, + "591": {"category": "Stack", "difficulty": "Hard", "id": 591, "link": "https://leetcode.com/problems/tag-validator/", "title": "Tag Validator"}, "592": { - "id": 592, "category": "Math & Geometry", - "title": "Fraction Addition and Subtraction", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fraction-addition-and-subtraction/" + "id": 592, + "link": "https://leetcode.com/problems/fraction-addition-and-subtraction/", + "title": "Fraction Addition and Subtraction" }, "593": { - "id": 593, "category": "Math & Geometry", - "title": "Valid Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-square/" + "id": 593, + "link": "https://leetcode.com/problems/valid-square/", + "title": "Valid Square" }, "594": { - "id": 594, "category": "Sliding Window", - "title": "Longest Harmonious Subsequence", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-harmonious-subsequence/" - }, - "595": { - "id": 595, - "category": "Database", - "title": "Big Countries", "difficulty": "Easy", - "link": "https://leetcode.com/problems/big-countries/" + "id": 594, + "link": "https://leetcode.com/problems/longest-harmonious-subsequence/", + "title": "Longest Harmonious Subsequence" }, + "595": {"category": "Database", "difficulty": "Easy", "id": 595, "link": "https://leetcode.com/problems/big-countries/", "title": "Big Countries"}, "596": { - "id": 596, "category": "Database", - "title": "Classes With at Least 5 Students", "difficulty": "Easy", - "link": "https://leetcode.com/problems/classes-with-at-least-5-students/" + "id": 596, + "link": "https://leetcode.com/problems/classes-with-at-least-5-students/", + "title": "Classes With at Least 5 Students" }, "597": { - "id": 597, "category": "Database", - "title": "Friend Requests I: Overall Acceptance Rate", "difficulty": "Easy", - "link": "https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate/" + "id": 597, + "link": "https://leetcode.com/problems/friend-requests-i-overall-acceptance-rate/", + "title": "Friend Requests I: Overall Acceptance Rate" }, "598": { - "id": 598, "category": "Math & Geometry", - "title": "Range Addition II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/range-addition-ii/" + "id": 598, + "link": "https://leetcode.com/problems/range-addition-ii/", + "title": "Range Addition II" }, "599": { - "id": 599, "category": "Array & Hashing", - "title": "Minimum Index Sum of Two Lists", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-index-sum-of-two-lists/" + "id": 599, + "link": "https://leetcode.com/problems/minimum-index-sum-of-two-lists/", + "title": "Minimum Index Sum of Two Lists" }, "600": { - "id": 600, "category": "Dynamic Programming", - "title": "Non-negative Integers without Consecutive Ones", "difficulty": "Hard", - "link": "https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/" + "id": 600, + "link": "https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/", + "title": "Non-negative Integers without Consecutive Ones" }, "601": { - "id": 601, "category": "Database", - "title": "Human Traffic of Stadium", "difficulty": "Hard", - "link": "https://leetcode.com/problems/human-traffic-of-stadium/" + "id": 601, + "link": "https://leetcode.com/problems/human-traffic-of-stadium/", + "title": "Human Traffic of Stadium" }, "602": { - "id": 602, "category": "Database", - "title": "Friend Requests II: Who Has the Most Friends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends/" + "id": 602, + "link": "https://leetcode.com/problems/friend-requests-ii-who-has-the-most-friends/", + "title": "Friend Requests II: Who Has the Most Friends" }, "603": { - "id": 603, "category": "Database", - "title": "Consecutive Available Seats", "difficulty": "Easy", - "link": "https://leetcode.com/problems/consecutive-available-seats/" + "id": 603, + "link": "https://leetcode.com/problems/consecutive-available-seats/", + "title": "Consecutive Available Seats" }, "604": { - "id": 604, "category": "Array & Hashing", - "title": "Design Compressed String Iterator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-compressed-string-iterator/" + "id": 604, + "link": "https://leetcode.com/problems/design-compressed-string-iterator/", + "title": "Design Compressed String Iterator" }, "605": { - "id": 605, "category": "Greedy", - "title": "Can Place Flowers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/can-place-flowers/" + "id": 605, + "link": "https://leetcode.com/problems/can-place-flowers/", + "title": "Can Place Flowers" }, "606": { - "id": 606, "category": "Tree", - "title": "Construct String from Binary Tree", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-string-from-binary-tree/" - }, - "607": { - "id": 607, - "category": "Database", - "title": "Sales Person", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/sales-person/" - }, - "608": { - "id": 608, - "category": "Database", - "title": "Tree Node", "difficulty": "Medium", - "link": "https://leetcode.com/problems/tree-node/" + "id": 606, + "link": "https://leetcode.com/problems/construct-string-from-binary-tree/", + "title": "Construct String from Binary Tree" }, + "607": {"category": "Database", "difficulty": "Easy", "id": 607, "link": "https://leetcode.com/problems/sales-person/", "title": "Sales Person"}, + "608": {"category": "Database", "difficulty": "Medium", "id": 608, "link": "https://leetcode.com/problems/tree-node/", "title": "Tree Node"}, "609": { - "id": 609, "category": "Array & Hashing", - "title": "Find Duplicate File in System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-duplicate-file-in-system/" + "id": 609, + "link": "https://leetcode.com/problems/find-duplicate-file-in-system/", + "title": "Find Duplicate File in System" }, "610": { - "id": 610, "category": "Database", - "title": "Triangle Judgement", "difficulty": "Easy", - "link": "https://leetcode.com/problems/triangle-judgement/" + "id": 610, + "link": "https://leetcode.com/problems/triangle-judgement/", + "title": "Triangle Judgement" }, "611": { - "id": 611, "category": "Binary Search", - "title": "Valid Triangle Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-triangle-number/" + "id": 611, + "link": "https://leetcode.com/problems/valid-triangle-number/", + "title": "Valid Triangle Number" }, "612": { - "id": 612, "category": "Database", - "title": "Shortest Distance in a Plane", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-distance-in-a-plane/" + "id": 612, + "link": "https://leetcode.com/problems/shortest-distance-in-a-plane/", + "title": "Shortest Distance in a Plane" }, "613": { - "id": 613, "category": "Database", - "title": "Shortest Distance in a Line", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-distance-in-a-line/" + "id": 613, + "link": "https://leetcode.com/problems/shortest-distance-in-a-line/", + "title": "Shortest Distance in a Line" }, "614": { - "id": 614, "category": "Database", - "title": "Second Degree Follower", "difficulty": "Medium", - "link": "https://leetcode.com/problems/second-degree-follower/" + "id": 614, + "link": "https://leetcode.com/problems/second-degree-follower/", + "title": "Second Degree Follower" }, "615": { - "id": 615, "category": "Database", - "title": "Average Salary: Departments VS Company", "difficulty": "Hard", - "link": "https://leetcode.com/problems/average-salary-departments-vs-company/" + "id": 615, + "link": "https://leetcode.com/problems/average-salary-departments-vs-company/", + "title": "Average Salary: Departments VS Company" }, "616": { - "id": 616, "category": "Trie", - "title": "Add Bold Tag in String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-bold-tag-in-string/" + "id": 616, + "link": "https://leetcode.com/problems/add-bold-tag-in-string/", + "title": "Add Bold Tag in String" }, "617": { - "id": 617, "category": "Tree", - "title": "Merge Two Binary Trees", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-two-binary-trees/" + "id": 617, + "link": "https://leetcode.com/problems/merge-two-binary-trees/", + "title": "Merge Two Binary Trees" }, "618": { - "id": 618, "category": "Database", - "title": "Students Report By Geography", "difficulty": "Hard", - "link": "https://leetcode.com/problems/students-report-by-geography/" + "id": 618, + "link": "https://leetcode.com/problems/students-report-by-geography/", + "title": "Students Report By Geography" }, "619": { - "id": 619, "category": "Database", - "title": "Biggest Single Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/biggest-single-number/" + "id": 619, + "link": "https://leetcode.com/problems/biggest-single-number/", + "title": "Biggest Single Number" }, "620": { - "id": 620, "category": "Database", - "title": "Not Boring Movies", "difficulty": "Easy", - "link": "https://leetcode.com/problems/not-boring-movies/" + "id": 620, + "link": "https://leetcode.com/problems/not-boring-movies/", + "title": "Not Boring Movies" }, "621": { - "id": 621, "category": "Heap (Priority Queue)", - "title": "Task Scheduler", "difficulty": "Medium", - "link": "https://leetcode.com/problems/task-scheduler/" + "id": 621, + "link": "https://leetcode.com/problems/task-scheduler/", + "title": "Task Scheduler" }, "622": { - "id": 622, "category": "Linked List", - "title": "Design Circular Queue", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-circular-queue/" + "id": 622, + "link": "https://leetcode.com/problems/design-circular-queue/", + "title": "Design Circular Queue" }, "623": { - "id": 623, "category": "Tree", - "title": "Add One Row to Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-one-row-to-tree/" + "id": 623, + "link": "https://leetcode.com/problems/add-one-row-to-tree/", + "title": "Add One Row to Tree" }, "624": { - "id": 624, "category": "Greedy", - "title": "Maximum Distance in Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-distance-in-arrays/" + "id": 624, + "link": "https://leetcode.com/problems/maximum-distance-in-arrays/", + "title": "Maximum Distance in Arrays" }, "625": { - "id": 625, "category": "Greedy", - "title": "Minimum Factorization", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-factorization/" + "id": 625, + "link": "https://leetcode.com/problems/minimum-factorization/", + "title": "Minimum Factorization" }, "626": { - "id": 626, "category": "Database", - "title": "Exchange Seats", "difficulty": "Medium", - "link": "https://leetcode.com/problems/exchange-seats/" + "id": 626, + "link": "https://leetcode.com/problems/exchange-seats/", + "title": "Exchange Seats" }, "627": { - "id": 627, "category": "Database", - "title": "Swap Sex of Employees", "difficulty": "Easy", - "link": "https://leetcode.com/problems/swap-sex-of-employees/" + "id": 627, + "link": "https://leetcode.com/problems/swap-sex-of-employees/", + "title": "Swap Sex of Employees" }, "628": { - "id": 628, "category": "Math & Geometry", - "title": "Maximum Product of Three Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-product-of-three-numbers/" + "id": 628, + "link": "https://leetcode.com/problems/maximum-product-of-three-numbers/", + "title": "Maximum Product of Three Numbers" }, "629": { - "id": 629, "category": "Dynamic Programming", - "title": "K Inverse Pairs Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/k-inverse-pairs-array/" + "id": 629, + "link": "https://leetcode.com/problems/k-inverse-pairs-array/", + "title": "K Inverse Pairs Array" }, "630": { - "id": 630, "category": "Heap (Priority Queue)", - "title": "Course Schedule III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/course-schedule-iii/" + "id": 630, + "link": "https://leetcode.com/problems/course-schedule-iii/", + "title": "Course Schedule III" }, "631": { - "id": 631, "category": "Graph Traversal", - "title": "Design Excel Sum Formula", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-excel-sum-formula/" + "id": 631, + "link": "https://leetcode.com/problems/design-excel-sum-formula/", + "title": "Design Excel Sum Formula" }, "632": { - "id": 632, "category": "Sliding Window", - "title": "Smallest Range Covering Elements from K Lists", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/" + "id": 632, + "link": "https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/", + "title": "Smallest Range Covering Elements from K Lists" }, "633": { - "id": 633, "category": "Binary Search", - "title": "Sum of Square Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-square-numbers/" + "id": 633, + "link": "https://leetcode.com/problems/sum-of-square-numbers/", + "title": "Sum of Square Numbers" }, "634": { - "id": 634, "category": "Dynamic Programming", - "title": "Find the Derangement of An Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-derangement-of-an-array/" + "id": 634, + "link": "https://leetcode.com/problems/find-the-derangement-of-an-array/", + "title": "Find the Derangement of An Array" }, "635": { - "id": 635, "category": "Array & Hashing", - "title": "Design Log Storage System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-log-storage-system/" + "id": 635, + "link": "https://leetcode.com/problems/design-log-storage-system/", + "title": "Design Log Storage System" }, "636": { - "id": 636, "category": "Stack", - "title": "Exclusive Time of Functions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/exclusive-time-of-functions/" + "id": 636, + "link": "https://leetcode.com/problems/exclusive-time-of-functions/", + "title": "Exclusive Time of Functions" }, "637": { - "id": 637, "category": "Tree", - "title": "Average of Levels in Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/average-of-levels-in-binary-tree/" + "id": 637, + "link": "https://leetcode.com/problems/average-of-levels-in-binary-tree/", + "title": "Average of Levels in Binary Tree" }, "638": { - "id": 638, "category": "Dynamic Programming", - "title": "Shopping Offers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shopping-offers/" + "id": 638, + "link": "https://leetcode.com/problems/shopping-offers/", + "title": "Shopping Offers" }, "639": { - "id": 639, "category": "Dynamic Programming", - "title": "Decode Ways II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/decode-ways-ii/" + "id": 639, + "link": "https://leetcode.com/problems/decode-ways-ii/", + "title": "Decode Ways II" }, "640": { - "id": 640, "category": "Math & Geometry", - "title": "Solve the Equation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/solve-the-equation/" + "id": 640, + "link": "https://leetcode.com/problems/solve-the-equation/", + "title": "Solve the Equation" }, "641": { - "id": 641, "category": "Linked List", - "title": "Design Circular Deque", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-circular-deque/" + "id": 641, + "link": "https://leetcode.com/problems/design-circular-deque/", + "title": "Design Circular Deque" }, "642": { - "id": 642, "category": "Graph Traversal", - "title": "Design Search Autocomplete System", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-search-autocomplete-system/" + "id": 642, + "link": "https://leetcode.com/problems/design-search-autocomplete-system/", + "title": "Design Search Autocomplete System" }, "643": { - "id": 643, "category": "Sliding Window", - "title": "Maximum Average Subarray I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-average-subarray-i/" + "id": 643, + "link": "https://leetcode.com/problems/maximum-average-subarray-i/", + "title": "Maximum Average Subarray I" }, "644": { - "id": 644, "category": "Binary Search", - "title": "Maximum Average Subarray II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-average-subarray-ii/" + "id": 644, + "link": "https://leetcode.com/problems/maximum-average-subarray-ii/", + "title": "Maximum Average Subarray II" }, "645": { - "id": 645, "category": "Bit Manipulation", - "title": "Set Mismatch", "difficulty": "Easy", - "link": "https://leetcode.com/problems/set-mismatch/" + "id": 645, + "link": "https://leetcode.com/problems/set-mismatch/", + "title": "Set Mismatch" }, "646": { - "id": 646, "category": "Dynamic Programming", - "title": "Maximum Length of Pair Chain", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-length-of-pair-chain/" + "id": 646, + "link": "https://leetcode.com/problems/maximum-length-of-pair-chain/", + "title": "Maximum Length of Pair Chain" }, "647": { - "id": 647, "category": "Dynamic Programming", - "title": "Palindromic Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/palindromic-substrings/" - }, - "648": { - "id": 648, - "category": "Trie", - "title": "Replace Words", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/replace-words/" - }, - "649": { - "id": 649, - "category": "Greedy", - "title": "Dota2 Senate", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/dota2-senate/" + "id": 647, + "link": "https://leetcode.com/problems/palindromic-substrings/", + "title": "Palindromic Substrings" }, + "648": {"category": "Trie", "difficulty": "Medium", "id": 648, "link": "https://leetcode.com/problems/replace-words/", "title": "Replace Words"}, + "649": {"category": "Greedy", "difficulty": "Medium", "id": 649, "link": "https://leetcode.com/problems/dota2-senate/", "title": "Dota2 Senate"}, "650": { - "id": 650, "category": "Dynamic Programming", - "title": "2 Keys Keyboard", "difficulty": "Medium", - "link": "https://leetcode.com/problems/2-keys-keyboard/" + "id": 650, + "link": "https://leetcode.com/problems/2-keys-keyboard/", + "title": "2 Keys Keyboard" }, "651": { - "id": 651, "category": "Dynamic Programming", - "title": "4 Keys Keyboard", "difficulty": "Medium", - "link": "https://leetcode.com/problems/4-keys-keyboard/" + "id": 651, + "link": "https://leetcode.com/problems/4-keys-keyboard/", + "title": "4 Keys Keyboard" }, "652": { - "id": 652, "category": "Tree", - "title": "Find Duplicate Subtrees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-duplicate-subtrees/" + "id": 652, + "link": "https://leetcode.com/problems/find-duplicate-subtrees/", + "title": "Find Duplicate Subtrees" }, "653": { - "id": 653, "category": "Tree", - "title": "Two Sum IV - Input is a BST", "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-sum-iv-input-is-a-bst/" + "id": 653, + "link": "https://leetcode.com/problems/two-sum-iv-input-is-a-bst/", + "title": "Two Sum IV - Input is a BST" }, "654": { - "id": 654, "category": "Tree", - "title": "Maximum Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-binary-tree/" + "id": 654, + "link": "https://leetcode.com/problems/maximum-binary-tree/", + "title": "Maximum Binary Tree" }, "655": { - "id": 655, "category": "Tree", - "title": "Print Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/print-binary-tree/" + "id": 655, + "link": "https://leetcode.com/problems/print-binary-tree/", + "title": "Print Binary Tree" }, "656": { - "id": 656, "category": "Dynamic Programming", - "title": "Coin Path", "difficulty": "Hard", - "link": "https://leetcode.com/problems/coin-path/" + "id": 656, + "link": "https://leetcode.com/problems/coin-path/", + "title": "Coin Path" }, "657": { - "id": 657, "category": "Array & Hashing", - "title": "Robot Return to Origin", "difficulty": "Easy", - "link": "https://leetcode.com/problems/robot-return-to-origin/" + "id": 657, + "link": "https://leetcode.com/problems/robot-return-to-origin/", + "title": "Robot Return to Origin" }, "658": { - "id": 658, "category": "Sliding Window", - "title": "Find K Closest Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-k-closest-elements/" + "id": 658, + "link": "https://leetcode.com/problems/find-k-closest-elements/", + "title": "Find K Closest Elements" }, "659": { - "id": 659, "category": "Heap (Priority Queue)", - "title": "Split Array into Consecutive Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-array-into-consecutive-subsequences/" - }, - "660": { - "id": 660, - "category": "Math & Geometry", - "title": "Remove 9", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/remove-9/" + "id": 659, + "link": "https://leetcode.com/problems/split-array-into-consecutive-subsequences/", + "title": "Split Array into Consecutive Subsequences" }, + "660": {"category": "Math & Geometry", "difficulty": "Hard", "id": 660, "link": "https://leetcode.com/problems/remove-9/", "title": "Remove 9"}, "661": { - "id": 661, "category": "Array & Hashing", - "title": "Image Smoother", "difficulty": "Easy", - "link": "https://leetcode.com/problems/image-smoother/" + "id": 661, + "link": "https://leetcode.com/problems/image-smoother/", + "title": "Image Smoother" }, "662": { - "id": 662, "category": "Tree", - "title": "Maximum Width of Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-width-of-binary-tree/" + "id": 662, + "link": "https://leetcode.com/problems/maximum-width-of-binary-tree/", + "title": "Maximum Width of Binary Tree" }, "663": { - "id": 663, "category": "Tree", - "title": "Equal Tree Partition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/equal-tree-partition/" + "id": 663, + "link": "https://leetcode.com/problems/equal-tree-partition/", + "title": "Equal Tree Partition" }, "664": { - "id": 664, "category": "Dynamic Programming", - "title": "Strange Printer", "difficulty": "Hard", - "link": "https://leetcode.com/problems/strange-printer/" + "id": 664, + "link": "https://leetcode.com/problems/strange-printer/", + "title": "Strange Printer" }, "665": { - "id": 665, "category": "Array & Hashing", - "title": "Non-decreasing Array", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/non-decreasing-array/" - }, - "666": { - "id": 666, - "category": "Tree", - "title": "Path Sum IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-sum-iv/" + "id": 665, + "link": "https://leetcode.com/problems/non-decreasing-array/", + "title": "Non-decreasing Array" }, + "666": {"category": "Tree", "difficulty": "Medium", "id": 666, "link": "https://leetcode.com/problems/path-sum-iv/", "title": "Path Sum IV"}, "667": { - "id": 667, "category": "Math & Geometry", - "title": "Beautiful Arrangement II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/beautiful-arrangement-ii/" + "id": 667, + "link": "https://leetcode.com/problems/beautiful-arrangement-ii/", + "title": "Beautiful Arrangement II" }, "668": { - "id": 668, "category": "Binary Search", - "title": "Kth Smallest Number in Multiplication Table", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/" + "id": 668, + "link": "https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/", + "title": "Kth Smallest Number in Multiplication Table" }, "669": { - "id": 669, "category": "Tree", - "title": "Trim a Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/trim-a-binary-search-tree/" - }, - "670": { - "id": 670, - "category": "Greedy", - "title": "Maximum Swap", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-swap/" + "id": 669, + "link": "https://leetcode.com/problems/trim-a-binary-search-tree/", + "title": "Trim a Binary Search Tree" }, + "670": {"category": "Greedy", "difficulty": "Medium", "id": 670, "link": "https://leetcode.com/problems/maximum-swap/", "title": "Maximum Swap"}, "671": { - "id": 671, "category": "Tree", - "title": "Second Minimum Node In a Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/" + "id": 671, + "link": "https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/", + "title": "Second Minimum Node In a Binary Tree" }, "672": { - "id": 672, "category": "Graph Traversal", - "title": "Bulb Switcher II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bulb-switcher-ii/" + "id": 672, + "link": "https://leetcode.com/problems/bulb-switcher-ii/", + "title": "Bulb Switcher II" }, "673": { - "id": 673, "category": "Tree", - "title": "Number of Longest Increasing Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-longest-increasing-subsequence/" + "id": 673, + "link": "https://leetcode.com/problems/number-of-longest-increasing-subsequence/", + "title": "Number of Longest Increasing Subsequence" }, "674": { - "id": 674, "category": "Array & Hashing", - "title": "Longest Continuous Increasing Subsequence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-continuous-increasing-subsequence/" + "id": 674, + "link": "https://leetcode.com/problems/longest-continuous-increasing-subsequence/", + "title": "Longest Continuous Increasing Subsequence" }, "675": { - "id": 675, "category": "Graph Traversal", - "title": "Cut Off Trees for Golf Event", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cut-off-trees-for-golf-event/" + "id": 675, + "link": "https://leetcode.com/problems/cut-off-trees-for-golf-event/", + "title": "Cut Off Trees for Golf Event" }, "676": { - "id": 676, "category": "Graph Traversal", - "title": "Implement Magic Dictionary", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/implement-magic-dictionary/" - }, - "677": { - "id": 677, - "category": "Trie", - "title": "Map Sum Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/map-sum-pairs/" + "id": 676, + "link": "https://leetcode.com/problems/implement-magic-dictionary/", + "title": "Implement Magic Dictionary" }, + "677": {"category": "Trie", "difficulty": "Medium", "id": 677, "link": "https://leetcode.com/problems/map-sum-pairs/", "title": "Map Sum Pairs"}, "678": { - "id": 678, "category": "Dynamic Programming", - "title": "Valid Parenthesis String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-parenthesis-string/" - }, - "679": { - "id": 679, - "category": "Backtracking", - "title": "24 Game", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/24-game/" + "id": 678, + "link": "https://leetcode.com/problems/valid-parenthesis-string/", + "title": "Valid Parenthesis String" }, + "679": {"category": "Backtracking", "difficulty": "Hard", "id": 679, "link": "https://leetcode.com/problems/24-game/", "title": "24 Game"}, "680": { - "id": 680, "category": "Greedy", - "title": "Valid Palindrome II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-palindrome-ii/" + "id": 680, + "link": "https://leetcode.com/problems/valid-palindrome-ii/", + "title": "Valid Palindrome II" }, "681": { - "id": 681, "category": "Backtracking", - "title": "Next Closest Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-closest-time/" - }, - "682": { - "id": 682, - "category": "Stack", - "title": "Baseball Game", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/baseball-game/" - }, - "683": { - "id": 683, - "category": "Tree", - "title": "K Empty Slots", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/k-empty-slots/" + "id": 681, + "link": "https://leetcode.com/problems/next-closest-time/", + "title": "Next Closest Time" }, + "682": {"category": "Stack", "difficulty": "Easy", "id": 682, "link": "https://leetcode.com/problems/baseball-game/", "title": "Baseball Game"}, + "683": {"category": "Tree", "difficulty": "Hard", "id": 683, "link": "https://leetcode.com/problems/k-empty-slots/", "title": "K Empty Slots"}, "684": { - "id": 684, "category": "Graph Traversal", - "title": "Redundant Connection", "difficulty": "Medium", - "link": "https://leetcode.com/problems/redundant-connection/" + "id": 684, + "link": "https://leetcode.com/problems/redundant-connection/", + "title": "Redundant Connection" }, "685": { - "id": 685, "category": "Graph Traversal", - "title": "Redundant Connection II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/redundant-connection-ii/" + "id": 685, + "link": "https://leetcode.com/problems/redundant-connection-ii/", + "title": "Redundant Connection II" }, "686": { - "id": 686, "category": "Array & Hashing", - "title": "Repeated String Match", "difficulty": "Medium", - "link": "https://leetcode.com/problems/repeated-string-match/" + "id": 686, + "link": "https://leetcode.com/problems/repeated-string-match/", + "title": "Repeated String Match" }, "687": { - "id": 687, "category": "Tree", - "title": "Longest Univalue Path", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-univalue-path/" + "id": 687, + "link": "https://leetcode.com/problems/longest-univalue-path/", + "title": "Longest Univalue Path" }, "688": { - "id": 688, "category": "Dynamic Programming", - "title": "Knight Probability in Chessboard", "difficulty": "Medium", - "link": "https://leetcode.com/problems/knight-probability-in-chessboard/" + "id": 688, + "link": "https://leetcode.com/problems/knight-probability-in-chessboard/", + "title": "Knight Probability in Chessboard" }, "689": { - "id": 689, "category": "Dynamic Programming", - "title": "Maximum Sum of 3 Non-Overlapping Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/" + "id": 689, + "link": "https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/", + "title": "Maximum Sum of 3 Non-Overlapping Subarrays" }, "690": { - "id": 690, "category": "Tree", - "title": "Employee Importance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/employee-importance/" + "id": 690, + "link": "https://leetcode.com/problems/employee-importance/", + "title": "Employee Importance" }, "691": { - "id": 691, "category": "Dynamic Programming", - "title": "Stickers to Spell Word", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stickers-to-spell-word/" + "id": 691, + "link": "https://leetcode.com/problems/stickers-to-spell-word/", + "title": "Stickers to Spell Word" }, "692": { - "id": 692, "category": "Heap (Priority Queue)", - "title": "Top K Frequent Words", "difficulty": "Medium", - "link": "https://leetcode.com/problems/top-k-frequent-words/" + "id": 692, + "link": "https://leetcode.com/problems/top-k-frequent-words/", + "title": "Top K Frequent Words" }, "693": { - "id": 693, "category": "Bit Manipulation", - "title": "Binary Number with Alternating Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-number-with-alternating-bits/" + "id": 693, + "link": "https://leetcode.com/problems/binary-number-with-alternating-bits/", + "title": "Binary Number with Alternating Bits" }, "694": { - "id": 694, "category": "Graph Traversal", - "title": "Number of Distinct Islands", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-distinct-islands/" + "id": 694, + "link": "https://leetcode.com/problems/number-of-distinct-islands/", + "title": "Number of Distinct Islands" }, "695": { - "id": 695, "category": "Graph Traversal", - "title": "Max Area of Island", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-area-of-island/" + "id": 695, + "link": "https://leetcode.com/problems/max-area-of-island/", + "title": "Max Area of Island" }, "696": { - "id": 696, "category": "Two Pointers", - "title": "Count Binary Substrings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-binary-substrings/" + "id": 696, + "link": "https://leetcode.com/problems/count-binary-substrings/", + "title": "Count Binary Substrings" }, "697": { - "id": 697, "category": "Array & Hashing", - "title": "Degree of an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/degree-of-an-array/" + "id": 697, + "link": "https://leetcode.com/problems/degree-of-an-array/", + "title": "Degree of an Array" }, "698": { - "id": 698, "category": "Dynamic Programming", - "title": "Partition to K Equal Sum Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-to-k-equal-sum-subsets/" - }, - "699": { - "id": 699, - "category": "Tree", - "title": "Falling Squares", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/falling-squares/" + "id": 698, + "link": "https://leetcode.com/problems/partition-to-k-equal-sum-subsets/", + "title": "Partition to K Equal Sum Subsets" }, + "699": {"category": "Tree", "difficulty": "Hard", "id": 699, "link": "https://leetcode.com/problems/falling-squares/", "title": "Falling Squares"}, "700": { - "id": 700, "category": "Tree", - "title": "Search in a Binary Search Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/search-in-a-binary-search-tree/" + "id": 700, + "link": "https://leetcode.com/problems/search-in-a-binary-search-tree/", + "title": "Search in a Binary Search Tree" }, "701": { - "id": 701, "category": "Tree", - "title": "Insert into a Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insert-into-a-binary-search-tree/" + "id": 701, + "link": "https://leetcode.com/problems/insert-into-a-binary-search-tree/", + "title": "Insert into a Binary Search Tree" }, "702": { - "id": 702, "category": "Binary Search", - "title": "Search in a Sorted Array of Unknown Size", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size/" + "id": 702, + "link": "https://leetcode.com/problems/search-in-a-sorted-array-of-unknown-size/", + "title": "Search in a Sorted Array of Unknown Size" }, "703": { - "id": 703, "category": "Tree", - "title": "Kth Largest Element in a Stream", "difficulty": "Easy", - "link": "https://leetcode.com/problems/kth-largest-element-in-a-stream/" + "id": 703, + "link": "https://leetcode.com/problems/kth-largest-element-in-a-stream/", + "title": "Kth Largest Element in a Stream" }, "704": { - "id": 704, "category": "Binary Search", - "title": "Binary Search", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-search/" + "id": 704, + "link": "https://leetcode.com/problems/binary-search/", + "title": "Binary Search" }, "705": { - "id": 705, "category": "Linked List", - "title": "Design HashSet", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-hashset/" + "id": 705, + "link": "https://leetcode.com/problems/design-hashset/", + "title": "Design HashSet" }, "706": { - "id": 706, "category": "Linked List", - "title": "Design HashMap", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-hashmap/" + "id": 706, + "link": "https://leetcode.com/problems/design-hashmap/", + "title": "Design HashMap" }, "707": { - "id": 707, "category": "Linked List", - "title": "Design Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-linked-list/" + "id": 707, + "link": "https://leetcode.com/problems/design-linked-list/", + "title": "Design Linked List" }, "708": { - "id": 708, "category": "Linked List", - "title": "Insert into a Sorted Circular Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list/" + "id": 708, + "link": "https://leetcode.com/problems/insert-into-a-sorted-circular-linked-list/", + "title": "Insert into a Sorted Circular Linked List" }, "709": { - "id": 709, "category": "Array & Hashing", - "title": "To Lower Case", "difficulty": "Easy", - "link": "https://leetcode.com/problems/to-lower-case/" + "id": 709, + "link": "https://leetcode.com/problems/to-lower-case/", + "title": "To Lower Case" }, "710": { - "id": 710, "category": "Binary Search", - "title": "Random Pick with Blacklist", "difficulty": "Hard", - "link": "https://leetcode.com/problems/random-pick-with-blacklist/" + "id": 710, + "link": "https://leetcode.com/problems/random-pick-with-blacklist/", + "title": "Random Pick with Blacklist" }, "711": { - "id": 711, "category": "Graph Traversal", - "title": "Number of Distinct Islands II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-distinct-islands-ii/" + "id": 711, + "link": "https://leetcode.com/problems/number-of-distinct-islands-ii/", + "title": "Number of Distinct Islands II" }, "712": { - "id": 712, "category": "Dynamic Programming", - "title": "Minimum ASCII Delete Sum for Two Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/" + "id": 712, + "link": "https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/", + "title": "Minimum ASCII Delete Sum for Two Strings" }, "713": { - "id": 713, "category": "Sliding Window", - "title": "Subarray Product Less Than K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subarray-product-less-than-k/" + "id": 713, + "link": "https://leetcode.com/problems/subarray-product-less-than-k/", + "title": "Subarray Product Less Than K" }, "714": { - "id": 714, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock with Transaction Fee", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/" - }, - "715": { - "id": 715, - "category": "Tree", - "title": "Range Module", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/range-module/" - }, - "716": { - "id": 716, - "category": "Stack", - "title": "Max Stack", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-stack/" + "id": 714, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/", + "title": "Best Time to Buy and Sell Stock with Transaction Fee" }, + "715": {"category": "Tree", "difficulty": "Hard", "id": 715, "link": "https://leetcode.com/problems/range-module/", "title": "Range Module"}, + "716": {"category": "Stack", "difficulty": "Hard", "id": 716, "link": "https://leetcode.com/problems/max-stack/", "title": "Max Stack"}, "717": { - "id": 717, "category": "Array & Hashing", - "title": "1-bit and 2-bit Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/1-bit-and-2-bit-characters/" + "id": 717, + "link": "https://leetcode.com/problems/1-bit-and-2-bit-characters/", + "title": "1-bit and 2-bit Characters" }, "718": { - "id": 718, "category": "Dynamic Programming", - "title": "Maximum Length of Repeated Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-length-of-repeated-subarray/" + "id": 718, + "link": "https://leetcode.com/problems/maximum-length-of-repeated-subarray/", + "title": "Maximum Length of Repeated Subarray" }, "719": { - "id": 719, "category": "Binary Search", - "title": "Find K-th Smallest Pair Distance", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-k-th-smallest-pair-distance/" + "id": 719, + "link": "https://leetcode.com/problems/find-k-th-smallest-pair-distance/", + "title": "Find K-th Smallest Pair Distance" }, "720": { - "id": 720, "category": "Trie", - "title": "Longest Word in Dictionary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-word-in-dictionary/" + "id": 720, + "link": "https://leetcode.com/problems/longest-word-in-dictionary/", + "title": "Longest Word in Dictionary" }, "721": { - "id": 721, "category": "Graph Traversal", - "title": "Accounts Merge", "difficulty": "Medium", - "link": "https://leetcode.com/problems/accounts-merge/" + "id": 721, + "link": "https://leetcode.com/problems/accounts-merge/", + "title": "Accounts Merge" }, "722": { - "id": 722, "category": "Array & Hashing", - "title": "Remove Comments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-comments/" + "id": 722, + "link": "https://leetcode.com/problems/remove-comments/", + "title": "Remove Comments" }, "723": { - "id": 723, "category": "Two Pointers", - "title": "Candy Crush", "difficulty": "Medium", - "link": "https://leetcode.com/problems/candy-crush/" + "id": 723, + "link": "https://leetcode.com/problems/candy-crush/", + "title": "Candy Crush" }, "724": { - "id": 724, "category": "Array & Hashing", - "title": "Find Pivot Index", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-pivot-index/" + "id": 724, + "link": "https://leetcode.com/problems/find-pivot-index/", + "title": "Find Pivot Index" }, "725": { - "id": 725, "category": "Linked List", - "title": "Split Linked List in Parts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-linked-list-in-parts/" - }, - "726": { - "id": 726, - "category": "Stack", - "title": "Number of Atoms", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-atoms/" + "id": 725, + "link": "https://leetcode.com/problems/split-linked-list-in-parts/", + "title": "Split Linked List in Parts" }, + "726": {"category": "Stack", "difficulty": "Hard", "id": 726, "link": "https://leetcode.com/problems/number-of-atoms/", "title": "Number of Atoms"}, "727": { - "id": 727, "category": "Dynamic Programming", - "title": "Minimum Window Subsequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-window-subsequence/" + "id": 727, + "link": "https://leetcode.com/problems/minimum-window-subsequence/", + "title": "Minimum Window Subsequence" }, "728": { - "id": 728, "category": "Math & Geometry", - "title": "Self Dividing Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/self-dividing-numbers/" - }, - "729": { - "id": 729, - "category": "Tree", - "title": "My Calendar I", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/my-calendar-i/" + "id": 728, + "link": "https://leetcode.com/problems/self-dividing-numbers/", + "title": "Self Dividing Numbers" }, + "729": {"category": "Tree", "difficulty": "Medium", "id": 729, "link": "https://leetcode.com/problems/my-calendar-i/", "title": "My Calendar I"}, "730": { - "id": 730, "category": "Dynamic Programming", - "title": "Count Different Palindromic Subsequences", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-different-palindromic-subsequences/" - }, - "731": { - "id": 731, - "category": "Tree", - "title": "My Calendar II", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/my-calendar-ii/" - }, - "732": { - "id": 732, - "category": "Tree", - "title": "My Calendar III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/my-calendar-iii/" - }, - "733": { - "id": 733, - "category": "Graph Traversal", - "title": "Flood Fill", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/flood-fill/" + "id": 730, + "link": "https://leetcode.com/problems/count-different-palindromic-subsequences/", + "title": "Count Different Palindromic Subsequences" }, + "731": {"category": "Tree", "difficulty": "Medium", "id": 731, "link": "https://leetcode.com/problems/my-calendar-ii/", "title": "My Calendar II"}, + "732": {"category": "Tree", "difficulty": "Hard", "id": 732, "link": "https://leetcode.com/problems/my-calendar-iii/", "title": "My Calendar III"}, + "733": {"category": "Graph Traversal", "difficulty": "Easy", "id": 733, "link": "https://leetcode.com/problems/flood-fill/", "title": "Flood Fill"}, "734": { - "id": 734, "category": "Array & Hashing", - "title": "Sentence Similarity", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sentence-similarity/" + "id": 734, + "link": "https://leetcode.com/problems/sentence-similarity/", + "title": "Sentence Similarity" }, "735": { - "id": 735, "category": "Stack", - "title": "Asteroid Collision", "difficulty": "Medium", - "link": "https://leetcode.com/problems/asteroid-collision/" + "id": 735, + "link": "https://leetcode.com/problems/asteroid-collision/", + "title": "Asteroid Collision" }, "736": { - "id": 736, "category": "Stack", - "title": "Parse Lisp Expression", "difficulty": "Hard", - "link": "https://leetcode.com/problems/parse-lisp-expression/" + "id": 736, + "link": "https://leetcode.com/problems/parse-lisp-expression/", + "title": "Parse Lisp Expression" }, "737": { - "id": 737, "category": "Graph Traversal", - "title": "Sentence Similarity II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sentence-similarity-ii/" + "id": 737, + "link": "https://leetcode.com/problems/sentence-similarity-ii/", + "title": "Sentence Similarity II" }, "738": { - "id": 738, "category": "Greedy", - "title": "Monotone Increasing Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/monotone-increasing-digits/" + "id": 738, + "link": "https://leetcode.com/problems/monotone-increasing-digits/", + "title": "Monotone Increasing Digits" }, "739": { - "id": 739, "category": "Stack", - "title": "Daily Temperatures", "difficulty": "Medium", - "link": "https://leetcode.com/problems/daily-temperatures/" + "id": 739, + "link": "https://leetcode.com/problems/daily-temperatures/", + "title": "Daily Temperatures" }, "740": { - "id": 740, "category": "Dynamic Programming", - "title": "Delete and Earn", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-and-earn/" + "id": 740, + "link": "https://leetcode.com/problems/delete-and-earn/", + "title": "Delete and Earn" }, "741": { - "id": 741, "category": "Dynamic Programming", - "title": "Cherry Pickup", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cherry-pickup/" + "id": 741, + "link": "https://leetcode.com/problems/cherry-pickup/", + "title": "Cherry Pickup" }, "742": { - "id": 742, "category": "Tree", - "title": "Closest Leaf in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-leaf-in-a-binary-tree/" + "id": 742, + "link": "https://leetcode.com/problems/closest-leaf-in-a-binary-tree/", + "title": "Closest Leaf in a Binary Tree" }, "743": { - "id": 743, "category": "Graph Traversal", - "title": "Network Delay Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/network-delay-time/" + "id": 743, + "link": "https://leetcode.com/problems/network-delay-time/", + "title": "Network Delay Time" }, "744": { - "id": 744, "category": "Binary Search", - "title": "Find Smallest Letter Greater Than Target", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-smallest-letter-greater-than-target/" + "id": 744, + "link": "https://leetcode.com/problems/find-smallest-letter-greater-than-target/", + "title": "Find Smallest Letter Greater Than Target" }, "745": { - "id": 745, "category": "Trie", - "title": "Prefix and Suffix Search", "difficulty": "Hard", - "link": "https://leetcode.com/problems/prefix-and-suffix-search/" + "id": 745, + "link": "https://leetcode.com/problems/prefix-and-suffix-search/", + "title": "Prefix and Suffix Search" }, "746": { - "id": 746, "category": "Dynamic Programming", - "title": "Min Cost Climbing Stairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/min-cost-climbing-stairs/" + "id": 746, + "link": "https://leetcode.com/problems/min-cost-climbing-stairs/", + "title": "Min Cost Climbing Stairs" }, "747": { - "id": 747, "category": "Array & Hashing", - "title": "Largest Number At Least Twice of Others", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-number-at-least-twice-of-others/" + "id": 747, + "link": "https://leetcode.com/problems/largest-number-at-least-twice-of-others/", + "title": "Largest Number At Least Twice of Others" }, "748": { - "id": 748, "category": "Array & Hashing", - "title": "Shortest Completing Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-completing-word/" + "id": 748, + "link": "https://leetcode.com/problems/shortest-completing-word/", + "title": "Shortest Completing Word" }, "749": { - "id": 749, "category": "Graph Traversal", - "title": "Contain Virus", "difficulty": "Hard", - "link": "https://leetcode.com/problems/contain-virus/" + "id": 749, + "link": "https://leetcode.com/problems/contain-virus/", + "title": "Contain Virus" }, "750": { - "id": 750, "category": "Dynamic Programming", - "title": "Number Of Corner Rectangles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-corner-rectangles/" + "id": 750, + "link": "https://leetcode.com/problems/number-of-corner-rectangles/", + "title": "Number Of Corner Rectangles" }, "751": { - "id": 751, "category": "Bit Manipulation", - "title": "IP to CIDR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ip-to-cidr/" + "id": 751, + "link": "https://leetcode.com/problems/ip-to-cidr/", + "title": "IP to CIDR" }, "752": { - "id": 752, "category": "Graph Traversal", - "title": "Open the Lock", "difficulty": "Medium", - "link": "https://leetcode.com/problems/open-the-lock/" + "id": 752, + "link": "https://leetcode.com/problems/open-the-lock/", + "title": "Open the Lock" }, "753": { - "id": 753, "category": "Graph Traversal", - "title": "Cracking the Safe", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cracking-the-safe/" + "id": 753, + "link": "https://leetcode.com/problems/cracking-the-safe/", + "title": "Cracking the Safe" }, "754": { - "id": 754, "category": "Binary Search", - "title": "Reach a Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reach-a-number/" + "id": 754, + "link": "https://leetcode.com/problems/reach-a-number/", + "title": "Reach a Number" }, "755": { - "id": 755, "category": "Array & Hashing", - "title": "Pour Water", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pour-water/" + "id": 755, + "link": "https://leetcode.com/problems/pour-water/", + "title": "Pour Water" }, "756": { - "id": 756, "category": "Backtracking", - "title": "Pyramid Transition Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pyramid-transition-matrix/" + "id": 756, + "link": "https://leetcode.com/problems/pyramid-transition-matrix/", + "title": "Pyramid Transition Matrix" }, "757": { - "id": 757, "category": "Greedy", - "title": "Set Intersection Size At Least Two", "difficulty": "Hard", - "link": "https://leetcode.com/problems/set-intersection-size-at-least-two/" + "id": 757, + "link": "https://leetcode.com/problems/set-intersection-size-at-least-two/", + "title": "Set Intersection Size At Least Two" }, "758": { - "id": 758, "category": "Trie", - "title": "Bold Words in String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bold-words-in-string/" + "id": 758, + "link": "https://leetcode.com/problems/bold-words-in-string/", + "title": "Bold Words in String" }, "759": { - "id": 759, "category": "Heap (Priority Queue)", - "title": "Employee Free Time", "difficulty": "Hard", - "link": "https://leetcode.com/problems/employee-free-time/" + "id": 759, + "link": "https://leetcode.com/problems/employee-free-time/", + "title": "Employee Free Time" }, "760": { - "id": 760, "category": "Array & Hashing", - "title": "Find Anagram Mappings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-anagram-mappings/" + "id": 760, + "link": "https://leetcode.com/problems/find-anagram-mappings/", + "title": "Find Anagram Mappings" }, "761": { - "id": 761, "category": "Array & Hashing", - "title": "Special Binary String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/special-binary-string/" + "id": 761, + "link": "https://leetcode.com/problems/special-binary-string/", + "title": "Special Binary String" }, "762": { - "id": 762, "category": "Bit Manipulation", - "title": "Prime Number of Set Bits in Binary Representation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/" + "id": 762, + "link": "https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/", + "title": "Prime Number of Set Bits in Binary Representation" }, "763": { - "id": 763, "category": "Greedy", - "title": "Partition Labels", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-labels/" + "id": 763, + "link": "https://leetcode.com/problems/partition-labels/", + "title": "Partition Labels" }, "764": { - "id": 764, "category": "Dynamic Programming", - "title": "Largest Plus Sign", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-plus-sign/" + "id": 764, + "link": "https://leetcode.com/problems/largest-plus-sign/", + "title": "Largest Plus Sign" }, "765": { - "id": 765, "category": "Graph Traversal", - "title": "Couples Holding Hands", "difficulty": "Hard", - "link": "https://leetcode.com/problems/couples-holding-hands/" + "id": 765, + "link": "https://leetcode.com/problems/couples-holding-hands/", + "title": "Couples Holding Hands" }, "766": { - "id": 766, "category": "Array & Hashing", - "title": "Toeplitz Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/toeplitz-matrix/" + "id": 766, + "link": "https://leetcode.com/problems/toeplitz-matrix/", + "title": "Toeplitz Matrix" }, "767": { - "id": 767, "category": "Heap (Priority Queue)", - "title": "Reorganize String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reorganize-string/" + "id": 767, + "link": "https://leetcode.com/problems/reorganize-string/", + "title": "Reorganize String" }, "768": { - "id": 768, "category": "Stack", - "title": "Max Chunks To Make Sorted II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-chunks-to-make-sorted-ii/" + "id": 768, + "link": "https://leetcode.com/problems/max-chunks-to-make-sorted-ii/", + "title": "Max Chunks To Make Sorted II" }, "769": { - "id": 769, "category": "Stack", - "title": "Max Chunks To Make Sorted", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-chunks-to-make-sorted/" + "id": 769, + "link": "https://leetcode.com/problems/max-chunks-to-make-sorted/", + "title": "Max Chunks To Make Sorted" }, "770": { - "id": 770, "category": "Stack", - "title": "Basic Calculator IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/basic-calculator-iv/" + "id": 770, + "link": "https://leetcode.com/problems/basic-calculator-iv/", + "title": "Basic Calculator IV" }, "771": { - "id": 771, "category": "Array & Hashing", - "title": "Jewels and Stones", "difficulty": "Easy", - "link": "https://leetcode.com/problems/jewels-and-stones/" + "id": 771, + "link": "https://leetcode.com/problems/jewels-and-stones/", + "title": "Jewels and Stones" }, "772": { - "id": 772, "category": "Stack", - "title": "Basic Calculator III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/basic-calculator-iii/" + "id": 772, + "link": "https://leetcode.com/problems/basic-calculator-iii/", + "title": "Basic Calculator III" }, "773": { - "id": 773, "category": "Graph Traversal", - "title": "Sliding Puzzle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sliding-puzzle/" + "id": 773, + "link": "https://leetcode.com/problems/sliding-puzzle/", + "title": "Sliding Puzzle" }, "774": { - "id": 774, "category": "Binary Search", - "title": "Minimize Max Distance to Gas Station", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-max-distance-to-gas-station/" + "id": 774, + "link": "https://leetcode.com/problems/minimize-max-distance-to-gas-station/", + "title": "Minimize Max Distance to Gas Station" }, "775": { - "id": 775, "category": "Math & Geometry", - "title": "Global and Local Inversions", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/global-and-local-inversions/" - }, - "776": { - "id": 776, - "category": "Tree", - "title": "Split BST", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-bst/" + "id": 775, + "link": "https://leetcode.com/problems/global-and-local-inversions/", + "title": "Global and Local Inversions" }, + "776": {"category": "Tree", "difficulty": "Medium", "id": 776, "link": "https://leetcode.com/problems/split-bst/", "title": "Split BST"}, "777": { - "id": 777, "category": "Two Pointers", - "title": "Swap Adjacent in LR String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/swap-adjacent-in-lr-string/" + "id": 777, + "link": "https://leetcode.com/problems/swap-adjacent-in-lr-string/", + "title": "Swap Adjacent in LR String" }, "778": { - "id": 778, "category": "Graph Traversal", - "title": "Swim in Rising Water", "difficulty": "Hard", - "link": "https://leetcode.com/problems/swim-in-rising-water/" + "id": 778, + "link": "https://leetcode.com/problems/swim-in-rising-water/", + "title": "Swim in Rising Water" }, "779": { - "id": 779, "category": "Bit Manipulation", - "title": "K-th Symbol in Grammar", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-th-symbol-in-grammar/" + "id": 779, + "link": "https://leetcode.com/problems/k-th-symbol-in-grammar/", + "title": "K-th Symbol in Grammar" }, "780": { - "id": 780, "category": "Math & Geometry", - "title": "Reaching Points", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reaching-points/" + "id": 780, + "link": "https://leetcode.com/problems/reaching-points/", + "title": "Reaching Points" }, "781": { - "id": 781, "category": "Greedy", - "title": "Rabbits in Forest", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rabbits-in-forest/" + "id": 781, + "link": "https://leetcode.com/problems/rabbits-in-forest/", + "title": "Rabbits in Forest" }, "782": { - "id": 782, "category": "Bit Manipulation", - "title": "Transform to Chessboard", "difficulty": "Hard", - "link": "https://leetcode.com/problems/transform-to-chessboard/" + "id": 782, + "link": "https://leetcode.com/problems/transform-to-chessboard/", + "title": "Transform to Chessboard" }, "783": { - "id": 783, "category": "Tree", - "title": "Minimum Distance Between BST Nodes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-distance-between-bst-nodes/" + "id": 783, + "link": "https://leetcode.com/problems/minimum-distance-between-bst-nodes/", + "title": "Minimum Distance Between BST Nodes" }, "784": { - "id": 784, "category": "Backtracking", - "title": "Letter Case Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/letter-case-permutation/" + "id": 784, + "link": "https://leetcode.com/problems/letter-case-permutation/", + "title": "Letter Case Permutation" }, "785": { - "id": 785, "category": "Graph Traversal", - "title": "Is Graph Bipartite?", "difficulty": "Medium", - "link": "https://leetcode.com/problems/is-graph-bipartite/" + "id": 785, + "link": "https://leetcode.com/problems/is-graph-bipartite/", + "title": "Is Graph Bipartite?" }, "786": { - "id": 786, "category": "Binary Search", - "title": "K-th Smallest Prime Fraction", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-th-smallest-prime-fraction/" + "id": 786, + "link": "https://leetcode.com/problems/k-th-smallest-prime-fraction/", + "title": "K-th Smallest Prime Fraction" }, "787": { - "id": 787, "category": "Graph Traversal", - "title": "Cheapest Flights Within K Stops", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cheapest-flights-within-k-stops/" + "id": 787, + "link": "https://leetcode.com/problems/cheapest-flights-within-k-stops/", + "title": "Cheapest Flights Within K Stops" }, "788": { - "id": 788, "category": "Dynamic Programming", - "title": "Rotated Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotated-digits/" + "id": 788, + "link": "https://leetcode.com/problems/rotated-digits/", + "title": "Rotated Digits" }, "789": { - "id": 789, "category": "Math & Geometry", - "title": "Escape The Ghosts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/escape-the-ghosts/" + "id": 789, + "link": "https://leetcode.com/problems/escape-the-ghosts/", + "title": "Escape The Ghosts" }, "790": { - "id": 790, "category": "Dynamic Programming", - "title": "Domino and Tromino Tiling", "difficulty": "Medium", - "link": "https://leetcode.com/problems/domino-and-tromino-tiling/" + "id": 790, + "link": "https://leetcode.com/problems/domino-and-tromino-tiling/", + "title": "Domino and Tromino Tiling" }, "791": { - "id": 791, "category": "Array & Hashing", - "title": "Custom Sort String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/custom-sort-string/" + "id": 791, + "link": "https://leetcode.com/problems/custom-sort-string/", + "title": "Custom Sort String" }, "792": { - "id": 792, "category": "Dynamic Programming", - "title": "Number of Matching Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-matching-subsequences/" + "id": 792, + "link": "https://leetcode.com/problems/number-of-matching-subsequences/", + "title": "Number of Matching Subsequences" }, "793": { - "id": 793, "category": "Binary Search", - "title": "Preimage Size of Factorial Zeroes Function", "difficulty": "Hard", - "link": "https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/" + "id": 793, + "link": "https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/", + "title": "Preimage Size of Factorial Zeroes Function" }, "794": { - "id": 794, "category": "Array & Hashing", - "title": "Valid Tic-Tac-Toe State", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-tic-tac-toe-state/" + "id": 794, + "link": "https://leetcode.com/problems/valid-tic-tac-toe-state/", + "title": "Valid Tic-Tac-Toe State" }, "795": { - "id": 795, "category": "Two Pointers", - "title": "Number of Subarrays with Bounded Maximum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/" + "id": 795, + "link": "https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/", + "title": "Number of Subarrays with Bounded Maximum" }, "796": { - "id": 796, "category": "Array & Hashing", - "title": "Rotate String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rotate-string/" + "id": 796, + "link": "https://leetcode.com/problems/rotate-string/", + "title": "Rotate String" }, "797": { - "id": 797, "category": "Graph Traversal", - "title": "All Paths From Source to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-paths-from-source-to-target/" + "id": 797, + "link": "https://leetcode.com/problems/all-paths-from-source-to-target/", + "title": "All Paths From Source to Target" }, "798": { - "id": 798, "category": "Array & Hashing", - "title": "Smallest Rotation with Highest Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-rotation-with-highest-score/" + "id": 798, + "link": "https://leetcode.com/problems/smallest-rotation-with-highest-score/", + "title": "Smallest Rotation with Highest Score" }, "799": { - "id": 799, "category": "Dynamic Programming", - "title": "Champagne Tower", "difficulty": "Medium", - "link": "https://leetcode.com/problems/champagne-tower/" + "id": 799, + "link": "https://leetcode.com/problems/champagne-tower/", + "title": "Champagne Tower" }, "800": { - "id": 800, "category": "Math & Geometry", - "title": "Similar RGB Color", "difficulty": "Easy", - "link": "https://leetcode.com/problems/similar-rgb-color/" + "id": 800, + "link": "https://leetcode.com/problems/similar-rgb-color/", + "title": "Similar RGB Color" }, "801": { - "id": 801, "category": "Dynamic Programming", - "title": "Minimum Swaps To Make Sequences Increasing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/" + "id": 801, + "link": "https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/", + "title": "Minimum Swaps To Make Sequences Increasing" }, "802": { - "id": 802, "category": "Graph Traversal", - "title": "Find Eventual Safe States", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-eventual-safe-states/" + "id": 802, + "link": "https://leetcode.com/problems/find-eventual-safe-states/", + "title": "Find Eventual Safe States" }, "803": { - "id": 803, "category": "Graph Traversal", - "title": "Bricks Falling When Hit", "difficulty": "Hard", - "link": "https://leetcode.com/problems/bricks-falling-when-hit/" + "id": 803, + "link": "https://leetcode.com/problems/bricks-falling-when-hit/", + "title": "Bricks Falling When Hit" }, "804": { - "id": 804, "category": "Array & Hashing", - "title": "Unique Morse Code Words", "difficulty": "Easy", - "link": "https://leetcode.com/problems/unique-morse-code-words/" + "id": 804, + "link": "https://leetcode.com/problems/unique-morse-code-words/", + "title": "Unique Morse Code Words" }, "805": { - "id": 805, "category": "Dynamic Programming", - "title": "Split Array With Same Average", "difficulty": "Hard", - "link": "https://leetcode.com/problems/split-array-with-same-average/" + "id": 805, + "link": "https://leetcode.com/problems/split-array-with-same-average/", + "title": "Split Array With Same Average" }, "806": { - "id": 806, "category": "Array & Hashing", - "title": "Number of Lines To Write String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-lines-to-write-string/" + "id": 806, + "link": "https://leetcode.com/problems/number-of-lines-to-write-string/", + "title": "Number of Lines To Write String" }, "807": { - "id": 807, "category": "Greedy", - "title": "Max Increase to Keep City Skyline", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-increase-to-keep-city-skyline/" + "id": 807, + "link": "https://leetcode.com/problems/max-increase-to-keep-city-skyline/", + "title": "Max Increase to Keep City Skyline" }, "808": { - "id": 808, "category": "Dynamic Programming", - "title": "Soup Servings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/soup-servings/" + "id": 808, + "link": "https://leetcode.com/problems/soup-servings/", + "title": "Soup Servings" }, "809": { - "id": 809, "category": "Two Pointers", - "title": "Expressive Words", "difficulty": "Medium", - "link": "https://leetcode.com/problems/expressive-words/" + "id": 809, + "link": "https://leetcode.com/problems/expressive-words/", + "title": "Expressive Words" }, "810": { - "id": 810, "category": "Bit Manipulation", - "title": "Chalkboard XOR Game", "difficulty": "Hard", - "link": "https://leetcode.com/problems/chalkboard-xor-game/" + "id": 810, + "link": "https://leetcode.com/problems/chalkboard-xor-game/", + "title": "Chalkboard XOR Game" }, "811": { - "id": 811, "category": "Array & Hashing", - "title": "Subdomain Visit Count", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subdomain-visit-count/" + "id": 811, + "link": "https://leetcode.com/problems/subdomain-visit-count/", + "title": "Subdomain Visit Count" }, "812": { - "id": 812, "category": "Math & Geometry", - "title": "Largest Triangle Area", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-triangle-area/" + "id": 812, + "link": "https://leetcode.com/problems/largest-triangle-area/", + "title": "Largest Triangle Area" }, "813": { - "id": 813, "category": "Dynamic Programming", - "title": "Largest Sum of Averages", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-sum-of-averages/" + "id": 813, + "link": "https://leetcode.com/problems/largest-sum-of-averages/", + "title": "Largest Sum of Averages" }, "814": { - "id": 814, "category": "Tree", - "title": "Binary Tree Pruning", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-pruning/" - }, - "815": { - "id": 815, - "category": "Graph Traversal", - "title": "Bus Routes", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/bus-routes/" + "id": 814, + "link": "https://leetcode.com/problems/binary-tree-pruning/", + "title": "Binary Tree Pruning" }, + "815": {"category": "Graph Traversal", "difficulty": "Hard", "id": 815, "link": "https://leetcode.com/problems/bus-routes/", "title": "Bus Routes"}, "816": { - "id": 816, "category": "Backtracking", - "title": "Ambiguous Coordinates", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ambiguous-coordinates/" + "id": 816, + "link": "https://leetcode.com/problems/ambiguous-coordinates/", + "title": "Ambiguous Coordinates" }, "817": { - "id": 817, "category": "Linked List", - "title": "Linked List Components", "difficulty": "Medium", - "link": "https://leetcode.com/problems/linked-list-components/" - }, - "818": { - "id": 818, - "category": "Dynamic Programming", - "title": "Race Car", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/race-car/" + "id": 817, + "link": "https://leetcode.com/problems/linked-list-components/", + "title": "Linked List Components" }, + "818": {"category": "Dynamic Programming", "difficulty": "Hard", "id": 818, "link": "https://leetcode.com/problems/race-car/", "title": "Race Car"}, "819": { - "id": 819, "category": "Array & Hashing", - "title": "Most Common Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/most-common-word/" + "id": 819, + "link": "https://leetcode.com/problems/most-common-word/", + "title": "Most Common Word" }, "820": { - "id": 820, "category": "Trie", - "title": "Short Encoding of Words", "difficulty": "Medium", - "link": "https://leetcode.com/problems/short-encoding-of-words/" + "id": 820, + "link": "https://leetcode.com/problems/short-encoding-of-words/", + "title": "Short Encoding of Words" }, "821": { - "id": 821, "category": "Two Pointers", - "title": "Shortest Distance to a Character", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-distance-to-a-character/" + "id": 821, + "link": "https://leetcode.com/problems/shortest-distance-to-a-character/", + "title": "Shortest Distance to a Character" }, "822": { - "id": 822, "category": "Array & Hashing", - "title": "Card Flipping Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/card-flipping-game/" + "id": 822, + "link": "https://leetcode.com/problems/card-flipping-game/", + "title": "Card Flipping Game" }, "823": { - "id": 823, "category": "Dynamic Programming", - "title": "Binary Trees With Factors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-trees-with-factors/" - }, - "824": { - "id": 824, - "category": "Array & Hashing", - "title": "Goat Latin", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/goat-latin/" + "id": 823, + "link": "https://leetcode.com/problems/binary-trees-with-factors/", + "title": "Binary Trees With Factors" }, + "824": {"category": "Array & Hashing", "difficulty": "Easy", "id": 824, "link": "https://leetcode.com/problems/goat-latin/", "title": "Goat Latin"}, "825": { - "id": 825, "category": "Binary Search", - "title": "Friends Of Appropriate Ages", "difficulty": "Medium", - "link": "https://leetcode.com/problems/friends-of-appropriate-ages/" + "id": 825, + "link": "https://leetcode.com/problems/friends-of-appropriate-ages/", + "title": "Friends Of Appropriate Ages" }, "826": { - "id": 826, "category": "Binary Search", - "title": "Most Profit Assigning Work", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-profit-assigning-work/" + "id": 826, + "link": "https://leetcode.com/problems/most-profit-assigning-work/", + "title": "Most Profit Assigning Work" }, "827": { - "id": 827, "category": "Graph Traversal", - "title": "Making A Large Island", "difficulty": "Hard", - "link": "https://leetcode.com/problems/making-a-large-island/" + "id": 827, + "link": "https://leetcode.com/problems/making-a-large-island/", + "title": "Making A Large Island" }, "828": { - "id": 828, "category": "Dynamic Programming", - "title": "Count Unique Characters of All Substrings of a Given String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/" + "id": 828, + "link": "https://leetcode.com/problems/count-unique-characters-of-all-substrings-of-a-given-string/", + "title": "Count Unique Characters of All Substrings of a Given String" }, "829": { - "id": 829, "category": "Math & Geometry", - "title": "Consecutive Numbers Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/consecutive-numbers-sum/" + "id": 829, + "link": "https://leetcode.com/problems/consecutive-numbers-sum/", + "title": "Consecutive Numbers Sum" }, "830": { - "id": 830, "category": "Array & Hashing", - "title": "Positions of Large Groups", "difficulty": "Easy", - "link": "https://leetcode.com/problems/positions-of-large-groups/" + "id": 830, + "link": "https://leetcode.com/problems/positions-of-large-groups/", + "title": "Positions of Large Groups" }, "831": { - "id": 831, "category": "Array & Hashing", - "title": "Masking Personal Information", "difficulty": "Medium", - "link": "https://leetcode.com/problems/masking-personal-information/" + "id": 831, + "link": "https://leetcode.com/problems/masking-personal-information/", + "title": "Masking Personal Information" }, "832": { - "id": 832, "category": "Bit Manipulation", - "title": "Flipping an Image", "difficulty": "Easy", - "link": "https://leetcode.com/problems/flipping-an-image/" + "id": 832, + "link": "https://leetcode.com/problems/flipping-an-image/", + "title": "Flipping an Image" }, "833": { - "id": 833, "category": "Array & Hashing", - "title": "Find And Replace in String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-and-replace-in-string/" + "id": 833, + "link": "https://leetcode.com/problems/find-and-replace-in-string/", + "title": "Find And Replace in String" }, "834": { - "id": 834, "category": "Tree", - "title": "Sum of Distances in Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-distances-in-tree/" + "id": 834, + "link": "https://leetcode.com/problems/sum-of-distances-in-tree/", + "title": "Sum of Distances in Tree" }, "835": { - "id": 835, "category": "Array & Hashing", - "title": "Image Overlap", "difficulty": "Medium", - "link": "https://leetcode.com/problems/image-overlap/" + "id": 835, + "link": "https://leetcode.com/problems/image-overlap/", + "title": "Image Overlap" }, "836": { - "id": 836, "category": "Math & Geometry", - "title": "Rectangle Overlap", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rectangle-overlap/" + "id": 836, + "link": "https://leetcode.com/problems/rectangle-overlap/", + "title": "Rectangle Overlap" }, "837": { - "id": 837, "category": "Dynamic Programming", - "title": "New 21 Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/new-21-game/" + "id": 837, + "link": "https://leetcode.com/problems/new-21-game/", + "title": "New 21 Game" }, "838": { - "id": 838, "category": "Dynamic Programming", - "title": "Push Dominoes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/push-dominoes/" + "id": 838, + "link": "https://leetcode.com/problems/push-dominoes/", + "title": "Push Dominoes" }, "839": { - "id": 839, "category": "Graph Traversal", - "title": "Similar String Groups", "difficulty": "Hard", - "link": "https://leetcode.com/problems/similar-string-groups/" + "id": 839, + "link": "https://leetcode.com/problems/similar-string-groups/", + "title": "Similar String Groups" }, "840": { - "id": 840, "category": "Math & Geometry", - "title": "Magic Squares In Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/magic-squares-in-grid/" + "id": 840, + "link": "https://leetcode.com/problems/magic-squares-in-grid/", + "title": "Magic Squares In Grid" }, "841": { - "id": 841, "category": "Graph Traversal", - "title": "Keys and Rooms", "difficulty": "Medium", - "link": "https://leetcode.com/problems/keys-and-rooms/" + "id": 841, + "link": "https://leetcode.com/problems/keys-and-rooms/", + "title": "Keys and Rooms" }, "842": { - "id": 842, "category": "Backtracking", - "title": "Split Array into Fibonacci Sequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-array-into-fibonacci-sequence/" + "id": 842, + "link": "https://leetcode.com/problems/split-array-into-fibonacci-sequence/", + "title": "Split Array into Fibonacci Sequence" }, "843": { - "id": 843, "category": "Math & Geometry", - "title": "Guess the Word", "difficulty": "Hard", - "link": "https://leetcode.com/problems/guess-the-word/" + "id": 843, + "link": "https://leetcode.com/problems/guess-the-word/", + "title": "Guess the Word" }, "844": { - "id": 844, "category": "Stack", - "title": "Backspace String Compare", "difficulty": "Easy", - "link": "https://leetcode.com/problems/backspace-string-compare/" + "id": 844, + "link": "https://leetcode.com/problems/backspace-string-compare/", + "title": "Backspace String Compare" }, "845": { - "id": 845, "category": "Dynamic Programming", - "title": "Longest Mountain in Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-mountain-in-array/" + "id": 845, + "link": "https://leetcode.com/problems/longest-mountain-in-array/", + "title": "Longest Mountain in Array" }, "846": { - "id": 846, "category": "Greedy", - "title": "Hand of Straights", "difficulty": "Medium", - "link": "https://leetcode.com/problems/hand-of-straights/" + "id": 846, + "link": "https://leetcode.com/problems/hand-of-straights/", + "title": "Hand of Straights" }, "847": { - "id": 847, "category": "Graph Traversal", - "title": "Shortest Path Visiting All Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-path-visiting-all-nodes/" + "id": 847, + "link": "https://leetcode.com/problems/shortest-path-visiting-all-nodes/", + "title": "Shortest Path Visiting All Nodes" }, "848": { - "id": 848, "category": "Array & Hashing", - "title": "Shifting Letters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shifting-letters/" + "id": 848, + "link": "https://leetcode.com/problems/shifting-letters/", + "title": "Shifting Letters" }, "849": { - "id": 849, "category": "Array & Hashing", - "title": "Maximize Distance to Closest Person", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-distance-to-closest-person/" + "id": 849, + "link": "https://leetcode.com/problems/maximize-distance-to-closest-person/", + "title": "Maximize Distance to Closest Person" }, "850": { - "id": 850, "category": "Tree", - "title": "Rectangle Area II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/rectangle-area-ii/" + "id": 850, + "link": "https://leetcode.com/problems/rectangle-area-ii/", + "title": "Rectangle Area II" }, "851": { - "id": 851, "category": "Graph Traversal", - "title": "Loud and Rich", "difficulty": "Medium", - "link": "https://leetcode.com/problems/loud-and-rich/" + "id": 851, + "link": "https://leetcode.com/problems/loud-and-rich/", + "title": "Loud and Rich" }, "852": { - "id": 852, "category": "Binary Search", - "title": "Peak Index in a Mountain Array", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/peak-index-in-a-mountain-array/" - }, - "853": { - "id": 853, - "category": "Stack", - "title": "Car Fleet", "difficulty": "Medium", - "link": "https://leetcode.com/problems/car-fleet/" + "id": 852, + "link": "https://leetcode.com/problems/peak-index-in-a-mountain-array/", + "title": "Peak Index in a Mountain Array" }, + "853": {"category": "Stack", "difficulty": "Medium", "id": 853, "link": "https://leetcode.com/problems/car-fleet/", "title": "Car Fleet"}, "854": { - "id": 854, "category": "Graph Traversal", - "title": "K-Similar Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/k-similar-strings/" + "id": 854, + "link": "https://leetcode.com/problems/k-similar-strings/", + "title": "K-Similar Strings" }, "855": { - "id": 855, "category": "Heap (Priority Queue)", - "title": "Exam Room", "difficulty": "Medium", - "link": "https://leetcode.com/problems/exam-room/" + "id": 855, + "link": "https://leetcode.com/problems/exam-room/", + "title": "Exam Room" }, "856": { - "id": 856, "category": "Stack", - "title": "Score of Parentheses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/score-of-parentheses/" + "id": 856, + "link": "https://leetcode.com/problems/score-of-parentheses/", + "title": "Score of Parentheses" }, "857": { - "id": 857, "category": "Heap (Priority Queue)", - "title": "Minimum Cost to Hire K Workers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-hire-k-workers/" + "id": 857, + "link": "https://leetcode.com/problems/minimum-cost-to-hire-k-workers/", + "title": "Minimum Cost to Hire K Workers" }, "858": { - "id": 858, "category": "Math & Geometry", - "title": "Mirror Reflection", "difficulty": "Medium", - "link": "https://leetcode.com/problems/mirror-reflection/" + "id": 858, + "link": "https://leetcode.com/problems/mirror-reflection/", + "title": "Mirror Reflection" }, "859": { - "id": 859, "category": "Array & Hashing", - "title": "Buddy Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/buddy-strings/" + "id": 859, + "link": "https://leetcode.com/problems/buddy-strings/", + "title": "Buddy Strings" }, "860": { - "id": 860, "category": "Greedy", - "title": "Lemonade Change", "difficulty": "Easy", - "link": "https://leetcode.com/problems/lemonade-change/" + "id": 860, + "link": "https://leetcode.com/problems/lemonade-change/", + "title": "Lemonade Change" }, "861": { - "id": 861, "category": "Bit Manipulation", - "title": "Score After Flipping Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/score-after-flipping-matrix/" + "id": 861, + "link": "https://leetcode.com/problems/score-after-flipping-matrix/", + "title": "Score After Flipping Matrix" }, "862": { - "id": 862, "category": "Sliding Window", - "title": "Shortest Subarray with Sum at Least K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/" + "id": 862, + "link": "https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/", + "title": "Shortest Subarray with Sum at Least K" }, "863": { - "id": 863, "category": "Tree", - "title": "All Nodes Distance K in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/" + "id": 863, + "link": "https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/", + "title": "All Nodes Distance K in Binary Tree" }, "864": { - "id": 864, "category": "Graph Traversal", - "title": "Shortest Path to Get All Keys", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-path-to-get-all-keys/" + "id": 864, + "link": "https://leetcode.com/problems/shortest-path-to-get-all-keys/", + "title": "Shortest Path to Get All Keys" }, "865": { - "id": 865, "category": "Tree", - "title": "Smallest Subtree with all the Deepest Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/" + "id": 865, + "link": "https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/", + "title": "Smallest Subtree with all the Deepest Nodes" }, "866": { - "id": 866, "category": "Math & Geometry", - "title": "Prime Palindrome", "difficulty": "Medium", - "link": "https://leetcode.com/problems/prime-palindrome/" + "id": 866, + "link": "https://leetcode.com/problems/prime-palindrome/", + "title": "Prime Palindrome" }, "867": { - "id": 867, "category": "Array & Hashing", - "title": "Transpose Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/transpose-matrix/" + "id": 867, + "link": "https://leetcode.com/problems/transpose-matrix/", + "title": "Transpose Matrix" }, "868": { - "id": 868, "category": "Bit Manipulation", - "title": "Binary Gap", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-gap/" + "id": 868, + "link": "https://leetcode.com/problems/binary-gap/", + "title": "Binary Gap" }, "869": { - "id": 869, "category": "Math & Geometry", - "title": "Reordered Power of 2", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reordered-power-of-2/" + "id": 869, + "link": "https://leetcode.com/problems/reordered-power-of-2/", + "title": "Reordered Power of 2" }, "870": { - "id": 870, "category": "Greedy", - "title": "Advantage Shuffle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/advantage-shuffle/" + "id": 870, + "link": "https://leetcode.com/problems/advantage-shuffle/", + "title": "Advantage Shuffle" }, "871": { - "id": 871, "category": "Dynamic Programming", - "title": "Minimum Number of Refueling Stops", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-refueling-stops/" + "id": 871, + "link": "https://leetcode.com/problems/minimum-number-of-refueling-stops/", + "title": "Minimum Number of Refueling Stops" }, "872": { - "id": 872, "category": "Tree", - "title": "Leaf-Similar Trees", "difficulty": "Easy", - "link": "https://leetcode.com/problems/leaf-similar-trees/" + "id": 872, + "link": "https://leetcode.com/problems/leaf-similar-trees/", + "title": "Leaf-Similar Trees" }, "873": { - "id": 873, "category": "Dynamic Programming", - "title": "Length of Longest Fibonacci Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/" + "id": 873, + "link": "https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/", + "title": "Length of Longest Fibonacci Subsequence" }, "874": { - "id": 874, "category": "Array & Hashing", - "title": "Walking Robot Simulation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/walking-robot-simulation/" + "id": 874, + "link": "https://leetcode.com/problems/walking-robot-simulation/", + "title": "Walking Robot Simulation" }, "875": { - "id": 875, "category": "Binary Search", - "title": "Koko Eating Bananas", "difficulty": "Medium", - "link": "https://leetcode.com/problems/koko-eating-bananas/" + "id": 875, + "link": "https://leetcode.com/problems/koko-eating-bananas/", + "title": "Koko Eating Bananas" }, "876": { - "id": 876, "category": "Linked List", - "title": "Middle of the Linked List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/middle-of-the-linked-list/" + "id": 876, + "link": "https://leetcode.com/problems/middle-of-the-linked-list/", + "title": "Middle of the Linked List" }, "877": { - "id": 877, "category": "Dynamic Programming", - "title": "Stone Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stone-game/" + "id": 877, + "link": "https://leetcode.com/problems/stone-game/", + "title": "Stone Game" }, "878": { - "id": 878, "category": "Binary Search", - "title": "Nth Magical Number", "difficulty": "Hard", - "link": "https://leetcode.com/problems/nth-magical-number/" + "id": 878, + "link": "https://leetcode.com/problems/nth-magical-number/", + "title": "Nth Magical Number" }, "879": { - "id": 879, "category": "Dynamic Programming", - "title": "Profitable Schemes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/profitable-schemes/" + "id": 879, + "link": "https://leetcode.com/problems/profitable-schemes/", + "title": "Profitable Schemes" }, "880": { - "id": 880, "category": "Stack", - "title": "Decoded String at Index", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decoded-string-at-index/" + "id": 880, + "link": "https://leetcode.com/problems/decoded-string-at-index/", + "title": "Decoded String at Index" }, "881": { - "id": 881, "category": "Greedy", - "title": "Boats to Save People", "difficulty": "Medium", - "link": "https://leetcode.com/problems/boats-to-save-people/" + "id": 881, + "link": "https://leetcode.com/problems/boats-to-save-people/", + "title": "Boats to Save People" }, "882": { - "id": 882, "category": "Graph Traversal", - "title": "Reachable Nodes In Subdivided Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/" + "id": 882, + "link": "https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/", + "title": "Reachable Nodes In Subdivided Graph" }, "883": { - "id": 883, "category": "Math & Geometry", - "title": "Projection Area of 3D Shapes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/projection-area-of-3d-shapes/" + "id": 883, + "link": "https://leetcode.com/problems/projection-area-of-3d-shapes/", + "title": "Projection Area of 3D Shapes" }, "884": { - "id": 884, "category": "Array & Hashing", - "title": "Uncommon Words from Two Sentences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/uncommon-words-from-two-sentences/" + "id": 884, + "link": "https://leetcode.com/problems/uncommon-words-from-two-sentences/", + "title": "Uncommon Words from Two Sentences" }, "885": { - "id": 885, "category": "Array & Hashing", - "title": "Spiral Matrix III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/spiral-matrix-iii/" + "id": 885, + "link": "https://leetcode.com/problems/spiral-matrix-iii/", + "title": "Spiral Matrix III" }, "886": { - "id": 886, "category": "Graph Traversal", - "title": "Possible Bipartition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/possible-bipartition/" + "id": 886, + "link": "https://leetcode.com/problems/possible-bipartition/", + "title": "Possible Bipartition" }, "887": { - "id": 887, "category": "Dynamic Programming", - "title": "Super Egg Drop", "difficulty": "Hard", - "link": "https://leetcode.com/problems/super-egg-drop/" + "id": 887, + "link": "https://leetcode.com/problems/super-egg-drop/", + "title": "Super Egg Drop" }, "888": { - "id": 888, "category": "Binary Search", - "title": "Fair Candy Swap", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fair-candy-swap/" + "id": 888, + "link": "https://leetcode.com/problems/fair-candy-swap/", + "title": "Fair Candy Swap" }, "889": { - "id": 889, "category": "Tree", - "title": "Construct Binary Tree from Preorder and Postorder Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/" + "id": 889, + "link": "https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/", + "title": "Construct Binary Tree from Preorder and Postorder Traversal" }, "890": { - "id": 890, "category": "Array & Hashing", - "title": "Find and Replace Pattern", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-and-replace-pattern/" + "id": 890, + "link": "https://leetcode.com/problems/find-and-replace-pattern/", + "title": "Find and Replace Pattern" }, "891": { - "id": 891, "category": "Math & Geometry", - "title": "Sum of Subsequence Widths", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-subsequence-widths/" + "id": 891, + "link": "https://leetcode.com/problems/sum-of-subsequence-widths/", + "title": "Sum of Subsequence Widths" }, "892": { - "id": 892, "category": "Math & Geometry", - "title": "Surface Area of 3D Shapes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/surface-area-of-3d-shapes/" + "id": 892, + "link": "https://leetcode.com/problems/surface-area-of-3d-shapes/", + "title": "Surface Area of 3D Shapes" }, "893": { - "id": 893, "category": "Array & Hashing", - "title": "Groups of Special-Equivalent Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/groups-of-special-equivalent-strings/" + "id": 893, + "link": "https://leetcode.com/problems/groups-of-special-equivalent-strings/", + "title": "Groups of Special-Equivalent Strings" }, "894": { - "id": 894, "category": "Tree", - "title": "All Possible Full Binary Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-possible-full-binary-trees/" + "id": 894, + "link": "https://leetcode.com/problems/all-possible-full-binary-trees/", + "title": "All Possible Full Binary Trees" }, "895": { - "id": 895, "category": "Stack", - "title": "Maximum Frequency Stack", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-frequency-stack/" + "id": 895, + "link": "https://leetcode.com/problems/maximum-frequency-stack/", + "title": "Maximum Frequency Stack" }, "896": { - "id": 896, "category": "Array & Hashing", - "title": "Monotonic Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/monotonic-array/" + "id": 896, + "link": "https://leetcode.com/problems/monotonic-array/", + "title": "Monotonic Array" }, "897": { - "id": 897, "category": "Tree", - "title": "Increasing Order Search Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/increasing-order-search-tree/" + "id": 897, + "link": "https://leetcode.com/problems/increasing-order-search-tree/", + "title": "Increasing Order Search Tree" }, "898": { - "id": 898, "category": "Dynamic Programming", - "title": "Bitwise ORs of Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bitwise-ors-of-subarrays/" + "id": 898, + "link": "https://leetcode.com/problems/bitwise-ors-of-subarrays/", + "title": "Bitwise ORs of Subarrays" }, "899": { - "id": 899, "category": "Math & Geometry", - "title": "Orderly Queue", "difficulty": "Hard", - "link": "https://leetcode.com/problems/orderly-queue/" + "id": 899, + "link": "https://leetcode.com/problems/orderly-queue/", + "title": "Orderly Queue" }, "900": { - "id": 900, "category": "Array & Hashing", - "title": "RLE Iterator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rle-iterator/" + "id": 900, + "link": "https://leetcode.com/problems/rle-iterator/", + "title": "RLE Iterator" }, "901": { - "id": 901, "category": "Stack", - "title": "Online Stock Span", "difficulty": "Medium", - "link": "https://leetcode.com/problems/online-stock-span/" + "id": 901, + "link": "https://leetcode.com/problems/online-stock-span/", + "title": "Online Stock Span" }, "902": { - "id": 902, "category": "Dynamic Programming", - "title": "Numbers At Most N Given Digit Set", "difficulty": "Hard", - "link": "https://leetcode.com/problems/numbers-at-most-n-given-digit-set/" + "id": 902, + "link": "https://leetcode.com/problems/numbers-at-most-n-given-digit-set/", + "title": "Numbers At Most N Given Digit Set" }, "903": { - "id": 903, "category": "Dynamic Programming", - "title": "Valid Permutations for DI Sequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/valid-permutations-for-di-sequence/" + "id": 903, + "link": "https://leetcode.com/problems/valid-permutations-for-di-sequence/", + "title": "Valid Permutations for DI Sequence" }, "904": { - "id": 904, "category": "Sliding Window", - "title": "Fruit Into Baskets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fruit-into-baskets/" + "id": 904, + "link": "https://leetcode.com/problems/fruit-into-baskets/", + "title": "Fruit Into Baskets" }, "905": { - "id": 905, "category": "Two Pointers", - "title": "Sort Array By Parity", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-array-by-parity/" + "id": 905, + "link": "https://leetcode.com/problems/sort-array-by-parity/", + "title": "Sort Array By Parity" }, "906": { - "id": 906, "category": "Math & Geometry", - "title": "Super Palindromes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/super-palindromes/" + "id": 906, + "link": "https://leetcode.com/problems/super-palindromes/", + "title": "Super Palindromes" }, "907": { - "id": 907, "category": "Dynamic Programming", - "title": "Sum of Subarray Minimums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-subarray-minimums/" + "id": 907, + "link": "https://leetcode.com/problems/sum-of-subarray-minimums/", + "title": "Sum of Subarray Minimums" }, "908": { - "id": 908, "category": "Math & Geometry", - "title": "Smallest Range I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-range-i/" + "id": 908, + "link": "https://leetcode.com/problems/smallest-range-i/", + "title": "Smallest Range I" }, "909": { - "id": 909, "category": "Graph Traversal", - "title": "Snakes and Ladders", "difficulty": "Medium", - "link": "https://leetcode.com/problems/snakes-and-ladders/" + "id": 909, + "link": "https://leetcode.com/problems/snakes-and-ladders/", + "title": "Snakes and Ladders" }, "910": { - "id": 910, "category": "Greedy", - "title": "Smallest Range II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-range-ii/" + "id": 910, + "link": "https://leetcode.com/problems/smallest-range-ii/", + "title": "Smallest Range II" }, "911": { - "id": 911, "category": "Binary Search", - "title": "Online Election", "difficulty": "Medium", - "link": "https://leetcode.com/problems/online-election/" + "id": 911, + "link": "https://leetcode.com/problems/online-election/", + "title": "Online Election" }, "912": { - "id": 912, "category": "Heap (Priority Queue)", - "title": "Sort an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-an-array/" + "id": 912, + "link": "https://leetcode.com/problems/sort-an-array/", + "title": "Sort an Array" }, "913": { - "id": 913, "category": "Graph Traversal", - "title": "Cat and Mouse", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cat-and-mouse/" + "id": 913, + "link": "https://leetcode.com/problems/cat-and-mouse/", + "title": "Cat and Mouse" }, "914": { - "id": 914, "category": "Math & Geometry", - "title": "X of a Kind in a Deck of Cards", "difficulty": "Easy", - "link": "https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/" + "id": 914, + "link": "https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/", + "title": "X of a Kind in a Deck of Cards" }, "915": { - "id": 915, "category": "Array & Hashing", - "title": "Partition Array into Disjoint Intervals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-into-disjoint-intervals/" + "id": 915, + "link": "https://leetcode.com/problems/partition-array-into-disjoint-intervals/", + "title": "Partition Array into Disjoint Intervals" }, "916": { - "id": 916, "category": "Array & Hashing", - "title": "Word Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/word-subsets/" + "id": 916, + "link": "https://leetcode.com/problems/word-subsets/", + "title": "Word Subsets" }, "917": { - "id": 917, "category": "Two Pointers", - "title": "Reverse Only Letters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-only-letters/" + "id": 917, + "link": "https://leetcode.com/problems/reverse-only-letters/", + "title": "Reverse Only Letters" }, "918": { - "id": 918, "category": "Dynamic Programming", - "title": "Maximum Sum Circular Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-circular-subarray/" + "id": 918, + "link": "https://leetcode.com/problems/maximum-sum-circular-subarray/", + "title": "Maximum Sum Circular Subarray" }, "919": { - "id": 919, "category": "Tree", - "title": "Complete Binary Tree Inserter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/complete-binary-tree-inserter/" + "id": 919, + "link": "https://leetcode.com/problems/complete-binary-tree-inserter/", + "title": "Complete Binary Tree Inserter" }, "920": { - "id": 920, "category": "Dynamic Programming", - "title": "Number of Music Playlists", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-music-playlists/" + "id": 920, + "link": "https://leetcode.com/problems/number-of-music-playlists/", + "title": "Number of Music Playlists" }, "921": { - "id": 921, "category": "Stack", - "title": "Minimum Add to Make Parentheses Valid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/" + "id": 921, + "link": "https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/", + "title": "Minimum Add to Make Parentheses Valid" }, "922": { - "id": 922, "category": "Two Pointers", - "title": "Sort Array By Parity II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-array-by-parity-ii/" + "id": 922, + "link": "https://leetcode.com/problems/sort-array-by-parity-ii/", + "title": "Sort Array By Parity II" }, "923": { - "id": 923, "category": "Two Pointers", - "title": "3Sum With Multiplicity", "difficulty": "Medium", - "link": "https://leetcode.com/problems/3sum-with-multiplicity/" + "id": 923, + "link": "https://leetcode.com/problems/3sum-with-multiplicity/", + "title": "3Sum With Multiplicity" }, "924": { - "id": 924, "category": "Graph Traversal", - "title": "Minimize Malware Spread", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-malware-spread/" + "id": 924, + "link": "https://leetcode.com/problems/minimize-malware-spread/", + "title": "Minimize Malware Spread" }, "925": { - "id": 925, "category": "Two Pointers", - "title": "Long Pressed Name", "difficulty": "Easy", - "link": "https://leetcode.com/problems/long-pressed-name/" + "id": 925, + "link": "https://leetcode.com/problems/long-pressed-name/", + "title": "Long Pressed Name" }, "926": { - "id": 926, "category": "Dynamic Programming", - "title": "Flip String to Monotone Increasing", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flip-string-to-monotone-increasing/" + "id": 926, + "link": "https://leetcode.com/problems/flip-string-to-monotone-increasing/", + "title": "Flip String to Monotone Increasing" }, "927": { - "id": 927, "category": "Math & Geometry", - "title": "Three Equal Parts", "difficulty": "Hard", - "link": "https://leetcode.com/problems/three-equal-parts/" + "id": 927, + "link": "https://leetcode.com/problems/three-equal-parts/", + "title": "Three Equal Parts" }, "928": { - "id": 928, "category": "Graph Traversal", - "title": "Minimize Malware Spread II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-malware-spread-ii/" + "id": 928, + "link": "https://leetcode.com/problems/minimize-malware-spread-ii/", + "title": "Minimize Malware Spread II" }, "929": { - "id": 929, "category": "Array & Hashing", - "title": "Unique Email Addresses", "difficulty": "Easy", - "link": "https://leetcode.com/problems/unique-email-addresses/" + "id": 929, + "link": "https://leetcode.com/problems/unique-email-addresses/", + "title": "Unique Email Addresses" }, "930": { - "id": 930, "category": "Sliding Window", - "title": "Binary Subarrays With Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-subarrays-with-sum/" + "id": 930, + "link": "https://leetcode.com/problems/binary-subarrays-with-sum/", + "title": "Binary Subarrays With Sum" }, "931": { - "id": 931, "category": "Dynamic Programming", - "title": "Minimum Falling Path Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-falling-path-sum/" + "id": 931, + "link": "https://leetcode.com/problems/minimum-falling-path-sum/", + "title": "Minimum Falling Path Sum" }, "932": { - "id": 932, "category": "Math & Geometry", - "title": "Beautiful Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/beautiful-array/" + "id": 932, + "link": "https://leetcode.com/problems/beautiful-array/", + "title": "Beautiful Array" }, "933": { - "id": 933, "category": "Array & Hashing", - "title": "Number of Recent Calls", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-recent-calls/" + "id": 933, + "link": "https://leetcode.com/problems/number-of-recent-calls/", + "title": "Number of Recent Calls" }, "934": { - "id": 934, "category": "Graph Traversal", - "title": "Shortest Bridge", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-bridge/" + "id": 934, + "link": "https://leetcode.com/problems/shortest-bridge/", + "title": "Shortest Bridge" }, "935": { - "id": 935, "category": "Dynamic Programming", - "title": "Knight Dialer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/knight-dialer/" + "id": 935, + "link": "https://leetcode.com/problems/knight-dialer/", + "title": "Knight Dialer" }, "936": { - "id": 936, "category": "Stack", - "title": "Stamping The Sequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stamping-the-sequence/" + "id": 936, + "link": "https://leetcode.com/problems/stamping-the-sequence/", + "title": "Stamping The Sequence" }, "937": { - "id": 937, "category": "Array & Hashing", - "title": "Reorder Data in Log Files", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reorder-data-in-log-files/" + "id": 937, + "link": "https://leetcode.com/problems/reorder-data-in-log-files/", + "title": "Reorder Data in Log Files" }, "938": { - "id": 938, "category": "Tree", - "title": "Range Sum of BST", "difficulty": "Easy", - "link": "https://leetcode.com/problems/range-sum-of-bst/" + "id": 938, + "link": "https://leetcode.com/problems/range-sum-of-bst/", + "title": "Range Sum of BST" }, "939": { - "id": 939, "category": "Math & Geometry", - "title": "Minimum Area Rectangle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-area-rectangle/" + "id": 939, + "link": "https://leetcode.com/problems/minimum-area-rectangle/", + "title": "Minimum Area Rectangle" }, "940": { - "id": 940, "category": "Dynamic Programming", - "title": "Distinct Subsequences II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distinct-subsequences-ii/" + "id": 940, + "link": "https://leetcode.com/problems/distinct-subsequences-ii/", + "title": "Distinct Subsequences II" }, "941": { - "id": 941, "category": "Array & Hashing", - "title": "Valid Mountain Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-mountain-array/" + "id": 941, + "link": "https://leetcode.com/problems/valid-mountain-array/", + "title": "Valid Mountain Array" }, "942": { - "id": 942, "category": "Greedy", - "title": "DI String Match", "difficulty": "Easy", - "link": "https://leetcode.com/problems/di-string-match/" + "id": 942, + "link": "https://leetcode.com/problems/di-string-match/", + "title": "DI String Match" }, "943": { - "id": 943, "category": "Dynamic Programming", - "title": "Find the Shortest Superstring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-shortest-superstring/" + "id": 943, + "link": "https://leetcode.com/problems/find-the-shortest-superstring/", + "title": "Find the Shortest Superstring" }, "944": { - "id": 944, "category": "Array & Hashing", - "title": "Delete Columns to Make Sorted", "difficulty": "Easy", - "link": "https://leetcode.com/problems/delete-columns-to-make-sorted/" + "id": 944, + "link": "https://leetcode.com/problems/delete-columns-to-make-sorted/", + "title": "Delete Columns to Make Sorted" }, "945": { - "id": 945, "category": "Greedy", - "title": "Minimum Increment to Make Array Unique", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-increment-to-make-array-unique/" + "id": 945, + "link": "https://leetcode.com/problems/minimum-increment-to-make-array-unique/", + "title": "Minimum Increment to Make Array Unique" }, "946": { - "id": 946, "category": "Stack", - "title": "Validate Stack Sequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/validate-stack-sequences/" + "id": 946, + "link": "https://leetcode.com/problems/validate-stack-sequences/", + "title": "Validate Stack Sequences" }, "947": { - "id": 947, "category": "Graph Traversal", - "title": "Most Stones Removed with Same Row or Column", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/" - }, - "948": { - "id": 948, - "category": "Greedy", - "title": "Bag of Tokens", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bag-of-tokens/" + "id": 947, + "link": "https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/", + "title": "Most Stones Removed with Same Row or Column" }, + "948": {"category": "Greedy", "difficulty": "Medium", "id": 948, "link": "https://leetcode.com/problems/bag-of-tokens/", "title": "Bag of Tokens"}, "949": { - "id": 949, "category": "Backtracking", - "title": "Largest Time for Given Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-time-for-given-digits/" + "id": 949, + "link": "https://leetcode.com/problems/largest-time-for-given-digits/", + "title": "Largest Time for Given Digits" }, "950": { - "id": 950, "category": "Array & Hashing", - "title": "Reveal Cards In Increasing Order", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reveal-cards-in-increasing-order/" + "id": 950, + "link": "https://leetcode.com/problems/reveal-cards-in-increasing-order/", + "title": "Reveal Cards In Increasing Order" }, "951": { - "id": 951, "category": "Tree", - "title": "Flip Equivalent Binary Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flip-equivalent-binary-trees/" + "id": 951, + "link": "https://leetcode.com/problems/flip-equivalent-binary-trees/", + "title": "Flip Equivalent Binary Trees" }, "952": { - "id": 952, "category": "Graph Traversal", - "title": "Largest Component Size by Common Factor", "difficulty": "Hard", - "link": "https://leetcode.com/problems/largest-component-size-by-common-factor/" + "id": 952, + "link": "https://leetcode.com/problems/largest-component-size-by-common-factor/", + "title": "Largest Component Size by Common Factor" }, "953": { - "id": 953, "category": "Array & Hashing", - "title": "Verifying an Alien Dictionary", "difficulty": "Easy", - "link": "https://leetcode.com/problems/verifying-an-alien-dictionary/" + "id": 953, + "link": "https://leetcode.com/problems/verifying-an-alien-dictionary/", + "title": "Verifying an Alien Dictionary" }, "954": { - "id": 954, "category": "Greedy", - "title": "Array of Doubled Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/array-of-doubled-pairs/" + "id": 954, + "link": "https://leetcode.com/problems/array-of-doubled-pairs/", + "title": "Array of Doubled Pairs" }, "955": { - "id": 955, "category": "Greedy", - "title": "Delete Columns to Make Sorted II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-columns-to-make-sorted-ii/" + "id": 955, + "link": "https://leetcode.com/problems/delete-columns-to-make-sorted-ii/", + "title": "Delete Columns to Make Sorted II" }, "956": { - "id": 956, "category": "Dynamic Programming", - "title": "Tallest Billboard", "difficulty": "Hard", - "link": "https://leetcode.com/problems/tallest-billboard/" + "id": 956, + "link": "https://leetcode.com/problems/tallest-billboard/", + "title": "Tallest Billboard" }, "957": { - "id": 957, "category": "Bit Manipulation", - "title": "Prison Cells After N Days", "difficulty": "Medium", - "link": "https://leetcode.com/problems/prison-cells-after-n-days/" + "id": 957, + "link": "https://leetcode.com/problems/prison-cells-after-n-days/", + "title": "Prison Cells After N Days" }, "958": { - "id": 958, "category": "Tree", - "title": "Check Completeness of a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-completeness-of-a-binary-tree/" + "id": 958, + "link": "https://leetcode.com/problems/check-completeness-of-a-binary-tree/", + "title": "Check Completeness of a Binary Tree" }, "959": { - "id": 959, "category": "Graph Traversal", - "title": "Regions Cut By Slashes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/regions-cut-by-slashes/" + "id": 959, + "link": "https://leetcode.com/problems/regions-cut-by-slashes/", + "title": "Regions Cut By Slashes" }, "960": { - "id": 960, "category": "Dynamic Programming", - "title": "Delete Columns to Make Sorted III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/delete-columns-to-make-sorted-iii/" + "id": 960, + "link": "https://leetcode.com/problems/delete-columns-to-make-sorted-iii/", + "title": "Delete Columns to Make Sorted III" }, "961": { - "id": 961, "category": "Array & Hashing", - "title": "N-Repeated Element in Size 2N Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/n-repeated-element-in-size-2n-array/" + "id": 961, + "link": "https://leetcode.com/problems/n-repeated-element-in-size-2n-array/", + "title": "N-Repeated Element in Size 2N Array" }, "962": { - "id": 962, "category": "Stack", - "title": "Maximum Width Ramp", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-width-ramp/" + "id": 962, + "link": "https://leetcode.com/problems/maximum-width-ramp/", + "title": "Maximum Width Ramp" }, "963": { - "id": 963, "category": "Math & Geometry", - "title": "Minimum Area Rectangle II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-area-rectangle-ii/" + "id": 963, + "link": "https://leetcode.com/problems/minimum-area-rectangle-ii/", + "title": "Minimum Area Rectangle II" }, "964": { - "id": 964, "category": "Dynamic Programming", - "title": "Least Operators to Express Number", "difficulty": "Hard", - "link": "https://leetcode.com/problems/least-operators-to-express-number/" + "id": 964, + "link": "https://leetcode.com/problems/least-operators-to-express-number/", + "title": "Least Operators to Express Number" }, "965": { - "id": 965, "category": "Tree", - "title": "Univalued Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/univalued-binary-tree/" + "id": 965, + "link": "https://leetcode.com/problems/univalued-binary-tree/", + "title": "Univalued Binary Tree" }, "966": { - "id": 966, "category": "Array & Hashing", - "title": "Vowel Spellchecker", "difficulty": "Medium", - "link": "https://leetcode.com/problems/vowel-spellchecker/" + "id": 966, + "link": "https://leetcode.com/problems/vowel-spellchecker/", + "title": "Vowel Spellchecker" }, "967": { - "id": 967, "category": "Graph Traversal", - "title": "Numbers With Same Consecutive Differences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/numbers-with-same-consecutive-differences/" + "id": 967, + "link": "https://leetcode.com/problems/numbers-with-same-consecutive-differences/", + "title": "Numbers With Same Consecutive Differences" }, "968": { - "id": 968, "category": "Tree", - "title": "Binary Tree Cameras", "difficulty": "Hard", - "link": "https://leetcode.com/problems/binary-tree-cameras/" + "id": 968, + "link": "https://leetcode.com/problems/binary-tree-cameras/", + "title": "Binary Tree Cameras" }, "969": { - "id": 969, "category": "Greedy", - "title": "Pancake Sorting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pancake-sorting/" + "id": 969, + "link": "https://leetcode.com/problems/pancake-sorting/", + "title": "Pancake Sorting" }, "970": { - "id": 970, "category": "Math & Geometry", - "title": "Powerful Integers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/powerful-integers/" + "id": 970, + "link": "https://leetcode.com/problems/powerful-integers/", + "title": "Powerful Integers" }, "971": { - "id": 971, "category": "Tree", - "title": "Flip Binary Tree To Match Preorder Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/" + "id": 971, + "link": "https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/", + "title": "Flip Binary Tree To Match Preorder Traversal" }, "972": { - "id": 972, "category": "Math & Geometry", - "title": "Equal Rational Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/equal-rational-numbers/" + "id": 972, + "link": "https://leetcode.com/problems/equal-rational-numbers/", + "title": "Equal Rational Numbers" }, "973": { - "id": 973, "category": "Heap (Priority Queue)", - "title": "K Closest Points to Origin", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-closest-points-to-origin/" + "id": 973, + "link": "https://leetcode.com/problems/k-closest-points-to-origin/", + "title": "K Closest Points to Origin" }, "974": { - "id": 974, "category": "Array & Hashing", - "title": "Subarray Sums Divisible by K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subarray-sums-divisible-by-k/" + "id": 974, + "link": "https://leetcode.com/problems/subarray-sums-divisible-by-k/", + "title": "Subarray Sums Divisible by K" }, "975": { - "id": 975, "category": "Dynamic Programming", - "title": "Odd Even Jump", "difficulty": "Hard", - "link": "https://leetcode.com/problems/odd-even-jump/" + "id": 975, + "link": "https://leetcode.com/problems/odd-even-jump/", + "title": "Odd Even Jump" }, "976": { - "id": 976, "category": "Greedy", - "title": "Largest Perimeter Triangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-perimeter-triangle/" + "id": 976, + "link": "https://leetcode.com/problems/largest-perimeter-triangle/", + "title": "Largest Perimeter Triangle" }, "977": { - "id": 977, "category": "Two Pointers", - "title": "Squares of a Sorted Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/squares-of-a-sorted-array/" + "id": 977, + "link": "https://leetcode.com/problems/squares-of-a-sorted-array/", + "title": "Squares of a Sorted Array" }, "978": { - "id": 978, "category": "Dynamic Programming", - "title": "Longest Turbulent Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-turbulent-subarray/" + "id": 978, + "link": "https://leetcode.com/problems/longest-turbulent-subarray/", + "title": "Longest Turbulent Subarray" }, "979": { - "id": 979, "category": "Tree", - "title": "Distribute Coins in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distribute-coins-in-binary-tree/" + "id": 979, + "link": "https://leetcode.com/problems/distribute-coins-in-binary-tree/", + "title": "Distribute Coins in Binary Tree" }, "980": { - "id": 980, "category": "Backtracking", - "title": "Unique Paths III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/unique-paths-iii/" + "id": 980, + "link": "https://leetcode.com/problems/unique-paths-iii/", + "title": "Unique Paths III" }, "981": { - "id": 981, "category": "Binary Search", - "title": "Time Based Key-Value Store", "difficulty": "Medium", - "link": "https://leetcode.com/problems/time-based-key-value-store/" + "id": 981, + "link": "https://leetcode.com/problems/time-based-key-value-store/", + "title": "Time Based Key-Value Store" }, "982": { - "id": 982, "category": "Bit Manipulation", - "title": "Triples with Bitwise AND Equal To Zero", "difficulty": "Hard", - "link": "https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero/" + "id": 982, + "link": "https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero/", + "title": "Triples with Bitwise AND Equal To Zero" }, "983": { - "id": 983, "category": "Dynamic Programming", - "title": "Minimum Cost For Tickets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-for-tickets/" + "id": 983, + "link": "https://leetcode.com/problems/minimum-cost-for-tickets/", + "title": "Minimum Cost For Tickets" }, "984": { - "id": 984, "category": "Greedy", - "title": "String Without AAA or BBB", "difficulty": "Medium", - "link": "https://leetcode.com/problems/string-without-aaa-or-bbb/" + "id": 984, + "link": "https://leetcode.com/problems/string-without-aaa-or-bbb/", + "title": "String Without AAA or BBB" }, "985": { - "id": 985, "category": "Array & Hashing", - "title": "Sum of Even Numbers After Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-even-numbers-after-queries/" + "id": 985, + "link": "https://leetcode.com/problems/sum-of-even-numbers-after-queries/", + "title": "Sum of Even Numbers After Queries" }, "986": { - "id": 986, "category": "Two Pointers", - "title": "Interval List Intersections", "difficulty": "Medium", - "link": "https://leetcode.com/problems/interval-list-intersections/" + "id": 986, + "link": "https://leetcode.com/problems/interval-list-intersections/", + "title": "Interval List Intersections" }, "987": { - "id": 987, "category": "Tree", - "title": "Vertical Order Traversal of a Binary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/" + "id": 987, + "link": "https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/", + "title": "Vertical Order Traversal of a Binary Tree" }, "988": { - "id": 988, "category": "Tree", - "title": "Smallest String Starting From Leaf", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-string-starting-from-leaf/" + "id": 988, + "link": "https://leetcode.com/problems/smallest-string-starting-from-leaf/", + "title": "Smallest String Starting From Leaf" }, "989": { - "id": 989, "category": "Math & Geometry", - "title": "Add to Array-Form of Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-to-array-form-of-integer/" + "id": 989, + "link": "https://leetcode.com/problems/add-to-array-form-of-integer/", + "title": "Add to Array-Form of Integer" }, "990": { - "id": 990, "category": "Graph Traversal", - "title": "Satisfiability of Equality Equations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/satisfiability-of-equality-equations/" + "id": 990, + "link": "https://leetcode.com/problems/satisfiability-of-equality-equations/", + "title": "Satisfiability of Equality Equations" }, "991": { - "id": 991, "category": "Greedy", - "title": "Broken Calculator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/broken-calculator/" + "id": 991, + "link": "https://leetcode.com/problems/broken-calculator/", + "title": "Broken Calculator" }, "992": { - "id": 992, "category": "Sliding Window", - "title": "Subarrays with K Different Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subarrays-with-k-different-integers/" + "id": 992, + "link": "https://leetcode.com/problems/subarrays-with-k-different-integers/", + "title": "Subarrays with K Different Integers" }, "993": { - "id": 993, "category": "Tree", - "title": "Cousins in Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/cousins-in-binary-tree/" + "id": 993, + "link": "https://leetcode.com/problems/cousins-in-binary-tree/", + "title": "Cousins in Binary Tree" }, "994": { - "id": 994, "category": "Graph Traversal", - "title": "Rotting Oranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotting-oranges/" + "id": 994, + "link": "https://leetcode.com/problems/rotting-oranges/", + "title": "Rotting Oranges" }, "995": { - "id": 995, "category": "Sliding Window", - "title": "Minimum Number of K Consecutive Bit Flips", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/" + "id": 995, + "link": "https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/", + "title": "Minimum Number of K Consecutive Bit Flips" }, "996": { - "id": 996, "category": "Dynamic Programming", - "title": "Number of Squareful Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-squareful-arrays/" + "id": 996, + "link": "https://leetcode.com/problems/number-of-squareful-arrays/", + "title": "Number of Squareful Arrays" }, "997": { - "id": 997, "category": "Graph Traversal", - "title": "Find the Town Judge", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-town-judge/" + "id": 997, + "link": "https://leetcode.com/problems/find-the-town-judge/", + "title": "Find the Town Judge" }, "998": { - "id": 998, "category": "Tree", - "title": "Maximum Binary Tree II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-binary-tree-ii/" + "id": 998, + "link": "https://leetcode.com/problems/maximum-binary-tree-ii/", + "title": "Maximum Binary Tree II" }, "999": { - "id": 999, "category": "Array & Hashing", - "title": "Available Captures for Rook", "difficulty": "Easy", - "link": "https://leetcode.com/problems/available-captures-for-rook/" + "id": 999, + "link": "https://leetcode.com/problems/available-captures-for-rook/", + "title": "Available Captures for Rook" }, "1000": { - "id": 1000, "category": "Dynamic Programming", - "title": "Minimum Cost to Merge Stones", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-merge-stones/" + "id": 1000, + "link": "https://leetcode.com/problems/minimum-cost-to-merge-stones/", + "title": "Minimum Cost to Merge Stones" }, "1001": { - "id": 1001, "category": "Array & Hashing", - "title": "Grid Illumination", "difficulty": "Hard", - "link": "https://leetcode.com/problems/grid-illumination/" + "id": 1001, + "link": "https://leetcode.com/problems/grid-illumination/", + "title": "Grid Illumination" }, "1002": { - "id": 1002, "category": "Array & Hashing", - "title": "Find Common Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-common-characters/" + "id": 1002, + "link": "https://leetcode.com/problems/find-common-characters/", + "title": "Find Common Characters" }, "1003": { - "id": 1003, "category": "Stack", - "title": "Check If Word Is Valid After Substitutions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/" + "id": 1003, + "link": "https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/", + "title": "Check If Word Is Valid After Substitutions" }, "1004": { - "id": 1004, "category": "Sliding Window", - "title": "Max Consecutive Ones III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-consecutive-ones-iii/" + "id": 1004, + "link": "https://leetcode.com/problems/max-consecutive-ones-iii/", + "title": "Max Consecutive Ones III" }, "1005": { - "id": 1005, "category": "Greedy", - "title": "Maximize Sum Of Array After K Negations", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/" + "id": 1005, + "link": "https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/", + "title": "Maximize Sum Of Array After K Negations" }, "1006": { - "id": 1006, "category": "Stack", - "title": "Clumsy Factorial", "difficulty": "Medium", - "link": "https://leetcode.com/problems/clumsy-factorial/" + "id": 1006, + "link": "https://leetcode.com/problems/clumsy-factorial/", + "title": "Clumsy Factorial" }, "1007": { - "id": 1007, "category": "Greedy", - "title": "Minimum Domino Rotations For Equal Row", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/" + "id": 1007, + "link": "https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/", + "title": "Minimum Domino Rotations For Equal Row" }, "1008": { - "id": 1008, "category": "Tree", - "title": "Construct Binary Search Tree from Preorder Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/" + "id": 1008, + "link": "https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/", + "title": "Construct Binary Search Tree from Preorder Traversal" }, "1009": { - "id": 1009, "category": "Bit Manipulation", - "title": "Complement of Base 10 Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/complement-of-base-10-integer/" + "id": 1009, + "link": "https://leetcode.com/problems/complement-of-base-10-integer/", + "title": "Complement of Base 10 Integer" }, "1010": { - "id": 1010, "category": "Array & Hashing", - "title": "Pairs of Songs With Total Durations Divisible by 60", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/" + "id": 1010, + "link": "https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/", + "title": "Pairs of Songs With Total Durations Divisible by 60" }, "1011": { - "id": 1011, "category": "Binary Search", - "title": "Capacity To Ship Packages Within D Days", "difficulty": "Medium", - "link": "https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/" + "id": 1011, + "link": "https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/", + "title": "Capacity To Ship Packages Within D Days" }, "1012": { - "id": 1012, "category": "Dynamic Programming", - "title": "Numbers With Repeated Digits", "difficulty": "Hard", - "link": "https://leetcode.com/problems/numbers-with-repeated-digits/" + "id": 1012, + "link": "https://leetcode.com/problems/numbers-with-repeated-digits/", + "title": "Numbers With Repeated Digits" }, "1013": { - "id": 1013, "category": "Greedy", - "title": "Partition Array Into Three Parts With Equal Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/" + "id": 1013, + "link": "https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/", + "title": "Partition Array Into Three Parts With Equal Sum" }, "1014": { - "id": 1014, "category": "Dynamic Programming", - "title": "Best Sightseeing Pair", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-sightseeing-pair/" + "id": 1014, + "link": "https://leetcode.com/problems/best-sightseeing-pair/", + "title": "Best Sightseeing Pair" }, "1015": { - "id": 1015, "category": "Math & Geometry", - "title": "Smallest Integer Divisible by K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-integer-divisible-by-k/" + "id": 1015, + "link": "https://leetcode.com/problems/smallest-integer-divisible-by-k/", + "title": "Smallest Integer Divisible by K" }, "1016": { - "id": 1016, "category": "Sliding Window", - "title": "Binary String With Substrings Representing 1 To N", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/" + "id": 1016, + "link": "https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/", + "title": "Binary String With Substrings Representing 1 To N" }, "1017": { - "id": 1017, "category": "Math & Geometry", - "title": "Convert to Base -2", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-to-base-2/" + "id": 1017, + "link": "https://leetcode.com/problems/convert-to-base-2/", + "title": "Convert to Base -2" }, "1018": { - "id": 1018, "category": "Bit Manipulation", - "title": "Binary Prefix Divisible By 5", "difficulty": "Easy", - "link": "https://leetcode.com/problems/binary-prefix-divisible-by-5/" + "id": 1018, + "link": "https://leetcode.com/problems/binary-prefix-divisible-by-5/", + "title": "Binary Prefix Divisible By 5" }, "1019": { - "id": 1019, "category": "Stack", - "title": "Next Greater Node In Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-greater-node-in-linked-list/" + "id": 1019, + "link": "https://leetcode.com/problems/next-greater-node-in-linked-list/", + "title": "Next Greater Node In Linked List" }, "1020": { - "id": 1020, "category": "Graph Traversal", - "title": "Number of Enclaves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-enclaves/" + "id": 1020, + "link": "https://leetcode.com/problems/number-of-enclaves/", + "title": "Number of Enclaves" }, "1021": { - "id": 1021, "category": "Stack", - "title": "Remove Outermost Parentheses", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-outermost-parentheses/" + "id": 1021, + "link": "https://leetcode.com/problems/remove-outermost-parentheses/", + "title": "Remove Outermost Parentheses" }, "1022": { - "id": 1022, "category": "Tree", - "title": "Sum of Root To Leaf Binary Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/" + "id": 1022, + "link": "https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/", + "title": "Sum of Root To Leaf Binary Numbers" }, "1023": { - "id": 1023, "category": "Trie", - "title": "Camelcase Matching", "difficulty": "Medium", - "link": "https://leetcode.com/problems/camelcase-matching/" + "id": 1023, + "link": "https://leetcode.com/problems/camelcase-matching/", + "title": "Camelcase Matching" }, "1024": { - "id": 1024, "category": "Dynamic Programming", - "title": "Video Stitching", "difficulty": "Medium", - "link": "https://leetcode.com/problems/video-stitching/" + "id": 1024, + "link": "https://leetcode.com/problems/video-stitching/", + "title": "Video Stitching" }, "1025": { - "id": 1025, "category": "Dynamic Programming", - "title": "Divisor Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/divisor-game/" + "id": 1025, + "link": "https://leetcode.com/problems/divisor-game/", + "title": "Divisor Game" }, "1026": { - "id": 1026, "category": "Tree", - "title": "Maximum Difference Between Node and Ancestor", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/" + "id": 1026, + "link": "https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/", + "title": "Maximum Difference Between Node and Ancestor" }, "1027": { - "id": 1027, "category": "Dynamic Programming", - "title": "Longest Arithmetic Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-arithmetic-subsequence/" + "id": 1027, + "link": "https://leetcode.com/problems/longest-arithmetic-subsequence/", + "title": "Longest Arithmetic Subsequence" }, "1028": { - "id": 1028, "category": "Tree", - "title": "Recover a Tree From Preorder Traversal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/" + "id": 1028, + "link": "https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/", + "title": "Recover a Tree From Preorder Traversal" }, "1029": { - "id": 1029, "category": "Greedy", - "title": "Two City Scheduling", "difficulty": "Medium", - "link": "https://leetcode.com/problems/two-city-scheduling/" + "id": 1029, + "link": "https://leetcode.com/problems/two-city-scheduling/", + "title": "Two City Scheduling" }, "1030": { - "id": 1030, "category": "Math & Geometry", - "title": "Matrix Cells in Distance Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/matrix-cells-in-distance-order/" + "id": 1030, + "link": "https://leetcode.com/problems/matrix-cells-in-distance-order/", + "title": "Matrix Cells in Distance Order" }, "1031": { - "id": 1031, "category": "Dynamic Programming", - "title": "Maximum Sum of Two Non-Overlapping Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/" + "id": 1031, + "link": "https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/", + "title": "Maximum Sum of Two Non-Overlapping Subarrays" }, "1032": { - "id": 1032, "category": "Trie", - "title": "Stream of Characters", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stream-of-characters/" + "id": 1032, + "link": "https://leetcode.com/problems/stream-of-characters/", + "title": "Stream of Characters" }, "1033": { - "id": 1033, "category": "Math & Geometry", - "title": "Moving Stones Until Consecutive", "difficulty": "Medium", - "link": "https://leetcode.com/problems/moving-stones-until-consecutive/" + "id": 1033, + "link": "https://leetcode.com/problems/moving-stones-until-consecutive/", + "title": "Moving Stones Until Consecutive" }, "1034": { - "id": 1034, "category": "Graph Traversal", - "title": "Coloring A Border", "difficulty": "Medium", - "link": "https://leetcode.com/problems/coloring-a-border/" + "id": 1034, + "link": "https://leetcode.com/problems/coloring-a-border/", + "title": "Coloring A Border" }, "1035": { - "id": 1035, "category": "Dynamic Programming", - "title": "Uncrossed Lines", "difficulty": "Medium", - "link": "https://leetcode.com/problems/uncrossed-lines/" + "id": 1035, + "link": "https://leetcode.com/problems/uncrossed-lines/", + "title": "Uncrossed Lines" }, "1036": { - "id": 1036, "category": "Graph Traversal", - "title": "Escape a Large Maze", "difficulty": "Hard", - "link": "https://leetcode.com/problems/escape-a-large-maze/" + "id": 1036, + "link": "https://leetcode.com/problems/escape-a-large-maze/", + "title": "Escape a Large Maze" }, "1037": { - "id": 1037, "category": "Math & Geometry", - "title": "Valid Boomerang", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-boomerang/" + "id": 1037, + "link": "https://leetcode.com/problems/valid-boomerang/", + "title": "Valid Boomerang" }, "1038": { - "id": 1038, "category": "Tree", - "title": "Binary Search Tree to Greater Sum Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/" + "id": 1038, + "link": "https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/", + "title": "Binary Search Tree to Greater Sum Tree" }, "1039": { - "id": 1039, "category": "Dynamic Programming", - "title": "Minimum Score Triangulation of Polygon", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-score-triangulation-of-polygon/" + "id": 1039, + "link": "https://leetcode.com/problems/minimum-score-triangulation-of-polygon/", + "title": "Minimum Score Triangulation of Polygon" }, "1040": { - "id": 1040, "category": "Sliding Window", - "title": "Moving Stones Until Consecutive II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/moving-stones-until-consecutive-ii/" + "id": 1040, + "link": "https://leetcode.com/problems/moving-stones-until-consecutive-ii/", + "title": "Moving Stones Until Consecutive II" }, "1041": { - "id": 1041, "category": "Math & Geometry", - "title": "Robot Bounded In Circle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/robot-bounded-in-circle/" + "id": 1041, + "link": "https://leetcode.com/problems/robot-bounded-in-circle/", + "title": "Robot Bounded In Circle" }, "1042": { - "id": 1042, "category": "Graph Traversal", - "title": "Flower Planting With No Adjacent", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flower-planting-with-no-adjacent/" + "id": 1042, + "link": "https://leetcode.com/problems/flower-planting-with-no-adjacent/", + "title": "Flower Planting With No Adjacent" }, "1043": { - "id": 1043, "category": "Dynamic Programming", - "title": "Partition Array for Maximum Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-for-maximum-sum/" + "id": 1043, + "link": "https://leetcode.com/problems/partition-array-for-maximum-sum/", + "title": "Partition Array for Maximum Sum" }, "1044": { - "id": 1044, "category": "Sliding Window", - "title": "Longest Duplicate Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-duplicate-substring/" + "id": 1044, + "link": "https://leetcode.com/problems/longest-duplicate-substring/", + "title": "Longest Duplicate Substring" }, "1045": { - "id": 1045, "category": "Database", - "title": "Customers Who Bought All Products", "difficulty": "Medium", - "link": "https://leetcode.com/problems/customers-who-bought-all-products/" + "id": 1045, + "link": "https://leetcode.com/problems/customers-who-bought-all-products/", + "title": "Customers Who Bought All Products" }, "1046": { - "id": 1046, "category": "Heap (Priority Queue)", - "title": "Last Stone Weight", "difficulty": "Easy", - "link": "https://leetcode.com/problems/last-stone-weight/" + "id": 1046, + "link": "https://leetcode.com/problems/last-stone-weight/", + "title": "Last Stone Weight" }, "1047": { - "id": 1047, "category": "Stack", - "title": "Remove All Adjacent Duplicates In String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/" + "id": 1047, + "link": "https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/", + "title": "Remove All Adjacent Duplicates In String" }, "1048": { - "id": 1048, "category": "Dynamic Programming", - "title": "Longest String Chain", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-string-chain/" + "id": 1048, + "link": "https://leetcode.com/problems/longest-string-chain/", + "title": "Longest String Chain" }, "1049": { - "id": 1049, "category": "Dynamic Programming", - "title": "Last Stone Weight II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/last-stone-weight-ii/" + "id": 1049, + "link": "https://leetcode.com/problems/last-stone-weight-ii/", + "title": "Last Stone Weight II" }, "1050": { - "id": 1050, "category": "Database", - "title": "Actors and Directors Who Cooperated At Least Three Times", "difficulty": "Easy", - "link": "https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/" + "id": 1050, + "link": "https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/", + "title": "Actors and Directors Who Cooperated At Least Three Times" }, "1051": { - "id": 1051, "category": "Array & Hashing", - "title": "Height Checker", "difficulty": "Easy", - "link": "https://leetcode.com/problems/height-checker/" + "id": 1051, + "link": "https://leetcode.com/problems/height-checker/", + "title": "Height Checker" }, "1052": { - "id": 1052, "category": "Sliding Window", - "title": "Grumpy Bookstore Owner", "difficulty": "Medium", - "link": "https://leetcode.com/problems/grumpy-bookstore-owner/" + "id": 1052, + "link": "https://leetcode.com/problems/grumpy-bookstore-owner/", + "title": "Grumpy Bookstore Owner" }, "1053": { - "id": 1053, "category": "Greedy", - "title": "Previous Permutation With One Swap", "difficulty": "Medium", - "link": "https://leetcode.com/problems/previous-permutation-with-one-swap/" + "id": 1053, + "link": "https://leetcode.com/problems/previous-permutation-with-one-swap/", + "title": "Previous Permutation With One Swap" }, "1054": { - "id": 1054, "category": "Heap (Priority Queue)", - "title": "Distant Barcodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distant-barcodes/" + "id": 1054, + "link": "https://leetcode.com/problems/distant-barcodes/", + "title": "Distant Barcodes" }, "1055": { - "id": 1055, "category": "Binary Search", - "title": "Shortest Way to Form String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-way-to-form-string/" + "id": 1055, + "link": "https://leetcode.com/problems/shortest-way-to-form-string/", + "title": "Shortest Way to Form String" }, "1056": { - "id": 1056, "category": "Math & Geometry", - "title": "Confusing Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/confusing-number/" + "id": 1056, + "link": "https://leetcode.com/problems/confusing-number/", + "title": "Confusing Number" }, "1057": { - "id": 1057, "category": "Heap (Priority Queue)", - "title": "Campus Bikes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/campus-bikes/" + "id": 1057, + "link": "https://leetcode.com/problems/campus-bikes/", + "title": "Campus Bikes" }, "1058": { - "id": 1058, "category": "Greedy", - "title": "Minimize Rounding Error to Meet Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-rounding-error-to-meet-target/" + "id": 1058, + "link": "https://leetcode.com/problems/minimize-rounding-error-to-meet-target/", + "title": "Minimize Rounding Error to Meet Target" }, "1059": { - "id": 1059, "category": "Graph Traversal", - "title": "All Paths from Source Lead to Destination", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-paths-from-source-lead-to-destination/" + "id": 1059, + "link": "https://leetcode.com/problems/all-paths-from-source-lead-to-destination/", + "title": "All Paths from Source Lead to Destination" }, "1060": { - "id": 1060, "category": "Binary Search", - "title": "Missing Element in Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/missing-element-in-sorted-array/" + "id": 1060, + "link": "https://leetcode.com/problems/missing-element-in-sorted-array/", + "title": "Missing Element in Sorted Array" }, "1061": { - "id": 1061, "category": "Graph Traversal", - "title": "Lexicographically Smallest Equivalent String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-equivalent-string/" + "id": 1061, + "link": "https://leetcode.com/problems/lexicographically-smallest-equivalent-string/", + "title": "Lexicographically Smallest Equivalent String" }, "1062": { - "id": 1062, "category": "Dynamic Programming", - "title": "Longest Repeating Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-repeating-substring/" + "id": 1062, + "link": "https://leetcode.com/problems/longest-repeating-substring/", + "title": "Longest Repeating Substring" }, "1063": { - "id": 1063, "category": "Stack", - "title": "Number of Valid Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-valid-subarrays/" + "id": 1063, + "link": "https://leetcode.com/problems/number-of-valid-subarrays/", + "title": "Number of Valid Subarrays" }, "1064": { - "id": 1064, "category": "Binary Search", - "title": "Fixed Point", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fixed-point/" + "id": 1064, + "link": "https://leetcode.com/problems/fixed-point/", + "title": "Fixed Point" }, "1065": { - "id": 1065, "category": "Trie", - "title": "Index Pairs of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/index-pairs-of-a-string/" + "id": 1065, + "link": "https://leetcode.com/problems/index-pairs-of-a-string/", + "title": "Index Pairs of a String" }, "1066": { - "id": 1066, "category": "Dynamic Programming", - "title": "Campus Bikes II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/campus-bikes-ii/" + "id": 1066, + "link": "https://leetcode.com/problems/campus-bikes-ii/", + "title": "Campus Bikes II" }, "1067": { - "id": 1067, "category": "Dynamic Programming", - "title": "Digit Count in Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/digit-count-in-range/" + "id": 1067, + "link": "https://leetcode.com/problems/digit-count-in-range/", + "title": "Digit Count in Range" }, "1068": { - "id": 1068, "category": "Database", - "title": "Product Sales Analysis I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/product-sales-analysis-i/" + "id": 1068, + "link": "https://leetcode.com/problems/product-sales-analysis-i/", + "title": "Product Sales Analysis I" }, "1069": { - "id": 1069, "category": "Database", - "title": "Product Sales Analysis II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/product-sales-analysis-ii/" + "id": 1069, + "link": "https://leetcode.com/problems/product-sales-analysis-ii/", + "title": "Product Sales Analysis II" }, "1070": { - "id": 1070, "category": "Database", - "title": "Product Sales Analysis III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-sales-analysis-iii/" + "id": 1070, + "link": "https://leetcode.com/problems/product-sales-analysis-iii/", + "title": "Product Sales Analysis III" }, "1071": { - "id": 1071, "category": "Math & Geometry", - "title": "Greatest Common Divisor of Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/greatest-common-divisor-of-strings/" + "id": 1071, + "link": "https://leetcode.com/problems/greatest-common-divisor-of-strings/", + "title": "Greatest Common Divisor of Strings" }, "1072": { - "id": 1072, "category": "Array & Hashing", - "title": "Flip Columns For Maximum Number of Equal Rows", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/" + "id": 1072, + "link": "https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/", + "title": "Flip Columns For Maximum Number of Equal Rows" }, "1073": { - "id": 1073, "category": "Math & Geometry", - "title": "Adding Two Negabinary Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/adding-two-negabinary-numbers/" + "id": 1073, + "link": "https://leetcode.com/problems/adding-two-negabinary-numbers/", + "title": "Adding Two Negabinary Numbers" }, "1074": { - "id": 1074, "category": "Array & Hashing", - "title": "Number of Submatrices That Sum to Target", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/" + "id": 1074, + "link": "https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/", + "title": "Number of Submatrices That Sum to Target" }, "1075": { - "id": 1075, "category": "Database", - "title": "Project Employees I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/project-employees-i/" + "id": 1075, + "link": "https://leetcode.com/problems/project-employees-i/", + "title": "Project Employees I" }, "1076": { - "id": 1076, "category": "Database", - "title": "Project Employees II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/project-employees-ii/" + "id": 1076, + "link": "https://leetcode.com/problems/project-employees-ii/", + "title": "Project Employees II" }, "1077": { - "id": 1077, "category": "Database", - "title": "Project Employees III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/project-employees-iii/" + "id": 1077, + "link": "https://leetcode.com/problems/project-employees-iii/", + "title": "Project Employees III" }, "1078": { - "id": 1078, "category": "Array & Hashing", - "title": "Occurrences After Bigram", "difficulty": "Easy", - "link": "https://leetcode.com/problems/occurrences-after-bigram/" + "id": 1078, + "link": "https://leetcode.com/problems/occurrences-after-bigram/", + "title": "Occurrences After Bigram" }, "1079": { - "id": 1079, "category": "Backtracking", - "title": "Letter Tile Possibilities", "difficulty": "Medium", - "link": "https://leetcode.com/problems/letter-tile-possibilities/" + "id": 1079, + "link": "https://leetcode.com/problems/letter-tile-possibilities/", + "title": "Letter Tile Possibilities" }, "1080": { - "id": 1080, "category": "Tree", - "title": "Insufficient Nodes in Root to Leaf Paths", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/" + "id": 1080, + "link": "https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/", + "title": "Insufficient Nodes in Root to Leaf Paths" }, "1081": { - "id": 1081, "category": "Stack", - "title": "Smallest Subsequence of Distinct Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/" + "id": 1081, + "link": "https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/", + "title": "Smallest Subsequence of Distinct Characters" }, "1082": { - "id": 1082, "category": "Database", - "title": "Sales Analysis I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sales-analysis-i/" + "id": 1082, + "link": "https://leetcode.com/problems/sales-analysis-i/", + "title": "Sales Analysis I" }, "1083": { - "id": 1083, "category": "Database", - "title": "Sales Analysis II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sales-analysis-ii/" + "id": 1083, + "link": "https://leetcode.com/problems/sales-analysis-ii/", + "title": "Sales Analysis II" }, "1084": { - "id": 1084, "category": "Database", - "title": "Sales Analysis III", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sales-analysis-iii/" + "id": 1084, + "link": "https://leetcode.com/problems/sales-analysis-iii/", + "title": "Sales Analysis III" }, "1085": { - "id": 1085, "category": "Math & Geometry", - "title": "Sum of Digits in the Minimum Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-digits-in-the-minimum-number/" + "id": 1085, + "link": "https://leetcode.com/problems/sum-of-digits-in-the-minimum-number/", + "title": "Sum of Digits in the Minimum Number" }, "1086": { - "id": 1086, "category": "Heap (Priority Queue)", - "title": "High Five", "difficulty": "Easy", - "link": "https://leetcode.com/problems/high-five/" + "id": 1086, + "link": "https://leetcode.com/problems/high-five/", + "title": "High Five" }, "1087": { - "id": 1087, "category": "Graph Traversal", - "title": "Brace Expansion", "difficulty": "Medium", - "link": "https://leetcode.com/problems/brace-expansion/" + "id": 1087, + "link": "https://leetcode.com/problems/brace-expansion/", + "title": "Brace Expansion" }, "1088": { - "id": 1088, "category": "Backtracking", - "title": "Confusing Number II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/confusing-number-ii/" + "id": 1088, + "link": "https://leetcode.com/problems/confusing-number-ii/", + "title": "Confusing Number II" }, "1089": { - "id": 1089, "category": "Two Pointers", - "title": "Duplicate Zeros", "difficulty": "Easy", - "link": "https://leetcode.com/problems/duplicate-zeros/" + "id": 1089, + "link": "https://leetcode.com/problems/duplicate-zeros/", + "title": "Duplicate Zeros" }, "1090": { - "id": 1090, "category": "Greedy", - "title": "Largest Values From Labels", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-values-from-labels/" + "id": 1090, + "link": "https://leetcode.com/problems/largest-values-from-labels/", + "title": "Largest Values From Labels" }, "1091": { - "id": 1091, "category": "Graph Traversal", - "title": "Shortest Path in Binary Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-path-in-binary-matrix/" + "id": 1091, + "link": "https://leetcode.com/problems/shortest-path-in-binary-matrix/", + "title": "Shortest Path in Binary Matrix" }, "1092": { - "id": 1092, "category": "Dynamic Programming", - "title": "Shortest Common Supersequence ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-common-supersequence/" + "id": 1092, + "link": "https://leetcode.com/problems/shortest-common-supersequence/", + "title": "Shortest Common Supersequence " }, "1093": { - "id": 1093, "category": "Math & Geometry", - "title": "Statistics from a Large Sample", "difficulty": "Medium", - "link": "https://leetcode.com/problems/statistics-from-a-large-sample/" + "id": 1093, + "link": "https://leetcode.com/problems/statistics-from-a-large-sample/", + "title": "Statistics from a Large Sample" }, "1094": { - "id": 1094, "category": "Heap (Priority Queue)", - "title": "Car Pooling", "difficulty": "Medium", - "link": "https://leetcode.com/problems/car-pooling/" + "id": 1094, + "link": "https://leetcode.com/problems/car-pooling/", + "title": "Car Pooling" }, "1095": { - "id": 1095, "category": "Binary Search", - "title": "Find in Mountain Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-in-mountain-array/" + "id": 1095, + "link": "https://leetcode.com/problems/find-in-mountain-array/", + "title": "Find in Mountain Array" }, "1096": { - "id": 1096, "category": "Graph Traversal", - "title": "Brace Expansion II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/brace-expansion-ii/" + "id": 1096, + "link": "https://leetcode.com/problems/brace-expansion-ii/", + "title": "Brace Expansion II" }, "1097": { - "id": 1097, "category": "Database", - "title": "Game Play Analysis V", "difficulty": "Hard", - "link": "https://leetcode.com/problems/game-play-analysis-v/" + "id": 1097, + "link": "https://leetcode.com/problems/game-play-analysis-v/", + "title": "Game Play Analysis V" }, "1098": { - "id": 1098, "category": "Database", - "title": "Unpopular Books", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unpopular-books/" + "id": 1098, + "link": "https://leetcode.com/problems/unpopular-books/", + "title": "Unpopular Books" }, "1099": { - "id": 1099, "category": "Binary Search", - "title": "Two Sum Less Than K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-sum-less-than-k/" + "id": 1099, + "link": "https://leetcode.com/problems/two-sum-less-than-k/", + "title": "Two Sum Less Than K" }, "1100": { - "id": 1100, "category": "Sliding Window", - "title": "Find K-Length Substrings With No Repeated Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters/" + "id": 1100, + "link": "https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters/", + "title": "Find K-Length Substrings With No Repeated Characters" }, "1101": { - "id": 1101, "category": "Graph Traversal", - "title": "The Earliest Moment When Everyone Become Friends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends/" + "id": 1101, + "link": "https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends/", + "title": "The Earliest Moment When Everyone Become Friends" }, "1102": { - "id": 1102, "category": "Graph Traversal", - "title": "Path With Maximum Minimum Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-with-maximum-minimum-value/" + "id": 1102, + "link": "https://leetcode.com/problems/path-with-maximum-minimum-value/", + "title": "Path With Maximum Minimum Value" }, "1103": { - "id": 1103, "category": "Math & Geometry", - "title": "Distribute Candies to People", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distribute-candies-to-people/" + "id": 1103, + "link": "https://leetcode.com/problems/distribute-candies-to-people/", + "title": "Distribute Candies to People" }, "1104": { - "id": 1104, "category": "Tree", - "title": "Path In Zigzag Labelled Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/" + "id": 1104, + "link": "https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/", + "title": "Path In Zigzag Labelled Binary Tree" }, "1105": { - "id": 1105, "category": "Dynamic Programming", - "title": "Filling Bookcase Shelves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/filling-bookcase-shelves/" + "id": 1105, + "link": "https://leetcode.com/problems/filling-bookcase-shelves/", + "title": "Filling Bookcase Shelves" }, "1106": { - "id": 1106, "category": "Stack", - "title": "Parsing A Boolean Expression", "difficulty": "Hard", - "link": "https://leetcode.com/problems/parsing-a-boolean-expression/" + "id": 1106, + "link": "https://leetcode.com/problems/parsing-a-boolean-expression/", + "title": "Parsing A Boolean Expression" }, "1107": { - "id": 1107, "category": "Database", - "title": "New Users Daily Count", "difficulty": "Medium", - "link": "https://leetcode.com/problems/new-users-daily-count/" + "id": 1107, + "link": "https://leetcode.com/problems/new-users-daily-count/", + "title": "New Users Daily Count" }, "1108": { - "id": 1108, "category": "Array & Hashing", - "title": "Defanging an IP Address", "difficulty": "Easy", - "link": "https://leetcode.com/problems/defanging-an-ip-address/" + "id": 1108, + "link": "https://leetcode.com/problems/defanging-an-ip-address/", + "title": "Defanging an IP Address" }, "1109": { - "id": 1109, "category": "Array & Hashing", - "title": "Corporate Flight Bookings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/corporate-flight-bookings/" + "id": 1109, + "link": "https://leetcode.com/problems/corporate-flight-bookings/", + "title": "Corporate Flight Bookings" }, "1110": { - "id": 1110, "category": "Tree", - "title": "Delete Nodes And Return Forest", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-nodes-and-return-forest/" + "id": 1110, + "link": "https://leetcode.com/problems/delete-nodes-and-return-forest/", + "title": "Delete Nodes And Return Forest" }, "1111": { - "id": 1111, "category": "Stack", - "title": "Maximum Nesting Depth of Two Valid Parentheses Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/" + "id": 1111, + "link": "https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/", + "title": "Maximum Nesting Depth of Two Valid Parentheses Strings" }, "1112": { - "id": 1112, "category": "Database", - "title": "Highest Grade For Each Student", "difficulty": "Medium", - "link": "https://leetcode.com/problems/highest-grade-for-each-student/" + "id": 1112, + "link": "https://leetcode.com/problems/highest-grade-for-each-student/", + "title": "Highest Grade For Each Student" }, "1113": { - "id": 1113, "category": "Database", - "title": "Reported Posts", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reported-posts/" + "id": 1113, + "link": "https://leetcode.com/problems/reported-posts/", + "title": "Reported Posts" }, "1114": { - "id": 1114, "category": "Array & Hashing", - "title": "Print in Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/print-in-order/" + "id": 1114, + "link": "https://leetcode.com/problems/print-in-order/", + "title": "Print in Order" }, "1115": { - "id": 1115, "category": "Array & Hashing", - "title": "Print FooBar Alternately", "difficulty": "Medium", - "link": "https://leetcode.com/problems/print-foobar-alternately/" + "id": 1115, + "link": "https://leetcode.com/problems/print-foobar-alternately/", + "title": "Print FooBar Alternately" }, "1116": { - "id": 1116, "category": "Array & Hashing", - "title": "Print Zero Even Odd", "difficulty": "Medium", - "link": "https://leetcode.com/problems/print-zero-even-odd/" + "id": 1116, + "link": "https://leetcode.com/problems/print-zero-even-odd/", + "title": "Print Zero Even Odd" }, "1117": { - "id": 1117, "category": "Array & Hashing", - "title": "Building H2O", "difficulty": "Medium", - "link": "https://leetcode.com/problems/building-h2o/" + "id": 1117, + "link": "https://leetcode.com/problems/building-h2o/", + "title": "Building H2O" }, "1118": { - "id": 1118, "category": "Math & Geometry", - "title": "Number of Days in a Month", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-days-in-a-month/" + "id": 1118, + "link": "https://leetcode.com/problems/number-of-days-in-a-month/", + "title": "Number of Days in a Month" }, "1119": { - "id": 1119, "category": "Array & Hashing", - "title": "Remove Vowels from a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-vowels-from-a-string/" + "id": 1119, + "link": "https://leetcode.com/problems/remove-vowels-from-a-string/", + "title": "Remove Vowels from a String" }, "1120": { - "id": 1120, "category": "Tree", - "title": "Maximum Average Subtree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-average-subtree/" + "id": 1120, + "link": "https://leetcode.com/problems/maximum-average-subtree/", + "title": "Maximum Average Subtree" }, "1121": { - "id": 1121, "category": "Array & Hashing", - "title": "Divide Array Into Increasing Sequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/divide-array-into-increasing-sequences/" + "id": 1121, + "link": "https://leetcode.com/problems/divide-array-into-increasing-sequences/", + "title": "Divide Array Into Increasing Sequences" }, "1122": { - "id": 1122, "category": "Array & Hashing", - "title": "Relative Sort Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/relative-sort-array/" + "id": 1122, + "link": "https://leetcode.com/problems/relative-sort-array/", + "title": "Relative Sort Array" }, "1123": { - "id": 1123, "category": "Tree", - "title": "Lowest Common Ancestor of Deepest Leaves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/" + "id": 1123, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/", + "title": "Lowest Common Ancestor of Deepest Leaves" }, "1124": { - "id": 1124, "category": "Stack", - "title": "Longest Well-Performing Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-well-performing-interval/" + "id": 1124, + "link": "https://leetcode.com/problems/longest-well-performing-interval/", + "title": "Longest Well-Performing Interval" }, "1125": { - "id": 1125, "category": "Dynamic Programming", - "title": "Smallest Sufficient Team", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-sufficient-team/" + "id": 1125, + "link": "https://leetcode.com/problems/smallest-sufficient-team/", + "title": "Smallest Sufficient Team" }, "1126": { - "id": 1126, "category": "Database", - "title": "Active Businesses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/active-businesses/" + "id": 1126, + "link": "https://leetcode.com/problems/active-businesses/", + "title": "Active Businesses" }, "1127": { - "id": 1127, "category": "Database", - "title": "User Purchase Platform", "difficulty": "Hard", - "link": "https://leetcode.com/problems/user-purchase-platform/" + "id": 1127, + "link": "https://leetcode.com/problems/user-purchase-platform/", + "title": "User Purchase Platform" }, "1128": { - "id": 1128, "category": "Array & Hashing", - "title": "Number of Equivalent Domino Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-equivalent-domino-pairs/" + "id": 1128, + "link": "https://leetcode.com/problems/number-of-equivalent-domino-pairs/", + "title": "Number of Equivalent Domino Pairs" }, "1129": { - "id": 1129, "category": "Graph Traversal", - "title": "Shortest Path with Alternating Colors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-path-with-alternating-colors/" + "id": 1129, + "link": "https://leetcode.com/problems/shortest-path-with-alternating-colors/", + "title": "Shortest Path with Alternating Colors" }, "1130": { - "id": 1130, "category": "Dynamic Programming", - "title": "Minimum Cost Tree From Leaf Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/" + "id": 1130, + "link": "https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/", + "title": "Minimum Cost Tree From Leaf Values" }, "1131": { - "id": 1131, "category": "Math & Geometry", - "title": "Maximum of Absolute Value Expression", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-of-absolute-value-expression/" + "id": 1131, + "link": "https://leetcode.com/problems/maximum-of-absolute-value-expression/", + "title": "Maximum of Absolute Value Expression" }, "1132": { - "id": 1132, "category": "Database", - "title": "Reported Posts II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reported-posts-ii/" + "id": 1132, + "link": "https://leetcode.com/problems/reported-posts-ii/", + "title": "Reported Posts II" }, "1133": { - "id": 1133, "category": "Array & Hashing", - "title": "Largest Unique Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-unique-number/" + "id": 1133, + "link": "https://leetcode.com/problems/largest-unique-number/", + "title": "Largest Unique Number" }, "1134": { - "id": 1134, "category": "Math & Geometry", - "title": "Armstrong Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/armstrong-number/" + "id": 1134, + "link": "https://leetcode.com/problems/armstrong-number/", + "title": "Armstrong Number" }, "1135": { - "id": 1135, "category": "Tree", - "title": "Connecting Cities With Minimum Cost", "difficulty": "Medium", - "link": "https://leetcode.com/problems/connecting-cities-with-minimum-cost/" + "id": 1135, + "link": "https://leetcode.com/problems/connecting-cities-with-minimum-cost/", + "title": "Connecting Cities With Minimum Cost" }, "1136": { - "id": 1136, "category": "Graph Traversal", - "title": "Parallel Courses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/parallel-courses/" + "id": 1136, + "link": "https://leetcode.com/problems/parallel-courses/", + "title": "Parallel Courses" }, "1137": { - "id": 1137, "category": "Dynamic Programming", - "title": "N-th Tribonacci Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/n-th-tribonacci-number/" + "id": 1137, + "link": "https://leetcode.com/problems/n-th-tribonacci-number/", + "title": "N-th Tribonacci Number" }, "1138": { - "id": 1138, "category": "Array & Hashing", - "title": "Alphabet Board Path", "difficulty": "Medium", - "link": "https://leetcode.com/problems/alphabet-board-path/" + "id": 1138, + "link": "https://leetcode.com/problems/alphabet-board-path/", + "title": "Alphabet Board Path" }, "1139": { - "id": 1139, "category": "Dynamic Programming", - "title": "Largest 1-Bordered Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-1-bordered-square/" + "id": 1139, + "link": "https://leetcode.com/problems/largest-1-bordered-square/", + "title": "Largest 1-Bordered Square" }, "1140": { - "id": 1140, "category": "Dynamic Programming", - "title": "Stone Game II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stone-game-ii/" + "id": 1140, + "link": "https://leetcode.com/problems/stone-game-ii/", + "title": "Stone Game II" }, "1141": { - "id": 1141, "category": "Database", - "title": "User Activity for the Past 30 Days I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/user-activity-for-the-past-30-days-i/" + "id": 1141, + "link": "https://leetcode.com/problems/user-activity-for-the-past-30-days-i/", + "title": "User Activity for the Past 30 Days I" }, "1142": { - "id": 1142, "category": "Database", - "title": "User Activity for the Past 30 Days II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/user-activity-for-the-past-30-days-ii/" + "id": 1142, + "link": "https://leetcode.com/problems/user-activity-for-the-past-30-days-ii/", + "title": "User Activity for the Past 30 Days II" }, "1143": { - "id": 1143, "category": "Dynamic Programming", - "title": "Longest Common Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-common-subsequence/" + "id": 1143, + "link": "https://leetcode.com/problems/longest-common-subsequence/", + "title": "Longest Common Subsequence" }, "1144": { - "id": 1144, "category": "Greedy", - "title": "Decrease Elements To Make Array Zigzag", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decrease-elements-to-make-array-zigzag/" + "id": 1144, + "link": "https://leetcode.com/problems/decrease-elements-to-make-array-zigzag/", + "title": "Decrease Elements To Make Array Zigzag" }, "1145": { - "id": 1145, "category": "Tree", - "title": "Binary Tree Coloring Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-coloring-game/" + "id": 1145, + "link": "https://leetcode.com/problems/binary-tree-coloring-game/", + "title": "Binary Tree Coloring Game" }, "1146": { - "id": 1146, "category": "Binary Search", - "title": "Snapshot Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/snapshot-array/" + "id": 1146, + "link": "https://leetcode.com/problems/snapshot-array/", + "title": "Snapshot Array" }, "1147": { - "id": 1147, "category": "Dynamic Programming", - "title": "Longest Chunked Palindrome Decomposition", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-chunked-palindrome-decomposition/" + "id": 1147, + "link": "https://leetcode.com/problems/longest-chunked-palindrome-decomposition/", + "title": "Longest Chunked Palindrome Decomposition" }, "1148": { - "id": 1148, "category": "Database", - "title": "Article Views I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/article-views-i/" + "id": 1148, + "link": "https://leetcode.com/problems/article-views-i/", + "title": "Article Views I" }, "1149": { - "id": 1149, "category": "Database", - "title": "Article Views II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/article-views-ii/" + "id": 1149, + "link": "https://leetcode.com/problems/article-views-ii/", + "title": "Article Views II" }, "1150": { - "id": 1150, "category": "Binary Search", - "title": "Check If a Number Is Majority Element in a Sorted Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array/" + "id": 1150, + "link": "https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array/", + "title": "Check If a Number Is Majority Element in a Sorted Array" }, "1151": { - "id": 1151, "category": "Sliding Window", - "title": "Minimum Swaps to Group All 1's Together", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together/" + "id": 1151, + "link": "https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together/", + "title": "Minimum Swaps to Group All 1's Together" }, "1152": { - "id": 1152, "category": "Array & Hashing", - "title": "Analyze User Website Visit Pattern", "difficulty": "Medium", - "link": "https://leetcode.com/problems/analyze-user-website-visit-pattern/" + "id": 1152, + "link": "https://leetcode.com/problems/analyze-user-website-visit-pattern/", + "title": "Analyze User Website Visit Pattern" }, "1153": { - "id": 1153, "category": "Graph Traversal", - "title": "String Transforms Into Another String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/string-transforms-into-another-string/" + "id": 1153, + "link": "https://leetcode.com/problems/string-transforms-into-another-string/", + "title": "String Transforms Into Another String" }, "1154": { - "id": 1154, "category": "Math & Geometry", - "title": "Day of the Year", "difficulty": "Easy", - "link": "https://leetcode.com/problems/day-of-the-year/" + "id": 1154, + "link": "https://leetcode.com/problems/day-of-the-year/", + "title": "Day of the Year" }, "1155": { - "id": 1155, "category": "Dynamic Programming", - "title": "Number of Dice Rolls With Target Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/" + "id": 1155, + "link": "https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/", + "title": "Number of Dice Rolls With Target Sum" }, "1156": { - "id": 1156, "category": "Sliding Window", - "title": "Swap For Longest Repeated Character Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/swap-for-longest-repeated-character-substring/" + "id": 1156, + "link": "https://leetcode.com/problems/swap-for-longest-repeated-character-substring/", + "title": "Swap For Longest Repeated Character Substring" }, "1157": { - "id": 1157, "category": "Tree", - "title": "Online Majority Element In Subarray", "difficulty": "Hard", - "link": "https://leetcode.com/problems/online-majority-element-in-subarray/" + "id": 1157, + "link": "https://leetcode.com/problems/online-majority-element-in-subarray/", + "title": "Online Majority Element In Subarray" }, "1158": { - "id": 1158, "category": "Database", - "title": "Market Analysis I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/market-analysis-i/" + "id": 1158, + "link": "https://leetcode.com/problems/market-analysis-i/", + "title": "Market Analysis I" }, "1159": { - "id": 1159, "category": "Database", - "title": "Market Analysis II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/market-analysis-ii/" + "id": 1159, + "link": "https://leetcode.com/problems/market-analysis-ii/", + "title": "Market Analysis II" }, "1160": { - "id": 1160, "category": "Array & Hashing", - "title": "Find Words That Can Be Formed by Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/" + "id": 1160, + "link": "https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/", + "title": "Find Words That Can Be Formed by Characters" }, "1161": { - "id": 1161, "category": "Tree", - "title": "Maximum Level Sum of a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/" + "id": 1161, + "link": "https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/", + "title": "Maximum Level Sum of a Binary Tree" }, "1162": { - "id": 1162, "category": "Graph Traversal", - "title": "As Far from Land as Possible", "difficulty": "Medium", - "link": "https://leetcode.com/problems/as-far-from-land-as-possible/" + "id": 1162, + "link": "https://leetcode.com/problems/as-far-from-land-as-possible/", + "title": "As Far from Land as Possible" }, "1163": { - "id": 1163, "category": "Two Pointers", - "title": "Last Substring in Lexicographical Order", "difficulty": "Hard", - "link": "https://leetcode.com/problems/last-substring-in-lexicographical-order/" + "id": 1163, + "link": "https://leetcode.com/problems/last-substring-in-lexicographical-order/", + "title": "Last Substring in Lexicographical Order" }, "1164": { - "id": 1164, "category": "Database", - "title": "Product Price at a Given Date", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-price-at-a-given-date/" + "id": 1164, + "link": "https://leetcode.com/problems/product-price-at-a-given-date/", + "title": "Product Price at a Given Date" }, "1165": { - "id": 1165, "category": "Array & Hashing", - "title": "Single-Row Keyboard", "difficulty": "Easy", - "link": "https://leetcode.com/problems/single-row-keyboard/" + "id": 1165, + "link": "https://leetcode.com/problems/single-row-keyboard/", + "title": "Single-Row Keyboard" }, "1166": { - "id": 1166, "category": "Trie", - "title": "Design File System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-file-system/" + "id": 1166, + "link": "https://leetcode.com/problems/design-file-system/", + "title": "Design File System" }, "1167": { - "id": 1167, "category": "Heap (Priority Queue)", - "title": "Minimum Cost to Connect Sticks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-connect-sticks/" + "id": 1167, + "link": "https://leetcode.com/problems/minimum-cost-to-connect-sticks/", + "title": "Minimum Cost to Connect Sticks" }, "1168": { - "id": 1168, "category": "Tree", - "title": "Optimize Water Distribution in a Village", "difficulty": "Hard", - "link": "https://leetcode.com/problems/optimize-water-distribution-in-a-village/" + "id": 1168, + "link": "https://leetcode.com/problems/optimize-water-distribution-in-a-village/", + "title": "Optimize Water Distribution in a Village" }, "1169": { - "id": 1169, "category": "Array & Hashing", - "title": "Invalid Transactions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/invalid-transactions/" + "id": 1169, + "link": "https://leetcode.com/problems/invalid-transactions/", + "title": "Invalid Transactions" }, "1170": { - "id": 1170, "category": "Binary Search", - "title": "Compare Strings by Frequency of the Smallest Character", "difficulty": "Medium", - "link": "https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character/" + "id": 1170, + "link": "https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character/", + "title": "Compare Strings by Frequency of the Smallest Character" }, "1171": { - "id": 1171, "category": "Linked List", - "title": "Remove Zero Sum Consecutive Nodes from Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/" + "id": 1171, + "link": "https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/", + "title": "Remove Zero Sum Consecutive Nodes from Linked List" }, "1172": { - "id": 1172, "category": "Heap (Priority Queue)", - "title": "Dinner Plate Stacks", "difficulty": "Hard", - "link": "https://leetcode.com/problems/dinner-plate-stacks/" + "id": 1172, + "link": "https://leetcode.com/problems/dinner-plate-stacks/", + "title": "Dinner Plate Stacks" }, "1173": { - "id": 1173, "category": "Database", - "title": "Immediate Food Delivery I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/immediate-food-delivery-i/" + "id": 1173, + "link": "https://leetcode.com/problems/immediate-food-delivery-i/", + "title": "Immediate Food Delivery I" }, "1174": { - "id": 1174, "category": "Database", - "title": "Immediate Food Delivery II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/immediate-food-delivery-ii/" + "id": 1174, + "link": "https://leetcode.com/problems/immediate-food-delivery-ii/", + "title": "Immediate Food Delivery II" }, "1175": { - "id": 1175, "category": "Math & Geometry", - "title": "Prime Arrangements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/prime-arrangements/" + "id": 1175, + "link": "https://leetcode.com/problems/prime-arrangements/", + "title": "Prime Arrangements" }, "1176": { - "id": 1176, "category": "Sliding Window", - "title": "Diet Plan Performance", "difficulty": "Easy", - "link": "https://leetcode.com/problems/diet-plan-performance/" + "id": 1176, + "link": "https://leetcode.com/problems/diet-plan-performance/", + "title": "Diet Plan Performance" }, "1177": { - "id": 1177, "category": "Bit Manipulation", - "title": "Can Make Palindrome from Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/can-make-palindrome-from-substring/" + "id": 1177, + "link": "https://leetcode.com/problems/can-make-palindrome-from-substring/", + "title": "Can Make Palindrome from Substring" }, "1178": { - "id": 1178, "category": "Trie", - "title": "Number of Valid Words for Each Puzzle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/" + "id": 1178, + "link": "https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/", + "title": "Number of Valid Words for Each Puzzle" }, "1179": { - "id": 1179, "category": "Database", - "title": "Reformat Department Table", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reformat-department-table/" + "id": 1179, + "link": "https://leetcode.com/problems/reformat-department-table/", + "title": "Reformat Department Table" }, "1180": { - "id": 1180, "category": "Math & Geometry", - "title": "Count Substrings with Only One Distinct Letter", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter/" + "id": 1180, + "link": "https://leetcode.com/problems/count-substrings-with-only-one-distinct-letter/", + "title": "Count Substrings with Only One Distinct Letter" }, "1181": { - "id": 1181, "category": "Array & Hashing", - "title": "Before and After Puzzle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/before-and-after-puzzle/" + "id": 1181, + "link": "https://leetcode.com/problems/before-and-after-puzzle/", + "title": "Before and After Puzzle" }, "1182": { - "id": 1182, "category": "Dynamic Programming", - "title": "Shortest Distance to Target Color", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-distance-to-target-color/" + "id": 1182, + "link": "https://leetcode.com/problems/shortest-distance-to-target-color/", + "title": "Shortest Distance to Target Color" }, "1183": { - "id": 1183, "category": "Heap (Priority Queue)", - "title": "Maximum Number of Ones", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-ones/" + "id": 1183, + "link": "https://leetcode.com/problems/maximum-number-of-ones/", + "title": "Maximum Number of Ones" }, "1184": { - "id": 1184, "category": "Array & Hashing", - "title": "Distance Between Bus Stops", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distance-between-bus-stops/" + "id": 1184, + "link": "https://leetcode.com/problems/distance-between-bus-stops/", + "title": "Distance Between Bus Stops" }, "1185": { - "id": 1185, "category": "Math & Geometry", - "title": "Day of the Week", "difficulty": "Easy", - "link": "https://leetcode.com/problems/day-of-the-week/" + "id": 1185, + "link": "https://leetcode.com/problems/day-of-the-week/", + "title": "Day of the Week" }, "1186": { - "id": 1186, "category": "Dynamic Programming", - "title": "Maximum Subarray Sum with One Deletion", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/" + "id": 1186, + "link": "https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/", + "title": "Maximum Subarray Sum with One Deletion" }, "1187": { - "id": 1187, "category": "Dynamic Programming", - "title": "Make Array Strictly Increasing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/make-array-strictly-increasing/" + "id": 1187, + "link": "https://leetcode.com/problems/make-array-strictly-increasing/", + "title": "Make Array Strictly Increasing" }, "1188": { - "id": 1188, "category": "Array & Hashing", - "title": "Design Bounded Blocking Queue", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-bounded-blocking-queue/" + "id": 1188, + "link": "https://leetcode.com/problems/design-bounded-blocking-queue/", + "title": "Design Bounded Blocking Queue" }, "1189": { - "id": 1189, "category": "Array & Hashing", - "title": "Maximum Number of Balloons", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-balloons/" + "id": 1189, + "link": "https://leetcode.com/problems/maximum-number-of-balloons/", + "title": "Maximum Number of Balloons" }, "1190": { - "id": 1190, "category": "Stack", - "title": "Reverse Substrings Between Each Pair of Parentheses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/" + "id": 1190, + "link": "https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/", + "title": "Reverse Substrings Between Each Pair of Parentheses" }, "1191": { - "id": 1191, "category": "Dynamic Programming", - "title": "K-Concatenation Maximum Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-concatenation-maximum-sum/" + "id": 1191, + "link": "https://leetcode.com/problems/k-concatenation-maximum-sum/", + "title": "K-Concatenation Maximum Sum" }, "1192": { - "id": 1192, "category": "Graph Traversal", - "title": "Critical Connections in a Network", "difficulty": "Hard", - "link": "https://leetcode.com/problems/critical-connections-in-a-network/" + "id": 1192, + "link": "https://leetcode.com/problems/critical-connections-in-a-network/", + "title": "Critical Connections in a Network" }, "1193": { - "id": 1193, "category": "Database", - "title": "Monthly Transactions I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/monthly-transactions-i/" + "id": 1193, + "link": "https://leetcode.com/problems/monthly-transactions-i/", + "title": "Monthly Transactions I" }, "1194": { - "id": 1194, "category": "Database", - "title": "Tournament Winners", "difficulty": "Hard", - "link": "https://leetcode.com/problems/tournament-winners/" + "id": 1194, + "link": "https://leetcode.com/problems/tournament-winners/", + "title": "Tournament Winners" }, "1195": { - "id": 1195, "category": "Array & Hashing", - "title": "Fizz Buzz Multithreaded", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fizz-buzz-multithreaded/" + "id": 1195, + "link": "https://leetcode.com/problems/fizz-buzz-multithreaded/", + "title": "Fizz Buzz Multithreaded" }, "1196": { - "id": 1196, "category": "Greedy", - "title": "How Many Apples Can You Put into the Basket", "difficulty": "Easy", - "link": "https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket/" + "id": 1196, + "link": "https://leetcode.com/problems/how-many-apples-can-you-put-into-the-basket/", + "title": "How Many Apples Can You Put into the Basket" }, "1197": { - "id": 1197, "category": "Graph Traversal", - "title": "Minimum Knight Moves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-knight-moves/" + "id": 1197, + "link": "https://leetcode.com/problems/minimum-knight-moves/", + "title": "Minimum Knight Moves" }, "1198": { - "id": 1198, "category": "Binary Search", - "title": "Find Smallest Common Element in All Rows", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-smallest-common-element-in-all-rows/" + "id": 1198, + "link": "https://leetcode.com/problems/find-smallest-common-element-in-all-rows/", + "title": "Find Smallest Common Element in All Rows" }, "1199": { - "id": 1199, "category": "Heap (Priority Queue)", - "title": "Minimum Time to Build Blocks", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-build-blocks/" + "id": 1199, + "link": "https://leetcode.com/problems/minimum-time-to-build-blocks/", + "title": "Minimum Time to Build Blocks" }, "1200": { - "id": 1200, "category": "Array & Hashing", - "title": "Minimum Absolute Difference", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-absolute-difference/" + "id": 1200, + "link": "https://leetcode.com/problems/minimum-absolute-difference/", + "title": "Minimum Absolute Difference" }, "1201": { - "id": 1201, "category": "Binary Search", - "title": "Ugly Number III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ugly-number-iii/" + "id": 1201, + "link": "https://leetcode.com/problems/ugly-number-iii/", + "title": "Ugly Number III" }, "1202": { - "id": 1202, "category": "Graph Traversal", - "title": "Smallest String With Swaps", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-string-with-swaps/" + "id": 1202, + "link": "https://leetcode.com/problems/smallest-string-with-swaps/", + "title": "Smallest String With Swaps" }, "1203": { - "id": 1203, "category": "Graph Traversal", - "title": "Sort Items by Groups Respecting Dependencies", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies/" + "id": 1203, + "link": "https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies/", + "title": "Sort Items by Groups Respecting Dependencies" }, "1204": { - "id": 1204, "category": "Database", - "title": "Last Person to Fit in the Bus", "difficulty": "Medium", - "link": "https://leetcode.com/problems/last-person-to-fit-in-the-bus/" + "id": 1204, + "link": "https://leetcode.com/problems/last-person-to-fit-in-the-bus/", + "title": "Last Person to Fit in the Bus" }, "1205": { - "id": 1205, "category": "Database", - "title": "Monthly Transactions II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/monthly-transactions-ii/" + "id": 1205, + "link": "https://leetcode.com/problems/monthly-transactions-ii/", + "title": "Monthly Transactions II" }, "1206": { - "id": 1206, "category": "Linked List", - "title": "Design Skiplist", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-skiplist/" + "id": 1206, + "link": "https://leetcode.com/problems/design-skiplist/", + "title": "Design Skiplist" }, "1207": { - "id": 1207, "category": "Array & Hashing", - "title": "Unique Number of Occurrences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/unique-number-of-occurrences/" + "id": 1207, + "link": "https://leetcode.com/problems/unique-number-of-occurrences/", + "title": "Unique Number of Occurrences" }, "1208": { - "id": 1208, "category": "Sliding Window", - "title": "Get Equal Substrings Within Budget", "difficulty": "Medium", - "link": "https://leetcode.com/problems/get-equal-substrings-within-budget/" + "id": 1208, + "link": "https://leetcode.com/problems/get-equal-substrings-within-budget/", + "title": "Get Equal Substrings Within Budget" }, "1209": { - "id": 1209, "category": "Stack", - "title": "Remove All Adjacent Duplicates in String II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/" + "id": 1209, + "link": "https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/", + "title": "Remove All Adjacent Duplicates in String II" }, "1210": { - "id": 1210, "category": "Graph Traversal", - "title": "Minimum Moves to Reach Target with Rotations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations/" + "id": 1210, + "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations/", + "title": "Minimum Moves to Reach Target with Rotations" }, "1211": { - "id": 1211, "category": "Database", - "title": "Queries Quality and Percentage", "difficulty": "Easy", - "link": "https://leetcode.com/problems/queries-quality-and-percentage/" + "id": 1211, + "link": "https://leetcode.com/problems/queries-quality-and-percentage/", + "title": "Queries Quality and Percentage" }, "1212": { - "id": 1212, "category": "Database", - "title": "Team Scores in Football Tournament", "difficulty": "Medium", - "link": "https://leetcode.com/problems/team-scores-in-football-tournament/" + "id": 1212, + "link": "https://leetcode.com/problems/team-scores-in-football-tournament/", + "title": "Team Scores in Football Tournament" }, "1213": { - "id": 1213, "category": "Binary Search", - "title": "Intersection of Three Sorted Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/intersection-of-three-sorted-arrays/" - }, - "1214": { - "id": 1214, - "category": "Tree", - "title": "Two Sum BSTs", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/two-sum-bsts/" + "id": 1213, + "link": "https://leetcode.com/problems/intersection-of-three-sorted-arrays/", + "title": "Intersection of Three Sorted Arrays" }, + "1214": {"category": "Tree", "difficulty": "Medium", "id": 1214, "link": "https://leetcode.com/problems/two-sum-bsts/", "title": "Two Sum BSTs"}, "1215": { - "id": 1215, "category": "Graph Traversal", - "title": "Stepping Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stepping-numbers/" + "id": 1215, + "link": "https://leetcode.com/problems/stepping-numbers/", + "title": "Stepping Numbers" }, "1216": { - "id": 1216, "category": "Dynamic Programming", - "title": "Valid Palindrome III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/valid-palindrome-iii/" + "id": 1216, + "link": "https://leetcode.com/problems/valid-palindrome-iii/", + "title": "Valid Palindrome III" }, "1217": { - "id": 1217, "category": "Greedy", - "title": "Minimum Cost to Move Chips to The Same Position", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position/" + "id": 1217, + "link": "https://leetcode.com/problems/minimum-cost-to-move-chips-to-the-same-position/", + "title": "Minimum Cost to Move Chips to The Same Position" }, "1218": { - "id": 1218, "category": "Dynamic Programming", - "title": "Longest Arithmetic Subsequence of Given Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference/" + "id": 1218, + "link": "https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference/", + "title": "Longest Arithmetic Subsequence of Given Difference" }, "1219": { - "id": 1219, "category": "Backtracking", - "title": "Path with Maximum Gold", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-with-maximum-gold/" + "id": 1219, + "link": "https://leetcode.com/problems/path-with-maximum-gold/", + "title": "Path with Maximum Gold" }, "1220": { - "id": 1220, "category": "Dynamic Programming", - "title": "Count Vowels Permutation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-vowels-permutation/" + "id": 1220, + "link": "https://leetcode.com/problems/count-vowels-permutation/", + "title": "Count Vowels Permutation" }, "1221": { - "id": 1221, "category": "Greedy", - "title": "Split a String in Balanced Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/split-a-string-in-balanced-strings/" + "id": 1221, + "link": "https://leetcode.com/problems/split-a-string-in-balanced-strings/", + "title": "Split a String in Balanced Strings" }, "1222": { - "id": 1222, "category": "Array & Hashing", - "title": "Queens That Can Attack the King", "difficulty": "Medium", - "link": "https://leetcode.com/problems/queens-that-can-attack-the-king/" + "id": 1222, + "link": "https://leetcode.com/problems/queens-that-can-attack-the-king/", + "title": "Queens That Can Attack the King" }, "1223": { - "id": 1223, "category": "Dynamic Programming", - "title": "Dice Roll Simulation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/dice-roll-simulation/" + "id": 1223, + "link": "https://leetcode.com/problems/dice-roll-simulation/", + "title": "Dice Roll Simulation" }, "1224": { - "id": 1224, "category": "Array & Hashing", - "title": "Maximum Equal Frequency", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-equal-frequency/" + "id": 1224, + "link": "https://leetcode.com/problems/maximum-equal-frequency/", + "title": "Maximum Equal Frequency" }, "1225": { - "id": 1225, "category": "Database", - "title": "Report Contiguous Dates", "difficulty": "Hard", - "link": "https://leetcode.com/problems/report-contiguous-dates/" + "id": 1225, + "link": "https://leetcode.com/problems/report-contiguous-dates/", + "title": "Report Contiguous Dates" }, "1226": { - "id": 1226, "category": "Array & Hashing", - "title": "The Dining Philosophers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-dining-philosophers/" + "id": 1226, + "link": "https://leetcode.com/problems/the-dining-philosophers/", + "title": "The Dining Philosophers" }, "1227": { - "id": 1227, "category": "Dynamic Programming", - "title": "Airplane Seat Assignment Probability", "difficulty": "Medium", - "link": "https://leetcode.com/problems/airplane-seat-assignment-probability/" + "id": 1227, + "link": "https://leetcode.com/problems/airplane-seat-assignment-probability/", + "title": "Airplane Seat Assignment Probability" }, "1228": { - "id": 1228, "category": "Math & Geometry", - "title": "Missing Number In Arithmetic Progression", "difficulty": "Easy", - "link": "https://leetcode.com/problems/missing-number-in-arithmetic-progression/" + "id": 1228, + "link": "https://leetcode.com/problems/missing-number-in-arithmetic-progression/", + "title": "Missing Number In Arithmetic Progression" }, "1229": { - "id": 1229, "category": "Two Pointers", - "title": "Meeting Scheduler", "difficulty": "Medium", - "link": "https://leetcode.com/problems/meeting-scheduler/" + "id": 1229, + "link": "https://leetcode.com/problems/meeting-scheduler/", + "title": "Meeting Scheduler" }, "1230": { - "id": 1230, "category": "Dynamic Programming", - "title": "Toss Strange Coins", "difficulty": "Medium", - "link": "https://leetcode.com/problems/toss-strange-coins/" + "id": 1230, + "link": "https://leetcode.com/problems/toss-strange-coins/", + "title": "Toss Strange Coins" }, "1231": { - "id": 1231, "category": "Binary Search", - "title": "Divide Chocolate", "difficulty": "Hard", - "link": "https://leetcode.com/problems/divide-chocolate/" + "id": 1231, + "link": "https://leetcode.com/problems/divide-chocolate/", + "title": "Divide Chocolate" }, "1232": { - "id": 1232, "category": "Math & Geometry", - "title": "Check If It Is a Straight Line", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-it-is-a-straight-line/" + "id": 1232, + "link": "https://leetcode.com/problems/check-if-it-is-a-straight-line/", + "title": "Check If It Is a Straight Line" }, "1233": { - "id": 1233, "category": "Graph Traversal", - "title": "Remove Sub-Folders from the Filesystem", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/" + "id": 1233, + "link": "https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/", + "title": "Remove Sub-Folders from the Filesystem" }, "1234": { - "id": 1234, "category": "Sliding Window", - "title": "Replace the Substring for Balanced String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/replace-the-substring-for-balanced-string/" + "id": 1234, + "link": "https://leetcode.com/problems/replace-the-substring-for-balanced-string/", + "title": "Replace the Substring for Balanced String" }, "1235": { - "id": 1235, "category": "Dynamic Programming", - "title": "Maximum Profit in Job Scheduling", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-profit-in-job-scheduling/" + "id": 1235, + "link": "https://leetcode.com/problems/maximum-profit-in-job-scheduling/", + "title": "Maximum Profit in Job Scheduling" }, "1236": { - "id": 1236, "category": "Graph Traversal", - "title": "Web Crawler", "difficulty": "Medium", - "link": "https://leetcode.com/problems/web-crawler/" + "id": 1236, + "link": "https://leetcode.com/problems/web-crawler/", + "title": "Web Crawler" }, "1237": { - "id": 1237, "category": "Binary Search", - "title": "Find Positive Integer Solution for a Given Equation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/" + "id": 1237, + "link": "https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/", + "title": "Find Positive Integer Solution for a Given Equation" }, "1238": { - "id": 1238, "category": "Backtracking", - "title": "Circular Permutation in Binary Representation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/circular-permutation-in-binary-representation/" + "id": 1238, + "link": "https://leetcode.com/problems/circular-permutation-in-binary-representation/", + "title": "Circular Permutation in Binary Representation" }, "1239": { - "id": 1239, "category": "Backtracking", - "title": "Maximum Length of a Concatenated String with Unique Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/" + "id": 1239, + "link": "https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/", + "title": "Maximum Length of a Concatenated String with Unique Characters" }, "1240": { - "id": 1240, "category": "Backtracking", - "title": "Tiling a Rectangle with the Fewest Squares", "difficulty": "Hard", - "link": "https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/" + "id": 1240, + "link": "https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/", + "title": "Tiling a Rectangle with the Fewest Squares" }, "1241": { - "id": 1241, "category": "Database", - "title": "Number of Comments per Post", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-comments-per-post/" + "id": 1241, + "link": "https://leetcode.com/problems/number-of-comments-per-post/", + "title": "Number of Comments per Post" }, "1242": { - "id": 1242, "category": "Graph Traversal", - "title": "Web Crawler Multithreaded", "difficulty": "Medium", - "link": "https://leetcode.com/problems/web-crawler-multithreaded/" + "id": 1242, + "link": "https://leetcode.com/problems/web-crawler-multithreaded/", + "title": "Web Crawler Multithreaded" }, "1243": { - "id": 1243, "category": "Array & Hashing", - "title": "Array Transformation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-transformation/" + "id": 1243, + "link": "https://leetcode.com/problems/array-transformation/", + "title": "Array Transformation" }, "1244": { - "id": 1244, "category": "Array & Hashing", - "title": "Design A Leaderboard", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-leaderboard/" - }, - "1245": { - "id": 1245, - "category": "Tree", - "title": "Tree Diameter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/tree-diameter/" + "id": 1244, + "link": "https://leetcode.com/problems/design-a-leaderboard/", + "title": "Design A Leaderboard" }, + "1245": {"category": "Tree", "difficulty": "Medium", "id": 1245, "link": "https://leetcode.com/problems/tree-diameter/", "title": "Tree Diameter"}, "1246": { - "id": 1246, "category": "Dynamic Programming", - "title": "Palindrome Removal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-removal/" + "id": 1246, + "link": "https://leetcode.com/problems/palindrome-removal/", + "title": "Palindrome Removal" }, "1247": { - "id": 1247, "category": "Greedy", - "title": "Minimum Swaps to Make Strings Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-swaps-to-make-strings-equal/" + "id": 1247, + "link": "https://leetcode.com/problems/minimum-swaps-to-make-strings-equal/", + "title": "Minimum Swaps to Make Strings Equal" }, "1248": { - "id": 1248, "category": "Sliding Window", - "title": "Count Number of Nice Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-nice-subarrays/" + "id": 1248, + "link": "https://leetcode.com/problems/count-number-of-nice-subarrays/", + "title": "Count Number of Nice Subarrays" }, "1249": { - "id": 1249, "category": "Stack", - "title": "Minimum Remove to Make Valid Parentheses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/" + "id": 1249, + "link": "https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/", + "title": "Minimum Remove to Make Valid Parentheses" }, "1250": { - "id": 1250, "category": "Math & Geometry", - "title": "Check If It Is a Good Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-it-is-a-good-array/" + "id": 1250, + "link": "https://leetcode.com/problems/check-if-it-is-a-good-array/", + "title": "Check If It Is a Good Array" }, "1251": { - "id": 1251, "category": "Database", - "title": "Average Selling Price", "difficulty": "Easy", - "link": "https://leetcode.com/problems/average-selling-price/" + "id": 1251, + "link": "https://leetcode.com/problems/average-selling-price/", + "title": "Average Selling Price" }, "1252": { - "id": 1252, "category": "Math & Geometry", - "title": "Cells with Odd Values in a Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/" + "id": 1252, + "link": "https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/", + "title": "Cells with Odd Values in a Matrix" }, "1253": { - "id": 1253, "category": "Greedy", - "title": "Reconstruct a 2-Row Binary Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix/" + "id": 1253, + "link": "https://leetcode.com/problems/reconstruct-a-2-row-binary-matrix/", + "title": "Reconstruct a 2-Row Binary Matrix" }, "1254": { - "id": 1254, "category": "Graph Traversal", - "title": "Number of Closed Islands", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-closed-islands/" + "id": 1254, + "link": "https://leetcode.com/problems/number-of-closed-islands/", + "title": "Number of Closed Islands" }, "1255": { - "id": 1255, "category": "Dynamic Programming", - "title": "Maximum Score Words Formed by Letters", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-words-formed-by-letters/" + "id": 1255, + "link": "https://leetcode.com/problems/maximum-score-words-formed-by-letters/", + "title": "Maximum Score Words Formed by Letters" }, "1256": { - "id": 1256, "category": "Bit Manipulation", - "title": "Encode Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/encode-number/" + "id": 1256, + "link": "https://leetcode.com/problems/encode-number/", + "title": "Encode Number" }, "1257": { - "id": 1257, "category": "Tree", - "title": "Smallest Common Region", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-common-region/" + "id": 1257, + "link": "https://leetcode.com/problems/smallest-common-region/", + "title": "Smallest Common Region" }, "1258": { - "id": 1258, "category": "Graph Traversal", - "title": "Synonymous Sentences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/synonymous-sentences/" + "id": 1258, + "link": "https://leetcode.com/problems/synonymous-sentences/", + "title": "Synonymous Sentences" }, "1259": { - "id": 1259, "category": "Dynamic Programming", - "title": "Handshakes That Don't Cross", "difficulty": "Hard", - "link": "https://leetcode.com/problems/handshakes-that-dont-cross/" + "id": 1259, + "link": "https://leetcode.com/problems/handshakes-that-dont-cross/", + "title": "Handshakes That Don't Cross" }, "1260": { - "id": 1260, "category": "Array & Hashing", - "title": "Shift 2D Grid", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shift-2d-grid/" + "id": 1260, + "link": "https://leetcode.com/problems/shift-2d-grid/", + "title": "Shift 2D Grid" }, "1261": { - "id": 1261, "category": "Tree", - "title": "Find Elements in a Contaminated Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/" + "id": 1261, + "link": "https://leetcode.com/problems/find-elements-in-a-contaminated-binary-tree/", + "title": "Find Elements in a Contaminated Binary Tree" }, "1262": { - "id": 1262, "category": "Dynamic Programming", - "title": "Greatest Sum Divisible by Three", "difficulty": "Medium", - "link": "https://leetcode.com/problems/greatest-sum-divisible-by-three/" + "id": 1262, + "link": "https://leetcode.com/problems/greatest-sum-divisible-by-three/", + "title": "Greatest Sum Divisible by Three" }, "1263": { - "id": 1263, "category": "Graph Traversal", - "title": "Minimum Moves to Move a Box to Their Target Location", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location/" + "id": 1263, + "link": "https://leetcode.com/problems/minimum-moves-to-move-a-box-to-their-target-location/", + "title": "Minimum Moves to Move a Box to Their Target Location" }, "1264": { - "id": 1264, "category": "Database", - "title": "Page Recommendations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/page-recommendations/" + "id": 1264, + "link": "https://leetcode.com/problems/page-recommendations/", + "title": "Page Recommendations" }, "1265": { - "id": 1265, "category": "Stack", - "title": "Print Immutable Linked List in Reverse", "difficulty": "Medium", - "link": "https://leetcode.com/problems/print-immutable-linked-list-in-reverse/" + "id": 1265, + "link": "https://leetcode.com/problems/print-immutable-linked-list-in-reverse/", + "title": "Print Immutable Linked List in Reverse" }, "1266": { - "id": 1266, "category": "Math & Geometry", - "title": "Minimum Time Visiting All Points", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-time-visiting-all-points/" + "id": 1266, + "link": "https://leetcode.com/problems/minimum-time-visiting-all-points/", + "title": "Minimum Time Visiting All Points" }, "1267": { - "id": 1267, "category": "Graph Traversal", - "title": "Count Servers that Communicate", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-servers-that-communicate/" + "id": 1267, + "link": "https://leetcode.com/problems/count-servers-that-communicate/", + "title": "Count Servers that Communicate" }, "1268": { - "id": 1268, "category": "Binary Search", - "title": "Search Suggestions System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/search-suggestions-system/" + "id": 1268, + "link": "https://leetcode.com/problems/search-suggestions-system/", + "title": "Search Suggestions System" }, "1269": { - "id": 1269, "category": "Dynamic Programming", - "title": "Number of Ways to Stay in the Same Place After Some Steps", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/" + "id": 1269, + "link": "https://leetcode.com/problems/number-of-ways-to-stay-in-the-same-place-after-some-steps/", + "title": "Number of Ways to Stay in the Same Place After Some Steps" }, "1270": { - "id": 1270, "category": "Database", - "title": "All People Report to the Given Manager", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-people-report-to-the-given-manager/" - }, - "1271": { - "id": 1271, - "category": "Math & Geometry", - "title": "Hexspeak", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/hexspeak/" + "id": 1270, + "link": "https://leetcode.com/problems/all-people-report-to-the-given-manager/", + "title": "All People Report to the Given Manager" }, + "1271": {"category": "Math & Geometry", "difficulty": "Easy", "id": 1271, "link": "https://leetcode.com/problems/hexspeak/", "title": "Hexspeak"}, "1272": { - "id": 1272, "category": "Array & Hashing", - "title": "Remove Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-interval/" + "id": 1272, + "link": "https://leetcode.com/problems/remove-interval/", + "title": "Remove Interval" }, "1273": { - "id": 1273, "category": "Tree", - "title": "Delete Tree Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-tree-nodes/" + "id": 1273, + "link": "https://leetcode.com/problems/delete-tree-nodes/", + "title": "Delete Tree Nodes" }, "1274": { - "id": 1274, "category": "Array & Hashing", - "title": "Number of Ships in a Rectangle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ships-in-a-rectangle/" + "id": 1274, + "link": "https://leetcode.com/problems/number-of-ships-in-a-rectangle/", + "title": "Number of Ships in a Rectangle" }, "1275": { - "id": 1275, "category": "Array & Hashing", - "title": "Find Winner on a Tic Tac Toe Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game/" + "id": 1275, + "link": "https://leetcode.com/problems/find-winner-on-a-tic-tac-toe-game/", + "title": "Find Winner on a Tic Tac Toe Game" }, "1276": { - "id": 1276, "category": "Math & Geometry", - "title": "Number of Burgers with No Waste of Ingredients", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients/" + "id": 1276, + "link": "https://leetcode.com/problems/number-of-burgers-with-no-waste-of-ingredients/", + "title": "Number of Burgers with No Waste of Ingredients" }, "1277": { - "id": 1277, "category": "Dynamic Programming", - "title": "Count Square Submatrices with All Ones", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-square-submatrices-with-all-ones/" + "id": 1277, + "link": "https://leetcode.com/problems/count-square-submatrices-with-all-ones/", + "title": "Count Square Submatrices with All Ones" }, "1278": { - "id": 1278, "category": "Dynamic Programming", - "title": "Palindrome Partitioning III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-partitioning-iii/" + "id": 1278, + "link": "https://leetcode.com/problems/palindrome-partitioning-iii/", + "title": "Palindrome Partitioning III" }, "1279": { - "id": 1279, "category": "Array & Hashing", - "title": "Traffic Light Controlled Intersection", "difficulty": "Easy", - "link": "https://leetcode.com/problems/traffic-light-controlled-intersection/" + "id": 1279, + "link": "https://leetcode.com/problems/traffic-light-controlled-intersection/", + "title": "Traffic Light Controlled Intersection" }, "1280": { - "id": 1280, "category": "Database", - "title": "Students and Examinations", "difficulty": "Easy", - "link": "https://leetcode.com/problems/students-and-examinations/" + "id": 1280, + "link": "https://leetcode.com/problems/students-and-examinations/", + "title": "Students and Examinations" }, "1281": { - "id": 1281, "category": "Math & Geometry", - "title": "Subtract the Product and Sum of Digits of an Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/" + "id": 1281, + "link": "https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/", + "title": "Subtract the Product and Sum of Digits of an Integer" }, "1282": { - "id": 1282, "category": "Greedy", - "title": "Group the People Given the Group Size They Belong To", "difficulty": "Medium", - "link": "https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/" + "id": 1282, + "link": "https://leetcode.com/problems/group-the-people-given-the-group-size-they-belong-to/", + "title": "Group the People Given the Group Size They Belong To" }, "1283": { - "id": 1283, "category": "Binary Search", - "title": "Find the Smallest Divisor Given a Threshold", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold/" + "id": 1283, + "link": "https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold/", + "title": "Find the Smallest Divisor Given a Threshold" }, "1284": { - "id": 1284, "category": "Graph Traversal", - "title": "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/" + "id": 1284, + "link": "https://leetcode.com/problems/minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix/", + "title": "Minimum Number of Flips to Convert Binary Matrix to Zero Matrix" }, "1285": { - "id": 1285, "category": "Database", - "title": "Find the Start and End Number of Continuous Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges/" + "id": 1285, + "link": "https://leetcode.com/problems/find-the-start-and-end-number-of-continuous-ranges/", + "title": "Find the Start and End Number of Continuous Ranges" }, "1286": { - "id": 1286, "category": "Backtracking", - "title": "Iterator for Combination", "difficulty": "Medium", - "link": "https://leetcode.com/problems/iterator-for-combination/" + "id": 1286, + "link": "https://leetcode.com/problems/iterator-for-combination/", + "title": "Iterator for Combination" }, "1287": { - "id": 1287, "category": "Array & Hashing", - "title": "Element Appearing More Than 25% In Sorted Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array/" + "id": 1287, + "link": "https://leetcode.com/problems/element-appearing-more-than-25-in-sorted-array/", + "title": "Element Appearing More Than 25% In Sorted Array" }, "1288": { - "id": 1288, "category": "Array & Hashing", - "title": "Remove Covered Intervals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-covered-intervals/" + "id": 1288, + "link": "https://leetcode.com/problems/remove-covered-intervals/", + "title": "Remove Covered Intervals" }, "1289": { - "id": 1289, "category": "Dynamic Programming", - "title": "Minimum Falling Path Sum II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-falling-path-sum-ii/" + "id": 1289, + "link": "https://leetcode.com/problems/minimum-falling-path-sum-ii/", + "title": "Minimum Falling Path Sum II" }, "1290": { - "id": 1290, "category": "Linked List", - "title": "Convert Binary Number in a Linked List to Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/" + "id": 1290, + "link": "https://leetcode.com/problems/convert-binary-number-in-a-linked-list-to-integer/", + "title": "Convert Binary Number in a Linked List to Integer" }, "1291": { - "id": 1291, "category": "Array & Hashing", - "title": "Sequential Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sequential-digits/" + "id": 1291, + "link": "https://leetcode.com/problems/sequential-digits/", + "title": "Sequential Digits" }, "1292": { - "id": 1292, "category": "Binary Search", - "title": "Maximum Side Length of a Square with Sum Less than or Equal to Threshold", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/" + "id": 1292, + "link": "https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/", + "title": "Maximum Side Length of a Square with Sum Less than or Equal to Threshold" }, "1293": { - "id": 1293, "category": "Graph Traversal", - "title": "Shortest Path in a Grid with Obstacles Elimination", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination/" + "id": 1293, + "link": "https://leetcode.com/problems/shortest-path-in-a-grid-with-obstacles-elimination/", + "title": "Shortest Path in a Grid with Obstacles Elimination" }, "1294": { - "id": 1294, "category": "Database", - "title": "Weather Type in Each Country", "difficulty": "Easy", - "link": "https://leetcode.com/problems/weather-type-in-each-country/" + "id": 1294, + "link": "https://leetcode.com/problems/weather-type-in-each-country/", + "title": "Weather Type in Each Country" }, "1295": { - "id": 1295, "category": "Math & Geometry", - "title": "Find Numbers with Even Number of Digits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-numbers-with-even-number-of-digits/" + "id": 1295, + "link": "https://leetcode.com/problems/find-numbers-with-even-number-of-digits/", + "title": "Find Numbers with Even Number of Digits" }, "1296": { - "id": 1296, "category": "Greedy", - "title": "Divide Array in Sets of K Consecutive Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/" + "id": 1296, + "link": "https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/", + "title": "Divide Array in Sets of K Consecutive Numbers" }, "1297": { - "id": 1297, "category": "Sliding Window", - "title": "Maximum Number of Occurrences of a Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/" + "id": 1297, + "link": "https://leetcode.com/problems/maximum-number-of-occurrences-of-a-substring/", + "title": "Maximum Number of Occurrences of a Substring" }, "1298": { - "id": 1298, "category": "Graph Traversal", - "title": "Maximum Candies You Can Get from Boxes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes/" + "id": 1298, + "link": "https://leetcode.com/problems/maximum-candies-you-can-get-from-boxes/", + "title": "Maximum Candies You Can Get from Boxes" }, "1299": { - "id": 1299, "category": "Array & Hashing", - "title": "Replace Elements with Greatest Element on Right Side", "difficulty": "Easy", - "link": "https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side/" + "id": 1299, + "link": "https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side/", + "title": "Replace Elements with Greatest Element on Right Side" }, "1300": { - "id": 1300, "category": "Binary Search", - "title": "Sum of Mutated Array Closest to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-mutated-array-closest-to-target/" + "id": 1300, + "link": "https://leetcode.com/problems/sum-of-mutated-array-closest-to-target/", + "title": "Sum of Mutated Array Closest to Target" }, "1301": { - "id": 1301, "category": "Dynamic Programming", - "title": "Number of Paths with Max Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-paths-with-max-score/" + "id": 1301, + "link": "https://leetcode.com/problems/number-of-paths-with-max-score/", + "title": "Number of Paths with Max Score" }, "1302": { - "id": 1302, "category": "Tree", - "title": "Deepest Leaves Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/deepest-leaves-sum/" + "id": 1302, + "link": "https://leetcode.com/problems/deepest-leaves-sum/", + "title": "Deepest Leaves Sum" }, "1303": { - "id": 1303, "category": "Database", - "title": "Find the Team Size", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-team-size/" + "id": 1303, + "link": "https://leetcode.com/problems/find-the-team-size/", + "title": "Find the Team Size" }, "1304": { - "id": 1304, "category": "Math & Geometry", - "title": "Find N Unique Integers Sum up to Zero", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero/" + "id": 1304, + "link": "https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero/", + "title": "Find N Unique Integers Sum up to Zero" }, "1305": { - "id": 1305, "category": "Tree", - "title": "All Elements in Two Binary Search Trees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-elements-in-two-binary-search-trees/" + "id": 1305, + "link": "https://leetcode.com/problems/all-elements-in-two-binary-search-trees/", + "title": "All Elements in Two Binary Search Trees" }, "1306": { - "id": 1306, "category": "Graph Traversal", - "title": "Jump Game III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-iii/" + "id": 1306, + "link": "https://leetcode.com/problems/jump-game-iii/", + "title": "Jump Game III" }, "1307": { - "id": 1307, "category": "Backtracking", - "title": "Verbal Arithmetic Puzzle", "difficulty": "Hard", - "link": "https://leetcode.com/problems/verbal-arithmetic-puzzle/" + "id": 1307, + "link": "https://leetcode.com/problems/verbal-arithmetic-puzzle/", + "title": "Verbal Arithmetic Puzzle" }, "1308": { - "id": 1308, "category": "Database", - "title": "Running Total for Different Genders", "difficulty": "Medium", - "link": "https://leetcode.com/problems/running-total-for-different-genders/" + "id": 1308, + "link": "https://leetcode.com/problems/running-total-for-different-genders/", + "title": "Running Total for Different Genders" }, "1309": { - "id": 1309, "category": "Array & Hashing", - "title": "Decrypt String from Alphabet to Integer Mapping", "difficulty": "Easy", - "link": "https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping/" + "id": 1309, + "link": "https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping/", + "title": "Decrypt String from Alphabet to Integer Mapping" }, "1310": { - "id": 1310, "category": "Bit Manipulation", - "title": "XOR Queries of a Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/xor-queries-of-a-subarray/" + "id": 1310, + "link": "https://leetcode.com/problems/xor-queries-of-a-subarray/", + "title": "XOR Queries of a Subarray" }, "1311": { - "id": 1311, "category": "Graph Traversal", - "title": "Get Watched Videos by Your Friends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/get-watched-videos-by-your-friends/" + "id": 1311, + "link": "https://leetcode.com/problems/get-watched-videos-by-your-friends/", + "title": "Get Watched Videos by Your Friends" }, "1312": { - "id": 1312, "category": "Dynamic Programming", - "title": "Minimum Insertion Steps to Make a String Palindrome", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/" + "id": 1312, + "link": "https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/", + "title": "Minimum Insertion Steps to Make a String Palindrome" }, "1313": { - "id": 1313, "category": "Array & Hashing", - "title": "Decompress Run-Length Encoded List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/decompress-run-length-encoded-list/" + "id": 1313, + "link": "https://leetcode.com/problems/decompress-run-length-encoded-list/", + "title": "Decompress Run-Length Encoded List" }, "1314": { - "id": 1314, "category": "Array & Hashing", - "title": "Matrix Block Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/matrix-block-sum/" + "id": 1314, + "link": "https://leetcode.com/problems/matrix-block-sum/", + "title": "Matrix Block Sum" }, "1315": { - "id": 1315, "category": "Tree", - "title": "Sum of Nodes with Even-Valued Grandparent", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/" + "id": 1315, + "link": "https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/", + "title": "Sum of Nodes with Even-Valued Grandparent" }, "1316": { - "id": 1316, "category": "Trie", - "title": "Distinct Echo Substrings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distinct-echo-substrings/" + "id": 1316, + "link": "https://leetcode.com/problems/distinct-echo-substrings/", + "title": "Distinct Echo Substrings" }, "1317": { - "id": 1317, "category": "Math & Geometry", - "title": "Convert Integer to the Sum of Two No-Zero Integers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/" + "id": 1317, + "link": "https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/", + "title": "Convert Integer to the Sum of Two No-Zero Integers" }, "1318": { - "id": 1318, "category": "Bit Manipulation", - "title": "Minimum Flips to Make a OR b Equal to c", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c/" + "id": 1318, + "link": "https://leetcode.com/problems/minimum-flips-to-make-a-or-b-equal-to-c/", + "title": "Minimum Flips to Make a OR b Equal to c" }, "1319": { - "id": 1319, "category": "Graph Traversal", - "title": "Number of Operations to Make Network Connected", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-operations-to-make-network-connected/" + "id": 1319, + "link": "https://leetcode.com/problems/number-of-operations-to-make-network-connected/", + "title": "Number of Operations to Make Network Connected" }, "1320": { - "id": 1320, "category": "Dynamic Programming", - "title": "Minimum Distance to Type a Word Using Two Fingers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/" + "id": 1320, + "link": "https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers/", + "title": "Minimum Distance to Type a Word Using Two Fingers" }, "1321": { - "id": 1321, "category": "Database", - "title": "Restaurant Growth", "difficulty": "Medium", - "link": "https://leetcode.com/problems/restaurant-growth/" + "id": 1321, + "link": "https://leetcode.com/problems/restaurant-growth/", + "title": "Restaurant Growth" }, "1322": { - "id": 1322, "category": "Database", - "title": "Ads Performance", "difficulty": "Easy", - "link": "https://leetcode.com/problems/ads-performance/" + "id": 1322, + "link": "https://leetcode.com/problems/ads-performance/", + "title": "Ads Performance" }, "1323": { - "id": 1323, "category": "Greedy", - "title": "Maximum 69 Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-69-number/" + "id": 1323, + "link": "https://leetcode.com/problems/maximum-69-number/", + "title": "Maximum 69 Number" }, "1324": { - "id": 1324, "category": "Array & Hashing", - "title": "Print Words Vertically", "difficulty": "Medium", - "link": "https://leetcode.com/problems/print-words-vertically/" + "id": 1324, + "link": "https://leetcode.com/problems/print-words-vertically/", + "title": "Print Words Vertically" }, "1325": { - "id": 1325, "category": "Tree", - "title": "Delete Leaves With a Given Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-leaves-with-a-given-value/" + "id": 1325, + "link": "https://leetcode.com/problems/delete-leaves-with-a-given-value/", + "title": "Delete Leaves With a Given Value" }, "1326": { - "id": 1326, "category": "Dynamic Programming", - "title": "Minimum Number of Taps to Open to Water a Garden", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden/" + "id": 1326, + "link": "https://leetcode.com/problems/minimum-number-of-taps-to-open-to-water-a-garden/", + "title": "Minimum Number of Taps to Open to Water a Garden" }, "1327": { - "id": 1327, "category": "Database", - "title": "List the Products Ordered in a Period", "difficulty": "Easy", - "link": "https://leetcode.com/problems/list-the-products-ordered-in-a-period/" + "id": 1327, + "link": "https://leetcode.com/problems/list-the-products-ordered-in-a-period/", + "title": "List the Products Ordered in a Period" }, "1328": { - "id": 1328, "category": "Greedy", - "title": "Break a Palindrome", "difficulty": "Medium", - "link": "https://leetcode.com/problems/break-a-palindrome/" + "id": 1328, + "link": "https://leetcode.com/problems/break-a-palindrome/", + "title": "Break a Palindrome" }, "1329": { - "id": 1329, "category": "Array & Hashing", - "title": "Sort the Matrix Diagonally", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-the-matrix-diagonally/" + "id": 1329, + "link": "https://leetcode.com/problems/sort-the-matrix-diagonally/", + "title": "Sort the Matrix Diagonally" }, "1330": { - "id": 1330, "category": "Greedy", - "title": "Reverse Subarray To Maximize Array Value", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reverse-subarray-to-maximize-array-value/" + "id": 1330, + "link": "https://leetcode.com/problems/reverse-subarray-to-maximize-array-value/", + "title": "Reverse Subarray To Maximize Array Value" }, "1331": { - "id": 1331, "category": "Array & Hashing", - "title": "Rank Transform of an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rank-transform-of-an-array/" + "id": 1331, + "link": "https://leetcode.com/problems/rank-transform-of-an-array/", + "title": "Rank Transform of an Array" }, "1332": { - "id": 1332, "category": "Two Pointers", - "title": "Remove Palindromic Subsequences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-palindromic-subsequences/" + "id": 1332, + "link": "https://leetcode.com/problems/remove-palindromic-subsequences/", + "title": "Remove Palindromic Subsequences" }, "1333": { - "id": 1333, "category": "Array & Hashing", - "title": "Filter Restaurants by Vegan-Friendly, Price and Distance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance/" + "id": 1333, + "link": "https://leetcode.com/problems/filter-restaurants-by-vegan-friendly-price-and-distance/", + "title": "Filter Restaurants by Vegan-Friendly, Price and Distance" }, "1334": { - "id": 1334, "category": "Graph Traversal", - "title": "Find the City With the Smallest Number of Neighbors at a Threshold Distance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/" + "id": 1334, + "link": "https://leetcode.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/", + "title": "Find the City With the Smallest Number of Neighbors at a Threshold Distance" }, "1335": { - "id": 1335, "category": "Dynamic Programming", - "title": "Minimum Difficulty of a Job Schedule", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/" + "id": 1335, + "link": "https://leetcode.com/problems/minimum-difficulty-of-a-job-schedule/", + "title": "Minimum Difficulty of a Job Schedule" }, "1336": { - "id": 1336, "category": "Database", - "title": "Number of Transactions per Visit", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-transactions-per-visit/" + "id": 1336, + "link": "https://leetcode.com/problems/number-of-transactions-per-visit/", + "title": "Number of Transactions per Visit" }, "1337": { - "id": 1337, "category": "Binary Search", - "title": "The K Weakest Rows in a Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/" + "id": 1337, + "link": "https://leetcode.com/problems/the-k-weakest-rows-in-a-matrix/", + "title": "The K Weakest Rows in a Matrix" }, "1338": { - "id": 1338, "category": "Heap (Priority Queue)", - "title": "Reduce Array Size to The Half", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reduce-array-size-to-the-half/" + "id": 1338, + "link": "https://leetcode.com/problems/reduce-array-size-to-the-half/", + "title": "Reduce Array Size to The Half" }, "1339": { - "id": 1339, "category": "Tree", - "title": "Maximum Product of Splitted Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/" + "id": 1339, + "link": "https://leetcode.com/problems/maximum-product-of-splitted-binary-tree/", + "title": "Maximum Product of Splitted Binary Tree" }, "1340": { - "id": 1340, "category": "Dynamic Programming", - "title": "Jump Game V", "difficulty": "Hard", - "link": "https://leetcode.com/problems/jump-game-v/" + "id": 1340, + "link": "https://leetcode.com/problems/jump-game-v/", + "title": "Jump Game V" }, "1341": { - "id": 1341, "category": "Database", - "title": "Movie Rating", "difficulty": "Medium", - "link": "https://leetcode.com/problems/movie-rating/" + "id": 1341, + "link": "https://leetcode.com/problems/movie-rating/", + "title": "Movie Rating" }, "1342": { - "id": 1342, "category": "Bit Manipulation", - "title": "Number of Steps to Reduce a Number to Zero", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/" + "id": 1342, + "link": "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/", + "title": "Number of Steps to Reduce a Number to Zero" }, "1343": { - "id": 1343, "category": "Sliding Window", - "title": "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/" + "id": 1343, + "link": "https://leetcode.com/problems/number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold/", + "title": "Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold" }, "1344": { - "id": 1344, "category": "Math & Geometry", - "title": "Angle Between Hands of a Clock", "difficulty": "Medium", - "link": "https://leetcode.com/problems/angle-between-hands-of-a-clock/" + "id": 1344, + "link": "https://leetcode.com/problems/angle-between-hands-of-a-clock/", + "title": "Angle Between Hands of a Clock" }, "1345": { - "id": 1345, "category": "Graph Traversal", - "title": "Jump Game IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/jump-game-iv/" + "id": 1345, + "link": "https://leetcode.com/problems/jump-game-iv/", + "title": "Jump Game IV" }, "1346": { - "id": 1346, "category": "Binary Search", - "title": "Check If N and Its Double Exist", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-n-and-its-double-exist/" + "id": 1346, + "link": "https://leetcode.com/problems/check-if-n-and-its-double-exist/", + "title": "Check If N and Its Double Exist" }, "1347": { - "id": 1347, "category": "Array & Hashing", - "title": "Minimum Number of Steps to Make Two Strings Anagram", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/" + "id": 1347, + "link": "https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/", + "title": "Minimum Number of Steps to Make Two Strings Anagram" }, "1348": { - "id": 1348, "category": "Binary Search", - "title": "Tweet Counts Per Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/tweet-counts-per-frequency/" + "id": 1348, + "link": "https://leetcode.com/problems/tweet-counts-per-frequency/", + "title": "Tweet Counts Per Frequency" }, "1349": { - "id": 1349, "category": "Dynamic Programming", - "title": "Maximum Students Taking Exam", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-students-taking-exam/" + "id": 1349, + "link": "https://leetcode.com/problems/maximum-students-taking-exam/", + "title": "Maximum Students Taking Exam" }, "1350": { - "id": 1350, "category": "Database", - "title": "Students With Invalid Departments", "difficulty": "Easy", - "link": "https://leetcode.com/problems/students-with-invalid-departments/" + "id": 1350, + "link": "https://leetcode.com/problems/students-with-invalid-departments/", + "title": "Students With Invalid Departments" }, "1351": { - "id": 1351, "category": "Binary Search", - "title": "Count Negative Numbers in a Sorted Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/" + "id": 1351, + "link": "https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/", + "title": "Count Negative Numbers in a Sorted Matrix" }, "1352": { - "id": 1352, "category": "Math & Geometry", - "title": "Product of the Last K Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-of-the-last-k-numbers/" + "id": 1352, + "link": "https://leetcode.com/problems/product-of-the-last-k-numbers/", + "title": "Product of the Last K Numbers" }, "1353": { - "id": 1353, "category": "Heap (Priority Queue)", - "title": "Maximum Number of Events That Can Be Attended", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended/" + "id": 1353, + "link": "https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended/", + "title": "Maximum Number of Events That Can Be Attended" }, "1354": { - "id": 1354, "category": "Heap (Priority Queue)", - "title": "Construct Target Array With Multiple Sums", "difficulty": "Hard", - "link": "https://leetcode.com/problems/construct-target-array-with-multiple-sums/" + "id": 1354, + "link": "https://leetcode.com/problems/construct-target-array-with-multiple-sums/", + "title": "Construct Target Array With Multiple Sums" }, "1355": { - "id": 1355, "category": "Database", - "title": "Activity Participants", "difficulty": "Medium", - "link": "https://leetcode.com/problems/activity-participants/" + "id": 1355, + "link": "https://leetcode.com/problems/activity-participants/", + "title": "Activity Participants" }, "1356": { - "id": 1356, "category": "Bit Manipulation", - "title": "Sort Integers by The Number of 1 Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits/" + "id": 1356, + "link": "https://leetcode.com/problems/sort-integers-by-the-number-of-1-bits/", + "title": "Sort Integers by The Number of 1 Bits" }, "1357": { - "id": 1357, "category": "Array & Hashing", - "title": "Apply Discount Every n Orders", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-discount-every-n-orders/" + "id": 1357, + "link": "https://leetcode.com/problems/apply-discount-every-n-orders/", + "title": "Apply Discount Every n Orders" }, "1358": { - "id": 1358, "category": "Sliding Window", - "title": "Number of Substrings Containing All Three Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/" + "id": 1358, + "link": "https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/", + "title": "Number of Substrings Containing All Three Characters" }, "1359": { - "id": 1359, "category": "Dynamic Programming", - "title": "Count All Valid Pickup and Delivery Options", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/" + "id": 1359, + "link": "https://leetcode.com/problems/count-all-valid-pickup-and-delivery-options/", + "title": "Count All Valid Pickup and Delivery Options" }, "1360": { - "id": 1360, "category": "Math & Geometry", - "title": "Number of Days Between Two Dates", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-days-between-two-dates/" + "id": 1360, + "link": "https://leetcode.com/problems/number-of-days-between-two-dates/", + "title": "Number of Days Between Two Dates" }, "1361": { - "id": 1361, "category": "Tree", - "title": "Validate Binary Tree Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/validate-binary-tree-nodes/" + "id": 1361, + "link": "https://leetcode.com/problems/validate-binary-tree-nodes/", + "title": "Validate Binary Tree Nodes" }, "1362": { - "id": 1362, "category": "Math & Geometry", - "title": "Closest Divisors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-divisors/" + "id": 1362, + "link": "https://leetcode.com/problems/closest-divisors/", + "title": "Closest Divisors" }, "1363": { - "id": 1363, "category": "Dynamic Programming", - "title": "Largest Multiple of Three", "difficulty": "Hard", - "link": "https://leetcode.com/problems/largest-multiple-of-three/" + "id": 1363, + "link": "https://leetcode.com/problems/largest-multiple-of-three/", + "title": "Largest Multiple of Three" }, "1364": { - "id": 1364, "category": "Database", - "title": "Number of Trusted Contacts of a Customer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer/" + "id": 1364, + "link": "https://leetcode.com/problems/number-of-trusted-contacts-of-a-customer/", + "title": "Number of Trusted Contacts of a Customer" }, "1365": { - "id": 1365, "category": "Array & Hashing", - "title": "How Many Numbers Are Smaller Than the Current Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/" + "id": 1365, + "link": "https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/", + "title": "How Many Numbers Are Smaller Than the Current Number" }, "1366": { - "id": 1366, "category": "Array & Hashing", - "title": "Rank Teams by Votes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rank-teams-by-votes/" + "id": 1366, + "link": "https://leetcode.com/problems/rank-teams-by-votes/", + "title": "Rank Teams by Votes" }, "1367": { - "id": 1367, "category": "Tree", - "title": "Linked List in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/linked-list-in-binary-tree/" + "id": 1367, + "link": "https://leetcode.com/problems/linked-list-in-binary-tree/", + "title": "Linked List in Binary Tree" }, "1368": { - "id": 1368, "category": "Graph Traversal", - "title": "Minimum Cost to Make at Least One Valid Path in a Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/" + "id": 1368, + "link": "https://leetcode.com/problems/minimum-cost-to-make-at-least-one-valid-path-in-a-grid/", + "title": "Minimum Cost to Make at Least One Valid Path in a Grid" }, "1369": { - "id": 1369, "category": "Database", - "title": "Get the Second Most Recent Activity", "difficulty": "Hard", - "link": "https://leetcode.com/problems/get-the-second-most-recent-activity/" + "id": 1369, + "link": "https://leetcode.com/problems/get-the-second-most-recent-activity/", + "title": "Get the Second Most Recent Activity" }, "1370": { - "id": 1370, "category": "Array & Hashing", - "title": "Increasing Decreasing String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/increasing-decreasing-string/" + "id": 1370, + "link": "https://leetcode.com/problems/increasing-decreasing-string/", + "title": "Increasing Decreasing String" }, "1371": { - "id": 1371, "category": "Bit Manipulation", - "title": "Find the Longest Substring Containing Vowels in Even Counts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts/" + "id": 1371, + "link": "https://leetcode.com/problems/find-the-longest-substring-containing-vowels-in-even-counts/", + "title": "Find the Longest Substring Containing Vowels in Even Counts" }, "1372": { - "id": 1372, "category": "Tree", - "title": "Longest ZigZag Path in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/" + "id": 1372, + "link": "https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/", + "title": "Longest ZigZag Path in a Binary Tree" }, "1373": { - "id": 1373, "category": "Tree", - "title": "Maximum Sum BST in Binary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/" + "id": 1373, + "link": "https://leetcode.com/problems/maximum-sum-bst-in-binary-tree/", + "title": "Maximum Sum BST in Binary Tree" }, "1374": { - "id": 1374, "category": "Array & Hashing", - "title": "Generate a String With Characters That Have Odd Counts", "difficulty": "Easy", - "link": "https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/" + "id": 1374, + "link": "https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/", + "title": "Generate a String With Characters That Have Odd Counts" }, "1375": { - "id": 1375, "category": "Array & Hashing", - "title": "Number of Times Binary String Is Prefix-Aligned", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned/" + "id": 1375, + "link": "https://leetcode.com/problems/number-of-times-binary-string-is-prefix-aligned/", + "title": "Number of Times Binary String Is Prefix-Aligned" }, "1376": { - "id": 1376, "category": "Tree", - "title": "Time Needed to Inform All Employees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/time-needed-to-inform-all-employees/" + "id": 1376, + "link": "https://leetcode.com/problems/time-needed-to-inform-all-employees/", + "title": "Time Needed to Inform All Employees" }, "1377": { - "id": 1377, "category": "Tree", - "title": "Frog Position After T Seconds", "difficulty": "Hard", - "link": "https://leetcode.com/problems/frog-position-after-t-seconds/" + "id": 1377, + "link": "https://leetcode.com/problems/frog-position-after-t-seconds/", + "title": "Frog Position After T Seconds" }, "1378": { - "id": 1378, "category": "Database", - "title": "Replace Employee ID With The Unique Identifier", "difficulty": "Easy", - "link": "https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/" + "id": 1378, + "link": "https://leetcode.com/problems/replace-employee-id-with-the-unique-identifier/", + "title": "Replace Employee ID With The Unique Identifier" }, "1379": { - "id": 1379, "category": "Tree", - "title": "Find a Corresponding Node of a Binary Tree in a Clone of That Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/" + "id": 1379, + "link": "https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree/", + "title": "Find a Corresponding Node of a Binary Tree in a Clone of That Tree" }, "1380": { - "id": 1380, "category": "Array & Hashing", - "title": "Lucky Numbers in a Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/lucky-numbers-in-a-matrix/" + "id": 1380, + "link": "https://leetcode.com/problems/lucky-numbers-in-a-matrix/", + "title": "Lucky Numbers in a Matrix" }, "1381": { - "id": 1381, "category": "Stack", - "title": "Design a Stack With Increment Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-stack-with-increment-operation/" + "id": 1381, + "link": "https://leetcode.com/problems/design-a-stack-with-increment-operation/", + "title": "Design a Stack With Increment Operation" }, "1382": { - "id": 1382, "category": "Tree", - "title": "Balance a Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/balance-a-binary-search-tree/" + "id": 1382, + "link": "https://leetcode.com/problems/balance-a-binary-search-tree/", + "title": "Balance a Binary Search Tree" }, "1383": { - "id": 1383, "category": "Heap (Priority Queue)", - "title": "Maximum Performance of a Team", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-performance-of-a-team/" + "id": 1383, + "link": "https://leetcode.com/problems/maximum-performance-of-a-team/", + "title": "Maximum Performance of a Team" }, "1384": { - "id": 1384, "category": "Database", - "title": "Total Sales Amount by Year", "difficulty": "Hard", - "link": "https://leetcode.com/problems/total-sales-amount-by-year/" + "id": 1384, + "link": "https://leetcode.com/problems/total-sales-amount-by-year/", + "title": "Total Sales Amount by Year" }, "1385": { - "id": 1385, "category": "Binary Search", - "title": "Find the Distance Value Between Two Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-distance-value-between-two-arrays/" + "id": 1385, + "link": "https://leetcode.com/problems/find-the-distance-value-between-two-arrays/", + "title": "Find the Distance Value Between Two Arrays" }, "1386": { - "id": 1386, "category": "Bit Manipulation", - "title": "Cinema Seat Allocation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cinema-seat-allocation/" + "id": 1386, + "link": "https://leetcode.com/problems/cinema-seat-allocation/", + "title": "Cinema Seat Allocation" }, "1387": { - "id": 1387, "category": "Dynamic Programming", - "title": "Sort Integers by The Power Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-integers-by-the-power-value/" + "id": 1387, + "link": "https://leetcode.com/problems/sort-integers-by-the-power-value/", + "title": "Sort Integers by The Power Value" }, "1388": { - "id": 1388, "category": "Dynamic Programming", - "title": "Pizza With 3n Slices", "difficulty": "Hard", - "link": "https://leetcode.com/problems/pizza-with-3n-slices/" + "id": 1388, + "link": "https://leetcode.com/problems/pizza-with-3n-slices/", + "title": "Pizza With 3n Slices" }, "1389": { - "id": 1389, "category": "Array & Hashing", - "title": "Create Target Array in the Given Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-target-array-in-the-given-order/" + "id": 1389, + "link": "https://leetcode.com/problems/create-target-array-in-the-given-order/", + "title": "Create Target Array in the Given Order" }, "1390": { - "id": 1390, "category": "Math & Geometry", - "title": "Four Divisors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/four-divisors/" + "id": 1390, + "link": "https://leetcode.com/problems/four-divisors/", + "title": "Four Divisors" }, "1391": { - "id": 1391, "category": "Graph Traversal", - "title": "Check if There is a Valid Path in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid/" + "id": 1391, + "link": "https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid/", + "title": "Check if There is a Valid Path in a Grid" }, "1392": { - "id": 1392, "category": "Array & Hashing", - "title": "Longest Happy Prefix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-happy-prefix/" + "id": 1392, + "link": "https://leetcode.com/problems/longest-happy-prefix/", + "title": "Longest Happy Prefix" }, "1393": { - "id": 1393, "category": "Database", - "title": "Capital Gain/Loss", "difficulty": "Medium", - "link": "https://leetcode.com/problems/capital-gainloss/" + "id": 1393, + "link": "https://leetcode.com/problems/capital-gainloss/", + "title": "Capital Gain/Loss" }, "1394": { - "id": 1394, "category": "Array & Hashing", - "title": "Find Lucky Integer in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-lucky-integer-in-an-array/" + "id": 1394, + "link": "https://leetcode.com/problems/find-lucky-integer-in-an-array/", + "title": "Find Lucky Integer in an Array" }, "1395": { - "id": 1395, "category": "Tree", - "title": "Count Number of Teams", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-teams/" + "id": 1395, + "link": "https://leetcode.com/problems/count-number-of-teams/", + "title": "Count Number of Teams" }, "1396": { - "id": 1396, "category": "Array & Hashing", - "title": "Design Underground System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-underground-system/" + "id": 1396, + "link": "https://leetcode.com/problems/design-underground-system/", + "title": "Design Underground System" }, "1397": { - "id": 1397, "category": "Dynamic Programming", - "title": "Find All Good Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-all-good-strings/" + "id": 1397, + "link": "https://leetcode.com/problems/find-all-good-strings/", + "title": "Find All Good Strings" }, "1398": { - "id": 1398, "category": "Database", - "title": "Customers Who Bought Products A and B but Not C", "difficulty": "Medium", - "link": "https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c/" + "id": 1398, + "link": "https://leetcode.com/problems/customers-who-bought-products-a-and-b-but-not-c/", + "title": "Customers Who Bought Products A and B but Not C" }, "1399": { - "id": 1399, "category": "Math & Geometry", - "title": "Count Largest Group", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-largest-group/" + "id": 1399, + "link": "https://leetcode.com/problems/count-largest-group/", + "title": "Count Largest Group" }, "1400": { - "id": 1400, "category": "Greedy", - "title": "Construct K Palindrome Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-k-palindrome-strings/" + "id": 1400, + "link": "https://leetcode.com/problems/construct-k-palindrome-strings/", + "title": "Construct K Palindrome Strings" }, "1401": { - "id": 1401, "category": "Math & Geometry", - "title": "Circle and Rectangle Overlapping", "difficulty": "Medium", - "link": "https://leetcode.com/problems/circle-and-rectangle-overlapping/" + "id": 1401, + "link": "https://leetcode.com/problems/circle-and-rectangle-overlapping/", + "title": "Circle and Rectangle Overlapping" }, "1402": { - "id": 1402, "category": "Dynamic Programming", - "title": "Reducing Dishes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/reducing-dishes/" + "id": 1402, + "link": "https://leetcode.com/problems/reducing-dishes/", + "title": "Reducing Dishes" }, "1403": { - "id": 1403, "category": "Greedy", - "title": "Minimum Subsequence in Non-Increasing Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order/" + "id": 1403, + "link": "https://leetcode.com/problems/minimum-subsequence-in-non-increasing-order/", + "title": "Minimum Subsequence in Non-Increasing Order" }, "1404": { - "id": 1404, "category": "Bit Manipulation", - "title": "Number of Steps to Reduce a Number in Binary Representation to One", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/" + "id": 1404, + "link": "https://leetcode.com/problems/number-of-steps-to-reduce-a-number-in-binary-representation-to-one/", + "title": "Number of Steps to Reduce a Number in Binary Representation to One" }, "1405": { - "id": 1405, "category": "Heap (Priority Queue)", - "title": "Longest Happy String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-happy-string/" + "id": 1405, + "link": "https://leetcode.com/problems/longest-happy-string/", + "title": "Longest Happy String" }, "1406": { - "id": 1406, "category": "Dynamic Programming", - "title": "Stone Game III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stone-game-iii/" + "id": 1406, + "link": "https://leetcode.com/problems/stone-game-iii/", + "title": "Stone Game III" }, "1407": { - "id": 1407, "category": "Database", - "title": "Top Travellers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/top-travellers/" + "id": 1407, + "link": "https://leetcode.com/problems/top-travellers/", + "title": "Top Travellers" }, "1408": { - "id": 1408, "category": "Array & Hashing", - "title": "String Matching in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/string-matching-in-an-array/" + "id": 1408, + "link": "https://leetcode.com/problems/string-matching-in-an-array/", + "title": "String Matching in an Array" }, "1409": { - "id": 1409, "category": "Tree", - "title": "Queries on a Permutation With Key", "difficulty": "Medium", - "link": "https://leetcode.com/problems/queries-on-a-permutation-with-key/" + "id": 1409, + "link": "https://leetcode.com/problems/queries-on-a-permutation-with-key/", + "title": "Queries on a Permutation With Key" }, "1410": { - "id": 1410, "category": "Array & Hashing", - "title": "HTML Entity Parser", "difficulty": "Medium", - "link": "https://leetcode.com/problems/html-entity-parser/" + "id": 1410, + "link": "https://leetcode.com/problems/html-entity-parser/", + "title": "HTML Entity Parser" }, "1411": { - "id": 1411, "category": "Dynamic Programming", - "title": "Number of Ways to Paint N \u00d7 3 Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid/" + "id": 1411, + "link": "https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid/", + "title": "Number of Ways to Paint N × 3 Grid" }, "1412": { - "id": 1412, "category": "Database", - "title": "Find the Quiet Students in All Exams", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-quiet-students-in-all-exams/" + "id": 1412, + "link": "https://leetcode.com/problems/find-the-quiet-students-in-all-exams/", + "title": "Find the Quiet Students in All Exams" }, "1413": { - "id": 1413, "category": "Array & Hashing", - "title": "Minimum Value to Get Positive Step by Step Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/" + "id": 1413, + "link": "https://leetcode.com/problems/minimum-value-to-get-positive-step-by-step-sum/", + "title": "Minimum Value to Get Positive Step by Step Sum" }, "1414": { - "id": 1414, "category": "Greedy", - "title": "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/" + "id": 1414, + "link": "https://leetcode.com/problems/find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k/", + "title": "Find the Minimum Number of Fibonacci Numbers Whose Sum Is K" }, "1415": { - "id": 1415, "category": "Backtracking", - "title": "The k-th Lexicographical String of All Happy Strings of Length n", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/" + "id": 1415, + "link": "https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/", + "title": "The k-th Lexicographical String of All Happy Strings of Length n" }, "1416": { - "id": 1416, "category": "Dynamic Programming", - "title": "Restore The Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/restore-the-array/" + "id": 1416, + "link": "https://leetcode.com/problems/restore-the-array/", + "title": "Restore The Array" }, "1417": { - "id": 1417, "category": "Array & Hashing", - "title": "Reformat The String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reformat-the-string/" + "id": 1417, + "link": "https://leetcode.com/problems/reformat-the-string/", + "title": "Reformat The String" }, "1418": { - "id": 1418, "category": "Array & Hashing", - "title": "Display Table of Food Orders in a Restaurant", "difficulty": "Medium", - "link": "https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant/" + "id": 1418, + "link": "https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant/", + "title": "Display Table of Food Orders in a Restaurant" }, "1419": { - "id": 1419, "category": "Array & Hashing", - "title": "Minimum Number of Frogs Croaking", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-frogs-croaking/" + "id": 1419, + "link": "https://leetcode.com/problems/minimum-number-of-frogs-croaking/", + "title": "Minimum Number of Frogs Croaking" }, "1420": { - "id": 1420, "category": "Dynamic Programming", - "title": "Build Array Where You Can Find The Maximum Exactly K Comparisons", "difficulty": "Hard", - "link": "https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/" - }, - "1421": { - "id": 1421, - "category": "Database", - "title": "NPV Queries", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/npv-queries/" + "id": 1420, + "link": "https://leetcode.com/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/", + "title": "Build Array Where You Can Find The Maximum Exactly K Comparisons" }, + "1421": {"category": "Database", "difficulty": "Easy", "id": 1421, "link": "https://leetcode.com/problems/npv-queries/", "title": "NPV Queries"}, "1422": { - "id": 1422, "category": "Array & Hashing", - "title": "Maximum Score After Splitting a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-score-after-splitting-a-string/" + "id": 1422, + "link": "https://leetcode.com/problems/maximum-score-after-splitting-a-string/", + "title": "Maximum Score After Splitting a String" }, "1423": { - "id": 1423, "category": "Sliding Window", - "title": "Maximum Points You Can Obtain from Cards", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/" + "id": 1423, + "link": "https://leetcode.com/problems/maximum-points-you-can-obtain-from-cards/", + "title": "Maximum Points You Can Obtain from Cards" }, "1424": { - "id": 1424, "category": "Heap (Priority Queue)", - "title": "Diagonal Traverse II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/diagonal-traverse-ii/" + "id": 1424, + "link": "https://leetcode.com/problems/diagonal-traverse-ii/", + "title": "Diagonal Traverse II" }, "1425": { - "id": 1425, "category": "Dynamic Programming", - "title": "Constrained Subsequence Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/constrained-subsequence-sum/" + "id": 1425, + "link": "https://leetcode.com/problems/constrained-subsequence-sum/", + "title": "Constrained Subsequence Sum" }, "1426": { - "id": 1426, "category": "Array & Hashing", - "title": "Counting Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/counting-elements/" + "id": 1426, + "link": "https://leetcode.com/problems/counting-elements/", + "title": "Counting Elements" }, "1427": { - "id": 1427, "category": "Math & Geometry", - "title": "Perform String Shifts", "difficulty": "Easy", - "link": "https://leetcode.com/problems/perform-string-shifts/" + "id": 1427, + "link": "https://leetcode.com/problems/perform-string-shifts/", + "title": "Perform String Shifts" }, "1428": { - "id": 1428, "category": "Binary Search", - "title": "Leftmost Column with at Least a One", "difficulty": "Medium", - "link": "https://leetcode.com/problems/leftmost-column-with-at-least-a-one/" + "id": 1428, + "link": "https://leetcode.com/problems/leftmost-column-with-at-least-a-one/", + "title": "Leftmost Column with at Least a One" }, "1429": { - "id": 1429, "category": "Array & Hashing", - "title": "First Unique Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/first-unique-number/" + "id": 1429, + "link": "https://leetcode.com/problems/first-unique-number/", + "title": "First Unique Number" }, "1430": { - "id": 1430, "category": "Tree", - "title": "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/" + "id": 1430, + "link": "https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/", + "title": "Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree" }, "1431": { - "id": 1431, "category": "Array & Hashing", - "title": "Kids With the Greatest Number of Candies", "difficulty": "Easy", - "link": "https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/" + "id": 1431, + "link": "https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/", + "title": "Kids With the Greatest Number of Candies" }, "1432": { - "id": 1432, "category": "Greedy", - "title": "Max Difference You Can Get From Changing an Integer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer/" + "id": 1432, + "link": "https://leetcode.com/problems/max-difference-you-can-get-from-changing-an-integer/", + "title": "Max Difference You Can Get From Changing an Integer" }, "1433": { - "id": 1433, "category": "Greedy", - "title": "Check If a String Can Break Another String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-a-string-can-break-another-string/" + "id": 1433, + "link": "https://leetcode.com/problems/check-if-a-string-can-break-another-string/", + "title": "Check If a String Can Break Another String" }, "1434": { - "id": 1434, "category": "Dynamic Programming", - "title": "Number of Ways to Wear Different Hats to Each Other", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other/" + "id": 1434, + "link": "https://leetcode.com/problems/number-of-ways-to-wear-different-hats-to-each-other/", + "title": "Number of Ways to Wear Different Hats to Each Other" }, "1435": { - "id": 1435, "category": "Database", - "title": "Create a Session Bar Chart", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-a-session-bar-chart/" + "id": 1435, + "link": "https://leetcode.com/problems/create-a-session-bar-chart/", + "title": "Create a Session Bar Chart" }, "1436": { - "id": 1436, "category": "Array & Hashing", - "title": "Destination City", "difficulty": "Easy", - "link": "https://leetcode.com/problems/destination-city/" + "id": 1436, + "link": "https://leetcode.com/problems/destination-city/", + "title": "Destination City" }, "1437": { - "id": 1437, "category": "Array & Hashing", - "title": "Check If All 1's Are at Least Length K Places Away", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/" + "id": 1437, + "link": "https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/", + "title": "Check If All 1's Are at Least Length K Places Away" }, "1438": { - "id": 1438, "category": "Sliding Window", - "title": "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/" + "id": 1438, + "link": "https://leetcode.com/problems/longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit/", + "title": "Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit" }, "1439": { - "id": 1439, "category": "Binary Search", - "title": "Find the Kth Smallest Sum of a Matrix With Sorted Rows", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/" + "id": 1439, + "link": "https://leetcode.com/problems/find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows/", + "title": "Find the Kth Smallest Sum of a Matrix With Sorted Rows" }, "1440": { - "id": 1440, "category": "Database", - "title": "Evaluate Boolean Expression", "difficulty": "Medium", - "link": "https://leetcode.com/problems/evaluate-boolean-expression/" + "id": 1440, + "link": "https://leetcode.com/problems/evaluate-boolean-expression/", + "title": "Evaluate Boolean Expression" }, "1441": { - "id": 1441, "category": "Stack", - "title": "Build an Array With Stack Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/build-an-array-with-stack-operations/" + "id": 1441, + "link": "https://leetcode.com/problems/build-an-array-with-stack-operations/", + "title": "Build an Array With Stack Operations" }, "1442": { - "id": 1442, "category": "Bit Manipulation", - "title": "Count Triplets That Can Form Two Arrays of Equal XOR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/" + "id": 1442, + "link": "https://leetcode.com/problems/count-triplets-that-can-form-two-arrays-of-equal-xor/", + "title": "Count Triplets That Can Form Two Arrays of Equal XOR" }, "1443": { - "id": 1443, "category": "Tree", - "title": "Minimum Time to Collect All Apples in a Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/" + "id": 1443, + "link": "https://leetcode.com/problems/minimum-time-to-collect-all-apples-in-a-tree/", + "title": "Minimum Time to Collect All Apples in a Tree" }, "1444": { - "id": 1444, "category": "Dynamic Programming", - "title": "Number of Ways of Cutting a Pizza", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza/" + "id": 1444, + "link": "https://leetcode.com/problems/number-of-ways-of-cutting-a-pizza/", + "title": "Number of Ways of Cutting a Pizza" }, "1445": { - "id": 1445, "category": "Database", - "title": "Apples & Oranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apples-oranges/" + "id": 1445, + "link": "https://leetcode.com/problems/apples-oranges/", + "title": "Apples & Oranges" }, "1446": { - "id": 1446, "category": "Array & Hashing", - "title": "Consecutive Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/consecutive-characters/" + "id": 1446, + "link": "https://leetcode.com/problems/consecutive-characters/", + "title": "Consecutive Characters" }, "1447": { - "id": 1447, "category": "Math & Geometry", - "title": "Simplified Fractions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/simplified-fractions/" + "id": 1447, + "link": "https://leetcode.com/problems/simplified-fractions/", + "title": "Simplified Fractions" }, "1448": { - "id": 1448, "category": "Tree", - "title": "Count Good Nodes in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-good-nodes-in-binary-tree/" + "id": 1448, + "link": "https://leetcode.com/problems/count-good-nodes-in-binary-tree/", + "title": "Count Good Nodes in Binary Tree" }, "1449": { - "id": 1449, "category": "Dynamic Programming", - "title": "Form Largest Integer With Digits That Add up to Target", "difficulty": "Hard", - "link": "https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target/" + "id": 1449, + "link": "https://leetcode.com/problems/form-largest-integer-with-digits-that-add-up-to-target/", + "title": "Form Largest Integer With Digits That Add up to Target" }, "1450": { - "id": 1450, "category": "Array & Hashing", - "title": "Number of Students Doing Homework at a Given Time", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time/" + "id": 1450, + "link": "https://leetcode.com/problems/number-of-students-doing-homework-at-a-given-time/", + "title": "Number of Students Doing Homework at a Given Time" }, "1451": { - "id": 1451, "category": "Array & Hashing", - "title": "Rearrange Words in a Sentence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rearrange-words-in-a-sentence/" + "id": 1451, + "link": "https://leetcode.com/problems/rearrange-words-in-a-sentence/", + "title": "Rearrange Words in a Sentence" }, "1452": { - "id": 1452, "category": "Array & Hashing", - "title": "People Whose List of Favorite Companies Is Not a Subset of Another List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/" + "id": 1452, + "link": "https://leetcode.com/problems/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list/", + "title": "People Whose List of Favorite Companies Is Not a Subset of Another List" }, "1453": { - "id": 1453, "category": "Math & Geometry", - "title": "Maximum Number of Darts Inside of a Circular Dartboard", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/" + "id": 1453, + "link": "https://leetcode.com/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/", + "title": "Maximum Number of Darts Inside of a Circular Dartboard" }, "1454": { - "id": 1454, "category": "Database", - "title": "Active Users", "difficulty": "Medium", - "link": "https://leetcode.com/problems/active-users/" + "id": 1454, + "link": "https://leetcode.com/problems/active-users/", + "title": "Active Users" }, "1455": { - "id": 1455, "category": "Two Pointers", - "title": "Check If a Word Occurs As a Prefix of Any Word in a Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/" + "id": 1455, + "link": "https://leetcode.com/problems/check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence/", + "title": "Check If a Word Occurs As a Prefix of Any Word in a Sentence" }, "1456": { - "id": 1456, "category": "Sliding Window", - "title": "Maximum Number of Vowels in a Substring of Given Length", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/" + "id": 1456, + "link": "https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/", + "title": "Maximum Number of Vowels in a Substring of Given Length" }, "1457": { - "id": 1457, "category": "Tree", - "title": "Pseudo-Palindromic Paths in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree/" + "id": 1457, + "link": "https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree/", + "title": "Pseudo-Palindromic Paths in a Binary Tree" }, "1458": { - "id": 1458, "category": "Dynamic Programming", - "title": "Max Dot Product of Two Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-dot-product-of-two-subsequences/" + "id": 1458, + "link": "https://leetcode.com/problems/max-dot-product-of-two-subsequences/", + "title": "Max Dot Product of Two Subsequences" }, "1459": { - "id": 1459, "category": "Database", - "title": "Rectangles Area", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rectangles-area/" + "id": 1459, + "link": "https://leetcode.com/problems/rectangles-area/", + "title": "Rectangles Area" }, "1460": { - "id": 1460, "category": "Array & Hashing", - "title": "Make Two Arrays Equal by Reversing Subarrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/" + "id": 1460, + "link": "https://leetcode.com/problems/make-two-arrays-equal-by-reversing-subarrays/", + "title": "Make Two Arrays Equal by Reversing Subarrays" }, "1461": { - "id": 1461, "category": "Bit Manipulation", - "title": "Check If a String Contains All Binary Codes of Size K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k/" + "id": 1461, + "link": "https://leetcode.com/problems/check-if-a-string-contains-all-binary-codes-of-size-k/", + "title": "Check If a String Contains All Binary Codes of Size K" }, "1462": { - "id": 1462, "category": "Graph Traversal", - "title": "Course Schedule IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/course-schedule-iv/" + "id": 1462, + "link": "https://leetcode.com/problems/course-schedule-iv/", + "title": "Course Schedule IV" }, "1463": { - "id": 1463, "category": "Dynamic Programming", - "title": "Cherry Pickup II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cherry-pickup-ii/" + "id": 1463, + "link": "https://leetcode.com/problems/cherry-pickup-ii/", + "title": "Cherry Pickup II" }, "1464": { - "id": 1464, "category": "Heap (Priority Queue)", - "title": "Maximum Product of Two Elements in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/" + "id": 1464, + "link": "https://leetcode.com/problems/maximum-product-of-two-elements-in-an-array/", + "title": "Maximum Product of Two Elements in an Array" }, "1465": { - "id": 1465, "category": "Greedy", - "title": "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/" + "id": 1465, + "link": "https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/", + "title": "Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts" }, "1466": { - "id": 1466, "category": "Graph Traversal", - "title": "Reorder Routes to Make All Paths Lead to the City Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/" + "id": 1466, + "link": "https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/", + "title": "Reorder Routes to Make All Paths Lead to the City Zero" }, "1467": { - "id": 1467, "category": "Dynamic Programming", - "title": "Probability of a Two Boxes Having The Same Number of Distinct Balls", "difficulty": "Hard", - "link": "https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/" + "id": 1467, + "link": "https://leetcode.com/problems/probability-of-a-two-boxes-having-the-same-number-of-distinct-balls/", + "title": "Probability of a Two Boxes Having The Same Number of Distinct Balls" }, "1468": { - "id": 1468, "category": "Database", - "title": "Calculate Salaries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-salaries/" + "id": 1468, + "link": "https://leetcode.com/problems/calculate-salaries/", + "title": "Calculate Salaries" }, "1469": { - "id": 1469, "category": "Tree", - "title": "Find All The Lonely Nodes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-all-the-lonely-nodes/" + "id": 1469, + "link": "https://leetcode.com/problems/find-all-the-lonely-nodes/", + "title": "Find All The Lonely Nodes" }, "1470": { - "id": 1470, "category": "Array & Hashing", - "title": "Shuffle the Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shuffle-the-array/" + "id": 1470, + "link": "https://leetcode.com/problems/shuffle-the-array/", + "title": "Shuffle the Array" }, "1471": { - "id": 1471, "category": "Two Pointers", - "title": "The k Strongest Values in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-k-strongest-values-in-an-array/" + "id": 1471, + "link": "https://leetcode.com/problems/the-k-strongest-values-in-an-array/", + "title": "The k Strongest Values in an Array" }, "1472": { - "id": 1472, "category": "Stack", - "title": "Design Browser History", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-browser-history/" + "id": 1472, + "link": "https://leetcode.com/problems/design-browser-history/", + "title": "Design Browser History" }, "1473": { - "id": 1473, "category": "Dynamic Programming", - "title": "Paint House III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/paint-house-iii/" + "id": 1473, + "link": "https://leetcode.com/problems/paint-house-iii/", + "title": "Paint House III" }, "1474": { - "id": 1474, "category": "Linked List", - "title": "Delete N Nodes After M Nodes of a Linked List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/" + "id": 1474, + "link": "https://leetcode.com/problems/delete-n-nodes-after-m-nodes-of-a-linked-list/", + "title": "Delete N Nodes After M Nodes of a Linked List" }, "1475": { - "id": 1475, "category": "Stack", - "title": "Final Prices With a Special Discount in a Shop", "difficulty": "Easy", - "link": "https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/" + "id": 1475, + "link": "https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/", + "title": "Final Prices With a Special Discount in a Shop" }, "1476": { - "id": 1476, "category": "Array & Hashing", - "title": "Subrectangle Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subrectangle-queries/" + "id": 1476, + "link": "https://leetcode.com/problems/subrectangle-queries/", + "title": "Subrectangle Queries" }, "1477": { - "id": 1477, "category": "Dynamic Programming", - "title": "Find Two Non-overlapping Sub-arrays Each With Target Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/" + "id": 1477, + "link": "https://leetcode.com/problems/find-two-non-overlapping-sub-arrays-each-with-target-sum/", + "title": "Find Two Non-overlapping Sub-arrays Each With Target Sum" }, "1478": { - "id": 1478, "category": "Dynamic Programming", - "title": "Allocate Mailboxes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/allocate-mailboxes/" + "id": 1478, + "link": "https://leetcode.com/problems/allocate-mailboxes/", + "title": "Allocate Mailboxes" }, "1479": { - "id": 1479, "category": "Database", - "title": "Sales by Day of the Week", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sales-by-day-of-the-week/" + "id": 1479, + "link": "https://leetcode.com/problems/sales-by-day-of-the-week/", + "title": "Sales by Day of the Week" }, "1480": { - "id": 1480, "category": "Array & Hashing", - "title": "Running Sum of 1d Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/running-sum-of-1d-array/" + "id": 1480, + "link": "https://leetcode.com/problems/running-sum-of-1d-array/", + "title": "Running Sum of 1d Array" }, "1481": { - "id": 1481, "category": "Greedy", - "title": "Least Number of Unique Integers after K Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/" + "id": 1481, + "link": "https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/", + "title": "Least Number of Unique Integers after K Removals" }, "1482": { - "id": 1482, "category": "Binary Search", - "title": "Minimum Number of Days to Make m Bouquets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/" + "id": 1482, + "link": "https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/", + "title": "Minimum Number of Days to Make m Bouquets" }, "1483": { - "id": 1483, "category": "Tree", - "title": "Kth Ancestor of a Tree Node", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-ancestor-of-a-tree-node/" + "id": 1483, + "link": "https://leetcode.com/problems/kth-ancestor-of-a-tree-node/", + "title": "Kth Ancestor of a Tree Node" }, "1484": { - "id": 1484, "category": "Database", - "title": "Group Sold Products By The Date", "difficulty": "Easy", - "link": "https://leetcode.com/problems/group-sold-products-by-the-date/" + "id": 1484, + "link": "https://leetcode.com/problems/group-sold-products-by-the-date/", + "title": "Group Sold Products By The Date" }, "1485": { - "id": 1485, "category": "Tree", - "title": "Clone Binary Tree With Random Pointer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/clone-binary-tree-with-random-pointer/" + "id": 1485, + "link": "https://leetcode.com/problems/clone-binary-tree-with-random-pointer/", + "title": "Clone Binary Tree With Random Pointer" }, "1486": { - "id": 1486, "category": "Bit Manipulation", - "title": "XOR Operation in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/xor-operation-in-an-array/" + "id": 1486, + "link": "https://leetcode.com/problems/xor-operation-in-an-array/", + "title": "XOR Operation in an Array" }, "1487": { - "id": 1487, "category": "Array & Hashing", - "title": "Making File Names Unique", "difficulty": "Medium", - "link": "https://leetcode.com/problems/making-file-names-unique/" + "id": 1487, + "link": "https://leetcode.com/problems/making-file-names-unique/", + "title": "Making File Names Unique" }, "1488": { - "id": 1488, "category": "Binary Search", - "title": "Avoid Flood in The City", "difficulty": "Medium", - "link": "https://leetcode.com/problems/avoid-flood-in-the-city/" + "id": 1488, + "link": "https://leetcode.com/problems/avoid-flood-in-the-city/", + "title": "Avoid Flood in The City" }, "1489": { - "id": 1489, "category": "Tree", - "title": "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/" + "id": 1489, + "link": "https://leetcode.com/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree/", + "title": "Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree" }, "1490": { - "id": 1490, "category": "Tree", - "title": "Clone N-ary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/clone-n-ary-tree/" + "id": 1490, + "link": "https://leetcode.com/problems/clone-n-ary-tree/", + "title": "Clone N-ary Tree" }, "1491": { - "id": 1491, "category": "Array & Hashing", - "title": "Average Salary Excluding the Minimum and Maximum Salary", "difficulty": "Easy", - "link": "https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/" + "id": 1491, + "link": "https://leetcode.com/problems/average-salary-excluding-the-minimum-and-maximum-salary/", + "title": "Average Salary Excluding the Minimum and Maximum Salary" }, "1492": { - "id": 1492, "category": "Math & Geometry", - "title": "The kth Factor of n", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-kth-factor-of-n/" + "id": 1492, + "link": "https://leetcode.com/problems/the-kth-factor-of-n/", + "title": "The kth Factor of n" }, "1493": { - "id": 1493, "category": "Dynamic Programming", - "title": "Longest Subarray of 1's After Deleting One Element", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element/" + "id": 1493, + "link": "https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element/", + "title": "Longest Subarray of 1's After Deleting One Element" }, "1494": { - "id": 1494, "category": "Graph Traversal", - "title": "Parallel Courses II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/parallel-courses-ii/" + "id": 1494, + "link": "https://leetcode.com/problems/parallel-courses-ii/", + "title": "Parallel Courses II" }, "1495": { - "id": 1495, "category": "Database", - "title": "Friendly Movies Streamed Last Month", "difficulty": "Easy", - "link": "https://leetcode.com/problems/friendly-movies-streamed-last-month/" + "id": 1495, + "link": "https://leetcode.com/problems/friendly-movies-streamed-last-month/", + "title": "Friendly Movies Streamed Last Month" }, "1496": { - "id": 1496, "category": "Array & Hashing", - "title": "Path Crossing", "difficulty": "Easy", - "link": "https://leetcode.com/problems/path-crossing/" + "id": 1496, + "link": "https://leetcode.com/problems/path-crossing/", + "title": "Path Crossing" }, "1497": { - "id": 1497, "category": "Array & Hashing", - "title": "Check If Array Pairs Are Divisible by k", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k/" + "id": 1497, + "link": "https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k/", + "title": "Check If Array Pairs Are Divisible by k" }, "1498": { - "id": 1498, "category": "Binary Search", - "title": "Number of Subsequences That Satisfy the Given Sum Condition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/" + "id": 1498, + "link": "https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/", + "title": "Number of Subsequences That Satisfy the Given Sum Condition" }, "1499": { - "id": 1499, "category": "Sliding Window", - "title": "Max Value of Equation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/max-value-of-equation/" + "id": 1499, + "link": "https://leetcode.com/problems/max-value-of-equation/", + "title": "Max Value of Equation" }, "1500": { - "id": 1500, "category": "Heap (Priority Queue)", - "title": "Design a File Sharing System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-file-sharing-system/" + "id": 1500, + "link": "https://leetcode.com/problems/design-a-file-sharing-system/", + "title": "Design a File Sharing System" }, "1501": { - "id": 1501, "category": "Database", - "title": "Countries You Can Safely Invest In", "difficulty": "Medium", - "link": "https://leetcode.com/problems/countries-you-can-safely-invest-in/" + "id": 1501, + "link": "https://leetcode.com/problems/countries-you-can-safely-invest-in/", + "title": "Countries You Can Safely Invest In" }, "1502": { - "id": 1502, "category": "Array & Hashing", - "title": "Can Make Arithmetic Progression From Sequence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/" + "id": 1502, + "link": "https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/", + "title": "Can Make Arithmetic Progression From Sequence" }, "1503": { - "id": 1503, "category": "Array & Hashing", - "title": "Last Moment Before All Ants Fall Out of a Plank", "difficulty": "Medium", - "link": "https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank/" + "id": 1503, + "link": "https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank/", + "title": "Last Moment Before All Ants Fall Out of a Plank" }, "1504": { - "id": 1504, "category": "Dynamic Programming", - "title": "Count Submatrices With All Ones", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-submatrices-with-all-ones/" + "id": 1504, + "link": "https://leetcode.com/problems/count-submatrices-with-all-ones/", + "title": "Count Submatrices With All Ones" }, "1505": { - "id": 1505, "category": "Tree", - "title": "Minimum Possible Integer After at Most K Adjacent Swaps On Digits", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/" + "id": 1505, + "link": "https://leetcode.com/problems/minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits/", + "title": "Minimum Possible Integer After at Most K Adjacent Swaps On Digits" }, "1506": { - "id": 1506, "category": "Tree", - "title": "Find Root of N-Ary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-root-of-n-ary-tree/" + "id": 1506, + "link": "https://leetcode.com/problems/find-root-of-n-ary-tree/", + "title": "Find Root of N-Ary Tree" }, "1507": { - "id": 1507, "category": "Array & Hashing", - "title": "Reformat Date", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reformat-date/" + "id": 1507, + "link": "https://leetcode.com/problems/reformat-date/", + "title": "Reformat Date" }, "1508": { - "id": 1508, "category": "Binary Search", - "title": "Range Sum of Sorted Subarray Sums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/" + "id": 1508, + "link": "https://leetcode.com/problems/range-sum-of-sorted-subarray-sums/", + "title": "Range Sum of Sorted Subarray Sums" }, "1509": { - "id": 1509, "category": "Greedy", - "title": "Minimum Difference Between Largest and Smallest Value in Three Moves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/" + "id": 1509, + "link": "https://leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/", + "title": "Minimum Difference Between Largest and Smallest Value in Three Moves" }, "1510": { - "id": 1510, "category": "Dynamic Programming", - "title": "Stone Game IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stone-game-iv/" + "id": 1510, + "link": "https://leetcode.com/problems/stone-game-iv/", + "title": "Stone Game IV" }, "1511": { - "id": 1511, "category": "Database", - "title": "Customer Order Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/customer-order-frequency/" + "id": 1511, + "link": "https://leetcode.com/problems/customer-order-frequency/", + "title": "Customer Order Frequency" }, "1512": { - "id": 1512, "category": "Math & Geometry", - "title": "Number of Good Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-good-pairs/" + "id": 1512, + "link": "https://leetcode.com/problems/number-of-good-pairs/", + "title": "Number of Good Pairs" }, "1513": { - "id": 1513, "category": "Math & Geometry", - "title": "Number of Substrings With Only 1s", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-substrings-with-only-1s/" + "id": 1513, + "link": "https://leetcode.com/problems/number-of-substrings-with-only-1s/", + "title": "Number of Substrings With Only 1s" }, "1514": { - "id": 1514, "category": "Graph Traversal", - "title": "Path with Maximum Probability", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-with-maximum-probability/" + "id": 1514, + "link": "https://leetcode.com/problems/path-with-maximum-probability/", + "title": "Path with Maximum Probability" }, "1515": { - "id": 1515, "category": "Math & Geometry", - "title": "Best Position for a Service Centre", "difficulty": "Hard", - "link": "https://leetcode.com/problems/best-position-for-a-service-centre/" + "id": 1515, + "link": "https://leetcode.com/problems/best-position-for-a-service-centre/", + "title": "Best Position for a Service Centre" }, "1516": { - "id": 1516, "category": "Tree", - "title": "Move Sub-Tree of N-Ary Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/move-sub-tree-of-n-ary-tree/" + "id": 1516, + "link": "https://leetcode.com/problems/move-sub-tree-of-n-ary-tree/", + "title": "Move Sub-Tree of N-Ary Tree" }, "1517": { - "id": 1517, "category": "Database", - "title": "Find Users With Valid E-Mails", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-users-with-valid-e-mails/" + "id": 1517, + "link": "https://leetcode.com/problems/find-users-with-valid-e-mails/", + "title": "Find Users With Valid E-Mails" }, "1518": { - "id": 1518, "category": "Math & Geometry", - "title": "Water Bottles", "difficulty": "Easy", - "link": "https://leetcode.com/problems/water-bottles/" + "id": 1518, + "link": "https://leetcode.com/problems/water-bottles/", + "title": "Water Bottles" }, "1519": { - "id": 1519, "category": "Tree", - "title": "Number of Nodes in the Sub-Tree With the Same Label", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/" + "id": 1519, + "link": "https://leetcode.com/problems/number-of-nodes-in-the-sub-tree-with-the-same-label/", + "title": "Number of Nodes in the Sub-Tree With the Same Label" }, "1520": { - "id": 1520, "category": "Greedy", - "title": "Maximum Number of Non-Overlapping Substrings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings/" + "id": 1520, + "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-substrings/", + "title": "Maximum Number of Non-Overlapping Substrings" }, "1521": { - "id": 1521, "category": "Tree", - "title": "Find a Value of a Mysterious Function Closest to Target", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target/" + "id": 1521, + "link": "https://leetcode.com/problems/find-a-value-of-a-mysterious-function-closest-to-target/", + "title": "Find a Value of a Mysterious Function Closest to Target" }, "1522": { - "id": 1522, "category": "Tree", - "title": "Diameter of N-Ary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/diameter-of-n-ary-tree/" + "id": 1522, + "link": "https://leetcode.com/problems/diameter-of-n-ary-tree/", + "title": "Diameter of N-Ary Tree" }, "1523": { - "id": 1523, "category": "Math & Geometry", - "title": "Count Odd Numbers in an Interval Range", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/" + "id": 1523, + "link": "https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/", + "title": "Count Odd Numbers in an Interval Range" }, "1524": { - "id": 1524, "category": "Dynamic Programming", - "title": "Number of Sub-arrays With Odd Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum/" + "id": 1524, + "link": "https://leetcode.com/problems/number-of-sub-arrays-with-odd-sum/", + "title": "Number of Sub-arrays With Odd Sum" }, "1525": { - "id": 1525, "category": "Dynamic Programming", - "title": "Number of Good Ways to Split a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-good-ways-to-split-a-string/" + "id": 1525, + "link": "https://leetcode.com/problems/number-of-good-ways-to-split-a-string/", + "title": "Number of Good Ways to Split a String" }, "1526": { - "id": 1526, "category": "Dynamic Programming", - "title": "Minimum Number of Increments on Subarrays to Form a Target Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/" + "id": 1526, + "link": "https://leetcode.com/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array/", + "title": "Minimum Number of Increments on Subarrays to Form a Target Array" }, "1527": { - "id": 1527, "category": "Database", - "title": "Patients With a Condition", "difficulty": "Easy", - "link": "https://leetcode.com/problems/patients-with-a-condition/" + "id": 1527, + "link": "https://leetcode.com/problems/patients-with-a-condition/", + "title": "Patients With a Condition" }, "1528": { - "id": 1528, "category": "Array & Hashing", - "title": "Shuffle String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shuffle-string/" + "id": 1528, + "link": "https://leetcode.com/problems/shuffle-string/", + "title": "Shuffle String" }, "1529": { - "id": 1529, "category": "Greedy", - "title": "Minimum Suffix Flips", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-suffix-flips/" + "id": 1529, + "link": "https://leetcode.com/problems/minimum-suffix-flips/", + "title": "Minimum Suffix Flips" }, "1530": { - "id": 1530, "category": "Tree", - "title": "Number of Good Leaf Nodes Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/" + "id": 1530, + "link": "https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/", + "title": "Number of Good Leaf Nodes Pairs" }, "1531": { - "id": 1531, "category": "Dynamic Programming", - "title": "String Compression II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/string-compression-ii/" + "id": 1531, + "link": "https://leetcode.com/problems/string-compression-ii/", + "title": "String Compression II" }, "1532": { - "id": 1532, "category": "Database", - "title": "The Most Recent Three Orders", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-most-recent-three-orders/" + "id": 1532, + "link": "https://leetcode.com/problems/the-most-recent-three-orders/", + "title": "The Most Recent Three Orders" }, "1533": { - "id": 1533, "category": "Binary Search", - "title": "Find the Index of the Large Integer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-index-of-the-large-integer/" + "id": 1533, + "link": "https://leetcode.com/problems/find-the-index-of-the-large-integer/", + "title": "Find the Index of the Large Integer" }, "1534": { - "id": 1534, "category": "Array & Hashing", - "title": "Count Good Triplets", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-good-triplets/" + "id": 1534, + "link": "https://leetcode.com/problems/count-good-triplets/", + "title": "Count Good Triplets" }, "1535": { - "id": 1535, "category": "Array & Hashing", - "title": "Find the Winner of an Array Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-winner-of-an-array-game/" + "id": 1535, + "link": "https://leetcode.com/problems/find-the-winner-of-an-array-game/", + "title": "Find the Winner of an Array Game" }, "1536": { - "id": 1536, "category": "Greedy", - "title": "Minimum Swaps to Arrange a Binary Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid/" + "id": 1536, + "link": "https://leetcode.com/problems/minimum-swaps-to-arrange-a-binary-grid/", + "title": "Minimum Swaps to Arrange a Binary Grid" }, "1537": { - "id": 1537, "category": "Dynamic Programming", - "title": "Get the Maximum Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/get-the-maximum-score/" + "id": 1537, + "link": "https://leetcode.com/problems/get-the-maximum-score/", + "title": "Get the Maximum Score" }, "1538": { - "id": 1538, "category": "Math & Geometry", - "title": "Guess the Majority in a Hidden Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/guess-the-majority-in-a-hidden-array/" + "id": 1538, + "link": "https://leetcode.com/problems/guess-the-majority-in-a-hidden-array/", + "title": "Guess the Majority in a Hidden Array" }, "1539": { - "id": 1539, "category": "Binary Search", - "title": "Kth Missing Positive Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/kth-missing-positive-number/" + "id": 1539, + "link": "https://leetcode.com/problems/kth-missing-positive-number/", + "title": "Kth Missing Positive Number" }, "1540": { - "id": 1540, "category": "Array & Hashing", - "title": "Can Convert String in K Moves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/can-convert-string-in-k-moves/" + "id": 1540, + "link": "https://leetcode.com/problems/can-convert-string-in-k-moves/", + "title": "Can Convert String in K Moves" }, "1541": { - "id": 1541, "category": "Stack", - "title": "Minimum Insertions to Balance a Parentheses String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string/" + "id": 1541, + "link": "https://leetcode.com/problems/minimum-insertions-to-balance-a-parentheses-string/", + "title": "Minimum Insertions to Balance a Parentheses String" }, "1542": { - "id": 1542, "category": "Bit Manipulation", - "title": "Find Longest Awesome Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-longest-awesome-substring/" + "id": 1542, + "link": "https://leetcode.com/problems/find-longest-awesome-substring/", + "title": "Find Longest Awesome Substring" }, "1543": { - "id": 1543, "category": "Database", - "title": "Fix Product Name Format", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fix-product-name-format/" + "id": 1543, + "link": "https://leetcode.com/problems/fix-product-name-format/", + "title": "Fix Product Name Format" }, "1544": { - "id": 1544, "category": "Stack", - "title": "Make The String Great", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-the-string-great/" + "id": 1544, + "link": "https://leetcode.com/problems/make-the-string-great/", + "title": "Make The String Great" }, "1545": { - "id": 1545, "category": "Array & Hashing", - "title": "Find Kth Bit in Nth Binary String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-kth-bit-in-nth-binary-string/" + "id": 1545, + "link": "https://leetcode.com/problems/find-kth-bit-in-nth-binary-string/", + "title": "Find Kth Bit in Nth Binary String" }, "1546": { - "id": 1546, "category": "Greedy", - "title": "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/" + "id": 1546, + "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-subarrays-with-sum-equals-target/", + "title": "Maximum Number of Non-Overlapping Subarrays With Sum Equals Target" }, "1547": { - "id": 1547, "category": "Dynamic Programming", - "title": "Minimum Cost to Cut a Stick", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-cut-a-stick/" + "id": 1547, + "link": "https://leetcode.com/problems/minimum-cost-to-cut-a-stick/", + "title": "Minimum Cost to Cut a Stick" }, "1548": { - "id": 1548, "category": "Graph Traversal", - "title": "The Most Similar Path in a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-most-similar-path-in-a-graph/" + "id": 1548, + "link": "https://leetcode.com/problems/the-most-similar-path-in-a-graph/", + "title": "The Most Similar Path in a Graph" }, "1549": { - "id": 1549, "category": "Database", - "title": "The Most Recent Orders for Each Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-most-recent-orders-for-each-product/" + "id": 1549, + "link": "https://leetcode.com/problems/the-most-recent-orders-for-each-product/", + "title": "The Most Recent Orders for Each Product" }, "1550": { - "id": 1550, "category": "Array & Hashing", - "title": "Three Consecutive Odds", "difficulty": "Easy", - "link": "https://leetcode.com/problems/three-consecutive-odds/" + "id": 1550, + "link": "https://leetcode.com/problems/three-consecutive-odds/", + "title": "Three Consecutive Odds" }, "1551": { - "id": 1551, "category": "Math & Geometry", - "title": "Minimum Operations to Make Array Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal/" + "id": 1551, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal/", + "title": "Minimum Operations to Make Array Equal" }, "1552": { - "id": 1552, "category": "Binary Search", - "title": "Magnetic Force Between Two Balls", "difficulty": "Medium", - "link": "https://leetcode.com/problems/magnetic-force-between-two-balls/" + "id": 1552, + "link": "https://leetcode.com/problems/magnetic-force-between-two-balls/", + "title": "Magnetic Force Between Two Balls" }, "1553": { - "id": 1553, "category": "Dynamic Programming", - "title": "Minimum Number of Days to Eat N Oranges", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges/" + "id": 1553, + "link": "https://leetcode.com/problems/minimum-number-of-days-to-eat-n-oranges/", + "title": "Minimum Number of Days to Eat N Oranges" }, "1554": { - "id": 1554, "category": "Array & Hashing", - "title": "Strings Differ by One Character", "difficulty": "Medium", - "link": "https://leetcode.com/problems/strings-differ-by-one-character/" + "id": 1554, + "link": "https://leetcode.com/problems/strings-differ-by-one-character/", + "title": "Strings Differ by One Character" }, "1555": { - "id": 1555, "category": "Database", - "title": "Bank Account Summary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bank-account-summary/" + "id": 1555, + "link": "https://leetcode.com/problems/bank-account-summary/", + "title": "Bank Account Summary" }, "1556": { - "id": 1556, "category": "Array & Hashing", - "title": "Thousand Separator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/thousand-separator/" + "id": 1556, + "link": "https://leetcode.com/problems/thousand-separator/", + "title": "Thousand Separator" }, "1557": { - "id": 1557, "category": "Graph Traversal", - "title": "Minimum Number of Vertices to Reach All Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/" + "id": 1557, + "link": "https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/", + "title": "Minimum Number of Vertices to Reach All Nodes" }, "1558": { - "id": 1558, "category": "Bit Manipulation", - "title": "Minimum Numbers of Function Calls to Make Target Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array/" + "id": 1558, + "link": "https://leetcode.com/problems/minimum-numbers-of-function-calls-to-make-target-array/", + "title": "Minimum Numbers of Function Calls to Make Target Array" }, "1559": { - "id": 1559, "category": "Graph Traversal", - "title": "Detect Cycles in 2D Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/detect-cycles-in-2d-grid/" + "id": 1559, + "link": "https://leetcode.com/problems/detect-cycles-in-2d-grid/", + "title": "Detect Cycles in 2D Grid" }, "1560": { - "id": 1560, "category": "Array & Hashing", - "title": "Most Visited Sector in a Circular Track", "difficulty": "Easy", - "link": "https://leetcode.com/problems/most-visited-sector-in-a-circular-track/" + "id": 1560, + "link": "https://leetcode.com/problems/most-visited-sector-in-a-circular-track/", + "title": "Most Visited Sector in a Circular Track" }, "1561": { - "id": 1561, "category": "Greedy", - "title": "Maximum Number of Coins You Can Get", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-coins-you-can-get/" + "id": 1561, + "link": "https://leetcode.com/problems/maximum-number-of-coins-you-can-get/", + "title": "Maximum Number of Coins You Can Get" }, "1562": { - "id": 1562, "category": "Binary Search", - "title": "Find Latest Group of Size M", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-latest-group-of-size-m/" + "id": 1562, + "link": "https://leetcode.com/problems/find-latest-group-of-size-m/", + "title": "Find Latest Group of Size M" }, "1563": { - "id": 1563, "category": "Dynamic Programming", - "title": "Stone Game V", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stone-game-v/" + "id": 1563, + "link": "https://leetcode.com/problems/stone-game-v/", + "title": "Stone Game V" }, "1564": { - "id": 1564, "category": "Greedy", - "title": "Put Boxes Into the Warehouse I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/put-boxes-into-the-warehouse-i/" + "id": 1564, + "link": "https://leetcode.com/problems/put-boxes-into-the-warehouse-i/", + "title": "Put Boxes Into the Warehouse I" }, "1565": { - "id": 1565, "category": "Database", - "title": "Unique Orders and Customers Per Month", "difficulty": "Easy", - "link": "https://leetcode.com/problems/unique-orders-and-customers-per-month/" + "id": 1565, + "link": "https://leetcode.com/problems/unique-orders-and-customers-per-month/", + "title": "Unique Orders and Customers Per Month" }, "1566": { - "id": 1566, "category": "Array & Hashing", - "title": "Detect Pattern of Length M Repeated K or More Times", "difficulty": "Easy", - "link": "https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times/" + "id": 1566, + "link": "https://leetcode.com/problems/detect-pattern-of-length-m-repeated-k-or-more-times/", + "title": "Detect Pattern of Length M Repeated K or More Times" }, "1567": { - "id": 1567, "category": "Dynamic Programming", - "title": "Maximum Length of Subarray With Positive Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product/" + "id": 1567, + "link": "https://leetcode.com/problems/maximum-length-of-subarray-with-positive-product/", + "title": "Maximum Length of Subarray With Positive Product" }, "1568": { - "id": 1568, "category": "Graph Traversal", - "title": "Minimum Number of Days to Disconnect Island", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/" + "id": 1568, + "link": "https://leetcode.com/problems/minimum-number-of-days-to-disconnect-island/", + "title": "Minimum Number of Days to Disconnect Island" }, "1569": { - "id": 1569, "category": "Tree", - "title": "Number of Ways to Reorder Array to Get Same BST", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst/" + "id": 1569, + "link": "https://leetcode.com/problems/number-of-ways-to-reorder-array-to-get-same-bst/", + "title": "Number of Ways to Reorder Array to Get Same BST" }, "1570": { - "id": 1570, "category": "Two Pointers", - "title": "Dot Product of Two Sparse Vectors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/dot-product-of-two-sparse-vectors/" + "id": 1570, + "link": "https://leetcode.com/problems/dot-product-of-two-sparse-vectors/", + "title": "Dot Product of Two Sparse Vectors" }, "1571": { - "id": 1571, "category": "Database", - "title": "Warehouse Manager", "difficulty": "Easy", - "link": "https://leetcode.com/problems/warehouse-manager/" + "id": 1571, + "link": "https://leetcode.com/problems/warehouse-manager/", + "title": "Warehouse Manager" }, "1572": { - "id": 1572, "category": "Array & Hashing", - "title": "Matrix Diagonal Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/matrix-diagonal-sum/" + "id": 1572, + "link": "https://leetcode.com/problems/matrix-diagonal-sum/", + "title": "Matrix Diagonal Sum" }, "1573": { - "id": 1573, "category": "Math & Geometry", - "title": "Number of Ways to Split a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-split-a-string/" + "id": 1573, + "link": "https://leetcode.com/problems/number-of-ways-to-split-a-string/", + "title": "Number of Ways to Split a String" }, "1574": { - "id": 1574, "category": "Binary Search", - "title": "Shortest Subarray to be Removed to Make Array Sorted", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted/" + "id": 1574, + "link": "https://leetcode.com/problems/shortest-subarray-to-be-removed-to-make-array-sorted/", + "title": "Shortest Subarray to be Removed to Make Array Sorted" }, "1575": { - "id": 1575, "category": "Dynamic Programming", - "title": "Count All Possible Routes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-all-possible-routes/" + "id": 1575, + "link": "https://leetcode.com/problems/count-all-possible-routes/", + "title": "Count All Possible Routes" }, "1576": { - "id": 1576, "category": "Array & Hashing", - "title": "Replace All ?'s to Avoid Consecutive Repeating Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters/" + "id": 1576, + "link": "https://leetcode.com/problems/replace-all-s-to-avoid-consecutive-repeating-characters/", + "title": "Replace All ?'s to Avoid Consecutive Repeating Characters" }, "1577": { - "id": 1577, "category": "Math & Geometry", - "title": "Number of Ways Where Square of Number Is Equal to Product of Two Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/" + "id": 1577, + "link": "https://leetcode.com/problems/number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers/", + "title": "Number of Ways Where Square of Number Is Equal to Product of Two Numbers" }, "1578": { - "id": 1578, "category": "Dynamic Programming", - "title": "Minimum Time to Make Rope Colorful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-make-rope-colorful/" + "id": 1578, + "link": "https://leetcode.com/problems/minimum-time-to-make-rope-colorful/", + "title": "Minimum Time to Make Rope Colorful" }, "1579": { - "id": 1579, "category": "Graph Traversal", - "title": "Remove Max Number of Edges to Keep Graph Fully Traversable", "difficulty": "Hard", - "link": "https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/" + "id": 1579, + "link": "https://leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/", + "title": "Remove Max Number of Edges to Keep Graph Fully Traversable" }, "1580": { - "id": 1580, "category": "Greedy", - "title": "Put Boxes Into the Warehouse II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/put-boxes-into-the-warehouse-ii/" + "id": 1580, + "link": "https://leetcode.com/problems/put-boxes-into-the-warehouse-ii/", + "title": "Put Boxes Into the Warehouse II" }, "1581": { - "id": 1581, "category": "Database", - "title": "Customer Who Visited but Did Not Make Any Transactions", "difficulty": "Easy", - "link": "https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/" + "id": 1581, + "link": "https://leetcode.com/problems/customer-who-visited-but-did-not-make-any-transactions/", + "title": "Customer Who Visited but Did Not Make Any Transactions" }, "1582": { - "id": 1582, "category": "Array & Hashing", - "title": "Special Positions in a Binary Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/special-positions-in-a-binary-matrix/" + "id": 1582, + "link": "https://leetcode.com/problems/special-positions-in-a-binary-matrix/", + "title": "Special Positions in a Binary Matrix" }, "1583": { - "id": 1583, "category": "Array & Hashing", - "title": "Count Unhappy Friends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-unhappy-friends/" + "id": 1583, + "link": "https://leetcode.com/problems/count-unhappy-friends/", + "title": "Count Unhappy Friends" }, "1584": { - "id": 1584, "category": "Tree", - "title": "Min Cost to Connect All Points", "difficulty": "Medium", - "link": "https://leetcode.com/problems/min-cost-to-connect-all-points/" + "id": 1584, + "link": "https://leetcode.com/problems/min-cost-to-connect-all-points/", + "title": "Min Cost to Connect All Points" }, "1585": { - "id": 1585, "category": "Greedy", - "title": "Check If String Is Transformable With Substring Sort Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations/" + "id": 1585, + "link": "https://leetcode.com/problems/check-if-string-is-transformable-with-substring-sort-operations/", + "title": "Check If String Is Transformable With Substring Sort Operations" }, "1586": { - "id": 1586, "category": "Tree", - "title": "Binary Search Tree Iterator II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-search-tree-iterator-ii/" + "id": 1586, + "link": "https://leetcode.com/problems/binary-search-tree-iterator-ii/", + "title": "Binary Search Tree Iterator II" }, "1587": { - "id": 1587, "category": "Database", - "title": "Bank Account Summary II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/bank-account-summary-ii/" + "id": 1587, + "link": "https://leetcode.com/problems/bank-account-summary-ii/", + "title": "Bank Account Summary II" }, "1588": { - "id": 1588, "category": "Math & Geometry", - "title": "Sum of All Odd Length Subarrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-all-odd-length-subarrays/" + "id": 1588, + "link": "https://leetcode.com/problems/sum-of-all-odd-length-subarrays/", + "title": "Sum of All Odd Length Subarrays" }, "1589": { - "id": 1589, "category": "Greedy", - "title": "Maximum Sum Obtained of Any Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation/" + "id": 1589, + "link": "https://leetcode.com/problems/maximum-sum-obtained-of-any-permutation/", + "title": "Maximum Sum Obtained of Any Permutation" }, "1590": { - "id": 1590, "category": "Array & Hashing", - "title": "Make Sum Divisible by P", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-sum-divisible-by-p/" + "id": 1590, + "link": "https://leetcode.com/problems/make-sum-divisible-by-p/", + "title": "Make Sum Divisible by P" }, "1591": { - "id": 1591, "category": "Graph Traversal", - "title": "Strange Printer II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/strange-printer-ii/" + "id": 1591, + "link": "https://leetcode.com/problems/strange-printer-ii/", + "title": "Strange Printer II" }, "1592": { - "id": 1592, "category": "Array & Hashing", - "title": "Rearrange Spaces Between Words", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rearrange-spaces-between-words/" + "id": 1592, + "link": "https://leetcode.com/problems/rearrange-spaces-between-words/", + "title": "Rearrange Spaces Between Words" }, "1593": { - "id": 1593, "category": "Backtracking", - "title": "Split a String Into the Max Number of Unique Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/" + "id": 1593, + "link": "https://leetcode.com/problems/split-a-string-into-the-max-number-of-unique-substrings/", + "title": "Split a String Into the Max Number of Unique Substrings" }, "1594": { - "id": 1594, "category": "Dynamic Programming", - "title": "Maximum Non Negative Product in a Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix/" + "id": 1594, + "link": "https://leetcode.com/problems/maximum-non-negative-product-in-a-matrix/", + "title": "Maximum Non Negative Product in a Matrix" }, "1595": { - "id": 1595, "category": "Dynamic Programming", - "title": "Minimum Cost to Connect Two Groups of Points", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points/" + "id": 1595, + "link": "https://leetcode.com/problems/minimum-cost-to-connect-two-groups-of-points/", + "title": "Minimum Cost to Connect Two Groups of Points" }, "1596": { - "id": 1596, "category": "Database", - "title": "The Most Frequently Ordered Products for Each Customer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer/" + "id": 1596, + "link": "https://leetcode.com/problems/the-most-frequently-ordered-products-for-each-customer/", + "title": "The Most Frequently Ordered Products for Each Customer" }, "1597": { - "id": 1597, "category": "Tree", - "title": "Build Binary Expression Tree From Infix Expression", "difficulty": "Hard", - "link": "https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression/" + "id": 1597, + "link": "https://leetcode.com/problems/build-binary-expression-tree-from-infix-expression/", + "title": "Build Binary Expression Tree From Infix Expression" }, "1598": { - "id": 1598, "category": "Stack", - "title": "Crawler Log Folder", "difficulty": "Easy", - "link": "https://leetcode.com/problems/crawler-log-folder/" + "id": 1598, + "link": "https://leetcode.com/problems/crawler-log-folder/", + "title": "Crawler Log Folder" }, "1599": { - "id": 1599, "category": "Array & Hashing", - "title": "Maximum Profit of Operating a Centennial Wheel", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel/" + "id": 1599, + "link": "https://leetcode.com/problems/maximum-profit-of-operating-a-centennial-wheel/", + "title": "Maximum Profit of Operating a Centennial Wheel" }, "1600": { - "id": 1600, "category": "Tree", - "title": "Throne Inheritance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/throne-inheritance/" + "id": 1600, + "link": "https://leetcode.com/problems/throne-inheritance/", + "title": "Throne Inheritance" }, "1601": { - "id": 1601, "category": "Backtracking", - "title": "Maximum Number of Achievable Transfer Requests", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests/" + "id": 1601, + "link": "https://leetcode.com/problems/maximum-number-of-achievable-transfer-requests/", + "title": "Maximum Number of Achievable Transfer Requests" }, "1602": { - "id": 1602, "category": "Tree", - "title": "Find Nearest Right Node in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-nearest-right-node-in-binary-tree/" + "id": 1602, + "link": "https://leetcode.com/problems/find-nearest-right-node-in-binary-tree/", + "title": "Find Nearest Right Node in Binary Tree" }, "1603": { - "id": 1603, "category": "Array & Hashing", - "title": "Design Parking System", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-parking-system/" + "id": 1603, + "link": "https://leetcode.com/problems/design-parking-system/", + "title": "Design Parking System" }, "1604": { - "id": 1604, "category": "Array & Hashing", - "title": "Alert Using Same Key-Card Three or More Times in a One Hour Period", "difficulty": "Medium", - "link": "https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/" + "id": 1604, + "link": "https://leetcode.com/problems/alert-using-same-key-card-three-or-more-times-in-a-one-hour-period/", + "title": "Alert Using Same Key-Card Three or More Times in a One Hour Period" }, "1605": { - "id": 1605, "category": "Greedy", - "title": "Find Valid Matrix Given Row and Column Sums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums/" + "id": 1605, + "link": "https://leetcode.com/problems/find-valid-matrix-given-row-and-column-sums/", + "title": "Find Valid Matrix Given Row and Column Sums" }, "1606": { - "id": 1606, "category": "Heap (Priority Queue)", - "title": "Find Servers That Handled Most Number of Requests", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests/" + "id": 1606, + "link": "https://leetcode.com/problems/find-servers-that-handled-most-number-of-requests/", + "title": "Find Servers That Handled Most Number of Requests" }, "1607": { - "id": 1607, "category": "Database", - "title": "Sellers With No Sales", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sellers-with-no-sales/" + "id": 1607, + "link": "https://leetcode.com/problems/sellers-with-no-sales/", + "title": "Sellers With No Sales" }, "1608": { - "id": 1608, "category": "Binary Search", - "title": "Special Array With X Elements Greater Than or Equal X", "difficulty": "Easy", - "link": "https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/" - }, - "1609": { - "id": 1609, - "category": "Tree", - "title": "Even Odd Tree", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/even-odd-tree/" + "id": 1608, + "link": "https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/", + "title": "Special Array With X Elements Greater Than or Equal X" }, + "1609": {"category": "Tree", "difficulty": "Medium", "id": 1609, "link": "https://leetcode.com/problems/even-odd-tree/", "title": "Even Odd Tree"}, "1610": { - "id": 1610, "category": "Sliding Window", - "title": "Maximum Number of Visible Points", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-visible-points/" + "id": 1610, + "link": "https://leetcode.com/problems/maximum-number-of-visible-points/", + "title": "Maximum Number of Visible Points" }, "1611": { - "id": 1611, "category": "Dynamic Programming", - "title": "Minimum One Bit Operations to Make Integers Zero", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/" + "id": 1611, + "link": "https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/", + "title": "Minimum One Bit Operations to Make Integers Zero" }, "1612": { - "id": 1612, "category": "Tree", - "title": "Check If Two Expression Trees are Equivalent", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent/" + "id": 1612, + "link": "https://leetcode.com/problems/check-if-two-expression-trees-are-equivalent/", + "title": "Check If Two Expression Trees are Equivalent" }, "1613": { - "id": 1613, "category": "Database", - "title": "Find the Missing IDs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-missing-ids/" + "id": 1613, + "link": "https://leetcode.com/problems/find-the-missing-ids/", + "title": "Find the Missing IDs" }, "1614": { - "id": 1614, "category": "Stack", - "title": "Maximum Nesting Depth of the Parentheses", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/" + "id": 1614, + "link": "https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/", + "title": "Maximum Nesting Depth of the Parentheses" }, "1615": { - "id": 1615, "category": "Graph Traversal", - "title": "Maximal Network Rank", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximal-network-rank/" + "id": 1615, + "link": "https://leetcode.com/problems/maximal-network-rank/", + "title": "Maximal Network Rank" }, "1616": { - "id": 1616, "category": "Two Pointers", - "title": "Split Two Strings to Make Palindrome", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-two-strings-to-make-palindrome/" + "id": 1616, + "link": "https://leetcode.com/problems/split-two-strings-to-make-palindrome/", + "title": "Split Two Strings to Make Palindrome" }, "1617": { - "id": 1617, "category": "Tree", - "title": "Count Subtrees With Max Distance Between Cities", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities/" + "id": 1617, + "link": "https://leetcode.com/problems/count-subtrees-with-max-distance-between-cities/", + "title": "Count Subtrees With Max Distance Between Cities" }, "1618": { - "id": 1618, "category": "Binary Search", - "title": "Maximum Font to Fit a Sentence in a Screen", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen/" + "id": 1618, + "link": "https://leetcode.com/problems/maximum-font-to-fit-a-sentence-in-a-screen/", + "title": "Maximum Font to Fit a Sentence in a Screen" }, "1619": { - "id": 1619, "category": "Array & Hashing", - "title": "Mean of Array After Removing Some Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/mean-of-array-after-removing-some-elements/" + "id": 1619, + "link": "https://leetcode.com/problems/mean-of-array-after-removing-some-elements/", + "title": "Mean of Array After Removing Some Elements" }, "1620": { - "id": 1620, "category": "Array & Hashing", - "title": "Coordinate With Maximum Network Quality", "difficulty": "Medium", - "link": "https://leetcode.com/problems/coordinate-with-maximum-network-quality/" + "id": 1620, + "link": "https://leetcode.com/problems/coordinate-with-maximum-network-quality/", + "title": "Coordinate With Maximum Network Quality" }, "1621": { - "id": 1621, "category": "Dynamic Programming", - "title": "Number of Sets of K Non-Overlapping Line Segments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments/" - }, - "1622": { - "id": 1622, - "category": "Tree", - "title": "Fancy Sequence", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/fancy-sequence/" + "id": 1621, + "link": "https://leetcode.com/problems/number-of-sets-of-k-non-overlapping-line-segments/", + "title": "Number of Sets of K Non-Overlapping Line Segments" }, + "1622": {"category": "Tree", "difficulty": "Hard", "id": 1622, "link": "https://leetcode.com/problems/fancy-sequence/", "title": "Fancy Sequence"}, "1623": { - "id": 1623, "category": "Database", - "title": "All Valid Triplets That Can Represent a Country", "difficulty": "Easy", - "link": "https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country/" + "id": 1623, + "link": "https://leetcode.com/problems/all-valid-triplets-that-can-represent-a-country/", + "title": "All Valid Triplets That Can Represent a Country" }, "1624": { - "id": 1624, "category": "Array & Hashing", - "title": "Largest Substring Between Two Equal Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-substring-between-two-equal-characters/" + "id": 1624, + "link": "https://leetcode.com/problems/largest-substring-between-two-equal-characters/", + "title": "Largest Substring Between Two Equal Characters" }, "1625": { - "id": 1625, "category": "Graph Traversal", - "title": "Lexicographically Smallest String After Applying Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations/" + "id": 1625, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-applying-operations/", + "title": "Lexicographically Smallest String After Applying Operations" }, "1626": { - "id": 1626, "category": "Dynamic Programming", - "title": "Best Team With No Conflicts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-team-with-no-conflicts/" + "id": 1626, + "link": "https://leetcode.com/problems/best-team-with-no-conflicts/", + "title": "Best Team With No Conflicts" }, "1627": { - "id": 1627, "category": "Graph Traversal", - "title": "Graph Connectivity With Threshold", "difficulty": "Hard", - "link": "https://leetcode.com/problems/graph-connectivity-with-threshold/" + "id": 1627, + "link": "https://leetcode.com/problems/graph-connectivity-with-threshold/", + "title": "Graph Connectivity With Threshold" }, "1628": { - "id": 1628, "category": "Tree", - "title": "Design an Expression Tree With Evaluate Function", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function/" + "id": 1628, + "link": "https://leetcode.com/problems/design-an-expression-tree-with-evaluate-function/", + "title": "Design an Expression Tree With Evaluate Function" }, "1629": { - "id": 1629, "category": "Array & Hashing", - "title": "Slowest Key", "difficulty": "Easy", - "link": "https://leetcode.com/problems/slowest-key/" + "id": 1629, + "link": "https://leetcode.com/problems/slowest-key/", + "title": "Slowest Key" }, "1630": { - "id": 1630, "category": "Array & Hashing", - "title": "Arithmetic Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/arithmetic-subarrays/" + "id": 1630, + "link": "https://leetcode.com/problems/arithmetic-subarrays/", + "title": "Arithmetic Subarrays" }, "1631": { - "id": 1631, "category": "Graph Traversal", - "title": "Path With Minimum Effort", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-with-minimum-effort/" + "id": 1631, + "link": "https://leetcode.com/problems/path-with-minimum-effort/", + "title": "Path With Minimum Effort" }, "1632": { - "id": 1632, "category": "Graph Traversal", - "title": "Rank Transform of a Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/rank-transform-of-a-matrix/" + "id": 1632, + "link": "https://leetcode.com/problems/rank-transform-of-a-matrix/", + "title": "Rank Transform of a Matrix" }, "1633": { - "id": 1633, "category": "Database", - "title": "Percentage of Users Attended a Contest", "difficulty": "Easy", - "link": "https://leetcode.com/problems/percentage-of-users-attended-a-contest/" + "id": 1633, + "link": "https://leetcode.com/problems/percentage-of-users-attended-a-contest/", + "title": "Percentage of Users Attended a Contest" }, "1634": { - "id": 1634, "category": "Linked List", - "title": "Add Two Polynomials Represented as Linked Lists", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists/" + "id": 1634, + "link": "https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists/", + "title": "Add Two Polynomials Represented as Linked Lists" }, "1635": { - "id": 1635, "category": "Database", - "title": "Hopper Company Queries I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/hopper-company-queries-i/" + "id": 1635, + "link": "https://leetcode.com/problems/hopper-company-queries-i/", + "title": "Hopper Company Queries I" }, "1636": { - "id": 1636, "category": "Array & Hashing", - "title": "Sort Array by Increasing Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-array-by-increasing-frequency/" + "id": 1636, + "link": "https://leetcode.com/problems/sort-array-by-increasing-frequency/", + "title": "Sort Array by Increasing Frequency" }, "1637": { - "id": 1637, "category": "Array & Hashing", - "title": "Widest Vertical Area Between Two Points Containing No Points", "difficulty": "Easy", - "link": "https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points/" + "id": 1637, + "link": "https://leetcode.com/problems/widest-vertical-area-between-two-points-containing-no-points/", + "title": "Widest Vertical Area Between Two Points Containing No Points" }, "1638": { - "id": 1638, "category": "Dynamic Programming", - "title": "Count Substrings That Differ by One Character", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-substrings-that-differ-by-one-character/" + "id": 1638, + "link": "https://leetcode.com/problems/count-substrings-that-differ-by-one-character/", + "title": "Count Substrings That Differ by One Character" }, "1639": { - "id": 1639, "category": "Dynamic Programming", - "title": "Number of Ways to Form a Target String Given a Dictionary", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/" + "id": 1639, + "link": "https://leetcode.com/problems/number-of-ways-to-form-a-target-string-given-a-dictionary/", + "title": "Number of Ways to Form a Target String Given a Dictionary" }, "1640": { - "id": 1640, "category": "Array & Hashing", - "title": "Check Array Formation Through Concatenation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-array-formation-through-concatenation/" + "id": 1640, + "link": "https://leetcode.com/problems/check-array-formation-through-concatenation/", + "title": "Check Array Formation Through Concatenation" }, "1641": { - "id": 1641, "category": "Dynamic Programming", - "title": "Count Sorted Vowel Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-sorted-vowel-strings/" + "id": 1641, + "link": "https://leetcode.com/problems/count-sorted-vowel-strings/", + "title": "Count Sorted Vowel Strings" }, "1642": { - "id": 1642, "category": "Heap (Priority Queue)", - "title": "Furthest Building You Can Reach", "difficulty": "Medium", - "link": "https://leetcode.com/problems/furthest-building-you-can-reach/" + "id": 1642, + "link": "https://leetcode.com/problems/furthest-building-you-can-reach/", + "title": "Furthest Building You Can Reach" }, "1643": { - "id": 1643, "category": "Dynamic Programming", - "title": "Kth Smallest Instructions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-smallest-instructions/" + "id": 1643, + "link": "https://leetcode.com/problems/kth-smallest-instructions/", + "title": "Kth Smallest Instructions" }, "1644": { - "id": 1644, "category": "Tree", - "title": "Lowest Common Ancestor of a Binary Tree II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii/" + "id": 1644, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii/", + "title": "Lowest Common Ancestor of a Binary Tree II" }, "1645": { - "id": 1645, "category": "Database", - "title": "Hopper Company Queries II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/hopper-company-queries-ii/" + "id": 1645, + "link": "https://leetcode.com/problems/hopper-company-queries-ii/", + "title": "Hopper Company Queries II" }, "1646": { - "id": 1646, "category": "Array & Hashing", - "title": "Get Maximum in Generated Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/get-maximum-in-generated-array/" + "id": 1646, + "link": "https://leetcode.com/problems/get-maximum-in-generated-array/", + "title": "Get Maximum in Generated Array" }, "1647": { - "id": 1647, "category": "Greedy", - "title": "Minimum Deletions to Make Character Frequencies Unique", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique/" + "id": 1647, + "link": "https://leetcode.com/problems/minimum-deletions-to-make-character-frequencies-unique/", + "title": "Minimum Deletions to Make Character Frequencies Unique" }, "1648": { - "id": 1648, "category": "Binary Search", - "title": "Sell Diminishing-Valued Colored Balls", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sell-diminishing-valued-colored-balls/" + "id": 1648, + "link": "https://leetcode.com/problems/sell-diminishing-valued-colored-balls/", + "title": "Sell Diminishing-Valued Colored Balls" }, "1649": { - "id": 1649, "category": "Tree", - "title": "Create Sorted Array through Instructions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/create-sorted-array-through-instructions/" + "id": 1649, + "link": "https://leetcode.com/problems/create-sorted-array-through-instructions/", + "title": "Create Sorted Array through Instructions" }, "1650": { - "id": 1650, "category": "Tree", - "title": "Lowest Common Ancestor of a Binary Tree III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii/" + "id": 1650, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iii/", + "title": "Lowest Common Ancestor of a Binary Tree III" }, "1651": { - "id": 1651, "category": "Database", - "title": "Hopper Company Queries III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/hopper-company-queries-iii/" + "id": 1651, + "link": "https://leetcode.com/problems/hopper-company-queries-iii/", + "title": "Hopper Company Queries III" }, "1652": { - "id": 1652, "category": "Sliding Window", - "title": "Defuse the Bomb", "difficulty": "Easy", - "link": "https://leetcode.com/problems/defuse-the-bomb/" + "id": 1652, + "link": "https://leetcode.com/problems/defuse-the-bomb/", + "title": "Defuse the Bomb" }, "1653": { - "id": 1653, "category": "Dynamic Programming", - "title": "Minimum Deletions to Make String Balanced", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-deletions-to-make-string-balanced/" + "id": 1653, + "link": "https://leetcode.com/problems/minimum-deletions-to-make-string-balanced/", + "title": "Minimum Deletions to Make String Balanced" }, "1654": { - "id": 1654, "category": "Graph Traversal", - "title": "Minimum Jumps to Reach Home", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-jumps-to-reach-home/" + "id": 1654, + "link": "https://leetcode.com/problems/minimum-jumps-to-reach-home/", + "title": "Minimum Jumps to Reach Home" }, "1655": { - "id": 1655, "category": "Dynamic Programming", - "title": "Distribute Repeating Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distribute-repeating-integers/" + "id": 1655, + "link": "https://leetcode.com/problems/distribute-repeating-integers/", + "title": "Distribute Repeating Integers" }, "1656": { - "id": 1656, "category": "Array & Hashing", - "title": "Design an Ordered Stream", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-an-ordered-stream/" + "id": 1656, + "link": "https://leetcode.com/problems/design-an-ordered-stream/", + "title": "Design an Ordered Stream" }, "1657": { - "id": 1657, "category": "Array & Hashing", - "title": "Determine if Two Strings Are Close", "difficulty": "Medium", - "link": "https://leetcode.com/problems/determine-if-two-strings-are-close/" + "id": 1657, + "link": "https://leetcode.com/problems/determine-if-two-strings-are-close/", + "title": "Determine if Two Strings Are Close" }, "1658": { - "id": 1658, "category": "Sliding Window", - "title": "Minimum Operations to Reduce X to Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero/" + "id": 1658, + "link": "https://leetcode.com/problems/minimum-operations-to-reduce-x-to-zero/", + "title": "Minimum Operations to Reduce X to Zero" }, "1659": { - "id": 1659, "category": "Dynamic Programming", - "title": "Maximize Grid Happiness", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-grid-happiness/" + "id": 1659, + "link": "https://leetcode.com/problems/maximize-grid-happiness/", + "title": "Maximize Grid Happiness" }, "1660": { - "id": 1660, "category": "Tree", - "title": "Correct a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/correct-a-binary-tree/" + "id": 1660, + "link": "https://leetcode.com/problems/correct-a-binary-tree/", + "title": "Correct a Binary Tree" }, "1661": { - "id": 1661, "category": "Database", - "title": "Average Time of Process per Machine", "difficulty": "Easy", - "link": "https://leetcode.com/problems/average-time-of-process-per-machine/" + "id": 1661, + "link": "https://leetcode.com/problems/average-time-of-process-per-machine/", + "title": "Average Time of Process per Machine" }, "1662": { - "id": 1662, "category": "Array & Hashing", - "title": "Check If Two String Arrays are Equivalent", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/" + "id": 1662, + "link": "https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/", + "title": "Check If Two String Arrays are Equivalent" }, "1663": { - "id": 1663, "category": "Greedy", - "title": "Smallest String With A Given Numeric Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/" + "id": 1663, + "link": "https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/", + "title": "Smallest String With A Given Numeric Value" }, "1664": { - "id": 1664, "category": "Array & Hashing", - "title": "Ways to Make a Fair Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ways-to-make-a-fair-array/" + "id": 1664, + "link": "https://leetcode.com/problems/ways-to-make-a-fair-array/", + "title": "Ways to Make a Fair Array" }, "1665": { - "id": 1665, "category": "Greedy", - "title": "Minimum Initial Energy to Finish Tasks", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/" + "id": 1665, + "link": "https://leetcode.com/problems/minimum-initial-energy-to-finish-tasks/", + "title": "Minimum Initial Energy to Finish Tasks" }, "1666": { - "id": 1666, "category": "Tree", - "title": "Change the Root of a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/change-the-root-of-a-binary-tree/" + "id": 1666, + "link": "https://leetcode.com/problems/change-the-root-of-a-binary-tree/", + "title": "Change the Root of a Binary Tree" }, "1667": { - "id": 1667, "category": "Database", - "title": "Fix Names in a Table", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fix-names-in-a-table/" + "id": 1667, + "link": "https://leetcode.com/problems/fix-names-in-a-table/", + "title": "Fix Names in a Table" }, "1668": { - "id": 1668, "category": "Dynamic Programming", - "title": "Maximum Repeating Substring", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-repeating-substring/" + "id": 1668, + "link": "https://leetcode.com/problems/maximum-repeating-substring/", + "title": "Maximum Repeating Substring" }, "1669": { - "id": 1669, "category": "Linked List", - "title": "Merge In Between Linked Lists", "difficulty": "Medium", - "link": "https://leetcode.com/problems/merge-in-between-linked-lists/" + "id": 1669, + "link": "https://leetcode.com/problems/merge-in-between-linked-lists/", + "title": "Merge In Between Linked Lists" }, "1670": { - "id": 1670, "category": "Linked List", - "title": "Design Front Middle Back Queue", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-front-middle-back-queue/" + "id": 1670, + "link": "https://leetcode.com/problems/design-front-middle-back-queue/", + "title": "Design Front Middle Back Queue" }, "1671": { - "id": 1671, "category": "Dynamic Programming", - "title": "Minimum Number of Removals to Make Mountain Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/" + "id": 1671, + "link": "https://leetcode.com/problems/minimum-number-of-removals-to-make-mountain-array/", + "title": "Minimum Number of Removals to Make Mountain Array" }, "1672": { - "id": 1672, "category": "Array & Hashing", - "title": "Richest Customer Wealth", "difficulty": "Easy", - "link": "https://leetcode.com/problems/richest-customer-wealth/" + "id": 1672, + "link": "https://leetcode.com/problems/richest-customer-wealth/", + "title": "Richest Customer Wealth" }, "1673": { - "id": 1673, "category": "Stack", - "title": "Find the Most Competitive Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-most-competitive-subsequence/" + "id": 1673, + "link": "https://leetcode.com/problems/find-the-most-competitive-subsequence/", + "title": "Find the Most Competitive Subsequence" }, "1674": { - "id": 1674, "category": "Array & Hashing", - "title": "Minimum Moves to Make Array Complementary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-make-array-complementary/" + "id": 1674, + "link": "https://leetcode.com/problems/minimum-moves-to-make-array-complementary/", + "title": "Minimum Moves to Make Array Complementary" }, "1675": { - "id": 1675, "category": "Heap (Priority Queue)", - "title": "Minimize Deviation in Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-deviation-in-array/" + "id": 1675, + "link": "https://leetcode.com/problems/minimize-deviation-in-array/", + "title": "Minimize Deviation in Array" }, "1676": { - "id": 1676, "category": "Tree", - "title": "Lowest Common Ancestor of a Binary Tree IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv/" + "id": 1676, + "link": "https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-iv/", + "title": "Lowest Common Ancestor of a Binary Tree IV" }, "1677": { - "id": 1677, "category": "Database", - "title": "Product's Worth Over Invoices", "difficulty": "Easy", - "link": "https://leetcode.com/problems/products-worth-over-invoices/" + "id": 1677, + "link": "https://leetcode.com/problems/products-worth-over-invoices/", + "title": "Product's Worth Over Invoices" }, "1678": { - "id": 1678, "category": "Array & Hashing", - "title": "Goal Parser Interpretation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/goal-parser-interpretation/" + "id": 1678, + "link": "https://leetcode.com/problems/goal-parser-interpretation/", + "title": "Goal Parser Interpretation" }, "1679": { - "id": 1679, "category": "Two Pointers", - "title": "Max Number of K-Sum Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-number-of-k-sum-pairs/" + "id": 1679, + "link": "https://leetcode.com/problems/max-number-of-k-sum-pairs/", + "title": "Max Number of K-Sum Pairs" }, "1680": { - "id": 1680, "category": "Bit Manipulation", - "title": "Concatenation of Consecutive Binary Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers/" + "id": 1680, + "link": "https://leetcode.com/problems/concatenation-of-consecutive-binary-numbers/", + "title": "Concatenation of Consecutive Binary Numbers" }, "1681": { - "id": 1681, "category": "Dynamic Programming", - "title": "Minimum Incompatibility", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-incompatibility/" + "id": 1681, + "link": "https://leetcode.com/problems/minimum-incompatibility/", + "title": "Minimum Incompatibility" }, "1682": { - "id": 1682, "category": "Dynamic Programming", - "title": "Longest Palindromic Subsequence II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindromic-subsequence-ii/" + "id": 1682, + "link": "https://leetcode.com/problems/longest-palindromic-subsequence-ii/", + "title": "Longest Palindromic Subsequence II" }, "1683": { - "id": 1683, "category": "Database", - "title": "Invalid Tweets", "difficulty": "Easy", - "link": "https://leetcode.com/problems/invalid-tweets/" + "id": 1683, + "link": "https://leetcode.com/problems/invalid-tweets/", + "title": "Invalid Tweets" }, "1684": { - "id": 1684, "category": "Bit Manipulation", - "title": "Count the Number of Consistent Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-the-number-of-consistent-strings/" + "id": 1684, + "link": "https://leetcode.com/problems/count-the-number-of-consistent-strings/", + "title": "Count the Number of Consistent Strings" }, "1685": { - "id": 1685, "category": "Math & Geometry", - "title": "Sum of Absolute Differences in a Sorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array/" + "id": 1685, + "link": "https://leetcode.com/problems/sum-of-absolute-differences-in-a-sorted-array/", + "title": "Sum of Absolute Differences in a Sorted Array" }, "1686": { - "id": 1686, "category": "Heap (Priority Queue)", - "title": "Stone Game VI", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stone-game-vi/" + "id": 1686, + "link": "https://leetcode.com/problems/stone-game-vi/", + "title": "Stone Game VI" }, "1687": { - "id": 1687, "category": "Tree", - "title": "Delivering Boxes from Storage to Ports", "difficulty": "Hard", - "link": "https://leetcode.com/problems/delivering-boxes-from-storage-to-ports/" + "id": 1687, + "link": "https://leetcode.com/problems/delivering-boxes-from-storage-to-ports/", + "title": "Delivering Boxes from Storage to Ports" }, "1688": { - "id": 1688, "category": "Math & Geometry", - "title": "Count of Matches in Tournament", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-of-matches-in-tournament/" + "id": 1688, + "link": "https://leetcode.com/problems/count-of-matches-in-tournament/", + "title": "Count of Matches in Tournament" }, "1689": { - "id": 1689, "category": "Greedy", - "title": "Partitioning Into Minimum Number Of Deci-Binary Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/" + "id": 1689, + "link": "https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/", + "title": "Partitioning Into Minimum Number Of Deci-Binary Numbers" }, "1690": { - "id": 1690, "category": "Dynamic Programming", - "title": "Stone Game VII", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stone-game-vii/" + "id": 1690, + "link": "https://leetcode.com/problems/stone-game-vii/", + "title": "Stone Game VII" }, "1691": { - "id": 1691, "category": "Dynamic Programming", - "title": "Maximum Height by Stacking Cuboids ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-height-by-stacking-cuboids/" + "id": 1691, + "link": "https://leetcode.com/problems/maximum-height-by-stacking-cuboids/", + "title": "Maximum Height by Stacking Cuboids " }, "1692": { - "id": 1692, "category": "Dynamic Programming", - "title": "Count Ways to Distribute Candies", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-ways-to-distribute-candies/" + "id": 1692, + "link": "https://leetcode.com/problems/count-ways-to-distribute-candies/", + "title": "Count Ways to Distribute Candies" }, "1693": { - "id": 1693, "category": "Database", - "title": "Daily Leads and Partners", "difficulty": "Easy", - "link": "https://leetcode.com/problems/daily-leads-and-partners/" + "id": 1693, + "link": "https://leetcode.com/problems/daily-leads-and-partners/", + "title": "Daily Leads and Partners" }, "1694": { - "id": 1694, "category": "Array & Hashing", - "title": "Reformat Phone Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reformat-phone-number/" + "id": 1694, + "link": "https://leetcode.com/problems/reformat-phone-number/", + "title": "Reformat Phone Number" }, "1695": { - "id": 1695, "category": "Sliding Window", - "title": "Maximum Erasure Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-erasure-value/" + "id": 1695, + "link": "https://leetcode.com/problems/maximum-erasure-value/", + "title": "Maximum Erasure Value" }, "1696": { - "id": 1696, "category": "Dynamic Programming", - "title": "Jump Game VI", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-vi/" + "id": 1696, + "link": "https://leetcode.com/problems/jump-game-vi/", + "title": "Jump Game VI" }, "1697": { - "id": 1697, "category": "Graph Traversal", - "title": "Checking Existence of Edge Length Limited Paths", "difficulty": "Hard", - "link": "https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths/" + "id": 1697, + "link": "https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths/", + "title": "Checking Existence of Edge Length Limited Paths" }, "1698": { - "id": 1698, "category": "Trie", - "title": "Number of Distinct Substrings in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-distinct-substrings-in-a-string/" + "id": 1698, + "link": "https://leetcode.com/problems/number-of-distinct-substrings-in-a-string/", + "title": "Number of Distinct Substrings in a String" }, "1699": { - "id": 1699, "category": "Database", - "title": "Number of Calls Between Two Persons", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-calls-between-two-persons/" + "id": 1699, + "link": "https://leetcode.com/problems/number-of-calls-between-two-persons/", + "title": "Number of Calls Between Two Persons" }, "1700": { - "id": 1700, "category": "Stack", - "title": "Number of Students Unable to Eat Lunch", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/" + "id": 1700, + "link": "https://leetcode.com/problems/number-of-students-unable-to-eat-lunch/", + "title": "Number of Students Unable to Eat Lunch" }, "1701": { - "id": 1701, "category": "Array & Hashing", - "title": "Average Waiting Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/average-waiting-time/" + "id": 1701, + "link": "https://leetcode.com/problems/average-waiting-time/", + "title": "Average Waiting Time" }, "1702": { - "id": 1702, "category": "Greedy", - "title": "Maximum Binary String After Change", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-binary-string-after-change/" + "id": 1702, + "link": "https://leetcode.com/problems/maximum-binary-string-after-change/", + "title": "Maximum Binary String After Change" }, "1703": { - "id": 1703, "category": "Sliding Window", - "title": "Minimum Adjacent Swaps for K Consecutive Ones", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones/" + "id": 1703, + "link": "https://leetcode.com/problems/minimum-adjacent-swaps-for-k-consecutive-ones/", + "title": "Minimum Adjacent Swaps for K Consecutive Ones" }, "1704": { - "id": 1704, "category": "Array & Hashing", - "title": "Determine if String Halves Are Alike", "difficulty": "Easy", - "link": "https://leetcode.com/problems/determine-if-string-halves-are-alike/" + "id": 1704, + "link": "https://leetcode.com/problems/determine-if-string-halves-are-alike/", + "title": "Determine if String Halves Are Alike" }, "1705": { - "id": 1705, "category": "Heap (Priority Queue)", - "title": "Maximum Number of Eaten Apples", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-eaten-apples/" + "id": 1705, + "link": "https://leetcode.com/problems/maximum-number-of-eaten-apples/", + "title": "Maximum Number of Eaten Apples" }, "1706": { - "id": 1706, "category": "Array & Hashing", - "title": "Where Will the Ball Fall", "difficulty": "Medium", - "link": "https://leetcode.com/problems/where-will-the-ball-fall/" + "id": 1706, + "link": "https://leetcode.com/problems/where-will-the-ball-fall/", + "title": "Where Will the Ball Fall" }, "1707": { - "id": 1707, "category": "Trie", - "title": "Maximum XOR With an Element From Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-xor-with-an-element-from-array/" + "id": 1707, + "link": "https://leetcode.com/problems/maximum-xor-with-an-element-from-array/", + "title": "Maximum XOR With an Element From Array" }, "1708": { - "id": 1708, "category": "Greedy", - "title": "Largest Subarray Length K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-subarray-length-k/" + "id": 1708, + "link": "https://leetcode.com/problems/largest-subarray-length-k/", + "title": "Largest Subarray Length K" }, "1709": { - "id": 1709, "category": "Database", - "title": "Biggest Window Between Visits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/biggest-window-between-visits/" + "id": 1709, + "link": "https://leetcode.com/problems/biggest-window-between-visits/", + "title": "Biggest Window Between Visits" }, "1710": { - "id": 1710, "category": "Greedy", - "title": "Maximum Units on a Truck", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-units-on-a-truck/" + "id": 1710, + "link": "https://leetcode.com/problems/maximum-units-on-a-truck/", + "title": "Maximum Units on a Truck" }, "1711": { - "id": 1711, "category": "Array & Hashing", - "title": "Count Good Meals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-good-meals/" + "id": 1711, + "link": "https://leetcode.com/problems/count-good-meals/", + "title": "Count Good Meals" }, "1712": { - "id": 1712, "category": "Binary Search", - "title": "Ways to Split Array Into Three Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ways-to-split-array-into-three-subarrays/" + "id": 1712, + "link": "https://leetcode.com/problems/ways-to-split-array-into-three-subarrays/", + "title": "Ways to Split Array Into Three Subarrays" }, "1713": { - "id": 1713, "category": "Binary Search", - "title": "Minimum Operations to Make a Subsequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-a-subsequence/" + "id": 1713, + "link": "https://leetcode.com/problems/minimum-operations-to-make-a-subsequence/", + "title": "Minimum Operations to Make a Subsequence" }, "1714": { - "id": 1714, "category": "Dynamic Programming", - "title": "Sum Of Special Evenly-Spaced Elements In Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array/" + "id": 1714, + "link": "https://leetcode.com/problems/sum-of-special-evenly-spaced-elements-in-array/", + "title": "Sum Of Special Evenly-Spaced Elements In Array" }, "1715": { - "id": 1715, "category": "Database", - "title": "Count Apples and Oranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-apples-and-oranges/" + "id": 1715, + "link": "https://leetcode.com/problems/count-apples-and-oranges/", + "title": "Count Apples and Oranges" }, "1716": { - "id": 1716, "category": "Math & Geometry", - "title": "Calculate Money in Leetcode Bank", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-money-in-leetcode-bank/" + "id": 1716, + "link": "https://leetcode.com/problems/calculate-money-in-leetcode-bank/", + "title": "Calculate Money in Leetcode Bank" }, "1717": { - "id": 1717, "category": "Stack", - "title": "Maximum Score From Removing Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-score-from-removing-substrings/" + "id": 1717, + "link": "https://leetcode.com/problems/maximum-score-from-removing-substrings/", + "title": "Maximum Score From Removing Substrings" }, "1718": { - "id": 1718, "category": "Backtracking", - "title": "Construct the Lexicographically Largest Valid Sequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/" + "id": 1718, + "link": "https://leetcode.com/problems/construct-the-lexicographically-largest-valid-sequence/", + "title": "Construct the Lexicographically Largest Valid Sequence" }, "1719": { - "id": 1719, "category": "Tree", - "title": "Number Of Ways To Reconstruct A Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree/" + "id": 1719, + "link": "https://leetcode.com/problems/number-of-ways-to-reconstruct-a-tree/", + "title": "Number Of Ways To Reconstruct A Tree" }, "1720": { - "id": 1720, "category": "Bit Manipulation", - "title": "Decode XORed Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/decode-xored-array/" + "id": 1720, + "link": "https://leetcode.com/problems/decode-xored-array/", + "title": "Decode XORed Array" }, "1721": { - "id": 1721, "category": "Linked List", - "title": "Swapping Nodes in a Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/swapping-nodes-in-a-linked-list/" + "id": 1721, + "link": "https://leetcode.com/problems/swapping-nodes-in-a-linked-list/", + "title": "Swapping Nodes in a Linked List" }, "1722": { - "id": 1722, "category": "Graph Traversal", - "title": "Minimize Hamming Distance After Swap Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations/" + "id": 1722, + "link": "https://leetcode.com/problems/minimize-hamming-distance-after-swap-operations/", + "title": "Minimize Hamming Distance After Swap Operations" }, "1723": { - "id": 1723, "category": "Dynamic Programming", - "title": "Find Minimum Time to Finish All Jobs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs/" + "id": 1723, + "link": "https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs/", + "title": "Find Minimum Time to Finish All Jobs" }, "1724": { - "id": 1724, "category": "Tree", - "title": "Checking Existence of Edge Length Limited Paths II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii/" + "id": 1724, + "link": "https://leetcode.com/problems/checking-existence-of-edge-length-limited-paths-ii/", + "title": "Checking Existence of Edge Length Limited Paths II" }, "1725": { - "id": 1725, "category": "Array & Hashing", - "title": "Number Of Rectangles That Can Form The Largest Square", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/" + "id": 1725, + "link": "https://leetcode.com/problems/number-of-rectangles-that-can-form-the-largest-square/", + "title": "Number Of Rectangles That Can Form The Largest Square" }, "1726": { - "id": 1726, "category": "Array & Hashing", - "title": "Tuple with Same Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/tuple-with-same-product/" + "id": 1726, + "link": "https://leetcode.com/problems/tuple-with-same-product/", + "title": "Tuple with Same Product" }, "1727": { - "id": 1727, "category": "Greedy", - "title": "Largest Submatrix With Rearrangements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-submatrix-with-rearrangements/" + "id": 1727, + "link": "https://leetcode.com/problems/largest-submatrix-with-rearrangements/", + "title": "Largest Submatrix With Rearrangements" }, "1728": { - "id": 1728, "category": "Graph Traversal", - "title": "Cat and Mouse II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cat-and-mouse-ii/" + "id": 1728, + "link": "https://leetcode.com/problems/cat-and-mouse-ii/", + "title": "Cat and Mouse II" }, "1729": { - "id": 1729, "category": "Database", - "title": "Find Followers Count", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-followers-count/" + "id": 1729, + "link": "https://leetcode.com/problems/find-followers-count/", + "title": "Find Followers Count" }, "1730": { - "id": 1730, "category": "Graph Traversal", - "title": "Shortest Path to Get Food", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-path-to-get-food/" + "id": 1730, + "link": "https://leetcode.com/problems/shortest-path-to-get-food/", + "title": "Shortest Path to Get Food" }, "1731": { - "id": 1731, "category": "Database", - "title": "The Number of Employees Which Report to Each Employee", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee/" + "id": 1731, + "link": "https://leetcode.com/problems/the-number-of-employees-which-report-to-each-employee/", + "title": "The Number of Employees Which Report to Each Employee" }, "1732": { - "id": 1732, "category": "Array & Hashing", - "title": "Find the Highest Altitude", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-highest-altitude/" + "id": 1732, + "link": "https://leetcode.com/problems/find-the-highest-altitude/", + "title": "Find the Highest Altitude" }, "1733": { - "id": 1733, "category": "Greedy", - "title": "Minimum Number of People to Teach", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-people-to-teach/" + "id": 1733, + "link": "https://leetcode.com/problems/minimum-number-of-people-to-teach/", + "title": "Minimum Number of People to Teach" }, "1734": { - "id": 1734, "category": "Bit Manipulation", - "title": "Decode XORed Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decode-xored-permutation/" + "id": 1734, + "link": "https://leetcode.com/problems/decode-xored-permutation/", + "title": "Decode XORed Permutation" }, "1735": { - "id": 1735, "category": "Dynamic Programming", - "title": "Count Ways to Make Array With Product", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-ways-to-make-array-with-product/" + "id": 1735, + "link": "https://leetcode.com/problems/count-ways-to-make-array-with-product/", + "title": "Count Ways to Make Array With Product" }, "1736": { - "id": 1736, "category": "Greedy", - "title": "Latest Time by Replacing Hidden Digits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/" + "id": 1736, + "link": "https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/", + "title": "Latest Time by Replacing Hidden Digits" }, "1737": { - "id": 1737, "category": "Array & Hashing", - "title": "Change Minimum Characters to Satisfy One of Three Conditions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/" + "id": 1737, + "link": "https://leetcode.com/problems/change-minimum-characters-to-satisfy-one-of-three-conditions/", + "title": "Change Minimum Characters to Satisfy One of Three Conditions" }, "1738": { - "id": 1738, "category": "Heap (Priority Queue)", - "title": "Find Kth Largest XOR Coordinate Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-kth-largest-xor-coordinate-value/" + "id": 1738, + "link": "https://leetcode.com/problems/find-kth-largest-xor-coordinate-value/", + "title": "Find Kth Largest XOR Coordinate Value" }, "1739": { - "id": 1739, "category": "Binary Search", - "title": "Building Boxes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/building-boxes/" + "id": 1739, + "link": "https://leetcode.com/problems/building-boxes/", + "title": "Building Boxes" }, "1740": { - "id": 1740, "category": "Tree", - "title": "Find Distance in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-distance-in-a-binary-tree/" + "id": 1740, + "link": "https://leetcode.com/problems/find-distance-in-a-binary-tree/", + "title": "Find Distance in a Binary Tree" }, "1741": { - "id": 1741, "category": "Database", - "title": "Find Total Time Spent by Each Employee", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-total-time-spent-by-each-employee/" + "id": 1741, + "link": "https://leetcode.com/problems/find-total-time-spent-by-each-employee/", + "title": "Find Total Time Spent by Each Employee" }, "1742": { - "id": 1742, "category": "Math & Geometry", - "title": "Maximum Number of Balls in a Box", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-balls-in-a-box/" + "id": 1742, + "link": "https://leetcode.com/problems/maximum-number-of-balls-in-a-box/", + "title": "Maximum Number of Balls in a Box" }, "1743": { - "id": 1743, "category": "Graph Traversal", - "title": "Restore the Array From Adjacent Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/restore-the-array-from-adjacent-pairs/" + "id": 1743, + "link": "https://leetcode.com/problems/restore-the-array-from-adjacent-pairs/", + "title": "Restore the Array From Adjacent Pairs" }, "1744": { - "id": 1744, "category": "Array & Hashing", - "title": "Can You Eat Your Favorite Candy on Your Favorite Day?", "difficulty": "Medium", - "link": "https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/" + "id": 1744, + "link": "https://leetcode.com/problems/can-you-eat-your-favorite-candy-on-your-favorite-day/", + "title": "Can You Eat Your Favorite Candy on Your Favorite Day?" }, "1745": { - "id": 1745, "category": "Dynamic Programming", - "title": "Palindrome Partitioning IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-partitioning-iv/" + "id": 1745, + "link": "https://leetcode.com/problems/palindrome-partitioning-iv/", + "title": "Palindrome Partitioning IV" }, "1746": { - "id": 1746, "category": "Dynamic Programming", - "title": "Maximum Subarray Sum After One Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subarray-sum-after-one-operation/" + "id": 1746, + "link": "https://leetcode.com/problems/maximum-subarray-sum-after-one-operation/", + "title": "Maximum Subarray Sum After One Operation" }, "1747": { - "id": 1747, "category": "Database", - "title": "Leetflex Banned Accounts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/leetflex-banned-accounts/" + "id": 1747, + "link": "https://leetcode.com/problems/leetflex-banned-accounts/", + "title": "Leetflex Banned Accounts" }, "1748": { - "id": 1748, "category": "Array & Hashing", - "title": "Sum of Unique Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-unique-elements/" + "id": 1748, + "link": "https://leetcode.com/problems/sum-of-unique-elements/", + "title": "Sum of Unique Elements" }, "1749": { - "id": 1749, "category": "Dynamic Programming", - "title": "Maximum Absolute Sum of Any Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray/" + "id": 1749, + "link": "https://leetcode.com/problems/maximum-absolute-sum-of-any-subarray/", + "title": "Maximum Absolute Sum of Any Subarray" }, "1750": { - "id": 1750, "category": "Two Pointers", - "title": "Minimum Length of String After Deleting Similar Ends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/" + "id": 1750, + "link": "https://leetcode.com/problems/minimum-length-of-string-after-deleting-similar-ends/", + "title": "Minimum Length of String After Deleting Similar Ends" }, "1751": { - "id": 1751, "category": "Dynamic Programming", - "title": "Maximum Number of Events That Can Be Attended II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii/" + "id": 1751, + "link": "https://leetcode.com/problems/maximum-number-of-events-that-can-be-attended-ii/", + "title": "Maximum Number of Events That Can Be Attended II" }, "1752": { - "id": 1752, "category": "Array & Hashing", - "title": "Check if Array Is Sorted and Rotated", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/" + "id": 1752, + "link": "https://leetcode.com/problems/check-if-array-is-sorted-and-rotated/", + "title": "Check if Array Is Sorted and Rotated" }, "1753": { - "id": 1753, "category": "Heap (Priority Queue)", - "title": "Maximum Score From Removing Stones", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-score-from-removing-stones/" + "id": 1753, + "link": "https://leetcode.com/problems/maximum-score-from-removing-stones/", + "title": "Maximum Score From Removing Stones" }, "1754": { - "id": 1754, "category": "Greedy", - "title": "Largest Merge Of Two Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-merge-of-two-strings/" + "id": 1754, + "link": "https://leetcode.com/problems/largest-merge-of-two-strings/", + "title": "Largest Merge Of Two Strings" }, "1755": { - "id": 1755, "category": "Dynamic Programming", - "title": "Closest Subsequence Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/closest-subsequence-sum/" + "id": 1755, + "link": "https://leetcode.com/problems/closest-subsequence-sum/", + "title": "Closest Subsequence Sum" }, "1756": { - "id": 1756, "category": "Linked List", - "title": "Design Most Recently Used Queue", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-most-recently-used-queue/" + "id": 1756, + "link": "https://leetcode.com/problems/design-most-recently-used-queue/", + "title": "Design Most Recently Used Queue" }, "1757": { - "id": 1757, "category": "Database", - "title": "Recyclable and Low Fat Products", "difficulty": "Easy", - "link": "https://leetcode.com/problems/recyclable-and-low-fat-products/" + "id": 1757, + "link": "https://leetcode.com/problems/recyclable-and-low-fat-products/", + "title": "Recyclable and Low Fat Products" }, "1758": { - "id": 1758, "category": "Array & Hashing", - "title": "Minimum Changes To Make Alternating Binary String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string/" + "id": 1758, + "link": "https://leetcode.com/problems/minimum-changes-to-make-alternating-binary-string/", + "title": "Minimum Changes To Make Alternating Binary String" }, "1759": { - "id": 1759, "category": "Math & Geometry", - "title": "Count Number of Homogenous Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-homogenous-substrings/" + "id": 1759, + "link": "https://leetcode.com/problems/count-number-of-homogenous-substrings/", + "title": "Count Number of Homogenous Substrings" }, "1760": { - "id": 1760, "category": "Binary Search", - "title": "Minimum Limit of Balls in a Bag", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag/" + "id": 1760, + "link": "https://leetcode.com/problems/minimum-limit-of-balls-in-a-bag/", + "title": "Minimum Limit of Balls in a Bag" }, "1761": { - "id": 1761, "category": "Graph Traversal", - "title": "Minimum Degree of a Connected Trio in a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph/" + "id": 1761, + "link": "https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph/", + "title": "Minimum Degree of a Connected Trio in a Graph" }, "1762": { - "id": 1762, "category": "Stack", - "title": "Buildings With an Ocean View", "difficulty": "Medium", - "link": "https://leetcode.com/problems/buildings-with-an-ocean-view/" + "id": 1762, + "link": "https://leetcode.com/problems/buildings-with-an-ocean-view/", + "title": "Buildings With an Ocean View" }, "1763": { - "id": 1763, "category": "Sliding Window", - "title": "Longest Nice Substring", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-nice-substring/" + "id": 1763, + "link": "https://leetcode.com/problems/longest-nice-substring/", + "title": "Longest Nice Substring" }, "1764": { - "id": 1764, "category": "Greedy", - "title": "Form Array by Concatenating Subarrays of Another Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array/" + "id": 1764, + "link": "https://leetcode.com/problems/form-array-by-concatenating-subarrays-of-another-array/", + "title": "Form Array by Concatenating Subarrays of Another Array" }, "1765": { - "id": 1765, "category": "Graph Traversal", - "title": "Map of Highest Peak", "difficulty": "Medium", - "link": "https://leetcode.com/problems/map-of-highest-peak/" + "id": 1765, + "link": "https://leetcode.com/problems/map-of-highest-peak/", + "title": "Map of Highest Peak" }, "1766": { - "id": 1766, "category": "Tree", - "title": "Tree of Coprimes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/tree-of-coprimes/" + "id": 1766, + "link": "https://leetcode.com/problems/tree-of-coprimes/", + "title": "Tree of Coprimes" }, "1767": { - "id": 1767, "category": "Database", - "title": "Find the Subtasks That Did Not Execute", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-subtasks-that-did-not-execute/" + "id": 1767, + "link": "https://leetcode.com/problems/find-the-subtasks-that-did-not-execute/", + "title": "Find the Subtasks That Did Not Execute" }, "1768": { - "id": 1768, "category": "Two Pointers", - "title": "Merge Strings Alternately", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-strings-alternately/" + "id": 1768, + "link": "https://leetcode.com/problems/merge-strings-alternately/", + "title": "Merge Strings Alternately" }, "1769": { - "id": 1769, "category": "Array & Hashing", - "title": "Minimum Number of Operations to Move All Balls to Each Box", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/" + "id": 1769, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/", + "title": "Minimum Number of Operations to Move All Balls to Each Box" }, "1770": { - "id": 1770, "category": "Dynamic Programming", - "title": "Maximum Score from Performing Multiplication Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations/" + "id": 1770, + "link": "https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations/", + "title": "Maximum Score from Performing Multiplication Operations" }, "1771": { - "id": 1771, "category": "Dynamic Programming", - "title": "Maximize Palindrome Length From Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-palindrome-length-from-subsequences/" + "id": 1771, + "link": "https://leetcode.com/problems/maximize-palindrome-length-from-subsequences/", + "title": "Maximize Palindrome Length From Subsequences" }, "1772": { - "id": 1772, "category": "Array & Hashing", - "title": "Sort Features by Popularity", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-features-by-popularity/" + "id": 1772, + "link": "https://leetcode.com/problems/sort-features-by-popularity/", + "title": "Sort Features by Popularity" }, "1773": { - "id": 1773, "category": "Array & Hashing", - "title": "Count Items Matching a Rule", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-items-matching-a-rule/" + "id": 1773, + "link": "https://leetcode.com/problems/count-items-matching-a-rule/", + "title": "Count Items Matching a Rule" }, "1774": { - "id": 1774, "category": "Dynamic Programming", - "title": "Closest Dessert Cost", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-dessert-cost/" + "id": 1774, + "link": "https://leetcode.com/problems/closest-dessert-cost/", + "title": "Closest Dessert Cost" }, "1775": { - "id": 1775, "category": "Greedy", - "title": "Equal Sum Arrays With Minimum Number of Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations/" + "id": 1775, + "link": "https://leetcode.com/problems/equal-sum-arrays-with-minimum-number-of-operations/", + "title": "Equal Sum Arrays With Minimum Number of Operations" }, "1776": { - "id": 1776, "category": "Heap (Priority Queue)", - "title": "Car Fleet II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/car-fleet-ii/" + "id": 1776, + "link": "https://leetcode.com/problems/car-fleet-ii/", + "title": "Car Fleet II" }, "1777": { - "id": 1777, "category": "Database", - "title": "Product's Price for Each Store", "difficulty": "Easy", - "link": "https://leetcode.com/problems/products-price-for-each-store/" + "id": 1777, + "link": "https://leetcode.com/problems/products-price-for-each-store/", + "title": "Product's Price for Each Store" }, "1778": { - "id": 1778, "category": "Graph Traversal", - "title": "Shortest Path in a Hidden Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-path-in-a-hidden-grid/" + "id": 1778, + "link": "https://leetcode.com/problems/shortest-path-in-a-hidden-grid/", + "title": "Shortest Path in a Hidden Grid" }, "1779": { - "id": 1779, "category": "Array & Hashing", - "title": "Find Nearest Point That Has the Same X or Y Coordinate", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/" + "id": 1779, + "link": "https://leetcode.com/problems/find-nearest-point-that-has-the-same-x-or-y-coordinate/", + "title": "Find Nearest Point That Has the Same X or Y Coordinate" }, "1780": { - "id": 1780, "category": "Math & Geometry", - "title": "Check if Number is a Sum of Powers of Three", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/" + "id": 1780, + "link": "https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/", + "title": "Check if Number is a Sum of Powers of Three" }, "1781": { - "id": 1781, "category": "Array & Hashing", - "title": "Sum of Beauty of All Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-beauty-of-all-substrings/" + "id": 1781, + "link": "https://leetcode.com/problems/sum-of-beauty-of-all-substrings/", + "title": "Sum of Beauty of All Substrings" }, "1782": { - "id": 1782, "category": "Graph Traversal", - "title": "Count Pairs Of Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-pairs-of-nodes/" + "id": 1782, + "link": "https://leetcode.com/problems/count-pairs-of-nodes/", + "title": "Count Pairs Of Nodes" }, "1783": { - "id": 1783, "category": "Database", - "title": "Grand Slam Titles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/grand-slam-titles/" + "id": 1783, + "link": "https://leetcode.com/problems/grand-slam-titles/", + "title": "Grand Slam Titles" }, "1784": { - "id": 1784, "category": "Array & Hashing", - "title": "Check if Binary String Has at Most One Segment of Ones", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones/" + "id": 1784, + "link": "https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones/", + "title": "Check if Binary String Has at Most One Segment of Ones" }, "1785": { - "id": 1785, "category": "Greedy", - "title": "Minimum Elements to Add to Form a Given Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum/" + "id": 1785, + "link": "https://leetcode.com/problems/minimum-elements-to-add-to-form-a-given-sum/", + "title": "Minimum Elements to Add to Form a Given Sum" }, "1786": { - "id": 1786, "category": "Graph Traversal", - "title": "Number of Restricted Paths From First to Last Node", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node/" + "id": 1786, + "link": "https://leetcode.com/problems/number-of-restricted-paths-from-first-to-last-node/", + "title": "Number of Restricted Paths From First to Last Node" }, "1787": { - "id": 1787, "category": "Dynamic Programming", - "title": "Make the XOR of All Segments Equal to Zero", "difficulty": "Hard", - "link": "https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero/" + "id": 1787, + "link": "https://leetcode.com/problems/make-the-xor-of-all-segments-equal-to-zero/", + "title": "Make the XOR of All Segments Equal to Zero" }, "1788": { - "id": 1788, "category": "Greedy", - "title": "Maximize the Beauty of the Garden", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-beauty-of-the-garden/" + "id": 1788, + "link": "https://leetcode.com/problems/maximize-the-beauty-of-the-garden/", + "title": "Maximize the Beauty of the Garden" }, "1789": { - "id": 1789, "category": "Database", - "title": "Primary Department for Each Employee", "difficulty": "Easy", - "link": "https://leetcode.com/problems/primary-department-for-each-employee/" + "id": 1789, + "link": "https://leetcode.com/problems/primary-department-for-each-employee/", + "title": "Primary Department for Each Employee" }, "1790": { - "id": 1790, "category": "Array & Hashing", - "title": "Check if One String Swap Can Make Strings Equal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal/" + "id": 1790, + "link": "https://leetcode.com/problems/check-if-one-string-swap-can-make-strings-equal/", + "title": "Check if One String Swap Can Make Strings Equal" }, "1791": { - "id": 1791, "category": "Graph Traversal", - "title": "Find Center of Star Graph", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-center-of-star-graph/" + "id": 1791, + "link": "https://leetcode.com/problems/find-center-of-star-graph/", + "title": "Find Center of Star Graph" }, "1792": { - "id": 1792, "category": "Heap (Priority Queue)", - "title": "Maximum Average Pass Ratio", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-average-pass-ratio/" + "id": 1792, + "link": "https://leetcode.com/problems/maximum-average-pass-ratio/", + "title": "Maximum Average Pass Ratio" }, "1793": { - "id": 1793, "category": "Binary Search", - "title": "Maximum Score of a Good Subarray", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-of-a-good-subarray/" + "id": 1793, + "link": "https://leetcode.com/problems/maximum-score-of-a-good-subarray/", + "title": "Maximum Score of a Good Subarray" }, "1794": { - "id": 1794, "category": "Greedy", - "title": "Count Pairs of Equal Substrings With Minimum Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference/" + "id": 1794, + "link": "https://leetcode.com/problems/count-pairs-of-equal-substrings-with-minimum-difference/", + "title": "Count Pairs of Equal Substrings With Minimum Difference" }, "1795": { - "id": 1795, "category": "Database", - "title": "Rearrange Products Table", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rearrange-products-table/" + "id": 1795, + "link": "https://leetcode.com/problems/rearrange-products-table/", + "title": "Rearrange Products Table" }, "1796": { - "id": 1796, "category": "Array & Hashing", - "title": "Second Largest Digit in a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/second-largest-digit-in-a-string/" + "id": 1796, + "link": "https://leetcode.com/problems/second-largest-digit-in-a-string/", + "title": "Second Largest Digit in a String" }, "1797": { - "id": 1797, "category": "Linked List", - "title": "Design Authentication Manager", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-authentication-manager/" + "id": 1797, + "link": "https://leetcode.com/problems/design-authentication-manager/", + "title": "Design Authentication Manager" }, "1798": { - "id": 1798, "category": "Greedy", - "title": "Maximum Number of Consecutive Values You Can Make", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make/" + "id": 1798, + "link": "https://leetcode.com/problems/maximum-number-of-consecutive-values-you-can-make/", + "title": "Maximum Number of Consecutive Values You Can Make" }, "1799": { - "id": 1799, "category": "Dynamic Programming", - "title": "Maximize Score After N Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-score-after-n-operations/" + "id": 1799, + "link": "https://leetcode.com/problems/maximize-score-after-n-operations/", + "title": "Maximize Score After N Operations" }, "1800": { - "id": 1800, "category": "Array & Hashing", - "title": "Maximum Ascending Subarray Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-ascending-subarray-sum/" + "id": 1800, + "link": "https://leetcode.com/problems/maximum-ascending-subarray-sum/", + "title": "Maximum Ascending Subarray Sum" }, "1801": { - "id": 1801, "category": "Heap (Priority Queue)", - "title": "Number of Orders in the Backlog", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-orders-in-the-backlog/" + "id": 1801, + "link": "https://leetcode.com/problems/number-of-orders-in-the-backlog/", + "title": "Number of Orders in the Backlog" }, "1802": { - "id": 1802, "category": "Binary Search", - "title": "Maximum Value at a Given Index in a Bounded Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array/" + "id": 1802, + "link": "https://leetcode.com/problems/maximum-value-at-a-given-index-in-a-bounded-array/", + "title": "Maximum Value at a Given Index in a Bounded Array" }, "1803": { - "id": 1803, "category": "Trie", - "title": "Count Pairs With XOR in a Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-pairs-with-xor-in-a-range/" + "id": 1803, + "link": "https://leetcode.com/problems/count-pairs-with-xor-in-a-range/", + "title": "Count Pairs With XOR in a Range" }, "1804": { - "id": 1804, "category": "Trie", - "title": "Implement Trie II (Prefix Tree)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/implement-trie-ii-prefix-tree/" + "id": 1804, + "link": "https://leetcode.com/problems/implement-trie-ii-prefix-tree/", + "title": "Implement Trie II (Prefix Tree)" }, "1805": { - "id": 1805, "category": "Array & Hashing", - "title": "Number of Different Integers in a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-different-integers-in-a-string/" + "id": 1805, + "link": "https://leetcode.com/problems/number-of-different-integers-in-a-string/", + "title": "Number of Different Integers in a String" }, "1806": { - "id": 1806, "category": "Math & Geometry", - "title": "Minimum Number of Operations to Reinitialize a Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation/" + "id": 1806, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-reinitialize-a-permutation/", + "title": "Minimum Number of Operations to Reinitialize a Permutation" }, "1807": { - "id": 1807, "category": "Array & Hashing", - "title": "Evaluate the Bracket Pairs of a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string/" + "id": 1807, + "link": "https://leetcode.com/problems/evaluate-the-bracket-pairs-of-a-string/", + "title": "Evaluate the Bracket Pairs of a String" }, "1808": { - "id": 1808, "category": "Math & Geometry", - "title": "Maximize Number of Nice Divisors", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-number-of-nice-divisors/" + "id": 1808, + "link": "https://leetcode.com/problems/maximize-number-of-nice-divisors/", + "title": "Maximize Number of Nice Divisors" }, "1809": { - "id": 1809, "category": "Database", - "title": "Ad-Free Sessions", "difficulty": "Easy", - "link": "https://leetcode.com/problems/ad-free-sessions/" + "id": 1809, + "link": "https://leetcode.com/problems/ad-free-sessions/", + "title": "Ad-Free Sessions" }, "1810": { - "id": 1810, "category": "Graph Traversal", - "title": "Minimum Path Cost in a Hidden Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid/" + "id": 1810, + "link": "https://leetcode.com/problems/minimum-path-cost-in-a-hidden-grid/", + "title": "Minimum Path Cost in a Hidden Grid" }, "1811": { - "id": 1811, "category": "Database", - "title": "Find Interview Candidates", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-interview-candidates/" + "id": 1811, + "link": "https://leetcode.com/problems/find-interview-candidates/", + "title": "Find Interview Candidates" }, "1812": { - "id": 1812, "category": "Math & Geometry", - "title": "Determine Color of a Chessboard Square", "difficulty": "Easy", - "link": "https://leetcode.com/problems/determine-color-of-a-chessboard-square/" + "id": 1812, + "link": "https://leetcode.com/problems/determine-color-of-a-chessboard-square/", + "title": "Determine Color of a Chessboard Square" }, "1813": { - "id": 1813, "category": "Two Pointers", - "title": "Sentence Similarity III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sentence-similarity-iii/" + "id": 1813, + "link": "https://leetcode.com/problems/sentence-similarity-iii/", + "title": "Sentence Similarity III" }, "1814": { - "id": 1814, "category": "Math & Geometry", - "title": "Count Nice Pairs in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-nice-pairs-in-an-array/" + "id": 1814, + "link": "https://leetcode.com/problems/count-nice-pairs-in-an-array/", + "title": "Count Nice Pairs in an Array" }, "1815": { - "id": 1815, "category": "Dynamic Programming", - "title": "Maximum Number of Groups Getting Fresh Donuts", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts/" + "id": 1815, + "link": "https://leetcode.com/problems/maximum-number-of-groups-getting-fresh-donuts/", + "title": "Maximum Number of Groups Getting Fresh Donuts" }, "1816": { - "id": 1816, "category": "Array & Hashing", - "title": "Truncate Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/truncate-sentence/" + "id": 1816, + "link": "https://leetcode.com/problems/truncate-sentence/", + "title": "Truncate Sentence" }, "1817": { - "id": 1817, "category": "Array & Hashing", - "title": "Finding the Users Active Minutes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/finding-the-users-active-minutes/" + "id": 1817, + "link": "https://leetcode.com/problems/finding-the-users-active-minutes/", + "title": "Finding the Users Active Minutes" }, "1818": { - "id": 1818, "category": "Binary Search", - "title": "Minimum Absolute Sum Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-absolute-sum-difference/" + "id": 1818, + "link": "https://leetcode.com/problems/minimum-absolute-sum-difference/", + "title": "Minimum Absolute Sum Difference" }, "1819": { - "id": 1819, "category": "Math & Geometry", - "title": "Number of Different Subsequences GCDs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-different-subsequences-gcds/" + "id": 1819, + "link": "https://leetcode.com/problems/number-of-different-subsequences-gcds/", + "title": "Number of Different Subsequences GCDs" }, "1820": { - "id": 1820, "category": "Graph Traversal", - "title": "Maximum Number of Accepted Invitations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-accepted-invitations/" + "id": 1820, + "link": "https://leetcode.com/problems/maximum-number-of-accepted-invitations/", + "title": "Maximum Number of Accepted Invitations" }, "1821": { - "id": 1821, "category": "Database", - "title": "Find Customers With Positive Revenue this Year", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-customers-with-positive-revenue-this-year/" + "id": 1821, + "link": "https://leetcode.com/problems/find-customers-with-positive-revenue-this-year/", + "title": "Find Customers With Positive Revenue this Year" }, "1822": { - "id": 1822, "category": "Math & Geometry", - "title": "Sign of the Product of an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sign-of-the-product-of-an-array/" + "id": 1822, + "link": "https://leetcode.com/problems/sign-of-the-product-of-an-array/", + "title": "Sign of the Product of an Array" }, "1823": { - "id": 1823, "category": "Math & Geometry", - "title": "Find the Winner of the Circular Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-winner-of-the-circular-game/" + "id": 1823, + "link": "https://leetcode.com/problems/find-the-winner-of-the-circular-game/", + "title": "Find the Winner of the Circular Game" }, "1824": { - "id": 1824, "category": "Dynamic Programming", - "title": "Minimum Sideway Jumps", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-sideway-jumps/" + "id": 1824, + "link": "https://leetcode.com/problems/minimum-sideway-jumps/", + "title": "Minimum Sideway Jumps" }, "1825": { - "id": 1825, "category": "Heap (Priority Queue)", - "title": "Finding MK Average", "difficulty": "Hard", - "link": "https://leetcode.com/problems/finding-mk-average/" + "id": 1825, + "link": "https://leetcode.com/problems/finding-mk-average/", + "title": "Finding MK Average" }, "1826": { - "id": 1826, "category": "Two Pointers", - "title": "Faulty Sensor", "difficulty": "Easy", - "link": "https://leetcode.com/problems/faulty-sensor/" + "id": 1826, + "link": "https://leetcode.com/problems/faulty-sensor/", + "title": "Faulty Sensor" }, "1827": { - "id": 1827, "category": "Greedy", - "title": "Minimum Operations to Make the Array Increasing", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing/" + "id": 1827, + "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-increasing/", + "title": "Minimum Operations to Make the Array Increasing" }, "1828": { - "id": 1828, "category": "Math & Geometry", - "title": "Queries on Number of Points Inside a Circle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle/" + "id": 1828, + "link": "https://leetcode.com/problems/queries-on-number-of-points-inside-a-circle/", + "title": "Queries on Number of Points Inside a Circle" }, "1829": { - "id": 1829, "category": "Bit Manipulation", - "title": "Maximum XOR for Each Query", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-xor-for-each-query/" + "id": 1829, + "link": "https://leetcode.com/problems/maximum-xor-for-each-query/", + "title": "Maximum XOR for Each Query" }, "1830": { - "id": 1830, "category": "Math & Geometry", - "title": "Minimum Number of Operations to Make String Sorted", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted/" + "id": 1830, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-string-sorted/", + "title": "Minimum Number of Operations to Make String Sorted" }, "1831": { - "id": 1831, "category": "Database", - "title": "Maximum Transaction Each Day", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-transaction-each-day/" + "id": 1831, + "link": "https://leetcode.com/problems/maximum-transaction-each-day/", + "title": "Maximum Transaction Each Day" }, "1832": { - "id": 1832, "category": "Array & Hashing", - "title": "Check if the Sentence Is Pangram", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-the-sentence-is-pangram/" + "id": 1832, + "link": "https://leetcode.com/problems/check-if-the-sentence-is-pangram/", + "title": "Check if the Sentence Is Pangram" }, "1833": { - "id": 1833, "category": "Greedy", - "title": "Maximum Ice Cream Bars", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-ice-cream-bars/" + "id": 1833, + "link": "https://leetcode.com/problems/maximum-ice-cream-bars/", + "title": "Maximum Ice Cream Bars" }, "1834": { - "id": 1834, "category": "Heap (Priority Queue)", - "title": "Single-Threaded CPU", "difficulty": "Medium", - "link": "https://leetcode.com/problems/single-threaded-cpu/" + "id": 1834, + "link": "https://leetcode.com/problems/single-threaded-cpu/", + "title": "Single-Threaded CPU" }, "1835": { - "id": 1835, "category": "Bit Manipulation", - "title": "Find XOR Sum of All Pairs Bitwise AND", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and/" + "id": 1835, + "link": "https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and/", + "title": "Find XOR Sum of All Pairs Bitwise AND" }, "1836": { - "id": 1836, "category": "Linked List", - "title": "Remove Duplicates From an Unsorted Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list/" + "id": 1836, + "link": "https://leetcode.com/problems/remove-duplicates-from-an-unsorted-linked-list/", + "title": "Remove Duplicates From an Unsorted Linked List" }, "1837": { - "id": 1837, "category": "Math & Geometry", - "title": "Sum of Digits in Base K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-digits-in-base-k/" + "id": 1837, + "link": "https://leetcode.com/problems/sum-of-digits-in-base-k/", + "title": "Sum of Digits in Base K" }, "1838": { - "id": 1838, "category": "Sliding Window", - "title": "Frequency of the Most Frequent Element", "difficulty": "Medium", - "link": "https://leetcode.com/problems/frequency-of-the-most-frequent-element/" + "id": 1838, + "link": "https://leetcode.com/problems/frequency-of-the-most-frequent-element/", + "title": "Frequency of the Most Frequent Element" }, "1839": { - "id": 1839, "category": "Sliding Window", - "title": "Longest Substring Of All Vowels in Order", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-substring-of-all-vowels-in-order/" + "id": 1839, + "link": "https://leetcode.com/problems/longest-substring-of-all-vowels-in-order/", + "title": "Longest Substring Of All Vowels in Order" }, "1840": { - "id": 1840, "category": "Math & Geometry", - "title": "Maximum Building Height", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-building-height/" + "id": 1840, + "link": "https://leetcode.com/problems/maximum-building-height/", + "title": "Maximum Building Height" }, "1841": { - "id": 1841, "category": "Database", - "title": "League Statistics", "difficulty": "Medium", - "link": "https://leetcode.com/problems/league-statistics/" + "id": 1841, + "link": "https://leetcode.com/problems/league-statistics/", + "title": "League Statistics" }, "1842": { - "id": 1842, "category": "Two Pointers", - "title": "Next Palindrome Using Same Digits", "difficulty": "Hard", - "link": "https://leetcode.com/problems/next-palindrome-using-same-digits/" + "id": 1842, + "link": "https://leetcode.com/problems/next-palindrome-using-same-digits/", + "title": "Next Palindrome Using Same Digits" }, "1843": { - "id": 1843, "category": "Database", - "title": "Suspicious Bank Accounts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/suspicious-bank-accounts/" + "id": 1843, + "link": "https://leetcode.com/problems/suspicious-bank-accounts/", + "title": "Suspicious Bank Accounts" }, "1844": { - "id": 1844, "category": "Array & Hashing", - "title": "Replace All Digits with Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/replace-all-digits-with-characters/" + "id": 1844, + "link": "https://leetcode.com/problems/replace-all-digits-with-characters/", + "title": "Replace All Digits with Characters" }, "1845": { - "id": 1845, "category": "Heap (Priority Queue)", - "title": "Seat Reservation Manager", "difficulty": "Medium", - "link": "https://leetcode.com/problems/seat-reservation-manager/" + "id": 1845, + "link": "https://leetcode.com/problems/seat-reservation-manager/", + "title": "Seat Reservation Manager" }, "1846": { - "id": 1846, "category": "Greedy", - "title": "Maximum Element After Decreasing and Rearranging", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/" + "id": 1846, + "link": "https://leetcode.com/problems/maximum-element-after-decreasing-and-rearranging/", + "title": "Maximum Element After Decreasing and Rearranging" }, "1847": { - "id": 1847, "category": "Binary Search", - "title": "Closest Room", "difficulty": "Hard", - "link": "https://leetcode.com/problems/closest-room/" + "id": 1847, + "link": "https://leetcode.com/problems/closest-room/", + "title": "Closest Room" }, "1848": { - "id": 1848, "category": "Array & Hashing", - "title": "Minimum Distance to the Target Element", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-distance-to-the-target-element/" + "id": 1848, + "link": "https://leetcode.com/problems/minimum-distance-to-the-target-element/", + "title": "Minimum Distance to the Target Element" }, "1849": { - "id": 1849, "category": "Backtracking", - "title": "Splitting a String Into Descending Consecutive Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/splitting-a-string-into-descending-consecutive-values/" + "id": 1849, + "link": "https://leetcode.com/problems/splitting-a-string-into-descending-consecutive-values/", + "title": "Splitting a String Into Descending Consecutive Values" }, "1850": { - "id": 1850, "category": "Greedy", - "title": "Minimum Adjacent Swaps to Reach the Kth Smallest Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/" + "id": 1850, + "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-reach-the-kth-smallest-number/", + "title": "Minimum Adjacent Swaps to Reach the Kth Smallest Number" }, "1851": { - "id": 1851, "category": "Binary Search", - "title": "Minimum Interval to Include Each Query", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-interval-to-include-each-query/" + "id": 1851, + "link": "https://leetcode.com/problems/minimum-interval-to-include-each-query/", + "title": "Minimum Interval to Include Each Query" }, "1852": { - "id": 1852, "category": "Sliding Window", - "title": "Distinct Numbers in Each Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distinct-numbers-in-each-subarray/" + "id": 1852, + "link": "https://leetcode.com/problems/distinct-numbers-in-each-subarray/", + "title": "Distinct Numbers in Each Subarray" }, "1853": { - "id": 1853, "category": "Database", - "title": "Convert Date Format", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-date-format/" + "id": 1853, + "link": "https://leetcode.com/problems/convert-date-format/", + "title": "Convert Date Format" }, "1854": { - "id": 1854, "category": "Array & Hashing", - "title": "Maximum Population Year", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-population-year/" + "id": 1854, + "link": "https://leetcode.com/problems/maximum-population-year/", + "title": "Maximum Population Year" }, "1855": { - "id": 1855, "category": "Binary Search", - "title": "Maximum Distance Between a Pair of Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-distance-between-a-pair-of-values/" + "id": 1855, + "link": "https://leetcode.com/problems/maximum-distance-between-a-pair-of-values/", + "title": "Maximum Distance Between a Pair of Values" }, "1856": { - "id": 1856, "category": "Stack", - "title": "Maximum Subarray Min-Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subarray-min-product/" + "id": 1856, + "link": "https://leetcode.com/problems/maximum-subarray-min-product/", + "title": "Maximum Subarray Min-Product" }, "1857": { - "id": 1857, "category": "Graph Traversal", - "title": "Largest Color Value in a Directed Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/largest-color-value-in-a-directed-graph/" + "id": 1857, + "link": "https://leetcode.com/problems/largest-color-value-in-a-directed-graph/", + "title": "Largest Color Value in a Directed Graph" }, "1858": { - "id": 1858, "category": "Graph Traversal", - "title": "Longest Word With All Prefixes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-word-with-all-prefixes/" + "id": 1858, + "link": "https://leetcode.com/problems/longest-word-with-all-prefixes/", + "title": "Longest Word With All Prefixes" }, "1859": { - "id": 1859, "category": "Array & Hashing", - "title": "Sorting the Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sorting-the-sentence/" + "id": 1859, + "link": "https://leetcode.com/problems/sorting-the-sentence/", + "title": "Sorting the Sentence" }, "1860": { - "id": 1860, "category": "Math & Geometry", - "title": "Incremental Memory Leak", "difficulty": "Medium", - "link": "https://leetcode.com/problems/incremental-memory-leak/" + "id": 1860, + "link": "https://leetcode.com/problems/incremental-memory-leak/", + "title": "Incremental Memory Leak" }, "1861": { - "id": 1861, "category": "Two Pointers", - "title": "Rotating the Box", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rotating-the-box/" + "id": 1861, + "link": "https://leetcode.com/problems/rotating-the-box/", + "title": "Rotating the Box" }, "1862": { - "id": 1862, "category": "Binary Search", - "title": "Sum of Floored Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-floored-pairs/" + "id": 1862, + "link": "https://leetcode.com/problems/sum-of-floored-pairs/", + "title": "Sum of Floored Pairs" }, "1863": { - "id": 1863, "category": "Backtracking", - "title": "Sum of All Subset XOR Totals", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-all-subset-xor-totals/" + "id": 1863, + "link": "https://leetcode.com/problems/sum-of-all-subset-xor-totals/", + "title": "Sum of All Subset XOR Totals" }, "1864": { - "id": 1864, "category": "Greedy", - "title": "Minimum Number of Swaps to Make the Binary String Alternating", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/" + "id": 1864, + "link": "https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/", + "title": "Minimum Number of Swaps to Make the Binary String Alternating" }, "1865": { - "id": 1865, "category": "Array & Hashing", - "title": "Finding Pairs With a Certain Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/finding-pairs-with-a-certain-sum/" + "id": 1865, + "link": "https://leetcode.com/problems/finding-pairs-with-a-certain-sum/", + "title": "Finding Pairs With a Certain Sum" }, "1866": { - "id": 1866, "category": "Dynamic Programming", - "title": "Number of Ways to Rearrange Sticks With K Sticks Visible", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/" + "id": 1866, + "link": "https://leetcode.com/problems/number-of-ways-to-rearrange-sticks-with-k-sticks-visible/", + "title": "Number of Ways to Rearrange Sticks With K Sticks Visible" }, "1867": { - "id": 1867, "category": "Database", - "title": "Orders With Maximum Quantity Above Average", "difficulty": "Medium", - "link": "https://leetcode.com/problems/orders-with-maximum-quantity-above-average/" + "id": 1867, + "link": "https://leetcode.com/problems/orders-with-maximum-quantity-above-average/", + "title": "Orders With Maximum Quantity Above Average" }, "1868": { - "id": 1868, "category": "Two Pointers", - "title": "Product of Two Run-Length Encoded Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-of-two-run-length-encoded-arrays/" + "id": 1868, + "link": "https://leetcode.com/problems/product-of-two-run-length-encoded-arrays/", + "title": "Product of Two Run-Length Encoded Arrays" }, "1869": { - "id": 1869, "category": "Array & Hashing", - "title": "Longer Contiguous Segments of Ones than Zeros", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/" + "id": 1869, + "link": "https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/", + "title": "Longer Contiguous Segments of Ones than Zeros" }, "1870": { - "id": 1870, "category": "Binary Search", - "title": "Minimum Speed to Arrive on Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-speed-to-arrive-on-time/" + "id": 1870, + "link": "https://leetcode.com/problems/minimum-speed-to-arrive-on-time/", + "title": "Minimum Speed to Arrive on Time" }, "1871": { - "id": 1871, "category": "Dynamic Programming", - "title": "Jump Game VII", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-vii/" + "id": 1871, + "link": "https://leetcode.com/problems/jump-game-vii/", + "title": "Jump Game VII" }, "1872": { - "id": 1872, "category": "Dynamic Programming", - "title": "Stone Game VIII", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stone-game-viii/" + "id": 1872, + "link": "https://leetcode.com/problems/stone-game-viii/", + "title": "Stone Game VIII" }, "1873": { - "id": 1873, "category": "Database", - "title": "Calculate Special Bonus", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-special-bonus/" + "id": 1873, + "link": "https://leetcode.com/problems/calculate-special-bonus/", + "title": "Calculate Special Bonus" }, "1874": { - "id": 1874, "category": "Greedy", - "title": "Minimize Product Sum of Two Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-product-sum-of-two-arrays/" + "id": 1874, + "link": "https://leetcode.com/problems/minimize-product-sum-of-two-arrays/", + "title": "Minimize Product Sum of Two Arrays" }, "1875": { - "id": 1875, "category": "Database", - "title": "Group Employees of the Same Salary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/group-employees-of-the-same-salary/" + "id": 1875, + "link": "https://leetcode.com/problems/group-employees-of-the-same-salary/", + "title": "Group Employees of the Same Salary" }, "1876": { - "id": 1876, "category": "Sliding Window", - "title": "Substrings of Size Three with Distinct Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/" + "id": 1876, + "link": "https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/", + "title": "Substrings of Size Three with Distinct Characters" }, "1877": { - "id": 1877, "category": "Greedy", - "title": "Minimize Maximum Pair Sum in Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/" + "id": 1877, + "link": "https://leetcode.com/problems/minimize-maximum-pair-sum-in-array/", + "title": "Minimize Maximum Pair Sum in Array" }, "1878": { - "id": 1878, "category": "Heap (Priority Queue)", - "title": "Get Biggest Three Rhombus Sums in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/" + "id": 1878, + "link": "https://leetcode.com/problems/get-biggest-three-rhombus-sums-in-a-grid/", + "title": "Get Biggest Three Rhombus Sums in a Grid" }, "1879": { - "id": 1879, "category": "Dynamic Programming", - "title": "Minimum XOR Sum of Two Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-xor-sum-of-two-arrays/" + "id": 1879, + "link": "https://leetcode.com/problems/minimum-xor-sum-of-two-arrays/", + "title": "Minimum XOR Sum of Two Arrays" }, "1880": { - "id": 1880, "category": "Array & Hashing", - "title": "Check if Word Equals Summation of Two Words", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/" + "id": 1880, + "link": "https://leetcode.com/problems/check-if-word-equals-summation-of-two-words/", + "title": "Check if Word Equals Summation of Two Words" }, "1881": { - "id": 1881, "category": "Greedy", - "title": "Maximum Value after Insertion", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-value-after-insertion/" + "id": 1881, + "link": "https://leetcode.com/problems/maximum-value-after-insertion/", + "title": "Maximum Value after Insertion" }, "1882": { - "id": 1882, "category": "Heap (Priority Queue)", - "title": "Process Tasks Using Servers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/process-tasks-using-servers/" + "id": 1882, + "link": "https://leetcode.com/problems/process-tasks-using-servers/", + "title": "Process Tasks Using Servers" }, "1883": { - "id": 1883, "category": "Dynamic Programming", - "title": "Minimum Skips to Arrive at Meeting On Time", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time/" + "id": 1883, + "link": "https://leetcode.com/problems/minimum-skips-to-arrive-at-meeting-on-time/", + "title": "Minimum Skips to Arrive at Meeting On Time" }, "1884": { - "id": 1884, "category": "Dynamic Programming", - "title": "Egg Drop With 2 Eggs and N Floors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors/" + "id": 1884, + "link": "https://leetcode.com/problems/egg-drop-with-2-eggs-and-n-floors/", + "title": "Egg Drop With 2 Eggs and N Floors" }, "1885": { - "id": 1885, "category": "Binary Search", - "title": "Count Pairs in Two Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-pairs-in-two-arrays/" + "id": 1885, + "link": "https://leetcode.com/problems/count-pairs-in-two-arrays/", + "title": "Count Pairs in Two Arrays" }, "1886": { - "id": 1886, "category": "Array & Hashing", - "title": "Determine Whether Matrix Can Be Obtained By Rotation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/" + "id": 1886, + "link": "https://leetcode.com/problems/determine-whether-matrix-can-be-obtained-by-rotation/", + "title": "Determine Whether Matrix Can Be Obtained By Rotation" }, "1887": { - "id": 1887, "category": "Array & Hashing", - "title": "Reduction Operations to Make the Array Elements Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal/" + "id": 1887, + "link": "https://leetcode.com/problems/reduction-operations-to-make-the-array-elements-equal/", + "title": "Reduction Operations to Make the Array Elements Equal" }, "1888": { - "id": 1888, "category": "Dynamic Programming", - "title": "Minimum Number of Flips to Make the Binary String Alternating", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/" + "id": 1888, + "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-the-binary-string-alternating/", + "title": "Minimum Number of Flips to Make the Binary String Alternating" }, "1889": { - "id": 1889, "category": "Binary Search", - "title": "Minimum Space Wasted From Packaging", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-space-wasted-from-packaging/" + "id": 1889, + "link": "https://leetcode.com/problems/minimum-space-wasted-from-packaging/", + "title": "Minimum Space Wasted From Packaging" }, "1890": { - "id": 1890, "category": "Database", - "title": "The Latest Login in 2020", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-latest-login-in-2020/" + "id": 1890, + "link": "https://leetcode.com/problems/the-latest-login-in-2020/", + "title": "The Latest Login in 2020" }, "1891": { - "id": 1891, "category": "Binary Search", - "title": "Cutting Ribbons", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cutting-ribbons/" + "id": 1891, + "link": "https://leetcode.com/problems/cutting-ribbons/", + "title": "Cutting Ribbons" }, "1892": { - "id": 1892, "category": "Database", - "title": "Page Recommendations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/page-recommendations-ii/" + "id": 1892, + "link": "https://leetcode.com/problems/page-recommendations-ii/", + "title": "Page Recommendations II" }, "1893": { - "id": 1893, "category": "Array & Hashing", - "title": "Check if All the Integers in a Range Are Covered", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-all-the-integers-in-a-range-are-covered/" + "id": 1893, + "link": "https://leetcode.com/problems/check-if-all-the-integers-in-a-range-are-covered/", + "title": "Check if All the Integers in a Range Are Covered" }, "1894": { - "id": 1894, "category": "Binary Search", - "title": "Find the Student that Will Replace the Chalk", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk/" + "id": 1894, + "link": "https://leetcode.com/problems/find-the-student-that-will-replace-the-chalk/", + "title": "Find the Student that Will Replace the Chalk" }, "1895": { - "id": 1895, "category": "Array & Hashing", - "title": "Largest Magic Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-magic-square/" + "id": 1895, + "link": "https://leetcode.com/problems/largest-magic-square/", + "title": "Largest Magic Square" }, "1896": { - "id": 1896, "category": "Dynamic Programming", - "title": "Minimum Cost to Change the Final Value of Expression", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-change-the-final-value-of-expression/" + "id": 1896, + "link": "https://leetcode.com/problems/minimum-cost-to-change-the-final-value-of-expression/", + "title": "Minimum Cost to Change the Final Value of Expression" }, "1897": { - "id": 1897, "category": "Array & Hashing", - "title": "Redistribute Characters to Make All Strings Equal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/" + "id": 1897, + "link": "https://leetcode.com/problems/redistribute-characters-to-make-all-strings-equal/", + "title": "Redistribute Characters to Make All Strings Equal" }, "1898": { - "id": 1898, "category": "Binary Search", - "title": "Maximum Number of Removable Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-removable-characters/" + "id": 1898, + "link": "https://leetcode.com/problems/maximum-number-of-removable-characters/", + "title": "Maximum Number of Removable Characters" }, "1899": { - "id": 1899, "category": "Greedy", - "title": "Merge Triplets to Form Target Triplet", "difficulty": "Medium", - "link": "https://leetcode.com/problems/merge-triplets-to-form-target-triplet/" + "id": 1899, + "link": "https://leetcode.com/problems/merge-triplets-to-form-target-triplet/", + "title": "Merge Triplets to Form Target Triplet" }, "1900": { - "id": 1900, "category": "Dynamic Programming", - "title": "The Earliest and Latest Rounds Where Players Compete", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete/" + "id": 1900, + "link": "https://leetcode.com/problems/the-earliest-and-latest-rounds-where-players-compete/", + "title": "The Earliest and Latest Rounds Where Players Compete" }, "1901": { - "id": 1901, "category": "Binary Search", - "title": "Find a Peak Element II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-a-peak-element-ii/" + "id": 1901, + "link": "https://leetcode.com/problems/find-a-peak-element-ii/", + "title": "Find a Peak Element II" }, "1902": { - "id": 1902, "category": "Tree", - "title": "Depth of BST Given Insertion Order", "difficulty": "Medium", - "link": "https://leetcode.com/problems/depth-of-bst-given-insertion-order/" + "id": 1902, + "link": "https://leetcode.com/problems/depth-of-bst-given-insertion-order/", + "title": "Depth of BST Given Insertion Order" }, "1903": { - "id": 1903, "category": "Greedy", - "title": "Largest Odd Number in String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-odd-number-in-string/" + "id": 1903, + "link": "https://leetcode.com/problems/largest-odd-number-in-string/", + "title": "Largest Odd Number in String" }, "1904": { - "id": 1904, "category": "Math & Geometry", - "title": "The Number of Full Rounds You Have Played", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-full-rounds-you-have-played/" + "id": 1904, + "link": "https://leetcode.com/problems/the-number-of-full-rounds-you-have-played/", + "title": "The Number of Full Rounds You Have Played" }, "1905": { - "id": 1905, "category": "Graph Traversal", - "title": "Count Sub Islands", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-sub-islands/" + "id": 1905, + "link": "https://leetcode.com/problems/count-sub-islands/", + "title": "Count Sub Islands" }, "1906": { - "id": 1906, "category": "Array & Hashing", - "title": "Minimum Absolute Difference Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-absolute-difference-queries/" + "id": 1906, + "link": "https://leetcode.com/problems/minimum-absolute-difference-queries/", + "title": "Minimum Absolute Difference Queries" }, "1907": { - "id": 1907, "category": "Database", - "title": "Count Salary Categories", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-salary-categories/" + "id": 1907, + "link": "https://leetcode.com/problems/count-salary-categories/", + "title": "Count Salary Categories" }, "1908": { - "id": 1908, "category": "Dynamic Programming", - "title": "Game of Nim", "difficulty": "Medium", - "link": "https://leetcode.com/problems/game-of-nim/" + "id": 1908, + "link": "https://leetcode.com/problems/game-of-nim/", + "title": "Game of Nim" }, "1909": { - "id": 1909, "category": "Array & Hashing", - "title": "Remove One Element to Make the Array Strictly Increasing", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/" + "id": 1909, + "link": "https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing/", + "title": "Remove One Element to Make the Array Strictly Increasing" }, "1910": { - "id": 1910, "category": "Stack", - "title": "Remove All Occurrences of a Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-all-occurrences-of-a-substring/" + "id": 1910, + "link": "https://leetcode.com/problems/remove-all-occurrences-of-a-substring/", + "title": "Remove All Occurrences of a Substring" }, "1911": { - "id": 1911, "category": "Dynamic Programming", - "title": "Maximum Alternating Subsequence Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-alternating-subsequence-sum/" + "id": 1911, + "link": "https://leetcode.com/problems/maximum-alternating-subsequence-sum/", + "title": "Maximum Alternating Subsequence Sum" }, "1912": { - "id": 1912, "category": "Heap (Priority Queue)", - "title": "Design Movie Rental System", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-movie-rental-system/" + "id": 1912, + "link": "https://leetcode.com/problems/design-movie-rental-system/", + "title": "Design Movie Rental System" }, "1913": { - "id": 1913, "category": "Array & Hashing", - "title": "Maximum Product Difference Between Two Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-product-difference-between-two-pairs/" + "id": 1913, + "link": "https://leetcode.com/problems/maximum-product-difference-between-two-pairs/", + "title": "Maximum Product Difference Between Two Pairs" }, "1914": { - "id": 1914, "category": "Array & Hashing", - "title": "Cyclically Rotating a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cyclically-rotating-a-grid/" + "id": 1914, + "link": "https://leetcode.com/problems/cyclically-rotating-a-grid/", + "title": "Cyclically Rotating a Grid" }, "1915": { - "id": 1915, "category": "Bit Manipulation", - "title": "Number of Wonderful Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-wonderful-substrings/" + "id": 1915, + "link": "https://leetcode.com/problems/number-of-wonderful-substrings/", + "title": "Number of Wonderful Substrings" }, "1916": { - "id": 1916, "category": "Tree", - "title": "Count Ways to Build Rooms in an Ant Colony", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony/" + "id": 1916, + "link": "https://leetcode.com/problems/count-ways-to-build-rooms-in-an-ant-colony/", + "title": "Count Ways to Build Rooms in an Ant Colony" }, "1917": { - "id": 1917, "category": "Database", - "title": "Leetcodify Friends Recommendations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/leetcodify-friends-recommendations/" + "id": 1917, + "link": "https://leetcode.com/problems/leetcodify-friends-recommendations/", + "title": "Leetcodify Friends Recommendations" }, "1918": { - "id": 1918, "category": "Sliding Window", - "title": "Kth Smallest Subarray Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kth-smallest-subarray-sum/" + "id": 1918, + "link": "https://leetcode.com/problems/kth-smallest-subarray-sum/", + "title": "Kth Smallest Subarray Sum" }, "1919": { - "id": 1919, "category": "Database", - "title": "Leetcodify Similar Friends", "difficulty": "Hard", - "link": "https://leetcode.com/problems/leetcodify-similar-friends/" + "id": 1919, + "link": "https://leetcode.com/problems/leetcodify-similar-friends/", + "title": "Leetcodify Similar Friends" }, "1920": { - "id": 1920, "category": "Array & Hashing", - "title": "Build Array from Permutation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/build-array-from-permutation/" + "id": 1920, + "link": "https://leetcode.com/problems/build-array-from-permutation/", + "title": "Build Array from Permutation" }, "1921": { - "id": 1921, "category": "Greedy", - "title": "Eliminate Maximum Number of Monsters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/eliminate-maximum-number-of-monsters/" + "id": 1921, + "link": "https://leetcode.com/problems/eliminate-maximum-number-of-monsters/", + "title": "Eliminate Maximum Number of Monsters" }, "1922": { - "id": 1922, "category": "Math & Geometry", - "title": "Count Good Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-good-numbers/" + "id": 1922, + "link": "https://leetcode.com/problems/count-good-numbers/", + "title": "Count Good Numbers" }, "1923": { - "id": 1923, "category": "Binary Search", - "title": "Longest Common Subpath", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-common-subpath/" + "id": 1923, + "link": "https://leetcode.com/problems/longest-common-subpath/", + "title": "Longest Common Subpath" }, "1924": { - "id": 1924, "category": "Math & Geometry", - "title": "Erect the Fence II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/erect-the-fence-ii/" + "id": 1924, + "link": "https://leetcode.com/problems/erect-the-fence-ii/", + "title": "Erect the Fence II" }, "1925": { - "id": 1925, "category": "Math & Geometry", - "title": "Count Square Sum Triples", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-square-sum-triples/" + "id": 1925, + "link": "https://leetcode.com/problems/count-square-sum-triples/", + "title": "Count Square Sum Triples" }, "1926": { - "id": 1926, "category": "Graph Traversal", - "title": "Nearest Exit from Entrance in Maze", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/" - }, - "1927": { - "id": 1927, - "category": "Greedy", - "title": "Sum Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-game/" + "id": 1926, + "link": "https://leetcode.com/problems/nearest-exit-from-entrance-in-maze/", + "title": "Nearest Exit from Entrance in Maze" }, + "1927": {"category": "Greedy", "difficulty": "Medium", "id": 1927, "link": "https://leetcode.com/problems/sum-game/", "title": "Sum Game"}, "1928": { - "id": 1928, "category": "Graph Traversal", - "title": "Minimum Cost to Reach Destination in Time", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time/" + "id": 1928, + "link": "https://leetcode.com/problems/minimum-cost-to-reach-destination-in-time/", + "title": "Minimum Cost to Reach Destination in Time" }, "1929": { - "id": 1929, "category": "Array & Hashing", - "title": "Concatenation of Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/concatenation-of-array/" + "id": 1929, + "link": "https://leetcode.com/problems/concatenation-of-array/", + "title": "Concatenation of Array" }, "1930": { - "id": 1930, "category": "Bit Manipulation", - "title": "Unique Length-3 Palindromic Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-length-3-palindromic-subsequences/" + "id": 1930, + "link": "https://leetcode.com/problems/unique-length-3-palindromic-subsequences/", + "title": "Unique Length-3 Palindromic Subsequences" }, "1931": { - "id": 1931, "category": "Dynamic Programming", - "title": "Painting a Grid With Three Different Colors", "difficulty": "Hard", - "link": "https://leetcode.com/problems/painting-a-grid-with-three-different-colors/" + "id": 1931, + "link": "https://leetcode.com/problems/painting-a-grid-with-three-different-colors/", + "title": "Painting a Grid With Three Different Colors" }, "1932": { - "id": 1932, "category": "Tree", - "title": "Merge BSTs to Create Single BST", "difficulty": "Hard", - "link": "https://leetcode.com/problems/merge-bsts-to-create-single-bst/" + "id": 1932, + "link": "https://leetcode.com/problems/merge-bsts-to-create-single-bst/", + "title": "Merge BSTs to Create Single BST" }, "1933": { - "id": 1933, "category": "Array & Hashing", - "title": "Check if String Is Decomposable Into Value-Equal Substrings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings/" + "id": 1933, + "link": "https://leetcode.com/problems/check-if-string-is-decomposable-into-value-equal-substrings/", + "title": "Check if String Is Decomposable Into Value-Equal Substrings" }, "1934": { - "id": 1934, "category": "Database", - "title": "Confirmation Rate", "difficulty": "Medium", - "link": "https://leetcode.com/problems/confirmation-rate/" + "id": 1934, + "link": "https://leetcode.com/problems/confirmation-rate/", + "title": "Confirmation Rate" }, "1935": { - "id": 1935, "category": "Array & Hashing", - "title": "Maximum Number of Words You Can Type", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-words-you-can-type/" + "id": 1935, + "link": "https://leetcode.com/problems/maximum-number-of-words-you-can-type/", + "title": "Maximum Number of Words You Can Type" }, "1936": { - "id": 1936, "category": "Greedy", - "title": "Add Minimum Number of Rungs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/add-minimum-number-of-rungs/" + "id": 1936, + "link": "https://leetcode.com/problems/add-minimum-number-of-rungs/", + "title": "Add Minimum Number of Rungs" }, "1937": { - "id": 1937, "category": "Dynamic Programming", - "title": "Maximum Number of Points with Cost", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-points-with-cost/" + "id": 1937, + "link": "https://leetcode.com/problems/maximum-number-of-points-with-cost/", + "title": "Maximum Number of Points with Cost" }, "1938": { - "id": 1938, "category": "Graph Traversal", - "title": "Maximum Genetic Difference Query", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-genetic-difference-query/" + "id": 1938, + "link": "https://leetcode.com/problems/maximum-genetic-difference-query/", + "title": "Maximum Genetic Difference Query" }, "1939": { - "id": 1939, "category": "Database", - "title": "Users That Actively Request Confirmation Messages", "difficulty": "Easy", - "link": "https://leetcode.com/problems/users-that-actively-request-confirmation-messages/" + "id": 1939, + "link": "https://leetcode.com/problems/users-that-actively-request-confirmation-messages/", + "title": "Users That Actively Request Confirmation Messages" }, "1940": { - "id": 1940, "category": "Array & Hashing", - "title": "Longest Common Subsequence Between Sorted Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays/" + "id": 1940, + "link": "https://leetcode.com/problems/longest-common-subsequence-between-sorted-arrays/", + "title": "Longest Common Subsequence Between Sorted Arrays" }, "1941": { - "id": 1941, "category": "Array & Hashing", - "title": "Check if All Characters Have Equal Number of Occurrences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/" + "id": 1941, + "link": "https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences/", + "title": "Check if All Characters Have Equal Number of Occurrences" }, "1942": { - "id": 1942, "category": "Heap (Priority Queue)", - "title": "The Number of the Smallest Unoccupied Chair", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair/" + "id": 1942, + "link": "https://leetcode.com/problems/the-number-of-the-smallest-unoccupied-chair/", + "title": "The Number of the Smallest Unoccupied Chair" }, "1943": { - "id": 1943, "category": "Array & Hashing", - "title": "Describe the Painting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/describe-the-painting/" + "id": 1943, + "link": "https://leetcode.com/problems/describe-the-painting/", + "title": "Describe the Painting" }, "1944": { - "id": 1944, "category": "Stack", - "title": "Number of Visible People in a Queue", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-visible-people-in-a-queue/" + "id": 1944, + "link": "https://leetcode.com/problems/number-of-visible-people-in-a-queue/", + "title": "Number of Visible People in a Queue" }, "1945": { - "id": 1945, "category": "Array & Hashing", - "title": "Sum of Digits of String After Convert", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-digits-of-string-after-convert/" + "id": 1945, + "link": "https://leetcode.com/problems/sum-of-digits-of-string-after-convert/", + "title": "Sum of Digits of String After Convert" }, "1946": { - "id": 1946, "category": "Greedy", - "title": "Largest Number After Mutating Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-number-after-mutating-substring/" + "id": 1946, + "link": "https://leetcode.com/problems/largest-number-after-mutating-substring/", + "title": "Largest Number After Mutating Substring" }, "1947": { - "id": 1947, "category": "Dynamic Programming", - "title": "Maximum Compatibility Score Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-compatibility-score-sum/" + "id": 1947, + "link": "https://leetcode.com/problems/maximum-compatibility-score-sum/", + "title": "Maximum Compatibility Score Sum" }, "1948": { - "id": 1948, "category": "Trie", - "title": "Delete Duplicate Folders in System", "difficulty": "Hard", - "link": "https://leetcode.com/problems/delete-duplicate-folders-in-system/" + "id": 1948, + "link": "https://leetcode.com/problems/delete-duplicate-folders-in-system/", + "title": "Delete Duplicate Folders in System" }, "1949": { - "id": 1949, "category": "Database", - "title": "Strong Friendship", "difficulty": "Medium", - "link": "https://leetcode.com/problems/strong-friendship/" + "id": 1949, + "link": "https://leetcode.com/problems/strong-friendship/", + "title": "Strong Friendship" }, "1950": { - "id": 1950, "category": "Stack", - "title": "Maximum of Minimum Values in All Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays/" + "id": 1950, + "link": "https://leetcode.com/problems/maximum-of-minimum-values-in-all-subarrays/", + "title": "Maximum of Minimum Values in All Subarrays" }, "1951": { - "id": 1951, "category": "Database", - "title": "All the Pairs With the Maximum Number of Common Followers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers/" + "id": 1951, + "link": "https://leetcode.com/problems/all-the-pairs-with-the-maximum-number-of-common-followers/", + "title": "All the Pairs With the Maximum Number of Common Followers" }, "1952": { - "id": 1952, "category": "Math & Geometry", - "title": "Three Divisors", "difficulty": "Easy", - "link": "https://leetcode.com/problems/three-divisors/" + "id": 1952, + "link": "https://leetcode.com/problems/three-divisors/", + "title": "Three Divisors" }, "1953": { - "id": 1953, "category": "Greedy", - "title": "Maximum Number of Weeks for Which You Can Work", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work/" + "id": 1953, + "link": "https://leetcode.com/problems/maximum-number-of-weeks-for-which-you-can-work/", + "title": "Maximum Number of Weeks for Which You Can Work" }, "1954": { - "id": 1954, "category": "Binary Search", - "title": "Minimum Garden Perimeter to Collect Enough Apples", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples/" + "id": 1954, + "link": "https://leetcode.com/problems/minimum-garden-perimeter-to-collect-enough-apples/", + "title": "Minimum Garden Perimeter to Collect Enough Apples" }, "1955": { - "id": 1955, "category": "Dynamic Programming", - "title": "Count Number of Special Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-number-of-special-subsequences/" + "id": 1955, + "link": "https://leetcode.com/problems/count-number-of-special-subsequences/", + "title": "Count Number of Special Subsequences" }, "1956": { - "id": 1956, "category": "Binary Search", - "title": "Minimum Time For K Virus Variants to Spread", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-for-k-virus-variants-to-spread/" + "id": 1956, + "link": "https://leetcode.com/problems/minimum-time-for-k-virus-variants-to-spread/", + "title": "Minimum Time For K Virus Variants to Spread" }, "1957": { - "id": 1957, "category": "Array & Hashing", - "title": "Delete Characters to Make Fancy String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/delete-characters-to-make-fancy-string/" + "id": 1957, + "link": "https://leetcode.com/problems/delete-characters-to-make-fancy-string/", + "title": "Delete Characters to Make Fancy String" }, "1958": { - "id": 1958, "category": "Array & Hashing", - "title": "Check if Move is Legal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-move-is-legal/" + "id": 1958, + "link": "https://leetcode.com/problems/check-if-move-is-legal/", + "title": "Check if Move is Legal" }, "1959": { - "id": 1959, "category": "Dynamic Programming", - "title": "Minimum Total Space Wasted With K Resizing Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-total-space-wasted-with-k-resizing-operations/" + "id": 1959, + "link": "https://leetcode.com/problems/minimum-total-space-wasted-with-k-resizing-operations/", + "title": "Minimum Total Space Wasted With K Resizing Operations" }, "1960": { - "id": 1960, "category": "Array & Hashing", - "title": "Maximum Product of the Length of Two Palindromic Substrings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-substrings/" + "id": 1960, + "link": "https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-substrings/", + "title": "Maximum Product of the Length of Two Palindromic Substrings" }, "1961": { - "id": 1961, "category": "Two Pointers", - "title": "Check If String Is a Prefix of Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-string-is-a-prefix-of-array/" + "id": 1961, + "link": "https://leetcode.com/problems/check-if-string-is-a-prefix-of-array/", + "title": "Check If String Is a Prefix of Array" }, "1962": { - "id": 1962, "category": "Heap (Priority Queue)", - "title": "Remove Stones to Minimize the Total", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-stones-to-minimize-the-total/" + "id": 1962, + "link": "https://leetcode.com/problems/remove-stones-to-minimize-the-total/", + "title": "Remove Stones to Minimize the Total" }, "1963": { - "id": 1963, "category": "Stack", - "title": "Minimum Number of Swaps to Make the String Balanced", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced/" + "id": 1963, + "link": "https://leetcode.com/problems/minimum-number-of-swaps-to-make-the-string-balanced/", + "title": "Minimum Number of Swaps to Make the String Balanced" }, "1964": { - "id": 1964, "category": "Tree", - "title": "Find the Longest Valid Obstacle Course at Each Position", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position/" + "id": 1964, + "link": "https://leetcode.com/problems/find-the-longest-valid-obstacle-course-at-each-position/", + "title": "Find the Longest Valid Obstacle Course at Each Position" }, "1965": { - "id": 1965, "category": "Database", - "title": "Employees With Missing Information", "difficulty": "Easy", - "link": "https://leetcode.com/problems/employees-with-missing-information/" + "id": 1965, + "link": "https://leetcode.com/problems/employees-with-missing-information/", + "title": "Employees With Missing Information" }, "1966": { - "id": 1966, "category": "Binary Search", - "title": "Binary Searchable Numbers in an Unsorted Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array/" + "id": 1966, + "link": "https://leetcode.com/problems/binary-searchable-numbers-in-an-unsorted-array/", + "title": "Binary Searchable Numbers in an Unsorted Array" }, "1967": { - "id": 1967, "category": "Array & Hashing", - "title": "Number of Strings That Appear as Substrings in Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/" + "id": 1967, + "link": "https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/", + "title": "Number of Strings That Appear as Substrings in Word" }, "1968": { - "id": 1968, "category": "Greedy", - "title": "Array With Elements Not Equal to Average of Neighbors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors/" + "id": 1968, + "link": "https://leetcode.com/problems/array-with-elements-not-equal-to-average-of-neighbors/", + "title": "Array With Elements Not Equal to Average of Neighbors" }, "1969": { - "id": 1969, "category": "Greedy", - "title": "Minimum Non-Zero Product of the Array Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements/" + "id": 1969, + "link": "https://leetcode.com/problems/minimum-non-zero-product-of-the-array-elements/", + "title": "Minimum Non-Zero Product of the Array Elements" }, "1970": { - "id": 1970, "category": "Graph Traversal", - "title": "Last Day Where You Can Still Cross", "difficulty": "Hard", - "link": "https://leetcode.com/problems/last-day-where-you-can-still-cross/" + "id": 1970, + "link": "https://leetcode.com/problems/last-day-where-you-can-still-cross/", + "title": "Last Day Where You Can Still Cross" }, "1971": { - "id": 1971, "category": "Graph Traversal", - "title": "Find if Path Exists in Graph", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-if-path-exists-in-graph/" + "id": 1971, + "link": "https://leetcode.com/problems/find-if-path-exists-in-graph/", + "title": "Find if Path Exists in Graph" }, "1972": { - "id": 1972, "category": "Database", - "title": "First and Last Call On the Same Day", "difficulty": "Hard", - "link": "https://leetcode.com/problems/first-and-last-call-on-the-same-day/" + "id": 1972, + "link": "https://leetcode.com/problems/first-and-last-call-on-the-same-day/", + "title": "First and Last Call On the Same Day" }, "1973": { - "id": 1973, "category": "Tree", - "title": "Count Nodes Equal to Sum of Descendants", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants/" + "id": 1973, + "link": "https://leetcode.com/problems/count-nodes-equal-to-sum-of-descendants/", + "title": "Count Nodes Equal to Sum of Descendants" }, "1974": { - "id": 1974, "category": "Greedy", - "title": "Minimum Time to Type Word Using Special Typewriter", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter/" + "id": 1974, + "link": "https://leetcode.com/problems/minimum-time-to-type-word-using-special-typewriter/", + "title": "Minimum Time to Type Word Using Special Typewriter" }, "1975": { - "id": 1975, "category": "Greedy", - "title": "Maximum Matrix Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-matrix-sum/" + "id": 1975, + "link": "https://leetcode.com/problems/maximum-matrix-sum/", + "title": "Maximum Matrix Sum" }, "1976": { - "id": 1976, "category": "Graph Traversal", - "title": "Number of Ways to Arrive at Destination", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-arrive-at-destination/" + "id": 1976, + "link": "https://leetcode.com/problems/number-of-ways-to-arrive-at-destination/", + "title": "Number of Ways to Arrive at Destination" }, "1977": { - "id": 1977, "category": "Dynamic Programming", - "title": "Number of Ways to Separate Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-separate-numbers/" + "id": 1977, + "link": "https://leetcode.com/problems/number-of-ways-to-separate-numbers/", + "title": "Number of Ways to Separate Numbers" }, "1978": { - "id": 1978, "category": "Database", - "title": "Employees Whose Manager Left the Company", "difficulty": "Easy", - "link": "https://leetcode.com/problems/employees-whose-manager-left-the-company/" + "id": 1978, + "link": "https://leetcode.com/problems/employees-whose-manager-left-the-company/", + "title": "Employees Whose Manager Left the Company" }, "1979": { - "id": 1979, "category": "Math & Geometry", - "title": "Find Greatest Common Divisor of Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-greatest-common-divisor-of-array/" + "id": 1979, + "link": "https://leetcode.com/problems/find-greatest-common-divisor-of-array/", + "title": "Find Greatest Common Divisor of Array" }, "1980": { - "id": 1980, "category": "Backtracking", - "title": "Find Unique Binary String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-unique-binary-string/" + "id": 1980, + "link": "https://leetcode.com/problems/find-unique-binary-string/", + "title": "Find Unique Binary String" }, "1981": { - "id": 1981, "category": "Dynamic Programming", - "title": "Minimize the Difference Between Target and Chosen Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements/" + "id": 1981, + "link": "https://leetcode.com/problems/minimize-the-difference-between-target-and-chosen-elements/", + "title": "Minimize the Difference Between Target and Chosen Elements" }, "1982": { - "id": 1982, "category": "Array & Hashing", - "title": "Find Array Given Subset Sums", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-array-given-subset-sums/" + "id": 1982, + "link": "https://leetcode.com/problems/find-array-given-subset-sums/", + "title": "Find Array Given Subset Sums" }, "1983": { - "id": 1983, "category": "Array & Hashing", - "title": "Widest Pair of Indices With Equal Range Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/widest-pair-of-indices-with-equal-range-sum/" + "id": 1983, + "link": "https://leetcode.com/problems/widest-pair-of-indices-with-equal-range-sum/", + "title": "Widest Pair of Indices With Equal Range Sum" }, "1984": { - "id": 1984, "category": "Sliding Window", - "title": "Minimum Difference Between Highest and Lowest of K Scores", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores/" + "id": 1984, + "link": "https://leetcode.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores/", + "title": "Minimum Difference Between Highest and Lowest of K Scores" }, "1985": { - "id": 1985, "category": "Heap (Priority Queue)", - "title": "Find the Kth Largest Integer in the Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array/" + "id": 1985, + "link": "https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array/", + "title": "Find the Kth Largest Integer in the Array" }, "1986": { - "id": 1986, "category": "Dynamic Programming", - "title": "Minimum Number of Work Sessions to Finish the Tasks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks/" + "id": 1986, + "link": "https://leetcode.com/problems/minimum-number-of-work-sessions-to-finish-the-tasks/", + "title": "Minimum Number of Work Sessions to Finish the Tasks" }, "1987": { - "id": 1987, "category": "Dynamic Programming", - "title": "Number of Unique Good Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-unique-good-subsequences/" + "id": 1987, + "link": "https://leetcode.com/problems/number-of-unique-good-subsequences/", + "title": "Number of Unique Good Subsequences" }, "1988": { - "id": 1988, "category": "Database", - "title": "Find Cutoff Score for Each School", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-cutoff-score-for-each-school/" + "id": 1988, + "link": "https://leetcode.com/problems/find-cutoff-score-for-each-school/", + "title": "Find Cutoff Score for Each School" }, "1989": { - "id": 1989, "category": "Greedy", - "title": "Maximum Number of People That Can Be Caught in Tag", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag/" + "id": 1989, + "link": "https://leetcode.com/problems/maximum-number-of-people-that-can-be-caught-in-tag/", + "title": "Maximum Number of People That Can Be Caught in Tag" }, "1990": { - "id": 1990, "category": "Database", - "title": "Count the Number of Experiments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-experiments/" + "id": 1990, + "link": "https://leetcode.com/problems/count-the-number-of-experiments/", + "title": "Count the Number of Experiments" }, "1991": { - "id": 1991, "category": "Array & Hashing", - "title": "Find the Middle Index in Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-middle-index-in-array/" + "id": 1991, + "link": "https://leetcode.com/problems/find-the-middle-index-in-array/", + "title": "Find the Middle Index in Array" }, "1992": { - "id": 1992, "category": "Graph Traversal", - "title": "Find All Groups of Farmland", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-groups-of-farmland/" + "id": 1992, + "link": "https://leetcode.com/problems/find-all-groups-of-farmland/", + "title": "Find All Groups of Farmland" }, "1993": { - "id": 1993, "category": "Tree", - "title": "Operations on Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/operations-on-tree/" + "id": 1993, + "link": "https://leetcode.com/problems/operations-on-tree/", + "title": "Operations on Tree" }, "1994": { - "id": 1994, "category": "Dynamic Programming", - "title": "The Number of Good Subsets", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-number-of-good-subsets/" + "id": 1994, + "link": "https://leetcode.com/problems/the-number-of-good-subsets/", + "title": "The Number of Good Subsets" }, "1995": { - "id": 1995, "category": "Array & Hashing", - "title": "Count Special Quadruplets", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-special-quadruplets/" + "id": 1995, + "link": "https://leetcode.com/problems/count-special-quadruplets/", + "title": "Count Special Quadruplets" }, "1996": { - "id": 1996, "category": "Stack", - "title": "The Number of Weak Characters in the Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-weak-characters-in-the-game/" + "id": 1996, + "link": "https://leetcode.com/problems/the-number-of-weak-characters-in-the-game/", + "title": "The Number of Weak Characters in the Game" }, "1997": { - "id": 1997, "category": "Dynamic Programming", - "title": "First Day Where You Have Been in All the Rooms", "difficulty": "Medium", - "link": "https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms/" + "id": 1997, + "link": "https://leetcode.com/problems/first-day-where-you-have-been-in-all-the-rooms/", + "title": "First Day Where You Have Been in All the Rooms" }, "1998": { - "id": 1998, "category": "Graph Traversal", - "title": "GCD Sort of an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/gcd-sort-of-an-array/" + "id": 1998, + "link": "https://leetcode.com/problems/gcd-sort-of-an-array/", + "title": "GCD Sort of an Array" }, "1999": { - "id": 1999, "category": "Math & Geometry", - "title": "Smallest Greater Multiple Made of Two Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits/" + "id": 1999, + "link": "https://leetcode.com/problems/smallest-greater-multiple-made-of-two-digits/", + "title": "Smallest Greater Multiple Made of Two Digits" }, "2000": { - "id": 2000, "category": "Stack", - "title": "Reverse Prefix of Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-prefix-of-word/" + "id": 2000, + "link": "https://leetcode.com/problems/reverse-prefix-of-word/", + "title": "Reverse Prefix of Word" }, "2001": { - "id": 2001, "category": "Math & Geometry", - "title": "Number of Pairs of Interchangeable Rectangles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles/" + "id": 2001, + "link": "https://leetcode.com/problems/number-of-pairs-of-interchangeable-rectangles/", + "title": "Number of Pairs of Interchangeable Rectangles" }, "2002": { - "id": 2002, "category": "Dynamic Programming", - "title": "Maximum Product of the Length of Two Palindromic Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/" + "id": 2002, + "link": "https://leetcode.com/problems/maximum-product-of-the-length-of-two-palindromic-subsequences/", + "title": "Maximum Product of the Length of Two Palindromic Subsequences" }, "2003": { - "id": 2003, "category": "Tree", - "title": "Smallest Missing Genetic Value in Each Subtree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree/" + "id": 2003, + "link": "https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree/", + "title": "Smallest Missing Genetic Value in Each Subtree" }, "2004": { - "id": 2004, "category": "Database", - "title": "The Number of Seniors and Juniors to Join the Company", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company/" + "id": 2004, + "link": "https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company/", + "title": "The Number of Seniors and Juniors to Join the Company" }, "2005": { - "id": 2005, "category": "Tree", - "title": "Subtree Removal Game with Fibonacci Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree/" + "id": 2005, + "link": "https://leetcode.com/problems/subtree-removal-game-with-fibonacci-tree/", + "title": "Subtree Removal Game with Fibonacci Tree" }, "2006": { - "id": 2006, "category": "Array & Hashing", - "title": "Count Number of Pairs With Absolute Difference K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k/" + "id": 2006, + "link": "https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k/", + "title": "Count Number of Pairs With Absolute Difference K" }, "2007": { - "id": 2007, "category": "Greedy", - "title": "Find Original Array From Doubled Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-original-array-from-doubled-array/" + "id": 2007, + "link": "https://leetcode.com/problems/find-original-array-from-doubled-array/", + "title": "Find Original Array From Doubled Array" }, "2008": { - "id": 2008, "category": "Dynamic Programming", - "title": "Maximum Earnings From Taxi", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-earnings-from-taxi/" + "id": 2008, + "link": "https://leetcode.com/problems/maximum-earnings-from-taxi/", + "title": "Maximum Earnings From Taxi" }, "2009": { - "id": 2009, "category": "Sliding Window", - "title": "Minimum Number of Operations to Make Array Continuous", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/" + "id": 2009, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-continuous/", + "title": "Minimum Number of Operations to Make Array Continuous" }, "2010": { - "id": 2010, "category": "Database", - "title": "The Number of Seniors and Juniors to Join the Company II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/" + "id": 2010, + "link": "https://leetcode.com/problems/the-number-of-seniors-and-juniors-to-join-the-company-ii/", + "title": "The Number of Seniors and Juniors to Join the Company II" }, "2011": { - "id": 2011, "category": "Array & Hashing", - "title": "Final Value of Variable After Performing Operations", "difficulty": "Easy", - "link": "https://leetcode.com/problems/final-value-of-variable-after-performing-operations/" + "id": 2011, + "link": "https://leetcode.com/problems/final-value-of-variable-after-performing-operations/", + "title": "Final Value of Variable After Performing Operations" }, "2012": { - "id": 2012, "category": "Array & Hashing", - "title": "Sum of Beauty in the Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-beauty-in-the-array/" + "id": 2012, + "link": "https://leetcode.com/problems/sum-of-beauty-in-the-array/", + "title": "Sum of Beauty in the Array" }, "2013": { - "id": 2013, "category": "Array & Hashing", - "title": "Detect Squares", "difficulty": "Medium", - "link": "https://leetcode.com/problems/detect-squares/" + "id": 2013, + "link": "https://leetcode.com/problems/detect-squares/", + "title": "Detect Squares" }, "2014": { - "id": 2014, "category": "Backtracking", - "title": "Longest Subsequence Repeated k Times", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-subsequence-repeated-k-times/" + "id": 2014, + "link": "https://leetcode.com/problems/longest-subsequence-repeated-k-times/", + "title": "Longest Subsequence Repeated k Times" }, "2015": { - "id": 2015, "category": "Heap (Priority Queue)", - "title": "Average Height of Buildings in Each Segment", "difficulty": "Medium", - "link": "https://leetcode.com/problems/average-height-of-buildings-in-each-segment/" + "id": 2015, + "link": "https://leetcode.com/problems/average-height-of-buildings-in-each-segment/", + "title": "Average Height of Buildings in Each Segment" }, "2016": { - "id": 2016, "category": "Array & Hashing", - "title": "Maximum Difference Between Increasing Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-difference-between-increasing-elements/" + "id": 2016, + "link": "https://leetcode.com/problems/maximum-difference-between-increasing-elements/", + "title": "Maximum Difference Between Increasing Elements" }, "2017": { - "id": 2017, "category": "Array & Hashing", - "title": "Grid Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/grid-game/" + "id": 2017, + "link": "https://leetcode.com/problems/grid-game/", + "title": "Grid Game" }, "2018": { - "id": 2018, "category": "Array & Hashing", - "title": "Check if Word Can Be Placed In Crossword", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword/" + "id": 2018, + "link": "https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword/", + "title": "Check if Word Can Be Placed In Crossword" }, "2019": { - "id": 2019, "category": "Dynamic Programming", - "title": "The Score of Students Solving Math Expression", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-score-of-students-solving-math-expression/" + "id": 2019, + "link": "https://leetcode.com/problems/the-score-of-students-solving-math-expression/", + "title": "The Score of Students Solving Math Expression" }, "2020": { - "id": 2020, "category": "Database", - "title": "Number of Accounts That Did Not Stream", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-accounts-that-did-not-stream/" + "id": 2020, + "link": "https://leetcode.com/problems/number-of-accounts-that-did-not-stream/", + "title": "Number of Accounts That Did Not Stream" }, "2021": { - "id": 2021, "category": "Array & Hashing", - "title": "Brightest Position on Street", "difficulty": "Medium", - "link": "https://leetcode.com/problems/brightest-position-on-street/" + "id": 2021, + "link": "https://leetcode.com/problems/brightest-position-on-street/", + "title": "Brightest Position on Street" }, "2022": { - "id": 2022, "category": "Array & Hashing", - "title": "Convert 1D Array Into 2D Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-1d-array-into-2d-array/" + "id": 2022, + "link": "https://leetcode.com/problems/convert-1d-array-into-2d-array/", + "title": "Convert 1D Array Into 2D Array" }, "2023": { - "id": 2023, "category": "Array & Hashing", - "title": "Number of Pairs of Strings With Concatenation Equal to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/" + "id": 2023, + "link": "https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target/", + "title": "Number of Pairs of Strings With Concatenation Equal to Target" }, "2024": { - "id": 2024, "category": "Sliding Window", - "title": "Maximize the Confusion of an Exam", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-the-confusion-of-an-exam/" + "id": 2024, + "link": "https://leetcode.com/problems/maximize-the-confusion-of-an-exam/", + "title": "Maximize the Confusion of an Exam" }, "2025": { - "id": 2025, "category": "Array & Hashing", - "title": "Maximum Number of Ways to Partition an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array/" + "id": 2025, + "link": "https://leetcode.com/problems/maximum-number-of-ways-to-partition-an-array/", + "title": "Maximum Number of Ways to Partition an Array" }, "2026": { - "id": 2026, "category": "Database", - "title": "Low-Quality Problems", "difficulty": "Easy", - "link": "https://leetcode.com/problems/low-quality-problems/" + "id": 2026, + "link": "https://leetcode.com/problems/low-quality-problems/", + "title": "Low-Quality Problems" }, "2027": { - "id": 2027, "category": "Greedy", - "title": "Minimum Moves to Convert String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-moves-to-convert-string/" + "id": 2027, + "link": "https://leetcode.com/problems/minimum-moves-to-convert-string/", + "title": "Minimum Moves to Convert String" }, "2028": { - "id": 2028, "category": "Math & Geometry", - "title": "Find Missing Observations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-missing-observations/" + "id": 2028, + "link": "https://leetcode.com/problems/find-missing-observations/", + "title": "Find Missing Observations" }, "2029": { - "id": 2029, "category": "Greedy", - "title": "Stone Game IX", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stone-game-ix/" + "id": 2029, + "link": "https://leetcode.com/problems/stone-game-ix/", + "title": "Stone Game IX" }, "2030": { - "id": 2030, "category": "Stack", - "title": "Smallest K-Length Subsequence With Occurrences of a Letter", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/" + "id": 2030, + "link": "https://leetcode.com/problems/smallest-k-length-subsequence-with-occurrences-of-a-letter/", + "title": "Smallest K-Length Subsequence With Occurrences of a Letter" }, "2031": { - "id": 2031, "category": "Tree", - "title": "Count Subarrays With More Ones Than Zeros", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros/" + "id": 2031, + "link": "https://leetcode.com/problems/count-subarrays-with-more-ones-than-zeros/", + "title": "Count Subarrays With More Ones Than Zeros" }, "2032": { - "id": 2032, "category": "Bit Manipulation", - "title": "Two Out of Three", "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-out-of-three/" + "id": 2032, + "link": "https://leetcode.com/problems/two-out-of-three/", + "title": "Two Out of Three" }, "2033": { - "id": 2033, "category": "Math & Geometry", - "title": "Minimum Operations to Make a Uni-Value Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid/" + "id": 2033, + "link": "https://leetcode.com/problems/minimum-operations-to-make-a-uni-value-grid/", + "title": "Minimum Operations to Make a Uni-Value Grid" }, "2034": { - "id": 2034, "category": "Heap (Priority Queue)", - "title": "Stock Price Fluctuation ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stock-price-fluctuation/" + "id": 2034, + "link": "https://leetcode.com/problems/stock-price-fluctuation/", + "title": "Stock Price Fluctuation " }, "2035": { - "id": 2035, "category": "Dynamic Programming", - "title": "Partition Array Into Two Arrays to Minimize Sum Difference", "difficulty": "Hard", - "link": "https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference/" + "id": 2035, + "link": "https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference/", + "title": "Partition Array Into Two Arrays to Minimize Sum Difference" }, "2036": { - "id": 2036, "category": "Dynamic Programming", - "title": "Maximum Alternating Subarray Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-alternating-subarray-sum/" + "id": 2036, + "link": "https://leetcode.com/problems/maximum-alternating-subarray-sum/", + "title": "Maximum Alternating Subarray Sum" }, "2037": { - "id": 2037, "category": "Greedy", - "title": "Minimum Number of Moves to Seat Everyone", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/" + "id": 2037, + "link": "https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/", + "title": "Minimum Number of Moves to Seat Everyone" }, "2038": { - "id": 2038, "category": "Greedy", - "title": "Remove Colored Pieces if Both Neighbors are the Same Color", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/" + "id": 2038, + "link": "https://leetcode.com/problems/remove-colored-pieces-if-both-neighbors-are-the-same-color/", + "title": "Remove Colored Pieces if Both Neighbors are the Same Color" }, "2039": { - "id": 2039, "category": "Graph Traversal", - "title": "The Time When the Network Becomes Idle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-time-when-the-network-becomes-idle/" + "id": 2039, + "link": "https://leetcode.com/problems/the-time-when-the-network-becomes-idle/", + "title": "The Time When the Network Becomes Idle" }, "2040": { - "id": 2040, "category": "Binary Search", - "title": "Kth Smallest Product of Two Sorted Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays/" + "id": 2040, + "link": "https://leetcode.com/problems/kth-smallest-product-of-two-sorted-arrays/", + "title": "Kth Smallest Product of Two Sorted Arrays" }, "2041": { - "id": 2041, "category": "Database", - "title": "Accepted Candidates From the Interviews", "difficulty": "Medium", - "link": "https://leetcode.com/problems/accepted-candidates-from-the-interviews/" + "id": 2041, + "link": "https://leetcode.com/problems/accepted-candidates-from-the-interviews/", + "title": "Accepted Candidates From the Interviews" }, "2042": { - "id": 2042, "category": "Array & Hashing", - "title": "Check if Numbers Are Ascending in a Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/" + "id": 2042, + "link": "https://leetcode.com/problems/check-if-numbers-are-ascending-in-a-sentence/", + "title": "Check if Numbers Are Ascending in a Sentence" }, "2043": { - "id": 2043, "category": "Array & Hashing", - "title": "Simple Bank System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/simple-bank-system/" + "id": 2043, + "link": "https://leetcode.com/problems/simple-bank-system/", + "title": "Simple Bank System" }, "2044": { - "id": 2044, "category": "Backtracking", - "title": "Count Number of Maximum Bitwise-OR Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/" + "id": 2044, + "link": "https://leetcode.com/problems/count-number-of-maximum-bitwise-or-subsets/", + "title": "Count Number of Maximum Bitwise-OR Subsets" }, "2045": { - "id": 2045, "category": "Graph Traversal", - "title": "Second Minimum Time to Reach Destination", "difficulty": "Hard", - "link": "https://leetcode.com/problems/second-minimum-time-to-reach-destination/" + "id": 2045, + "link": "https://leetcode.com/problems/second-minimum-time-to-reach-destination/", + "title": "Second Minimum Time to Reach Destination" }, "2046": { - "id": 2046, "category": "Linked List", - "title": "Sort Linked List Already Sorted Using Absolute Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values/" + "id": 2046, + "link": "https://leetcode.com/problems/sort-linked-list-already-sorted-using-absolute-values/", + "title": "Sort Linked List Already Sorted Using Absolute Values" }, "2047": { - "id": 2047, "category": "Array & Hashing", - "title": "Number of Valid Words in a Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-valid-words-in-a-sentence/" + "id": 2047, + "link": "https://leetcode.com/problems/number-of-valid-words-in-a-sentence/", + "title": "Number of Valid Words in a Sentence" }, "2048": { - "id": 2048, "category": "Backtracking", - "title": "Next Greater Numerically Balanced Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/next-greater-numerically-balanced-number/" + "id": 2048, + "link": "https://leetcode.com/problems/next-greater-numerically-balanced-number/", + "title": "Next Greater Numerically Balanced Number" }, "2049": { - "id": 2049, "category": "Tree", - "title": "Count Nodes With the Highest Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-nodes-with-the-highest-score/" + "id": 2049, + "link": "https://leetcode.com/problems/count-nodes-with-the-highest-score/", + "title": "Count Nodes With the Highest Score" }, "2050": { - "id": 2050, "category": "Graph Traversal", - "title": "Parallel Courses III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/parallel-courses-iii/" + "id": 2050, + "link": "https://leetcode.com/problems/parallel-courses-iii/", + "title": "Parallel Courses III" }, "2051": { - "id": 2051, "category": "Database", - "title": "The Category of Each Member in the Store", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-category-of-each-member-in-the-store/" + "id": 2051, + "link": "https://leetcode.com/problems/the-category-of-each-member-in-the-store/", + "title": "The Category of Each Member in the Store" }, "2052": { - "id": 2052, "category": "Dynamic Programming", - "title": "Minimum Cost to Separate Sentence Into Rows", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows/" + "id": 2052, + "link": "https://leetcode.com/problems/minimum-cost-to-separate-sentence-into-rows/", + "title": "Minimum Cost to Separate Sentence Into Rows" }, "2053": { - "id": 2053, "category": "Array & Hashing", - "title": "Kth Distinct String in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/kth-distinct-string-in-an-array/" + "id": 2053, + "link": "https://leetcode.com/problems/kth-distinct-string-in-an-array/", + "title": "Kth Distinct String in an Array" }, "2054": { - "id": 2054, "category": "Dynamic Programming", - "title": "Two Best Non-Overlapping Events", "difficulty": "Medium", - "link": "https://leetcode.com/problems/two-best-non-overlapping-events/" + "id": 2054, + "link": "https://leetcode.com/problems/two-best-non-overlapping-events/", + "title": "Two Best Non-Overlapping Events" }, "2055": { - "id": 2055, "category": "Binary Search", - "title": "Plates Between Candles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/plates-between-candles/" + "id": 2055, + "link": "https://leetcode.com/problems/plates-between-candles/", + "title": "Plates Between Candles" }, "2056": { - "id": 2056, "category": "Backtracking", - "title": "Number of Valid Move Combinations On Chessboard", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-valid-move-combinations-on-chessboard/" + "id": 2056, + "link": "https://leetcode.com/problems/number-of-valid-move-combinations-on-chessboard/", + "title": "Number of Valid Move Combinations On Chessboard" }, "2057": { - "id": 2057, "category": "Array & Hashing", - "title": "Smallest Index With Equal Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-index-with-equal-value/" + "id": 2057, + "link": "https://leetcode.com/problems/smallest-index-with-equal-value/", + "title": "Smallest Index With Equal Value" }, "2058": { - "id": 2058, "category": "Linked List", - "title": "Find the Minimum and Maximum Number of Nodes Between Critical Points", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/" + "id": 2058, + "link": "https://leetcode.com/problems/find-the-minimum-and-maximum-number-of-nodes-between-critical-points/", + "title": "Find the Minimum and Maximum Number of Nodes Between Critical Points" }, "2059": { - "id": 2059, "category": "Graph Traversal", - "title": "Minimum Operations to Convert Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-convert-number/" + "id": 2059, + "link": "https://leetcode.com/problems/minimum-operations-to-convert-number/", + "title": "Minimum Operations to Convert Number" }, "2060": { - "id": 2060, "category": "Dynamic Programming", - "title": "Check if an Original String Exists Given Two Encoded Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings/" + "id": 2060, + "link": "https://leetcode.com/problems/check-if-an-original-string-exists-given-two-encoded-strings/", + "title": "Check if an Original String Exists Given Two Encoded Strings" }, "2061": { - "id": 2061, "category": "Array & Hashing", - "title": "Number of Spaces Cleaning Robot Cleaned", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned/" + "id": 2061, + "link": "https://leetcode.com/problems/number-of-spaces-cleaning-robot-cleaned/", + "title": "Number of Spaces Cleaning Robot Cleaned" }, "2062": { - "id": 2062, "category": "Array & Hashing", - "title": "Count Vowel Substrings of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-vowel-substrings-of-a-string/" + "id": 2062, + "link": "https://leetcode.com/problems/count-vowel-substrings-of-a-string/", + "title": "Count Vowel Substrings of a String" }, "2063": { - "id": 2063, "category": "Dynamic Programming", - "title": "Vowels of All Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/vowels-of-all-substrings/" + "id": 2063, + "link": "https://leetcode.com/problems/vowels-of-all-substrings/", + "title": "Vowels of All Substrings" }, "2064": { - "id": 2064, "category": "Binary Search", - "title": "Minimized Maximum of Products Distributed to Any Store", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/" + "id": 2064, + "link": "https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/", + "title": "Minimized Maximum of Products Distributed to Any Store" }, "2065": { - "id": 2065, "category": "Graph Traversal", - "title": "Maximum Path Quality of a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-path-quality-of-a-graph/" + "id": 2065, + "link": "https://leetcode.com/problems/maximum-path-quality-of-a-graph/", + "title": "Maximum Path Quality of a Graph" }, "2066": { - "id": 2066, "category": "Database", - "title": "Account Balance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/account-balance/" + "id": 2066, + "link": "https://leetcode.com/problems/account-balance/", + "title": "Account Balance" }, "2067": { - "id": 2067, "category": "Sliding Window", - "title": "Number of Equal Count Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-equal-count-substrings/" + "id": 2067, + "link": "https://leetcode.com/problems/number-of-equal-count-substrings/", + "title": "Number of Equal Count Substrings" }, "2068": { - "id": 2068, "category": "Array & Hashing", - "title": "Check Whether Two Strings are Almost Equivalent", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent/" + "id": 2068, + "link": "https://leetcode.com/problems/check-whether-two-strings-are-almost-equivalent/", + "title": "Check Whether Two Strings are Almost Equivalent" }, "2069": { - "id": 2069, "category": "Array & Hashing", - "title": "Walking Robot Simulation II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/walking-robot-simulation-ii/" + "id": 2069, + "link": "https://leetcode.com/problems/walking-robot-simulation-ii/", + "title": "Walking Robot Simulation II" }, "2070": { - "id": 2070, "category": "Binary Search", - "title": "Most Beautiful Item for Each Query", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-beautiful-item-for-each-query/" + "id": 2070, + "link": "https://leetcode.com/problems/most-beautiful-item-for-each-query/", + "title": "Most Beautiful Item for Each Query" }, "2071": { - "id": 2071, "category": "Binary Search", - "title": "Maximum Number of Tasks You Can Assign", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign/" + "id": 2071, + "link": "https://leetcode.com/problems/maximum-number-of-tasks-you-can-assign/", + "title": "Maximum Number of Tasks You Can Assign" }, "2072": { - "id": 2072, "category": "Database", - "title": "The Winner University", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-winner-university/" + "id": 2072, + "link": "https://leetcode.com/problems/the-winner-university/", + "title": "The Winner University" }, "2073": { - "id": 2073, "category": "Array & Hashing", - "title": "Time Needed to Buy Tickets", "difficulty": "Easy", - "link": "https://leetcode.com/problems/time-needed-to-buy-tickets/" + "id": 2073, + "link": "https://leetcode.com/problems/time-needed-to-buy-tickets/", + "title": "Time Needed to Buy Tickets" }, "2074": { - "id": 2074, "category": "Linked List", - "title": "Reverse Nodes in Even Length Groups", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-nodes-in-even-length-groups/" + "id": 2074, + "link": "https://leetcode.com/problems/reverse-nodes-in-even-length-groups/", + "title": "Reverse Nodes in Even Length Groups" }, "2075": { - "id": 2075, "category": "Array & Hashing", - "title": "Decode the Slanted Ciphertext", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decode-the-slanted-ciphertext/" + "id": 2075, + "link": "https://leetcode.com/problems/decode-the-slanted-ciphertext/", + "title": "Decode the Slanted Ciphertext" }, "2076": { - "id": 2076, "category": "Graph Traversal", - "title": "Process Restricted Friend Requests", "difficulty": "Hard", - "link": "https://leetcode.com/problems/process-restricted-friend-requests/" + "id": 2076, + "link": "https://leetcode.com/problems/process-restricted-friend-requests/", + "title": "Process Restricted Friend Requests" }, "2077": { - "id": 2077, "category": "Graph Traversal", - "title": "Paths in Maze That Lead to Same Room", "difficulty": "Medium", - "link": "https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room/" + "id": 2077, + "link": "https://leetcode.com/problems/paths-in-maze-that-lead-to-same-room/", + "title": "Paths in Maze That Lead to Same Room" }, "2078": { - "id": 2078, "category": "Greedy", - "title": "Two Furthest Houses With Different Colors", "difficulty": "Easy", - "link": "https://leetcode.com/problems/two-furthest-houses-with-different-colors/" + "id": 2078, + "link": "https://leetcode.com/problems/two-furthest-houses-with-different-colors/", + "title": "Two Furthest Houses With Different Colors" }, "2079": { - "id": 2079, "category": "Array & Hashing", - "title": "Watering Plants", "difficulty": "Medium", - "link": "https://leetcode.com/problems/watering-plants/" + "id": 2079, + "link": "https://leetcode.com/problems/watering-plants/", + "title": "Watering Plants" }, "2080": { - "id": 2080, "category": "Tree", - "title": "Range Frequency Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-frequency-queries/" + "id": 2080, + "link": "https://leetcode.com/problems/range-frequency-queries/", + "title": "Range Frequency Queries" }, "2081": { - "id": 2081, "category": "Math & Geometry", - "title": "Sum of k-Mirror Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-k-mirror-numbers/" + "id": 2081, + "link": "https://leetcode.com/problems/sum-of-k-mirror-numbers/", + "title": "Sum of k-Mirror Numbers" }, "2082": { - "id": 2082, "category": "Database", - "title": "The Number of Rich Customers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-number-of-rich-customers/" + "id": 2082, + "link": "https://leetcode.com/problems/the-number-of-rich-customers/", + "title": "The Number of Rich Customers" }, "2083": { - "id": 2083, "category": "Math & Geometry", - "title": "Substrings That Begin and End With the Same Letter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter/" + "id": 2083, + "link": "https://leetcode.com/problems/substrings-that-begin-and-end-with-the-same-letter/", + "title": "Substrings That Begin and End With the Same Letter" }, "2084": { - "id": 2084, "category": "Database", - "title": "Drop Type 1 Orders for Customers With Type 0 Orders", "difficulty": "Medium", - "link": "https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders/" + "id": 2084, + "link": "https://leetcode.com/problems/drop-type-1-orders-for-customers-with-type-0-orders/", + "title": "Drop Type 1 Orders for Customers With Type 0 Orders" }, "2085": { - "id": 2085, "category": "Array & Hashing", - "title": "Count Common Words With One Occurrence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-common-words-with-one-occurrence/" + "id": 2085, + "link": "https://leetcode.com/problems/count-common-words-with-one-occurrence/", + "title": "Count Common Words With One Occurrence" }, "2086": { - "id": 2086, "category": "Dynamic Programming", - "title": "Minimum Number of Food Buckets to Feed the Hamsters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-food-buckets-to-feed-the-hamsters/" + "id": 2086, + "link": "https://leetcode.com/problems/minimum-number-of-food-buckets-to-feed-the-hamsters/", + "title": "Minimum Number of Food Buckets to Feed the Hamsters" }, "2087": { - "id": 2087, "category": "Greedy", - "title": "Minimum Cost Homecoming of a Robot in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/" + "id": 2087, + "link": "https://leetcode.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid/", + "title": "Minimum Cost Homecoming of a Robot in a Grid" }, "2088": { - "id": 2088, "category": "Dynamic Programming", - "title": "Count Fertile Pyramids in a Land", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-fertile-pyramids-in-a-land/" + "id": 2088, + "link": "https://leetcode.com/problems/count-fertile-pyramids-in-a-land/", + "title": "Count Fertile Pyramids in a Land" }, "2089": { - "id": 2089, "category": "Binary Search", - "title": "Find Target Indices After Sorting Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-target-indices-after-sorting-array/" + "id": 2089, + "link": "https://leetcode.com/problems/find-target-indices-after-sorting-array/", + "title": "Find Target Indices After Sorting Array" }, "2090": { - "id": 2090, "category": "Sliding Window", - "title": "K Radius Subarray Averages", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-radius-subarray-averages/" + "id": 2090, + "link": "https://leetcode.com/problems/k-radius-subarray-averages/", + "title": "K Radius Subarray Averages" }, "2091": { - "id": 2091, "category": "Greedy", - "title": "Removing Minimum and Maximum From Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/removing-minimum-and-maximum-from-array/" + "id": 2091, + "link": "https://leetcode.com/problems/removing-minimum-and-maximum-from-array/", + "title": "Removing Minimum and Maximum From Array" }, "2092": { - "id": 2092, "category": "Graph Traversal", - "title": "Find All People With Secret", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-all-people-with-secret/" + "id": 2092, + "link": "https://leetcode.com/problems/find-all-people-with-secret/", + "title": "Find All People With Secret" }, "2093": { - "id": 2093, "category": "Graph Traversal", - "title": "Minimum Cost to Reach City With Discounts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts/" + "id": 2093, + "link": "https://leetcode.com/problems/minimum-cost-to-reach-city-with-discounts/", + "title": "Minimum Cost to Reach City With Discounts" }, "2094": { - "id": 2094, "category": "Array & Hashing", - "title": "Finding 3-Digit Even Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/finding-3-digit-even-numbers/" + "id": 2094, + "link": "https://leetcode.com/problems/finding-3-digit-even-numbers/", + "title": "Finding 3-Digit Even Numbers" }, "2095": { - "id": 2095, "category": "Linked List", - "title": "Delete the Middle Node of a Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/" + "id": 2095, + "link": "https://leetcode.com/problems/delete-the-middle-node-of-a-linked-list/", + "title": "Delete the Middle Node of a Linked List" }, "2096": { - "id": 2096, "category": "Tree", - "title": "Step-By-Step Directions From a Binary Tree Node to Another", "difficulty": "Medium", - "link": "https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another/" + "id": 2096, + "link": "https://leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another/", + "title": "Step-By-Step Directions From a Binary Tree Node to Another" }, "2097": { - "id": 2097, "category": "Graph Traversal", - "title": "Valid Arrangement of Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/valid-arrangement-of-pairs/" + "id": 2097, + "link": "https://leetcode.com/problems/valid-arrangement-of-pairs/", + "title": "Valid Arrangement of Pairs" }, "2098": { - "id": 2098, "category": "Greedy", - "title": "Subsequence of Size K With the Largest Even Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum/" + "id": 2098, + "link": "https://leetcode.com/problems/subsequence-of-size-k-with-the-largest-even-sum/", + "title": "Subsequence of Size K With the Largest Even Sum" }, "2099": { - "id": 2099, "category": "Heap (Priority Queue)", - "title": "Find Subsequence of Length K With the Largest Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum/" + "id": 2099, + "link": "https://leetcode.com/problems/find-subsequence-of-length-k-with-the-largest-sum/", + "title": "Find Subsequence of Length K With the Largest Sum" }, "2100": { - "id": 2100, "category": "Dynamic Programming", - "title": "Find Good Days to Rob the Bank", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-good-days-to-rob-the-bank/" + "id": 2100, + "link": "https://leetcode.com/problems/find-good-days-to-rob-the-bank/", + "title": "Find Good Days to Rob the Bank" }, "2101": { - "id": 2101, "category": "Graph Traversal", - "title": "Detonate the Maximum Bombs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/detonate-the-maximum-bombs/" + "id": 2101, + "link": "https://leetcode.com/problems/detonate-the-maximum-bombs/", + "title": "Detonate the Maximum Bombs" }, "2102": { - "id": 2102, "category": "Heap (Priority Queue)", - "title": "Sequentially Ordinal Rank Tracker", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sequentially-ordinal-rank-tracker/" + "id": 2102, + "link": "https://leetcode.com/problems/sequentially-ordinal-rank-tracker/", + "title": "Sequentially Ordinal Rank Tracker" }, "2103": { - "id": 2103, "category": "Array & Hashing", - "title": "Rings and Rods", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rings-and-rods/" + "id": 2103, + "link": "https://leetcode.com/problems/rings-and-rods/", + "title": "Rings and Rods" }, "2104": { - "id": 2104, "category": "Stack", - "title": "Sum of Subarray Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-subarray-ranges/" + "id": 2104, + "link": "https://leetcode.com/problems/sum-of-subarray-ranges/", + "title": "Sum of Subarray Ranges" }, "2105": { - "id": 2105, "category": "Two Pointers", - "title": "Watering Plants II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/watering-plants-ii/" + "id": 2105, + "link": "https://leetcode.com/problems/watering-plants-ii/", + "title": "Watering Plants II" }, "2106": { - "id": 2106, "category": "Sliding Window", - "title": "Maximum Fruits Harvested After at Most K Steps", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps/" + "id": 2106, + "link": "https://leetcode.com/problems/maximum-fruits-harvested-after-at-most-k-steps/", + "title": "Maximum Fruits Harvested After at Most K Steps" }, "2107": { - "id": 2107, "category": "Sliding Window", - "title": "Number of Unique Flavors After Sharing K Candies", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies/" + "id": 2107, + "link": "https://leetcode.com/problems/number-of-unique-flavors-after-sharing-k-candies/", + "title": "Number of Unique Flavors After Sharing K Candies" }, "2108": { - "id": 2108, "category": "Two Pointers", - "title": "Find First Palindromic String in the Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-first-palindromic-string-in-the-array/" + "id": 2108, + "link": "https://leetcode.com/problems/find-first-palindromic-string-in-the-array/", + "title": "Find First Palindromic String in the Array" }, "2109": { - "id": 2109, "category": "Two Pointers", - "title": "Adding Spaces to a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/adding-spaces-to-a-string/" + "id": 2109, + "link": "https://leetcode.com/problems/adding-spaces-to-a-string/", + "title": "Adding Spaces to a String" }, "2110": { - "id": 2110, "category": "Dynamic Programming", - "title": "Number of Smooth Descent Periods of a Stock", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock/" + "id": 2110, + "link": "https://leetcode.com/problems/number-of-smooth-descent-periods-of-a-stock/", + "title": "Number of Smooth Descent Periods of a Stock" }, "2111": { - "id": 2111, "category": "Binary Search", - "title": "Minimum Operations to Make the Array K-Increasing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing/" + "id": 2111, + "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-k-increasing/", + "title": "Minimum Operations to Make the Array K-Increasing" }, "2112": { - "id": 2112, "category": "Database", - "title": "The Airport With the Most Traffic", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-airport-with-the-most-traffic/" + "id": 2112, + "link": "https://leetcode.com/problems/the-airport-with-the-most-traffic/", + "title": "The Airport With the Most Traffic" }, "2113": { - "id": 2113, "category": "Array & Hashing", - "title": "Elements in Array After Removing and Replacing Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements/" + "id": 2113, + "link": "https://leetcode.com/problems/elements-in-array-after-removing-and-replacing-elements/", + "title": "Elements in Array After Removing and Replacing Elements" }, "2114": { - "id": 2114, "category": "Array & Hashing", - "title": "Maximum Number of Words Found in Sentences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-words-found-in-sentences/" + "id": 2114, + "link": "https://leetcode.com/problems/maximum-number-of-words-found-in-sentences/", + "title": "Maximum Number of Words Found in Sentences" }, "2115": { - "id": 2115, "category": "Graph Traversal", - "title": "Find All Possible Recipes from Given Supplies", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/" + "id": 2115, + "link": "https://leetcode.com/problems/find-all-possible-recipes-from-given-supplies/", + "title": "Find All Possible Recipes from Given Supplies" }, "2116": { - "id": 2116, "category": "Stack", - "title": "Check if a Parentheses String Can Be Valid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid/" + "id": 2116, + "link": "https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid/", + "title": "Check if a Parentheses String Can Be Valid" }, "2117": { - "id": 2117, "category": "Math & Geometry", - "title": "Abbreviating the Product of a Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/abbreviating-the-product-of-a-range/" + "id": 2117, + "link": "https://leetcode.com/problems/abbreviating-the-product-of-a-range/", + "title": "Abbreviating the Product of a Range" }, "2118": { - "id": 2118, "category": "Database", - "title": "Build the Equation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/build-the-equation/" + "id": 2118, + "link": "https://leetcode.com/problems/build-the-equation/", + "title": "Build the Equation" }, "2119": { - "id": 2119, "category": "Math & Geometry", - "title": "A Number After a Double Reversal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/a-number-after-a-double-reversal/" + "id": 2119, + "link": "https://leetcode.com/problems/a-number-after-a-double-reversal/", + "title": "A Number After a Double Reversal" }, "2120": { - "id": 2120, "category": "Array & Hashing", - "title": "Execution of All Suffix Instructions Staying in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid/" + "id": 2120, + "link": "https://leetcode.com/problems/execution-of-all-suffix-instructions-staying-in-a-grid/", + "title": "Execution of All Suffix Instructions Staying in a Grid" }, "2121": { - "id": 2121, "category": "Array & Hashing", - "title": "Intervals Between Identical Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/intervals-between-identical-elements/" + "id": 2121, + "link": "https://leetcode.com/problems/intervals-between-identical-elements/", + "title": "Intervals Between Identical Elements" }, "2122": { - "id": 2122, "category": "Two Pointers", - "title": "Recover the Original Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/recover-the-original-array/" + "id": 2122, + "link": "https://leetcode.com/problems/recover-the-original-array/", + "title": "Recover the Original Array" }, "2123": { - "id": 2123, "category": "Graph Traversal", - "title": "Minimum Operations to Remove Adjacent Ones in Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/" + "id": 2123, + "link": "https://leetcode.com/problems/minimum-operations-to-remove-adjacent-ones-in-matrix/", + "title": "Minimum Operations to Remove Adjacent Ones in Matrix" }, "2124": { - "id": 2124, "category": "Array & Hashing", - "title": "Check if All A's Appears Before All B's", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/" + "id": 2124, + "link": "https://leetcode.com/problems/check-if-all-as-appears-before-all-bs/", + "title": "Check if All A's Appears Before All B's" }, "2125": { - "id": 2125, "category": "Math & Geometry", - "title": "Number of Laser Beams in a Bank", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-laser-beams-in-a-bank/" + "id": 2125, + "link": "https://leetcode.com/problems/number-of-laser-beams-in-a-bank/", + "title": "Number of Laser Beams in a Bank" }, "2126": { - "id": 2126, "category": "Greedy", - "title": "Destroying Asteroids", "difficulty": "Medium", - "link": "https://leetcode.com/problems/destroying-asteroids/" + "id": 2126, + "link": "https://leetcode.com/problems/destroying-asteroids/", + "title": "Destroying Asteroids" }, "2127": { - "id": 2127, "category": "Graph Traversal", - "title": "Maximum Employees to Be Invited to a Meeting", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting/" + "id": 2127, + "link": "https://leetcode.com/problems/maximum-employees-to-be-invited-to-a-meeting/", + "title": "Maximum Employees to Be Invited to a Meeting" }, "2128": { - "id": 2128, "category": "Bit Manipulation", - "title": "Remove All Ones With Row and Column Flips", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips/" + "id": 2128, + "link": "https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips/", + "title": "Remove All Ones With Row and Column Flips" }, "2129": { - "id": 2129, "category": "Array & Hashing", - "title": "Capitalize the Title", "difficulty": "Easy", - "link": "https://leetcode.com/problems/capitalize-the-title/" + "id": 2129, + "link": "https://leetcode.com/problems/capitalize-the-title/", + "title": "Capitalize the Title" }, "2130": { - "id": 2130, "category": "Stack", - "title": "Maximum Twin Sum of a Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/" + "id": 2130, + "link": "https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/", + "title": "Maximum Twin Sum of a Linked List" }, "2131": { - "id": 2131, "category": "Greedy", - "title": "Longest Palindrome by Concatenating Two Letter Words", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/" + "id": 2131, + "link": "https://leetcode.com/problems/longest-palindrome-by-concatenating-two-letter-words/", + "title": "Longest Palindrome by Concatenating Two Letter Words" }, "2132": { - "id": 2132, "category": "Greedy", - "title": "Stamping the Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/stamping-the-grid/" + "id": 2132, + "link": "https://leetcode.com/problems/stamping-the-grid/", + "title": "Stamping the Grid" }, "2133": { - "id": 2133, "category": "Array & Hashing", - "title": "Check if Every Row and Column Contains All Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/" + "id": 2133, + "link": "https://leetcode.com/problems/check-if-every-row-and-column-contains-all-numbers/", + "title": "Check if Every Row and Column Contains All Numbers" }, "2134": { - "id": 2134, "category": "Sliding Window", - "title": "Minimum Swaps to Group All 1's Together II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/" + "id": 2134, + "link": "https://leetcode.com/problems/minimum-swaps-to-group-all-1s-together-ii/", + "title": "Minimum Swaps to Group All 1's Together II" }, "2135": { - "id": 2135, "category": "Bit Manipulation", - "title": "Count Words Obtained After Adding a Letter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-words-obtained-after-adding-a-letter/" + "id": 2135, + "link": "https://leetcode.com/problems/count-words-obtained-after-adding-a-letter/", + "title": "Count Words Obtained After Adding a Letter" }, "2136": { - "id": 2136, "category": "Greedy", - "title": "Earliest Possible Day of Full Bloom", "difficulty": "Hard", - "link": "https://leetcode.com/problems/earliest-possible-day-of-full-bloom/" + "id": 2136, + "link": "https://leetcode.com/problems/earliest-possible-day-of-full-bloom/", + "title": "Earliest Possible Day of Full Bloom" }, "2137": { - "id": 2137, "category": "Binary Search", - "title": "Pour Water Between Buckets to Make Water Levels Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal/" + "id": 2137, + "link": "https://leetcode.com/problems/pour-water-between-buckets-to-make-water-levels-equal/", + "title": "Pour Water Between Buckets to Make Water Levels Equal" }, "2138": { - "id": 2138, "category": "Array & Hashing", - "title": "Divide a String Into Groups of Size k", "difficulty": "Easy", - "link": "https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/" + "id": 2138, + "link": "https://leetcode.com/problems/divide-a-string-into-groups-of-size-k/", + "title": "Divide a String Into Groups of Size k" }, "2139": { - "id": 2139, "category": "Greedy", - "title": "Minimum Moves to Reach Target Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-score/" + "id": 2139, + "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-score/", + "title": "Minimum Moves to Reach Target Score" }, "2140": { - "id": 2140, "category": "Dynamic Programming", - "title": "Solving Questions With Brainpower", "difficulty": "Medium", - "link": "https://leetcode.com/problems/solving-questions-with-brainpower/" + "id": 2140, + "link": "https://leetcode.com/problems/solving-questions-with-brainpower/", + "title": "Solving Questions With Brainpower" }, "2141": { - "id": 2141, "category": "Binary Search", - "title": "Maximum Running Time of N Computers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-running-time-of-n-computers/" + "id": 2141, + "link": "https://leetcode.com/problems/maximum-running-time-of-n-computers/", + "title": "Maximum Running Time of N Computers" }, "2142": { - "id": 2142, "category": "Database", - "title": "The Number of Passengers in Each Bus I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i/" + "id": 2142, + "link": "https://leetcode.com/problems/the-number-of-passengers-in-each-bus-i/", + "title": "The Number of Passengers in Each Bus I" }, "2143": { - "id": 2143, "category": "Dynamic Programming", - "title": "Choose Numbers From Two Arrays in Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range/" + "id": 2143, + "link": "https://leetcode.com/problems/choose-numbers-from-two-arrays-in-range/", + "title": "Choose Numbers From Two Arrays in Range" }, "2144": { - "id": 2144, "category": "Greedy", - "title": "Minimum Cost of Buying Candies With Discount", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount/" + "id": 2144, + "link": "https://leetcode.com/problems/minimum-cost-of-buying-candies-with-discount/", + "title": "Minimum Cost of Buying Candies With Discount" }, "2145": { - "id": 2145, "category": "Array & Hashing", - "title": "Count the Hidden Sequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-hidden-sequences/" + "id": 2145, + "link": "https://leetcode.com/problems/count-the-hidden-sequences/", + "title": "Count the Hidden Sequences" }, "2146": { - "id": 2146, "category": "Graph Traversal", - "title": "K Highest Ranked Items Within a Price Range", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range/" + "id": 2146, + "link": "https://leetcode.com/problems/k-highest-ranked-items-within-a-price-range/", + "title": "K Highest Ranked Items Within a Price Range" }, "2147": { - "id": 2147, "category": "Dynamic Programming", - "title": "Number of Ways to Divide a Long Corridor", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor/" + "id": 2147, + "link": "https://leetcode.com/problems/number-of-ways-to-divide-a-long-corridor/", + "title": "Number of Ways to Divide a Long Corridor" }, "2148": { - "id": 2148, "category": "Array & Hashing", - "title": "Count Elements With Strictly Smaller and Greater Elements ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/" + "id": 2148, + "link": "https://leetcode.com/problems/count-elements-with-strictly-smaller-and-greater-elements/", + "title": "Count Elements With Strictly Smaller and Greater Elements " }, "2149": { - "id": 2149, "category": "Two Pointers", - "title": "Rearrange Array Elements by Sign", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rearrange-array-elements-by-sign/" + "id": 2149, + "link": "https://leetcode.com/problems/rearrange-array-elements-by-sign/", + "title": "Rearrange Array Elements by Sign" }, "2150": { - "id": 2150, "category": "Array & Hashing", - "title": "Find All Lonely Numbers in the Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-lonely-numbers-in-the-array/" + "id": 2150, + "link": "https://leetcode.com/problems/find-all-lonely-numbers-in-the-array/", + "title": "Find All Lonely Numbers in the Array" }, "2151": { - "id": 2151, "category": "Backtracking", - "title": "Maximum Good People Based on Statements", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-good-people-based-on-statements/" + "id": 2151, + "link": "https://leetcode.com/problems/maximum-good-people-based-on-statements/", + "title": "Maximum Good People Based on Statements" }, "2152": { - "id": 2152, "category": "Dynamic Programming", - "title": "Minimum Number of Lines to Cover Points", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-lines-to-cover-points/" + "id": 2152, + "link": "https://leetcode.com/problems/minimum-number-of-lines-to-cover-points/", + "title": "Minimum Number of Lines to Cover Points" }, "2153": { - "id": 2153, "category": "Database", - "title": "The Number of Passengers in Each Bus II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii/" + "id": 2153, + "link": "https://leetcode.com/problems/the-number-of-passengers-in-each-bus-ii/", + "title": "The Number of Passengers in Each Bus II" }, "2154": { - "id": 2154, "category": "Array & Hashing", - "title": "Keep Multiplying Found Values by Two", "difficulty": "Easy", - "link": "https://leetcode.com/problems/keep-multiplying-found-values-by-two/" + "id": 2154, + "link": "https://leetcode.com/problems/keep-multiplying-found-values-by-two/", + "title": "Keep Multiplying Found Values by Two" }, "2155": { - "id": 2155, "category": "Array & Hashing", - "title": "All Divisions With the Highest Score of a Binary Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array/" + "id": 2155, + "link": "https://leetcode.com/problems/all-divisions-with-the-highest-score-of-a-binary-array/", + "title": "All Divisions With the Highest Score of a Binary Array" }, "2156": { - "id": 2156, "category": "Sliding Window", - "title": "Find Substring With Given Hash Value", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-substring-with-given-hash-value/" + "id": 2156, + "link": "https://leetcode.com/problems/find-substring-with-given-hash-value/", + "title": "Find Substring With Given Hash Value" }, "2157": { - "id": 2157, "category": "Graph Traversal", - "title": "Groups of Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/groups-of-strings/" + "id": 2157, + "link": "https://leetcode.com/problems/groups-of-strings/", + "title": "Groups of Strings" }, "2158": { - "id": 2158, "category": "Tree", - "title": "Amount of New Area Painted Each Day", "difficulty": "Hard", - "link": "https://leetcode.com/problems/amount-of-new-area-painted-each-day/" + "id": 2158, + "link": "https://leetcode.com/problems/amount-of-new-area-painted-each-day/", + "title": "Amount of New Area Painted Each Day" }, "2159": { - "id": 2159, "category": "Database", - "title": "Order Two Columns Independently", "difficulty": "Medium", - "link": "https://leetcode.com/problems/order-two-columns-independently/" + "id": 2159, + "link": "https://leetcode.com/problems/order-two-columns-independently/", + "title": "Order Two Columns Independently" }, "2160": { - "id": 2160, "category": "Greedy", - "title": "Minimum Sum of Four Digit Number After Splitting Digits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/" + "id": 2160, + "link": "https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/", + "title": "Minimum Sum of Four Digit Number After Splitting Digits" }, "2161": { - "id": 2161, "category": "Two Pointers", - "title": "Partition Array According to Given Pivot", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-according-to-given-pivot/" + "id": 2161, + "link": "https://leetcode.com/problems/partition-array-according-to-given-pivot/", + "title": "Partition Array According to Given Pivot" }, "2162": { - "id": 2162, "category": "Math & Geometry", - "title": "Minimum Cost to Set Cooking Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-set-cooking-time/" + "id": 2162, + "link": "https://leetcode.com/problems/minimum-cost-to-set-cooking-time/", + "title": "Minimum Cost to Set Cooking Time" }, "2163": { - "id": 2163, "category": "Dynamic Programming", - "title": "Minimum Difference in Sums After Removal of Elements", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements/" + "id": 2163, + "link": "https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements/", + "title": "Minimum Difference in Sums After Removal of Elements" }, "2164": { - "id": 2164, "category": "Array & Hashing", - "title": "Sort Even and Odd Indices Independently", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-even-and-odd-indices-independently/" + "id": 2164, + "link": "https://leetcode.com/problems/sort-even-and-odd-indices-independently/", + "title": "Sort Even and Odd Indices Independently" }, "2165": { - "id": 2165, "category": "Math & Geometry", - "title": "Smallest Value of the Rearranged Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-value-of-the-rearranged-number/" + "id": 2165, + "link": "https://leetcode.com/problems/smallest-value-of-the-rearranged-number/", + "title": "Smallest Value of the Rearranged Number" }, "2166": { - "id": 2166, "category": "Array & Hashing", - "title": "Design Bitset", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-bitset/" + "id": 2166, + "link": "https://leetcode.com/problems/design-bitset/", + "title": "Design Bitset" }, "2167": { - "id": 2167, "category": "Dynamic Programming", - "title": "Minimum Time to Remove All Cars Containing Illegal Goods", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/" + "id": 2167, + "link": "https://leetcode.com/problems/minimum-time-to-remove-all-cars-containing-illegal-goods/", + "title": "Minimum Time to Remove All Cars Containing Illegal Goods" }, "2168": { - "id": 2168, "category": "Array & Hashing", - "title": "Unique Substrings With Equal Digit Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency/" + "id": 2168, + "link": "https://leetcode.com/problems/unique-substrings-with-equal-digit-frequency/", + "title": "Unique Substrings With Equal Digit Frequency" }, "2169": { - "id": 2169, "category": "Math & Geometry", - "title": "Count Operations to Obtain Zero", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-operations-to-obtain-zero/" + "id": 2169, + "link": "https://leetcode.com/problems/count-operations-to-obtain-zero/", + "title": "Count Operations to Obtain Zero" }, "2170": { - "id": 2170, "category": "Greedy", - "title": "Minimum Operations to Make the Array Alternating", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating/" + "id": 2170, + "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-alternating/", + "title": "Minimum Operations to Make the Array Alternating" }, "2171": { - "id": 2171, "category": "Greedy", - "title": "Removing Minimum Number of Magic Beans", "difficulty": "Medium", - "link": "https://leetcode.com/problems/removing-minimum-number-of-magic-beans/" + "id": 2171, + "link": "https://leetcode.com/problems/removing-minimum-number-of-magic-beans/", + "title": "Removing Minimum Number of Magic Beans" }, "2172": { - "id": 2172, "category": "Dynamic Programming", - "title": "Maximum AND Sum of Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-and-sum-of-array/" + "id": 2172, + "link": "https://leetcode.com/problems/maximum-and-sum-of-array/", + "title": "Maximum AND Sum of Array" }, "2173": { - "id": 2173, "category": "Database", - "title": "Longest Winning Streak", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-winning-streak/" + "id": 2173, + "link": "https://leetcode.com/problems/longest-winning-streak/", + "title": "Longest Winning Streak" }, "2174": { - "id": 2174, "category": "Graph Traversal", - "title": "Remove All Ones With Row and Column Flips II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips-ii/" + "id": 2174, + "link": "https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips-ii/", + "title": "Remove All Ones With Row and Column Flips II" }, "2175": { - "id": 2175, "category": "Database", - "title": "The Change in Global Rankings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-change-in-global-rankings/" + "id": 2175, + "link": "https://leetcode.com/problems/the-change-in-global-rankings/", + "title": "The Change in Global Rankings" }, "2176": { - "id": 2176, "category": "Array & Hashing", - "title": "Count Equal and Divisible Pairs in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/" + "id": 2176, + "link": "https://leetcode.com/problems/count-equal-and-divisible-pairs-in-an-array/", + "title": "Count Equal and Divisible Pairs in an Array" }, "2177": { - "id": 2177, "category": "Math & Geometry", - "title": "Find Three Consecutive Integers That Sum to a Given Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-three-consecutive-integers-that-sum-to-a-given-number/" + "id": 2177, + "link": "https://leetcode.com/problems/find-three-consecutive-integers-that-sum-to-a-given-number/", + "title": "Find Three Consecutive Integers That Sum to a Given Number" }, "2178": { - "id": 2178, "category": "Backtracking", - "title": "Maximum Split of Positive Even Integers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-split-of-positive-even-integers/" + "id": 2178, + "link": "https://leetcode.com/problems/maximum-split-of-positive-even-integers/", + "title": "Maximum Split of Positive Even Integers" }, "2179": { - "id": 2179, "category": "Tree", - "title": "Count Good Triplets in an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-good-triplets-in-an-array/" + "id": 2179, + "link": "https://leetcode.com/problems/count-good-triplets-in-an-array/", + "title": "Count Good Triplets in an Array" }, "2180": { - "id": 2180, "category": "Math & Geometry", - "title": "Count Integers With Even Digit Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-integers-with-even-digit-sum/" + "id": 2180, + "link": "https://leetcode.com/problems/count-integers-with-even-digit-sum/", + "title": "Count Integers With Even Digit Sum" }, "2181": { - "id": 2181, "category": "Linked List", - "title": "Merge Nodes in Between Zeros", "difficulty": "Medium", - "link": "https://leetcode.com/problems/merge-nodes-in-between-zeros/" + "id": 2181, + "link": "https://leetcode.com/problems/merge-nodes-in-between-zeros/", + "title": "Merge Nodes in Between Zeros" }, "2182": { - "id": 2182, "category": "Heap (Priority Queue)", - "title": "Construct String With Repeat Limit", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-string-with-repeat-limit/" + "id": 2182, + "link": "https://leetcode.com/problems/construct-string-with-repeat-limit/", + "title": "Construct String With Repeat Limit" }, "2183": { - "id": 2183, "category": "Math & Geometry", - "title": "Count Array Pairs Divisible by K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-array-pairs-divisible-by-k/" + "id": 2183, + "link": "https://leetcode.com/problems/count-array-pairs-divisible-by-k/", + "title": "Count Array Pairs Divisible by K" }, "2184": { - "id": 2184, "category": "Dynamic Programming", - "title": "Number of Ways to Build Sturdy Brick Wall", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-build-sturdy-brick-wall/" + "id": 2184, + "link": "https://leetcode.com/problems/number-of-ways-to-build-sturdy-brick-wall/", + "title": "Number of Ways to Build Sturdy Brick Wall" }, "2185": { - "id": 2185, "category": "Array & Hashing", - "title": "Counting Words With a Given Prefix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/counting-words-with-a-given-prefix/" + "id": 2185, + "link": "https://leetcode.com/problems/counting-words-with-a-given-prefix/", + "title": "Counting Words With a Given Prefix" }, "2186": { - "id": 2186, "category": "Array & Hashing", - "title": "Minimum Number of Steps to Make Two Strings Anagram II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii/" + "id": 2186, + "link": "https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii/", + "title": "Minimum Number of Steps to Make Two Strings Anagram II" }, "2187": { - "id": 2187, "category": "Binary Search", - "title": "Minimum Time to Complete Trips", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-complete-trips/" + "id": 2187, + "link": "https://leetcode.com/problems/minimum-time-to-complete-trips/", + "title": "Minimum Time to Complete Trips" }, "2188": { - "id": 2188, "category": "Dynamic Programming", - "title": "Minimum Time to Finish the Race", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-finish-the-race/" + "id": 2188, + "link": "https://leetcode.com/problems/minimum-time-to-finish-the-race/", + "title": "Minimum Time to Finish the Race" }, "2189": { - "id": 2189, "category": "Dynamic Programming", - "title": "Number of Ways to Build House of Cards", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-build-house-of-cards/" + "id": 2189, + "link": "https://leetcode.com/problems/number-of-ways-to-build-house-of-cards/", + "title": "Number of Ways to Build House of Cards" }, "2190": { - "id": 2190, "category": "Array & Hashing", - "title": "Most Frequent Number Following Key In an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/most-frequent-number-following-key-in-an-array/" + "id": 2190, + "link": "https://leetcode.com/problems/most-frequent-number-following-key-in-an-array/", + "title": "Most Frequent Number Following Key In an Array" }, "2191": { - "id": 2191, "category": "Array & Hashing", - "title": "Sort the Jumbled Numbers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-the-jumbled-numbers/" + "id": 2191, + "link": "https://leetcode.com/problems/sort-the-jumbled-numbers/", + "title": "Sort the Jumbled Numbers" }, "2192": { - "id": 2192, "category": "Graph Traversal", - "title": "All Ancestors of a Node in a Directed Acyclic Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/" + "id": 2192, + "link": "https://leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/", + "title": "All Ancestors of a Node in a Directed Acyclic Graph" }, "2193": { - "id": 2193, "category": "Tree", - "title": "Minimum Number of Moves to Make Palindrome", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-moves-to-make-palindrome/" + "id": 2193, + "link": "https://leetcode.com/problems/minimum-number-of-moves-to-make-palindrome/", + "title": "Minimum Number of Moves to Make Palindrome" }, "2194": { - "id": 2194, "category": "Array & Hashing", - "title": "Cells in a Range on an Excel Sheet", "difficulty": "Easy", - "link": "https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/" + "id": 2194, + "link": "https://leetcode.com/problems/cells-in-a-range-on-an-excel-sheet/", + "title": "Cells in a Range on an Excel Sheet" }, "2195": { - "id": 2195, "category": "Greedy", - "title": "Append K Integers With Minimal Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/append-k-integers-with-minimal-sum/" + "id": 2195, + "link": "https://leetcode.com/problems/append-k-integers-with-minimal-sum/", + "title": "Append K Integers With Minimal Sum" }, "2196": { - "id": 2196, "category": "Tree", - "title": "Create Binary Tree From Descriptions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/create-binary-tree-from-descriptions/" + "id": 2196, + "link": "https://leetcode.com/problems/create-binary-tree-from-descriptions/", + "title": "Create Binary Tree From Descriptions" }, "2197": { - "id": 2197, "category": "Stack", - "title": "Replace Non-Coprime Numbers in Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/replace-non-coprime-numbers-in-array/" + "id": 2197, + "link": "https://leetcode.com/problems/replace-non-coprime-numbers-in-array/", + "title": "Replace Non-Coprime Numbers in Array" }, "2198": { - "id": 2198, "category": "Math & Geometry", - "title": "Number of Single Divisor Triplets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-single-divisor-triplets/" + "id": 2198, + "link": "https://leetcode.com/problems/number-of-single-divisor-triplets/", + "title": "Number of Single Divisor Triplets" }, "2199": { - "id": 2199, "category": "Database", - "title": "Finding the Topic of Each Post", "difficulty": "Hard", - "link": "https://leetcode.com/problems/finding-the-topic-of-each-post/" + "id": 2199, + "link": "https://leetcode.com/problems/finding-the-topic-of-each-post/", + "title": "Finding the Topic of Each Post" }, "2200": { - "id": 2200, "category": "Two Pointers", - "title": "Find All K-Distant Indices in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-all-k-distant-indices-in-an-array/" + "id": 2200, + "link": "https://leetcode.com/problems/find-all-k-distant-indices-in-an-array/", + "title": "Find All K-Distant Indices in an Array" }, "2201": { - "id": 2201, "category": "Array & Hashing", - "title": "Count Artifacts That Can Be Extracted", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-artifacts-that-can-be-extracted/" + "id": 2201, + "link": "https://leetcode.com/problems/count-artifacts-that-can-be-extracted/", + "title": "Count Artifacts That Can Be Extracted" }, "2202": { - "id": 2202, "category": "Greedy", - "title": "Maximize the Topmost Element After K Moves", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-the-topmost-element-after-k-moves/" + "id": 2202, + "link": "https://leetcode.com/problems/maximize-the-topmost-element-after-k-moves/", + "title": "Maximize the Topmost Element After K Moves" }, "2203": { - "id": 2203, "category": "Graph Traversal", - "title": "Minimum Weighted Subgraph With the Required Paths", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths/" + "id": 2203, + "link": "https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths/", + "title": "Minimum Weighted Subgraph With the Required Paths" }, "2204": { - "id": 2204, "category": "Graph Traversal", - "title": "Distance to a Cycle in Undirected Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distance-to-a-cycle-in-undirected-graph/" + "id": 2204, + "link": "https://leetcode.com/problems/distance-to-a-cycle-in-undirected-graph/", + "title": "Distance to a Cycle in Undirected Graph" }, "2205": { - "id": 2205, "category": "Database", - "title": "The Number of Users That Are Eligible for Discount", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-number-of-users-that-are-eligible-for-discount/" + "id": 2205, + "link": "https://leetcode.com/problems/the-number-of-users-that-are-eligible-for-discount/", + "title": "The Number of Users That Are Eligible for Discount" }, "2206": { - "id": 2206, "category": "Bit Manipulation", - "title": "Divide Array Into Equal Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/divide-array-into-equal-pairs/" + "id": 2206, + "link": "https://leetcode.com/problems/divide-array-into-equal-pairs/", + "title": "Divide Array Into Equal Pairs" }, "2207": { - "id": 2207, "category": "Greedy", - "title": "Maximize Number of Subsequences in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-number-of-subsequences-in-a-string/" + "id": 2207, + "link": "https://leetcode.com/problems/maximize-number-of-subsequences-in-a-string/", + "title": "Maximize Number of Subsequences in a String" }, "2208": { - "id": 2208, "category": "Heap (Priority Queue)", - "title": "Minimum Operations to Halve Array Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-halve-array-sum/" + "id": 2208, + "link": "https://leetcode.com/problems/minimum-operations-to-halve-array-sum/", + "title": "Minimum Operations to Halve Array Sum" }, "2209": { - "id": 2209, "category": "Dynamic Programming", - "title": "Minimum White Tiles After Covering With Carpets", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-white-tiles-after-covering-with-carpets/" + "id": 2209, + "link": "https://leetcode.com/problems/minimum-white-tiles-after-covering-with-carpets/", + "title": "Minimum White Tiles After Covering With Carpets" }, "2210": { - "id": 2210, "category": "Array & Hashing", - "title": "Count Hills and Valleys in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-hills-and-valleys-in-an-array/" + "id": 2210, + "link": "https://leetcode.com/problems/count-hills-and-valleys-in-an-array/", + "title": "Count Hills and Valleys in an Array" }, "2211": { - "id": 2211, "category": "Stack", - "title": "Count Collisions on a Road", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-collisions-on-a-road/" + "id": 2211, + "link": "https://leetcode.com/problems/count-collisions-on-a-road/", + "title": "Count Collisions on a Road" }, "2212": { - "id": 2212, "category": "Backtracking", - "title": "Maximum Points in an Archery Competition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-points-in-an-archery-competition/" + "id": 2212, + "link": "https://leetcode.com/problems/maximum-points-in-an-archery-competition/", + "title": "Maximum Points in an Archery Competition" }, "2213": { - "id": 2213, "category": "Tree", - "title": "Longest Substring of One Repeating Character", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-substring-of-one-repeating-character/" + "id": 2213, + "link": "https://leetcode.com/problems/longest-substring-of-one-repeating-character/", + "title": "Longest Substring of One Repeating Character" }, "2214": { - "id": 2214, "category": "Greedy", - "title": "Minimum Health to Beat Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-health-to-beat-game/" + "id": 2214, + "link": "https://leetcode.com/problems/minimum-health-to-beat-game/", + "title": "Minimum Health to Beat Game" }, "2215": { - "id": 2215, "category": "Array & Hashing", - "title": "Find the Difference of Two Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-difference-of-two-arrays/" + "id": 2215, + "link": "https://leetcode.com/problems/find-the-difference-of-two-arrays/", + "title": "Find the Difference of Two Arrays" }, "2216": { - "id": 2216, "category": "Stack", - "title": "Minimum Deletions to Make Array Beautiful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-deletions-to-make-array-beautiful/" + "id": 2216, + "link": "https://leetcode.com/problems/minimum-deletions-to-make-array-beautiful/", + "title": "Minimum Deletions to Make Array Beautiful" }, "2217": { - "id": 2217, "category": "Math & Geometry", - "title": "Find Palindrome With Fixed Length", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-palindrome-with-fixed-length/" + "id": 2217, + "link": "https://leetcode.com/problems/find-palindrome-with-fixed-length/", + "title": "Find Palindrome With Fixed Length" }, "2218": { - "id": 2218, "category": "Dynamic Programming", - "title": "Maximum Value of K Coins From Piles", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-value-of-k-coins-from-piles/" + "id": 2218, + "link": "https://leetcode.com/problems/maximum-value-of-k-coins-from-piles/", + "title": "Maximum Value of K Coins From Piles" }, "2219": { - "id": 2219, "category": "Array & Hashing", - "title": "Maximum Sum Score of Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-score-of-array/" + "id": 2219, + "link": "https://leetcode.com/problems/maximum-sum-score-of-array/", + "title": "Maximum Sum Score of Array" }, "2220": { - "id": 2220, "category": "Bit Manipulation", - "title": "Minimum Bit Flips to Convert Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-bit-flips-to-convert-number/" + "id": 2220, + "link": "https://leetcode.com/problems/minimum-bit-flips-to-convert-number/", + "title": "Minimum Bit Flips to Convert Number" }, "2221": { - "id": 2221, "category": "Math & Geometry", - "title": "Find Triangular Sum of an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-triangular-sum-of-an-array/" + "id": 2221, + "link": "https://leetcode.com/problems/find-triangular-sum-of-an-array/", + "title": "Find Triangular Sum of an Array" }, "2222": { - "id": 2222, "category": "Dynamic Programming", - "title": "Number of Ways to Select Buildings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-select-buildings/" + "id": 2222, + "link": "https://leetcode.com/problems/number-of-ways-to-select-buildings/", + "title": "Number of Ways to Select Buildings" }, "2223": { - "id": 2223, "category": "Binary Search", - "title": "Sum of Scores of Built Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-scores-of-built-strings/" + "id": 2223, + "link": "https://leetcode.com/problems/sum-of-scores-of-built-strings/", + "title": "Sum of Scores of Built Strings" }, "2224": { - "id": 2224, "category": "Greedy", - "title": "Minimum Number of Operations to Convert Time", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-convert-time/" + "id": 2224, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-convert-time/", + "title": "Minimum Number of Operations to Convert Time" }, "2225": { - "id": 2225, "category": "Array & Hashing", - "title": "Find Players With Zero or One Losses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-players-with-zero-or-one-losses/" + "id": 2225, + "link": "https://leetcode.com/problems/find-players-with-zero-or-one-losses/", + "title": "Find Players With Zero or One Losses" }, "2226": { - "id": 2226, "category": "Binary Search", - "title": "Maximum Candies Allocated to K Children", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-candies-allocated-to-k-children/" + "id": 2226, + "link": "https://leetcode.com/problems/maximum-candies-allocated-to-k-children/", + "title": "Maximum Candies Allocated to K Children" }, "2227": { - "id": 2227, "category": "Trie", - "title": "Encrypt and Decrypt Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/encrypt-and-decrypt-strings/" + "id": 2227, + "link": "https://leetcode.com/problems/encrypt-and-decrypt-strings/", + "title": "Encrypt and Decrypt Strings" }, "2228": { - "id": 2228, "category": "Database", - "title": "Users With Two Purchases Within Seven Days", "difficulty": "Medium", - "link": "https://leetcode.com/problems/users-with-two-purchases-within-seven-days/" + "id": 2228, + "link": "https://leetcode.com/problems/users-with-two-purchases-within-seven-days/", + "title": "Users With Two Purchases Within Seven Days" }, "2229": { - "id": 2229, "category": "Array & Hashing", - "title": "Check if an Array Is Consecutive", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-an-array-is-consecutive/" + "id": 2229, + "link": "https://leetcode.com/problems/check-if-an-array-is-consecutive/", + "title": "Check if an Array Is Consecutive" }, "2230": { - "id": 2230, "category": "Database", - "title": "The Users That Are Eligible for Discount", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-users-that-are-eligible-for-discount/" + "id": 2230, + "link": "https://leetcode.com/problems/the-users-that-are-eligible-for-discount/", + "title": "The Users That Are Eligible for Discount" }, "2231": { - "id": 2231, "category": "Heap (Priority Queue)", - "title": "Largest Number After Digit Swaps by Parity", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-number-after-digit-swaps-by-parity/" + "id": 2231, + "link": "https://leetcode.com/problems/largest-number-after-digit-swaps-by-parity/", + "title": "Largest Number After Digit Swaps by Parity" }, "2232": { - "id": 2232, "category": "Array & Hashing", - "title": "Minimize Result by Adding Parentheses to Expression", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-result-by-adding-parentheses-to-expression/" + "id": 2232, + "link": "https://leetcode.com/problems/minimize-result-by-adding-parentheses-to-expression/", + "title": "Minimize Result by Adding Parentheses to Expression" }, "2233": { - "id": 2233, "category": "Heap (Priority Queue)", - "title": "Maximum Product After K Increments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-after-k-increments/" + "id": 2233, + "link": "https://leetcode.com/problems/maximum-product-after-k-increments/", + "title": "Maximum Product After K Increments" }, "2234": { - "id": 2234, "category": "Binary Search", - "title": "Maximum Total Beauty of the Gardens", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-total-beauty-of-the-gardens/" + "id": 2234, + "link": "https://leetcode.com/problems/maximum-total-beauty-of-the-gardens/", + "title": "Maximum Total Beauty of the Gardens" }, "2235": { - "id": 2235, "category": "Math & Geometry", - "title": "Add Two Integers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-two-integers/" + "id": 2235, + "link": "https://leetcode.com/problems/add-two-integers/", + "title": "Add Two Integers" }, "2236": { - "id": 2236, "category": "Tree", - "title": "Root Equals Sum of Children", "difficulty": "Easy", - "link": "https://leetcode.com/problems/root-equals-sum-of-children/" + "id": 2236, + "link": "https://leetcode.com/problems/root-equals-sum-of-children/", + "title": "Root Equals Sum of Children" }, "2237": { - "id": 2237, "category": "Array & Hashing", - "title": "Count Positions on Street With Required Brightness", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-positions-on-street-with-required-brightness/" + "id": 2237, + "link": "https://leetcode.com/problems/count-positions-on-street-with-required-brightness/", + "title": "Count Positions on Street With Required Brightness" }, "2238": { - "id": 2238, "category": "Database", - "title": "Number of Times a Driver Was a Passenger", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-times-a-driver-was-a-passenger/" + "id": 2238, + "link": "https://leetcode.com/problems/number-of-times-a-driver-was-a-passenger/", + "title": "Number of Times a Driver Was a Passenger" }, "2239": { - "id": 2239, "category": "Array & Hashing", - "title": "Find Closest Number to Zero", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-closest-number-to-zero/" + "id": 2239, + "link": "https://leetcode.com/problems/find-closest-number-to-zero/", + "title": "Find Closest Number to Zero" }, "2240": { - "id": 2240, "category": "Math & Geometry", - "title": "Number of Ways to Buy Pens and Pencils", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-buy-pens-and-pencils/" + "id": 2240, + "link": "https://leetcode.com/problems/number-of-ways-to-buy-pens-and-pencils/", + "title": "Number of Ways to Buy Pens and Pencils" }, "2241": { - "id": 2241, "category": "Greedy", - "title": "Design an ATM Machine", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-an-atm-machine/" + "id": 2241, + "link": "https://leetcode.com/problems/design-an-atm-machine/", + "title": "Design an ATM Machine" }, "2242": { - "id": 2242, "category": "Graph Traversal", - "title": "Maximum Score of a Node Sequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-of-a-node-sequence/" + "id": 2242, + "link": "https://leetcode.com/problems/maximum-score-of-a-node-sequence/", + "title": "Maximum Score of a Node Sequence" }, "2243": { - "id": 2243, "category": "Array & Hashing", - "title": "Calculate Digit Sum of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-digit-sum-of-a-string/" + "id": 2243, + "link": "https://leetcode.com/problems/calculate-digit-sum-of-a-string/", + "title": "Calculate Digit Sum of a String" }, "2244": { - "id": 2244, "category": "Greedy", - "title": "Minimum Rounds to Complete All Tasks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-rounds-to-complete-all-tasks/" + "id": 2244, + "link": "https://leetcode.com/problems/minimum-rounds-to-complete-all-tasks/", + "title": "Minimum Rounds to Complete All Tasks" }, "2245": { - "id": 2245, "category": "Array & Hashing", - "title": "Maximum Trailing Zeros in a Cornered Path", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-trailing-zeros-in-a-cornered-path/" + "id": 2245, + "link": "https://leetcode.com/problems/maximum-trailing-zeros-in-a-cornered-path/", + "title": "Maximum Trailing Zeros in a Cornered Path" }, "2246": { - "id": 2246, "category": "Tree", - "title": "Longest Path With Different Adjacent Characters", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-path-with-different-adjacent-characters/" + "id": 2246, + "link": "https://leetcode.com/problems/longest-path-with-different-adjacent-characters/", + "title": "Longest Path With Different Adjacent Characters" }, "2247": { - "id": 2247, "category": "Graph Traversal", - "title": "Maximum Cost of Trip With K Highways", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-cost-of-trip-with-k-highways/" + "id": 2247, + "link": "https://leetcode.com/problems/maximum-cost-of-trip-with-k-highways/", + "title": "Maximum Cost of Trip With K Highways" }, "2248": { - "id": 2248, "category": "Array & Hashing", - "title": "Intersection of Multiple Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/intersection-of-multiple-arrays/" + "id": 2248, + "link": "https://leetcode.com/problems/intersection-of-multiple-arrays/", + "title": "Intersection of Multiple Arrays" }, "2249": { - "id": 2249, "category": "Math & Geometry", - "title": "Count Lattice Points Inside a Circle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-lattice-points-inside-a-circle/" + "id": 2249, + "link": "https://leetcode.com/problems/count-lattice-points-inside-a-circle/", + "title": "Count Lattice Points Inside a Circle" }, "2250": { - "id": 2250, "category": "Tree", - "title": "Count Number of Rectangles Containing Each Point", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-rectangles-containing-each-point/" + "id": 2250, + "link": "https://leetcode.com/problems/count-number-of-rectangles-containing-each-point/", + "title": "Count Number of Rectangles Containing Each Point" }, "2251": { - "id": 2251, "category": "Binary Search", - "title": "Number of Flowers in Full Bloom", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-flowers-in-full-bloom/" + "id": 2251, + "link": "https://leetcode.com/problems/number-of-flowers-in-full-bloom/", + "title": "Number of Flowers in Full Bloom" }, "2252": { - "id": 2252, "category": "Database", - "title": "Dynamic Pivoting of a Table", "difficulty": "Hard", - "link": "https://leetcode.com/problems/dynamic-pivoting-of-a-table/" + "id": 2252, + "link": "https://leetcode.com/problems/dynamic-pivoting-of-a-table/", + "title": "Dynamic Pivoting of a Table" }, "2253": { - "id": 2253, "category": "Database", - "title": "Dynamic Unpivoting of a Table", "difficulty": "Hard", - "link": "https://leetcode.com/problems/dynamic-unpivoting-of-a-table/" + "id": 2253, + "link": "https://leetcode.com/problems/dynamic-unpivoting-of-a-table/", + "title": "Dynamic Unpivoting of a Table" }, "2254": { - "id": 2254, "category": "Stack", - "title": "Design Video Sharing Platform", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-video-sharing-platform/" + "id": 2254, + "link": "https://leetcode.com/problems/design-video-sharing-platform/", + "title": "Design Video Sharing Platform" }, "2255": { - "id": 2255, "category": "Array & Hashing", - "title": "Count Prefixes of a Given String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-prefixes-of-a-given-string/" + "id": 2255, + "link": "https://leetcode.com/problems/count-prefixes-of-a-given-string/", + "title": "Count Prefixes of a Given String" }, "2256": { - "id": 2256, "category": "Array & Hashing", - "title": "Minimum Average Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-average-difference/" + "id": 2256, + "link": "https://leetcode.com/problems/minimum-average-difference/", + "title": "Minimum Average Difference" }, "2257": { - "id": 2257, "category": "Array & Hashing", - "title": "Count Unguarded Cells in the Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-unguarded-cells-in-the-grid/" + "id": 2257, + "link": "https://leetcode.com/problems/count-unguarded-cells-in-the-grid/", + "title": "Count Unguarded Cells in the Grid" }, "2258": { - "id": 2258, "category": "Graph Traversal", - "title": "Escape the Spreading Fire", "difficulty": "Hard", - "link": "https://leetcode.com/problems/escape-the-spreading-fire/" + "id": 2258, + "link": "https://leetcode.com/problems/escape-the-spreading-fire/", + "title": "Escape the Spreading Fire" }, "2259": { - "id": 2259, "category": "Greedy", - "title": "Remove Digit From Number to Maximize Result", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-digit-from-number-to-maximize-result/" + "id": 2259, + "link": "https://leetcode.com/problems/remove-digit-from-number-to-maximize-result/", + "title": "Remove Digit From Number to Maximize Result" }, "2260": { - "id": 2260, "category": "Sliding Window", - "title": "Minimum Consecutive Cards to Pick Up", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up/" + "id": 2260, + "link": "https://leetcode.com/problems/minimum-consecutive-cards-to-pick-up/", + "title": "Minimum Consecutive Cards to Pick Up" }, "2261": { - "id": 2261, "category": "Trie", - "title": "K Divisible Elements Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-divisible-elements-subarrays/" + "id": 2261, + "link": "https://leetcode.com/problems/k-divisible-elements-subarrays/", + "title": "K Divisible Elements Subarrays" }, "2262": { - "id": 2262, "category": "Dynamic Programming", - "title": "Total Appeal of A String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/total-appeal-of-a-string/" + "id": 2262, + "link": "https://leetcode.com/problems/total-appeal-of-a-string/", + "title": "Total Appeal of A String" }, "2263": { - "id": 2263, "category": "Dynamic Programming", - "title": "Make Array Non-decreasing or Non-increasing", "difficulty": "Hard", - "link": "https://leetcode.com/problems/make-array-non-decreasing-or-non-increasing/" + "id": 2263, + "link": "https://leetcode.com/problems/make-array-non-decreasing-or-non-increasing/", + "title": "Make Array Non-decreasing or Non-increasing" }, "2264": { - "id": 2264, "category": "Array & Hashing", - "title": "Largest 3-Same-Digit Number in String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-3-same-digit-number-in-string/" + "id": 2264, + "link": "https://leetcode.com/problems/largest-3-same-digit-number-in-string/", + "title": "Largest 3-Same-Digit Number in String" }, "2265": { - "id": 2265, "category": "Tree", - "title": "Count Nodes Equal to Average of Subtree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-nodes-equal-to-average-of-subtree/" + "id": 2265, + "link": "https://leetcode.com/problems/count-nodes-equal-to-average-of-subtree/", + "title": "Count Nodes Equal to Average of Subtree" }, "2266": { - "id": 2266, "category": "Dynamic Programming", - "title": "Count Number of Texts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-texts/" + "id": 2266, + "link": "https://leetcode.com/problems/count-number-of-texts/", + "title": "Count Number of Texts" }, "2267": { - "id": 2267, "category": "Dynamic Programming", - "title": " Check if There Is a Valid Parentheses String Path", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-there-is-a-valid-parentheses-string-path/" + "id": 2267, + "link": "https://leetcode.com/problems/check-if-there-is-a-valid-parentheses-string-path/", + "title": " Check if There Is a Valid Parentheses String Path" }, "2268": { - "id": 2268, "category": "Greedy", - "title": "Minimum Number of Keypresses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-keypresses/" + "id": 2268, + "link": "https://leetcode.com/problems/minimum-number-of-keypresses/", + "title": "Minimum Number of Keypresses" }, "2269": { - "id": 2269, "category": "Sliding Window", - "title": "Find the K-Beauty of a Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-k-beauty-of-a-number/" + "id": 2269, + "link": "https://leetcode.com/problems/find-the-k-beauty-of-a-number/", + "title": "Find the K-Beauty of a Number" }, "2270": { - "id": 2270, "category": "Array & Hashing", - "title": "Number of Ways to Split Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-split-array/" + "id": 2270, + "link": "https://leetcode.com/problems/number-of-ways-to-split-array/", + "title": "Number of Ways to Split Array" }, "2271": { - "id": 2271, "category": "Sliding Window", - "title": "Maximum White Tiles Covered by a Carpet", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-white-tiles-covered-by-a-carpet/" + "id": 2271, + "link": "https://leetcode.com/problems/maximum-white-tiles-covered-by-a-carpet/", + "title": "Maximum White Tiles Covered by a Carpet" }, "2272": { - "id": 2272, "category": "Dynamic Programming", - "title": "Substring With Largest Variance", "difficulty": "Hard", - "link": "https://leetcode.com/problems/substring-with-largest-variance/" + "id": 2272, + "link": "https://leetcode.com/problems/substring-with-largest-variance/", + "title": "Substring With Largest Variance" }, "2273": { - "id": 2273, "category": "Array & Hashing", - "title": "Find Resultant Array After Removing Anagrams", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-resultant-array-after-removing-anagrams/" + "id": 2273, + "link": "https://leetcode.com/problems/find-resultant-array-after-removing-anagrams/", + "title": "Find Resultant Array After Removing Anagrams" }, "2274": { - "id": 2274, "category": "Array & Hashing", - "title": "Maximum Consecutive Floors Without Special Floors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-consecutive-floors-without-special-floors/" + "id": 2274, + "link": "https://leetcode.com/problems/maximum-consecutive-floors-without-special-floors/", + "title": "Maximum Consecutive Floors Without Special Floors" }, "2275": { - "id": 2275, "category": "Bit Manipulation", - "title": "Largest Combination With Bitwise AND Greater Than Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-combination-with-bitwise-and-greater-than-zero/" + "id": 2275, + "link": "https://leetcode.com/problems/largest-combination-with-bitwise-and-greater-than-zero/", + "title": "Largest Combination With Bitwise AND Greater Than Zero" }, "2276": { - "id": 2276, "category": "Tree", - "title": "Count Integers in Intervals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-integers-in-intervals/" + "id": 2276, + "link": "https://leetcode.com/problems/count-integers-in-intervals/", + "title": "Count Integers in Intervals" }, "2277": { - "id": 2277, "category": "Tree", - "title": "Closest Node to Path in Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/closest-node-to-path-in-tree/" + "id": 2277, + "link": "https://leetcode.com/problems/closest-node-to-path-in-tree/", + "title": "Closest Node to Path in Tree" }, "2278": { - "id": 2278, "category": "Array & Hashing", - "title": "Percentage of Letter in String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/percentage-of-letter-in-string/" + "id": 2278, + "link": "https://leetcode.com/problems/percentage-of-letter-in-string/", + "title": "Percentage of Letter in String" }, "2279": { - "id": 2279, "category": "Greedy", - "title": "Maximum Bags With Full Capacity of Rocks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-bags-with-full-capacity-of-rocks/" + "id": 2279, + "link": "https://leetcode.com/problems/maximum-bags-with-full-capacity-of-rocks/", + "title": "Maximum Bags With Full Capacity of Rocks" }, "2280": { - "id": 2280, "category": "Math & Geometry", - "title": "Minimum Lines to Represent a Line Chart", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-lines-to-represent-a-line-chart/" + "id": 2280, + "link": "https://leetcode.com/problems/minimum-lines-to-represent-a-line-chart/", + "title": "Minimum Lines to Represent a Line Chart" }, "2281": { - "id": 2281, "category": "Stack", - "title": "Sum of Total Strength of Wizards", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-total-strength-of-wizards/" + "id": 2281, + "link": "https://leetcode.com/problems/sum-of-total-strength-of-wizards/", + "title": "Sum of Total Strength of Wizards" }, "2282": { - "id": 2282, "category": "Stack", - "title": "Number of People That Can Be Seen in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-people-that-can-be-seen-in-a-grid/" + "id": 2282, + "link": "https://leetcode.com/problems/number-of-people-that-can-be-seen-in-a-grid/", + "title": "Number of People That Can Be Seen in a Grid" }, "2283": { - "id": 2283, "category": "Array & Hashing", - "title": "Check if Number Has Equal Digit Count and Digit Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-number-has-equal-digit-count-and-digit-value/" + "id": 2283, + "link": "https://leetcode.com/problems/check-if-number-has-equal-digit-count-and-digit-value/", + "title": "Check if Number Has Equal Digit Count and Digit Value" }, "2284": { - "id": 2284, "category": "Array & Hashing", - "title": "Sender With Largest Word Count", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sender-with-largest-word-count/" + "id": 2284, + "link": "https://leetcode.com/problems/sender-with-largest-word-count/", + "title": "Sender With Largest Word Count" }, "2285": { - "id": 2285, "category": "Graph Traversal", - "title": "Maximum Total Importance of Roads", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-total-importance-of-roads/" + "id": 2285, + "link": "https://leetcode.com/problems/maximum-total-importance-of-roads/", + "title": "Maximum Total Importance of Roads" }, "2286": { - "id": 2286, "category": "Tree", - "title": "Booking Concert Tickets in Groups", "difficulty": "Hard", - "link": "https://leetcode.com/problems/booking-concert-tickets-in-groups/" + "id": 2286, + "link": "https://leetcode.com/problems/booking-concert-tickets-in-groups/", + "title": "Booking Concert Tickets in Groups" }, "2287": { - "id": 2287, "category": "Array & Hashing", - "title": "Rearrange Characters to Make Target String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rearrange-characters-to-make-target-string/" + "id": 2287, + "link": "https://leetcode.com/problems/rearrange-characters-to-make-target-string/", + "title": "Rearrange Characters to Make Target String" }, "2288": { - "id": 2288, "category": "Array & Hashing", - "title": "Apply Discount to Prices", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-discount-to-prices/" + "id": 2288, + "link": "https://leetcode.com/problems/apply-discount-to-prices/", + "title": "Apply Discount to Prices" }, "2289": { - "id": 2289, "category": "Stack", - "title": "Steps to Make Array Non-decreasing", "difficulty": "Medium", - "link": "https://leetcode.com/problems/steps-to-make-array-non-decreasing/" + "id": 2289, + "link": "https://leetcode.com/problems/steps-to-make-array-non-decreasing/", + "title": "Steps to Make Array Non-decreasing" }, "2290": { - "id": 2290, "category": "Graph Traversal", - "title": "Minimum Obstacle Removal to Reach Corner", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/" + "id": 2290, + "link": "https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/", + "title": "Minimum Obstacle Removal to Reach Corner" }, "2291": { - "id": 2291, "category": "Dynamic Programming", - "title": "Maximum Profit From Trading Stocks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-profit-from-trading-stocks/" + "id": 2291, + "link": "https://leetcode.com/problems/maximum-profit-from-trading-stocks/", + "title": "Maximum Profit From Trading Stocks" }, "2292": { - "id": 2292, "category": "Database", - "title": "Products With Three or More Orders in Two Consecutive Years", "difficulty": "Medium", - "link": "https://leetcode.com/problems/products-with-three-or-more-orders-in-two-consecutive-years/" + "id": 2292, + "link": "https://leetcode.com/problems/products-with-three-or-more-orders-in-two-consecutive-years/", + "title": "Products With Three or More Orders in Two Consecutive Years" }, "2293": { - "id": 2293, "category": "Array & Hashing", - "title": "Min Max Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/min-max-game/" + "id": 2293, + "link": "https://leetcode.com/problems/min-max-game/", + "title": "Min Max Game" }, "2294": { - "id": 2294, "category": "Greedy", - "title": "Partition Array Such That Maximum Difference Is K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-such-that-maximum-difference-is-k/" + "id": 2294, + "link": "https://leetcode.com/problems/partition-array-such-that-maximum-difference-is-k/", + "title": "Partition Array Such That Maximum Difference Is K" }, "2295": { - "id": 2295, "category": "Array & Hashing", - "title": "Replace Elements in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/replace-elements-in-an-array/" + "id": 2295, + "link": "https://leetcode.com/problems/replace-elements-in-an-array/", + "title": "Replace Elements in an Array" }, "2296": { - "id": 2296, "category": "Stack", - "title": "Design a Text Editor", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-a-text-editor/" + "id": 2296, + "link": "https://leetcode.com/problems/design-a-text-editor/", + "title": "Design a Text Editor" }, "2297": { - "id": 2297, "category": "Graph Traversal", - "title": "Jump Game VIII", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-viii/" + "id": 2297, + "link": "https://leetcode.com/problems/jump-game-viii/", + "title": "Jump Game VIII" }, "2298": { - "id": 2298, "category": "Database", - "title": "Tasks Count in the Weekend", "difficulty": "Medium", - "link": "https://leetcode.com/problems/tasks-count-in-the-weekend/" + "id": 2298, + "link": "https://leetcode.com/problems/tasks-count-in-the-weekend/", + "title": "Tasks Count in the Weekend" }, "2299": { - "id": 2299, "category": "Array & Hashing", - "title": "Strong Password Checker II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/strong-password-checker-ii/" + "id": 2299, + "link": "https://leetcode.com/problems/strong-password-checker-ii/", + "title": "Strong Password Checker II" }, "2300": { - "id": 2300, "category": "Binary Search", - "title": "Successful Pairs of Spells and Potions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/successful-pairs-of-spells-and-potions/" + "id": 2300, + "link": "https://leetcode.com/problems/successful-pairs-of-spells-and-potions/", + "title": "Successful Pairs of Spells and Potions" }, "2301": { - "id": 2301, "category": "Array & Hashing", - "title": "Match Substring After Replacement", "difficulty": "Hard", - "link": "https://leetcode.com/problems/match-substring-after-replacement/" + "id": 2301, + "link": "https://leetcode.com/problems/match-substring-after-replacement/", + "title": "Match Substring After Replacement" }, "2302": { - "id": 2302, "category": "Sliding Window", - "title": "Count Subarrays With Score Less Than K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-subarrays-with-score-less-than-k/" + "id": 2302, + "link": "https://leetcode.com/problems/count-subarrays-with-score-less-than-k/", + "title": "Count Subarrays With Score Less Than K" }, "2303": { - "id": 2303, "category": "Array & Hashing", - "title": "Calculate Amount Paid in Taxes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-amount-paid-in-taxes/" + "id": 2303, + "link": "https://leetcode.com/problems/calculate-amount-paid-in-taxes/", + "title": "Calculate Amount Paid in Taxes" }, "2304": { - "id": 2304, "category": "Dynamic Programming", - "title": "Minimum Path Cost in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-path-cost-in-a-grid/" + "id": 2304, + "link": "https://leetcode.com/problems/minimum-path-cost-in-a-grid/", + "title": "Minimum Path Cost in a Grid" }, "2305": { - "id": 2305, "category": "Dynamic Programming", - "title": "Fair Distribution of Cookies", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fair-distribution-of-cookies/" + "id": 2305, + "link": "https://leetcode.com/problems/fair-distribution-of-cookies/", + "title": "Fair Distribution of Cookies" }, "2306": { - "id": 2306, "category": "Bit Manipulation", - "title": "Naming a Company", "difficulty": "Hard", - "link": "https://leetcode.com/problems/naming-a-company/" + "id": 2306, + "link": "https://leetcode.com/problems/naming-a-company/", + "title": "Naming a Company" }, "2307": { - "id": 2307, "category": "Graph Traversal", - "title": "Check for Contradictions in Equations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-for-contradictions-in-equations/" + "id": 2307, + "link": "https://leetcode.com/problems/check-for-contradictions-in-equations/", + "title": "Check for Contradictions in Equations" }, "2308": { - "id": 2308, "category": "Database", - "title": "Arrange Table by Gender", "difficulty": "Medium", - "link": "https://leetcode.com/problems/arrange-table-by-gender/" + "id": 2308, + "link": "https://leetcode.com/problems/arrange-table-by-gender/", + "title": "Arrange Table by Gender" }, "2309": { - "id": 2309, "category": "Array & Hashing", - "title": "Greatest English Letter in Upper and Lower Case", "difficulty": "Easy", - "link": "https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/" + "id": 2309, + "link": "https://leetcode.com/problems/greatest-english-letter-in-upper-and-lower-case/", + "title": "Greatest English Letter in Upper and Lower Case" }, "2310": { - "id": 2310, "category": "Dynamic Programming", - "title": "Sum of Numbers With Units Digit K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-numbers-with-units-digit-k/" + "id": 2310, + "link": "https://leetcode.com/problems/sum-of-numbers-with-units-digit-k/", + "title": "Sum of Numbers With Units Digit K" }, "2311": { - "id": 2311, "category": "Dynamic Programming", - "title": "Longest Binary Subsequence Less Than or Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-binary-subsequence-less-than-or-equal-to-k/" + "id": 2311, + "link": "https://leetcode.com/problems/longest-binary-subsequence-less-than-or-equal-to-k/", + "title": "Longest Binary Subsequence Less Than or Equal to K" }, "2312": { - "id": 2312, "category": "Dynamic Programming", - "title": "Selling Pieces of Wood", "difficulty": "Hard", - "link": "https://leetcode.com/problems/selling-pieces-of-wood/" + "id": 2312, + "link": "https://leetcode.com/problems/selling-pieces-of-wood/", + "title": "Selling Pieces of Wood" }, "2313": { - "id": 2313, "category": "Tree", - "title": "Minimum Flips in Binary Tree to Get Result", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-flips-in-binary-tree-to-get-result/" + "id": 2313, + "link": "https://leetcode.com/problems/minimum-flips-in-binary-tree-to-get-result/", + "title": "Minimum Flips in Binary Tree to Get Result" }, "2314": { - "id": 2314, "category": "Database", - "title": "The First Day of the Maximum Recorded Degree in Each City", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-first-day-of-the-maximum-recorded-degree-in-each-city/" + "id": 2314, + "link": "https://leetcode.com/problems/the-first-day-of-the-maximum-recorded-degree-in-each-city/", + "title": "The First Day of the Maximum Recorded Degree in Each City" }, "2315": { - "id": 2315, "category": "Array & Hashing", - "title": "Count Asterisks", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-asterisks/" + "id": 2315, + "link": "https://leetcode.com/problems/count-asterisks/", + "title": "Count Asterisks" }, "2316": { - "id": 2316, "category": "Graph Traversal", - "title": "Count Unreachable Pairs of Nodes in an Undirected Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-unreachable-pairs-of-nodes-in-an-undirected-graph/" + "id": 2316, + "link": "https://leetcode.com/problems/count-unreachable-pairs-of-nodes-in-an-undirected-graph/", + "title": "Count Unreachable Pairs of Nodes in an Undirected Graph" }, "2317": { - "id": 2317, "category": "Bit Manipulation", - "title": "Maximum XOR After Operations ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-xor-after-operations/" + "id": 2317, + "link": "https://leetcode.com/problems/maximum-xor-after-operations/", + "title": "Maximum XOR After Operations " }, "2318": { - "id": 2318, "category": "Dynamic Programming", - "title": "Number of Distinct Roll Sequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-distinct-roll-sequences/" + "id": 2318, + "link": "https://leetcode.com/problems/number-of-distinct-roll-sequences/", + "title": "Number of Distinct Roll Sequences" }, "2319": { - "id": 2319, "category": "Array & Hashing", - "title": "Check if Matrix Is X-Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-matrix-is-x-matrix/" + "id": 2319, + "link": "https://leetcode.com/problems/check-if-matrix-is-x-matrix/", + "title": "Check if Matrix Is X-Matrix" }, "2320": { - "id": 2320, "category": "Dynamic Programming", - "title": "Count Number of Ways to Place Houses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-ways-to-place-houses/" + "id": 2320, + "link": "https://leetcode.com/problems/count-number-of-ways-to-place-houses/", + "title": "Count Number of Ways to Place Houses" }, "2321": { - "id": 2321, "category": "Dynamic Programming", - "title": "Maximum Score Of Spliced Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-of-spliced-array/" + "id": 2321, + "link": "https://leetcode.com/problems/maximum-score-of-spliced-array/", + "title": "Maximum Score Of Spliced Array" }, "2322": { - "id": 2322, "category": "Tree", - "title": "Minimum Score After Removals on a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-score-after-removals-on-a-tree/" + "id": 2322, + "link": "https://leetcode.com/problems/minimum-score-after-removals-on-a-tree/", + "title": "Minimum Score After Removals on a Tree" }, "2323": { - "id": 2323, "category": "Greedy", - "title": "Find Minimum Time to Finish All Jobs II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs-ii/" + "id": 2323, + "link": "https://leetcode.com/problems/find-minimum-time-to-finish-all-jobs-ii/", + "title": "Find Minimum Time to Finish All Jobs II" }, "2324": { - "id": 2324, "category": "Database", - "title": "Product Sales Analysis IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/product-sales-analysis-iv/" + "id": 2324, + "link": "https://leetcode.com/problems/product-sales-analysis-iv/", + "title": "Product Sales Analysis IV" }, "2325": { - "id": 2325, "category": "Array & Hashing", - "title": "Decode the Message", "difficulty": "Easy", - "link": "https://leetcode.com/problems/decode-the-message/" + "id": 2325, + "link": "https://leetcode.com/problems/decode-the-message/", + "title": "Decode the Message" }, "2326": { - "id": 2326, "category": "Linked List", - "title": "Spiral Matrix IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/spiral-matrix-iv/" + "id": 2326, + "link": "https://leetcode.com/problems/spiral-matrix-iv/", + "title": "Spiral Matrix IV" }, "2327": { - "id": 2327, "category": "Dynamic Programming", - "title": "Number of People Aware of a Secret", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-people-aware-of-a-secret/" + "id": 2327, + "link": "https://leetcode.com/problems/number-of-people-aware-of-a-secret/", + "title": "Number of People Aware of a Secret" }, "2328": { - "id": 2328, "category": "Graph Traversal", - "title": "Number of Increasing Paths in a Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-increasing-paths-in-a-grid/" + "id": 2328, + "link": "https://leetcode.com/problems/number-of-increasing-paths-in-a-grid/", + "title": "Number of Increasing Paths in a Grid" }, "2329": { - "id": 2329, "category": "Database", - "title": "Product Sales Analysis V", "difficulty": "Easy", - "link": "https://leetcode.com/problems/product-sales-analysis-v/" + "id": 2329, + "link": "https://leetcode.com/problems/product-sales-analysis-v/", + "title": "Product Sales Analysis V" }, "2330": { - "id": 2330, "category": "Two Pointers", - "title": "Valid Palindrome IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/valid-palindrome-iv/" + "id": 2330, + "link": "https://leetcode.com/problems/valid-palindrome-iv/", + "title": "Valid Palindrome IV" }, "2331": { - "id": 2331, "category": "Tree", - "title": "Evaluate Boolean Binary Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/evaluate-boolean-binary-tree/" + "id": 2331, + "link": "https://leetcode.com/problems/evaluate-boolean-binary-tree/", + "title": "Evaluate Boolean Binary Tree" }, "2332": { - "id": 2332, "category": "Binary Search", - "title": "The Latest Time to Catch a Bus", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-latest-time-to-catch-a-bus/" + "id": 2332, + "link": "https://leetcode.com/problems/the-latest-time-to-catch-a-bus/", + "title": "The Latest Time to Catch a Bus" }, "2333": { - "id": 2333, "category": "Binary Search", - "title": "Minimum Sum of Squared Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-sum-of-squared-difference/" + "id": 2333, + "link": "https://leetcode.com/problems/minimum-sum-of-squared-difference/", + "title": "Minimum Sum of Squared Difference" }, "2334": { - "id": 2334, "category": "Graph Traversal", - "title": "Subarray With Elements Greater Than Varying Threshold", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subarray-with-elements-greater-than-varying-threshold/" + "id": 2334, + "link": "https://leetcode.com/problems/subarray-with-elements-greater-than-varying-threshold/", + "title": "Subarray With Elements Greater Than Varying Threshold" }, "2335": { - "id": 2335, "category": "Heap (Priority Queue)", - "title": "Minimum Amount of Time to Fill Cups", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/" + "id": 2335, + "link": "https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/", + "title": "Minimum Amount of Time to Fill Cups" }, "2336": { - "id": 2336, "category": "Heap (Priority Queue)", - "title": "Smallest Number in Infinite Set", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-number-in-infinite-set/" + "id": 2336, + "link": "https://leetcode.com/problems/smallest-number-in-infinite-set/", + "title": "Smallest Number in Infinite Set" }, "2337": { - "id": 2337, "category": "Two Pointers", - "title": "Move Pieces to Obtain a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/move-pieces-to-obtain-a-string/" + "id": 2337, + "link": "https://leetcode.com/problems/move-pieces-to-obtain-a-string/", + "title": "Move Pieces to Obtain a String" }, "2338": { - "id": 2338, "category": "Dynamic Programming", - "title": "Count the Number of Ideal Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-ideal-arrays/" + "id": 2338, + "link": "https://leetcode.com/problems/count-the-number-of-ideal-arrays/", + "title": "Count the Number of Ideal Arrays" }, "2339": { - "id": 2339, "category": "Database", - "title": "All the Matches of the League", "difficulty": "Easy", - "link": "https://leetcode.com/problems/all-the-matches-of-the-league/" + "id": 2339, + "link": "https://leetcode.com/problems/all-the-matches-of-the-league/", + "title": "All the Matches of the League" }, "2340": { - "id": 2340, "category": "Greedy", - "title": "Minimum Adjacent Swaps to Make a Valid Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-make-a-valid-array/" + "id": 2340, + "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-make-a-valid-array/", + "title": "Minimum Adjacent Swaps to Make a Valid Array" }, "2341": { - "id": 2341, "category": "Array & Hashing", - "title": "Maximum Number of Pairs in Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-pairs-in-array/" + "id": 2341, + "link": "https://leetcode.com/problems/maximum-number-of-pairs-in-array/", + "title": "Maximum Number of Pairs in Array" }, "2342": { - "id": 2342, "category": "Heap (Priority Queue)", - "title": "Max Sum of a Pair With Equal Sum of Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/max-sum-of-a-pair-with-equal-sum-of-digits/" + "id": 2342, + "link": "https://leetcode.com/problems/max-sum-of-a-pair-with-equal-sum-of-digits/", + "title": "Max Sum of a Pair With Equal Sum of Digits" }, "2343": { - "id": 2343, "category": "Heap (Priority Queue)", - "title": "Query Kth Smallest Trimmed Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/query-kth-smallest-trimmed-number/" + "id": 2343, + "link": "https://leetcode.com/problems/query-kth-smallest-trimmed-number/", + "title": "Query Kth Smallest Trimmed Number" }, "2344": { - "id": 2344, "category": "Heap (Priority Queue)", - "title": "Minimum Deletions to Make Array Divisible", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-deletions-to-make-array-divisible/" + "id": 2344, + "link": "https://leetcode.com/problems/minimum-deletions-to-make-array-divisible/", + "title": "Minimum Deletions to Make Array Divisible" }, "2345": { - "id": 2345, "category": "Stack", - "title": "Finding the Number of Visible Mountains", "difficulty": "Medium", - "link": "https://leetcode.com/problems/finding-the-number-of-visible-mountains/" + "id": 2345, + "link": "https://leetcode.com/problems/finding-the-number-of-visible-mountains/", + "title": "Finding the Number of Visible Mountains" }, "2346": { - "id": 2346, "category": "Database", - "title": "Compute the Rank as a Percentage", "difficulty": "Medium", - "link": "https://leetcode.com/problems/compute-the-rank-as-a-percentage/" + "id": 2346, + "link": "https://leetcode.com/problems/compute-the-rank-as-a-percentage/", + "title": "Compute the Rank as a Percentage" }, "2347": { - "id": 2347, "category": "Array & Hashing", - "title": "Best Poker Hand", "difficulty": "Easy", - "link": "https://leetcode.com/problems/best-poker-hand/" + "id": 2347, + "link": "https://leetcode.com/problems/best-poker-hand/", + "title": "Best Poker Hand" }, "2348": { - "id": 2348, "category": "Math & Geometry", - "title": "Number of Zero-Filled Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-zero-filled-subarrays/" + "id": 2348, + "link": "https://leetcode.com/problems/number-of-zero-filled-subarrays/", + "title": "Number of Zero-Filled Subarrays" }, "2349": { - "id": 2349, "category": "Heap (Priority Queue)", - "title": "Design a Number Container System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-number-container-system/" + "id": 2349, + "link": "https://leetcode.com/problems/design-a-number-container-system/", + "title": "Design a Number Container System" }, "2350": { - "id": 2350, "category": "Greedy", - "title": "Shortest Impossible Sequence of Rolls", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-impossible-sequence-of-rolls/" + "id": 2350, + "link": "https://leetcode.com/problems/shortest-impossible-sequence-of-rolls/", + "title": "Shortest Impossible Sequence of Rolls" }, "2351": { - "id": 2351, "category": "Bit Manipulation", - "title": "First Letter to Appear Twice", "difficulty": "Easy", - "link": "https://leetcode.com/problems/first-letter-to-appear-twice/" + "id": 2351, + "link": "https://leetcode.com/problems/first-letter-to-appear-twice/", + "title": "First Letter to Appear Twice" }, "2352": { - "id": 2352, "category": "Array & Hashing", - "title": "Equal Row and Column Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/equal-row-and-column-pairs/" + "id": 2352, + "link": "https://leetcode.com/problems/equal-row-and-column-pairs/", + "title": "Equal Row and Column Pairs" }, "2353": { - "id": 2353, "category": "Heap (Priority Queue)", - "title": "Design a Food Rating System", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-food-rating-system/" + "id": 2353, + "link": "https://leetcode.com/problems/design-a-food-rating-system/", + "title": "Design a Food Rating System" }, "2354": { - "id": 2354, "category": "Binary Search", - "title": "Number of Excellent Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-excellent-pairs/" + "id": 2354, + "link": "https://leetcode.com/problems/number-of-excellent-pairs/", + "title": "Number of Excellent Pairs" }, "2355": { - "id": 2355, "category": "Dynamic Programming", - "title": "Maximum Number of Books You Can Take", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-books-you-can-take/" + "id": 2355, + "link": "https://leetcode.com/problems/maximum-number-of-books-you-can-take/", + "title": "Maximum Number of Books You Can Take" }, "2356": { - "id": 2356, "category": "Database", - "title": "Number of Unique Subjects Taught by Each Teacher", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/" + "id": 2356, + "link": "https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/", + "title": "Number of Unique Subjects Taught by Each Teacher" }, "2357": { - "id": 2357, "category": "Heap (Priority Queue)", - "title": "Make Array Zero by Subtracting Equal Amounts", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-array-zero-by-subtracting-equal-amounts/" + "id": 2357, + "link": "https://leetcode.com/problems/make-array-zero-by-subtracting-equal-amounts/", + "title": "Make Array Zero by Subtracting Equal Amounts" }, "2358": { - "id": 2358, "category": "Binary Search", - "title": "Maximum Number of Groups Entering a Competition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-groups-entering-a-competition/" + "id": 2358, + "link": "https://leetcode.com/problems/maximum-number-of-groups-entering-a-competition/", + "title": "Maximum Number of Groups Entering a Competition" }, "2359": { - "id": 2359, "category": "Graph Traversal", - "title": "Find Closest Node to Given Two Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-closest-node-to-given-two-nodes/" + "id": 2359, + "link": "https://leetcode.com/problems/find-closest-node-to-given-two-nodes/", + "title": "Find Closest Node to Given Two Nodes" }, "2360": { - "id": 2360, "category": "Graph Traversal", - "title": "Longest Cycle in a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-cycle-in-a-graph/" + "id": 2360, + "link": "https://leetcode.com/problems/longest-cycle-in-a-graph/", + "title": "Longest Cycle in a Graph" }, "2361": { - "id": 2361, "category": "Dynamic Programming", - "title": "Minimum Costs Using the Train Line", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-costs-using-the-train-line/" + "id": 2361, + "link": "https://leetcode.com/problems/minimum-costs-using-the-train-line/", + "title": "Minimum Costs Using the Train Line" }, "2362": { - "id": 2362, "category": "Database", - "title": "Generate the Invoice", "difficulty": "Hard", - "link": "https://leetcode.com/problems/generate-the-invoice/" + "id": 2362, + "link": "https://leetcode.com/problems/generate-the-invoice/", + "title": "Generate the Invoice" }, "2363": { - "id": 2363, "category": "Array & Hashing", - "title": "Merge Similar Items", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-similar-items/" + "id": 2363, + "link": "https://leetcode.com/problems/merge-similar-items/", + "title": "Merge Similar Items" }, "2364": { - "id": 2364, "category": "Math & Geometry", - "title": "Count Number of Bad Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-bad-pairs/" + "id": 2364, + "link": "https://leetcode.com/problems/count-number-of-bad-pairs/", + "title": "Count Number of Bad Pairs" }, "2365": { - "id": 2365, "category": "Array & Hashing", - "title": "Task Scheduler II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/task-scheduler-ii/" + "id": 2365, + "link": "https://leetcode.com/problems/task-scheduler-ii/", + "title": "Task Scheduler II" }, "2366": { - "id": 2366, "category": "Greedy", - "title": "Minimum Replacements to Sort the Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-replacements-to-sort-the-array/" + "id": 2366, + "link": "https://leetcode.com/problems/minimum-replacements-to-sort-the-array/", + "title": "Minimum Replacements to Sort the Array" }, "2367": { - "id": 2367, "category": "Two Pointers", - "title": "Number of Arithmetic Triplets", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-arithmetic-triplets/" + "id": 2367, + "link": "https://leetcode.com/problems/number-of-arithmetic-triplets/", + "title": "Number of Arithmetic Triplets" }, "2368": { - "id": 2368, "category": "Tree", - "title": "Reachable Nodes With Restrictions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reachable-nodes-with-restrictions/" + "id": 2368, + "link": "https://leetcode.com/problems/reachable-nodes-with-restrictions/", + "title": "Reachable Nodes With Restrictions" }, "2369": { - "id": 2369, "category": "Dynamic Programming", - "title": "Check if There is a Valid Partition For The Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array/" + "id": 2369, + "link": "https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array/", + "title": "Check if There is a Valid Partition For The Array" }, "2370": { - "id": 2370, "category": "Dynamic Programming", - "title": "Longest Ideal Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-ideal-subsequence/" + "id": 2370, + "link": "https://leetcode.com/problems/longest-ideal-subsequence/", + "title": "Longest Ideal Subsequence" }, "2371": { - "id": 2371, "category": "Graph Traversal", - "title": "Minimize Maximum Value in a Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-maximum-value-in-a-grid/" + "id": 2371, + "link": "https://leetcode.com/problems/minimize-maximum-value-in-a-grid/", + "title": "Minimize Maximum Value in a Grid" }, "2372": { - "id": 2372, "category": "Database", - "title": "Calculate the Influence of Each Salesperson", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-the-influence-of-each-salesperson/" + "id": 2372, + "link": "https://leetcode.com/problems/calculate-the-influence-of-each-salesperson/", + "title": "Calculate the Influence of Each Salesperson" }, "2373": { - "id": 2373, "category": "Array & Hashing", - "title": "Largest Local Values in a Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-local-values-in-a-matrix/" + "id": 2373, + "link": "https://leetcode.com/problems/largest-local-values-in-a-matrix/", + "title": "Largest Local Values in a Matrix" }, "2374": { - "id": 2374, "category": "Graph Traversal", - "title": "Node With Highest Edge Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/node-with-highest-edge-score/" + "id": 2374, + "link": "https://leetcode.com/problems/node-with-highest-edge-score/", + "title": "Node With Highest Edge Score" }, "2375": { - "id": 2375, "category": "Backtracking", - "title": "Construct Smallest Number From DI String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-smallest-number-from-di-string/" + "id": 2375, + "link": "https://leetcode.com/problems/construct-smallest-number-from-di-string/", + "title": "Construct Smallest Number From DI String" }, "2376": { - "id": 2376, "category": "Dynamic Programming", - "title": "Count Special Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-special-integers/" + "id": 2376, + "link": "https://leetcode.com/problems/count-special-integers/", + "title": "Count Special Integers" }, "2377": { - "id": 2377, "category": "Database", - "title": "Sort the Olympic Table", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-the-olympic-table/" + "id": 2377, + "link": "https://leetcode.com/problems/sort-the-olympic-table/", + "title": "Sort the Olympic Table" }, "2378": { - "id": 2378, "category": "Tree", - "title": "Choose Edges to Maximize Score in a Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/choose-edges-to-maximize-score-in-a-tree/" + "id": 2378, + "link": "https://leetcode.com/problems/choose-edges-to-maximize-score-in-a-tree/", + "title": "Choose Edges to Maximize Score in a Tree" }, "2379": { - "id": 2379, "category": "Sliding Window", - "title": "Minimum Recolors to Get K Consecutive Black Blocks", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-recolors-to-get-k-consecutive-black-blocks/" + "id": 2379, + "link": "https://leetcode.com/problems/minimum-recolors-to-get-k-consecutive-black-blocks/", + "title": "Minimum Recolors to Get K Consecutive Black Blocks" }, "2380": { - "id": 2380, "category": "Dynamic Programming", - "title": "Time Needed to Rearrange a Binary String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/" + "id": 2380, + "link": "https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/", + "title": "Time Needed to Rearrange a Binary String" }, "2381": { - "id": 2381, "category": "Array & Hashing", - "title": "Shifting Letters II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shifting-letters-ii/" + "id": 2381, + "link": "https://leetcode.com/problems/shifting-letters-ii/", + "title": "Shifting Letters II" }, "2382": { - "id": 2382, "category": "Graph Traversal", - "title": "Maximum Segment Sum After Removals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-segment-sum-after-removals/" + "id": 2382, + "link": "https://leetcode.com/problems/maximum-segment-sum-after-removals/", + "title": "Maximum Segment Sum After Removals" }, "2383": { - "id": 2383, "category": "Greedy", - "title": "Minimum Hours of Training to Win a Competition", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-hours-of-training-to-win-a-competition/" + "id": 2383, + "link": "https://leetcode.com/problems/minimum-hours-of-training-to-win-a-competition/", + "title": "Minimum Hours of Training to Win a Competition" }, "2384": { - "id": 2384, "category": "Greedy", - "title": "Largest Palindromic Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-palindromic-number/" + "id": 2384, + "link": "https://leetcode.com/problems/largest-palindromic-number/", + "title": "Largest Palindromic Number" }, "2385": { - "id": 2385, "category": "Tree", - "title": "Amount of Time for Binary Tree to Be Infected", "difficulty": "Medium", - "link": "https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/" + "id": 2385, + "link": "https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/", + "title": "Amount of Time for Binary Tree to Be Infected" }, "2386": { - "id": 2386, "category": "Heap (Priority Queue)", - "title": "Find the K-Sum of an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-k-sum-of-an-array/" + "id": 2386, + "link": "https://leetcode.com/problems/find-the-k-sum-of-an-array/", + "title": "Find the K-Sum of an Array" }, "2387": { - "id": 2387, "category": "Binary Search", - "title": "Median of a Row Wise Sorted Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/median-of-a-row-wise-sorted-matrix/" + "id": 2387, + "link": "https://leetcode.com/problems/median-of-a-row-wise-sorted-matrix/", + "title": "Median of a Row Wise Sorted Matrix" }, "2388": { - "id": 2388, "category": "Database", - "title": "Change Null Values in a Table to the Previous Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/change-null-values-in-a-table-to-the-previous-value/" + "id": 2388, + "link": "https://leetcode.com/problems/change-null-values-in-a-table-to-the-previous-value/", + "title": "Change Null Values in a Table to the Previous Value" }, "2389": { - "id": 2389, "category": "Binary Search", - "title": "Longest Subsequence With Limited Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-subsequence-with-limited-sum/" + "id": 2389, + "link": "https://leetcode.com/problems/longest-subsequence-with-limited-sum/", + "title": "Longest Subsequence With Limited Sum" }, "2390": { - "id": 2390, "category": "Stack", - "title": "Removing Stars From a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/removing-stars-from-a-string/" + "id": 2390, + "link": "https://leetcode.com/problems/removing-stars-from-a-string/", + "title": "Removing Stars From a String" }, "2391": { - "id": 2391, "category": "Array & Hashing", - "title": "Minimum Amount of Time to Collect Garbage", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-amount-of-time-to-collect-garbage/" + "id": 2391, + "link": "https://leetcode.com/problems/minimum-amount-of-time-to-collect-garbage/", + "title": "Minimum Amount of Time to Collect Garbage" }, "2392": { - "id": 2392, "category": "Graph Traversal", - "title": "Build a Matrix With Conditions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/build-a-matrix-with-conditions/" + "id": 2392, + "link": "https://leetcode.com/problems/build-a-matrix-with-conditions/", + "title": "Build a Matrix With Conditions" }, "2393": { - "id": 2393, "category": "Dynamic Programming", - "title": "Count Strictly Increasing Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-strictly-increasing-subarrays/" + "id": 2393, + "link": "https://leetcode.com/problems/count-strictly-increasing-subarrays/", + "title": "Count Strictly Increasing Subarrays" }, "2394": { - "id": 2394, "category": "Database", - "title": "Employees With Deductions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/employees-with-deductions/" + "id": 2394, + "link": "https://leetcode.com/problems/employees-with-deductions/", + "title": "Employees With Deductions" }, "2395": { - "id": 2395, "category": "Array & Hashing", - "title": "Find Subarrays With Equal Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-subarrays-with-equal-sum/" + "id": 2395, + "link": "https://leetcode.com/problems/find-subarrays-with-equal-sum/", + "title": "Find Subarrays With Equal Sum" }, "2396": { - "id": 2396, "category": "Math & Geometry", - "title": "Strictly Palindromic Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/strictly-palindromic-number/" + "id": 2396, + "link": "https://leetcode.com/problems/strictly-palindromic-number/", + "title": "Strictly Palindromic Number" }, "2397": { - "id": 2397, "category": "Backtracking", - "title": "Maximum Rows Covered by Columns", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-rows-covered-by-columns/" + "id": 2397, + "link": "https://leetcode.com/problems/maximum-rows-covered-by-columns/", + "title": "Maximum Rows Covered by Columns" }, "2398": { - "id": 2398, "category": "Sliding Window", - "title": "Maximum Number of Robots Within Budget", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-robots-within-budget/" + "id": 2398, + "link": "https://leetcode.com/problems/maximum-number-of-robots-within-budget/", + "title": "Maximum Number of Robots Within Budget" }, "2399": { - "id": 2399, "category": "Array & Hashing", - "title": "Check Distances Between Same Letters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-distances-between-same-letters/" + "id": 2399, + "link": "https://leetcode.com/problems/check-distances-between-same-letters/", + "title": "Check Distances Between Same Letters" }, "2400": { - "id": 2400, "category": "Dynamic Programming", - "title": "Number of Ways to Reach a Position After Exactly k Steps", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/" + "id": 2400, + "link": "https://leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/", + "title": "Number of Ways to Reach a Position After Exactly k Steps" }, "2401": { - "id": 2401, "category": "Sliding Window", - "title": "Longest Nice Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-nice-subarray/" + "id": 2401, + "link": "https://leetcode.com/problems/longest-nice-subarray/", + "title": "Longest Nice Subarray" }, "2402": { - "id": 2402, "category": "Heap (Priority Queue)", - "title": "Meeting Rooms III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/meeting-rooms-iii/" + "id": 2402, + "link": "https://leetcode.com/problems/meeting-rooms-iii/", + "title": "Meeting Rooms III" }, "2403": { - "id": 2403, "category": "Dynamic Programming", - "title": "Minimum Time to Kill All Monsters", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-kill-all-monsters/" + "id": 2403, + "link": "https://leetcode.com/problems/minimum-time-to-kill-all-monsters/", + "title": "Minimum Time to Kill All Monsters" }, "2404": { - "id": 2404, "category": "Array & Hashing", - "title": "Most Frequent Even Element", "difficulty": "Easy", - "link": "https://leetcode.com/problems/most-frequent-even-element/" + "id": 2404, + "link": "https://leetcode.com/problems/most-frequent-even-element/", + "title": "Most Frequent Even Element" }, "2405": { - "id": 2405, "category": "Greedy", - "title": "Optimal Partition of String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/optimal-partition-of-string/" + "id": 2405, + "link": "https://leetcode.com/problems/optimal-partition-of-string/", + "title": "Optimal Partition of String" }, "2406": { - "id": 2406, "category": "Heap (Priority Queue)", - "title": "Divide Intervals Into Minimum Number of Groups", "difficulty": "Medium", - "link": "https://leetcode.com/problems/divide-intervals-into-minimum-number-of-groups/" + "id": 2406, + "link": "https://leetcode.com/problems/divide-intervals-into-minimum-number-of-groups/", + "title": "Divide Intervals Into Minimum Number of Groups" }, "2407": { - "id": 2407, "category": "Tree", - "title": "Longest Increasing Subsequence II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-increasing-subsequence-ii/" + "id": 2407, + "link": "https://leetcode.com/problems/longest-increasing-subsequence-ii/", + "title": "Longest Increasing Subsequence II" }, "2408": { - "id": 2408, "category": "Array & Hashing", - "title": "Design SQL", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-sql/" + "id": 2408, + "link": "https://leetcode.com/problems/design-sql/", + "title": "Design SQL" }, "2409": { - "id": 2409, "category": "Math & Geometry", - "title": "Count Days Spent Together", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-days-spent-together/" + "id": 2409, + "link": "https://leetcode.com/problems/count-days-spent-together/", + "title": "Count Days Spent Together" }, "2410": { - "id": 2410, "category": "Greedy", - "title": "Maximum Matching of Players With Trainers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-matching-of-players-with-trainers/" + "id": 2410, + "link": "https://leetcode.com/problems/maximum-matching-of-players-with-trainers/", + "title": "Maximum Matching of Players With Trainers" }, "2411": { - "id": 2411, "category": "Sliding Window", - "title": "Smallest Subarrays With Maximum Bitwise OR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-subarrays-with-maximum-bitwise-or/" + "id": 2411, + "link": "https://leetcode.com/problems/smallest-subarrays-with-maximum-bitwise-or/", + "title": "Smallest Subarrays With Maximum Bitwise OR" }, "2412": { - "id": 2412, "category": "Greedy", - "title": "Minimum Money Required Before Transactions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-money-required-before-transactions/" + "id": 2412, + "link": "https://leetcode.com/problems/minimum-money-required-before-transactions/", + "title": "Minimum Money Required Before Transactions" }, "2413": { - "id": 2413, "category": "Math & Geometry", - "title": "Smallest Even Multiple", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-even-multiple/" + "id": 2413, + "link": "https://leetcode.com/problems/smallest-even-multiple/", + "title": "Smallest Even Multiple" }, "2414": { - "id": 2414, "category": "Array & Hashing", - "title": "Length of the Longest Alphabetical Continuous Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/length-of-the-longest-alphabetical-continuous-substring/" + "id": 2414, + "link": "https://leetcode.com/problems/length-of-the-longest-alphabetical-continuous-substring/", + "title": "Length of the Longest Alphabetical Continuous Substring" }, "2415": { - "id": 2415, "category": "Tree", - "title": "Reverse Odd Levels of Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reverse-odd-levels-of-binary-tree/" + "id": 2415, + "link": "https://leetcode.com/problems/reverse-odd-levels-of-binary-tree/", + "title": "Reverse Odd Levels of Binary Tree" }, "2416": { - "id": 2416, "category": "Trie", - "title": "Sum of Prefix Scores of Strings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-prefix-scores-of-strings/" + "id": 2416, + "link": "https://leetcode.com/problems/sum-of-prefix-scores-of-strings/", + "title": "Sum of Prefix Scores of Strings" }, "2417": { - "id": 2417, "category": "Math & Geometry", - "title": "Closest Fair Integer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-fair-integer/" + "id": 2417, + "link": "https://leetcode.com/problems/closest-fair-integer/", + "title": "Closest Fair Integer" }, "2418": { - "id": 2418, "category": "Array & Hashing", - "title": "Sort the People", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-the-people/" + "id": 2418, + "link": "https://leetcode.com/problems/sort-the-people/", + "title": "Sort the People" }, "2419": { - "id": 2419, "category": "Bit Manipulation", - "title": "Longest Subarray With Maximum Bitwise AND", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-subarray-with-maximum-bitwise-and/" + "id": 2419, + "link": "https://leetcode.com/problems/longest-subarray-with-maximum-bitwise-and/", + "title": "Longest Subarray With Maximum Bitwise AND" }, "2420": { - "id": 2420, "category": "Dynamic Programming", - "title": "Find All Good Indices", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-good-indices/" + "id": 2420, + "link": "https://leetcode.com/problems/find-all-good-indices/", + "title": "Find All Good Indices" }, "2421": { - "id": 2421, "category": "Tree", - "title": "Number of Good Paths", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-good-paths/" + "id": 2421, + "link": "https://leetcode.com/problems/number-of-good-paths/", + "title": "Number of Good Paths" }, "2422": { - "id": 2422, "category": "Greedy", - "title": "Merge Operations to Turn Array Into a Palindrome", "difficulty": "Medium", - "link": "https://leetcode.com/problems/merge-operations-to-turn-array-into-a-palindrome/" + "id": 2422, + "link": "https://leetcode.com/problems/merge-operations-to-turn-array-into-a-palindrome/", + "title": "Merge Operations to Turn Array Into a Palindrome" }, "2423": { - "id": 2423, "category": "Array & Hashing", - "title": "Remove Letter To Equalize Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-letter-to-equalize-frequency/" + "id": 2423, + "link": "https://leetcode.com/problems/remove-letter-to-equalize-frequency/", + "title": "Remove Letter To Equalize Frequency" }, "2424": { - "id": 2424, "category": "Tree", - "title": "Longest Uploaded Prefix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-uploaded-prefix/" + "id": 2424, + "link": "https://leetcode.com/problems/longest-uploaded-prefix/", + "title": "Longest Uploaded Prefix" }, "2425": { - "id": 2425, "category": "Bit Manipulation", - "title": "Bitwise XOR of All Pairings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bitwise-xor-of-all-pairings/" + "id": 2425, + "link": "https://leetcode.com/problems/bitwise-xor-of-all-pairings/", + "title": "Bitwise XOR of All Pairings" }, "2426": { - "id": 2426, "category": "Tree", - "title": "Number of Pairs Satisfying Inequality", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-pairs-satisfying-inequality/" + "id": 2426, + "link": "https://leetcode.com/problems/number-of-pairs-satisfying-inequality/", + "title": "Number of Pairs Satisfying Inequality" }, "2427": { - "id": 2427, "category": "Math & Geometry", - "title": "Number of Common Factors", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-common-factors/" + "id": 2427, + "link": "https://leetcode.com/problems/number-of-common-factors/", + "title": "Number of Common Factors" }, "2428": { - "id": 2428, "category": "Array & Hashing", - "title": "Maximum Sum of an Hourglass", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-of-an-hourglass/" + "id": 2428, + "link": "https://leetcode.com/problems/maximum-sum-of-an-hourglass/", + "title": "Maximum Sum of an Hourglass" }, "2429": { - "id": 2429, "category": "Bit Manipulation", - "title": "Minimize XOR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-xor/" + "id": 2429, + "link": "https://leetcode.com/problems/minimize-xor/", + "title": "Minimize XOR" }, "2430": { - "id": 2430, "category": "Dynamic Programming", - "title": "Maximum Deletions on a String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-deletions-on-a-string/" + "id": 2430, + "link": "https://leetcode.com/problems/maximum-deletions-on-a-string/", + "title": "Maximum Deletions on a String" }, "2431": { - "id": 2431, "category": "Dynamic Programming", - "title": "Maximize Total Tastiness of Purchased Fruits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-total-tastiness-of-purchased-fruits/" + "id": 2431, + "link": "https://leetcode.com/problems/maximize-total-tastiness-of-purchased-fruits/", + "title": "Maximize Total Tastiness of Purchased Fruits" }, "2432": { - "id": 2432, "category": "Array & Hashing", - "title": "The Employee That Worked on the Longest Task", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/" + "id": 2432, + "link": "https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/", + "title": "The Employee That Worked on the Longest Task" }, "2433": { - "id": 2433, "category": "Bit Manipulation", - "title": "Find The Original Array of Prefix Xor", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-original-array-of-prefix-xor/" + "id": 2433, + "link": "https://leetcode.com/problems/find-the-original-array-of-prefix-xor/", + "title": "Find The Original Array of Prefix Xor" }, "2434": { - "id": 2434, "category": "Stack", - "title": "Using a Robot to Print the Lexicographically Smallest String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/using-a-robot-to-print-the-lexicographically-smallest-string/" + "id": 2434, + "link": "https://leetcode.com/problems/using-a-robot-to-print-the-lexicographically-smallest-string/", + "title": "Using a Robot to Print the Lexicographically Smallest String" }, "2435": { - "id": 2435, "category": "Dynamic Programming", - "title": "Paths in Matrix Whose Sum Is Divisible by K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/paths-in-matrix-whose-sum-is-divisible-by-k/" + "id": 2435, + "link": "https://leetcode.com/problems/paths-in-matrix-whose-sum-is-divisible-by-k/", + "title": "Paths in Matrix Whose Sum Is Divisible by K" }, "2436": { - "id": 2436, "category": "Dynamic Programming", - "title": "Minimum Split Into Subarrays With GCD Greater Than One", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-split-into-subarrays-with-gcd-greater-than-one/" + "id": 2436, + "link": "https://leetcode.com/problems/minimum-split-into-subarrays-with-gcd-greater-than-one/", + "title": "Minimum Split Into Subarrays With GCD Greater Than One" }, "2437": { - "id": 2437, "category": "Array & Hashing", - "title": "Number of Valid Clock Times", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-valid-clock-times/" + "id": 2437, + "link": "https://leetcode.com/problems/number-of-valid-clock-times/", + "title": "Number of Valid Clock Times" }, "2438": { - "id": 2438, "category": "Bit Manipulation", - "title": "Range Product Queries of Powers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/range-product-queries-of-powers/" + "id": 2438, + "link": "https://leetcode.com/problems/range-product-queries-of-powers/", + "title": "Range Product Queries of Powers" }, "2439": { - "id": 2439, "category": "Dynamic Programming", - "title": "Minimize Maximum of Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-maximum-of-array/" + "id": 2439, + "link": "https://leetcode.com/problems/minimize-maximum-of-array/", + "title": "Minimize Maximum of Array" }, "2440": { - "id": 2440, "category": "Tree", - "title": "Create Components With Same Value", "difficulty": "Hard", - "link": "https://leetcode.com/problems/create-components-with-same-value/" + "id": 2440, + "link": "https://leetcode.com/problems/create-components-with-same-value/", + "title": "Create Components With Same Value" }, "2441": { - "id": 2441, "category": "Two Pointers", - "title": "Largest Positive Integer That Exists With Its Negative", "difficulty": "Easy", - "link": "https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/" + "id": 2441, + "link": "https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/", + "title": "Largest Positive Integer That Exists With Its Negative" }, "2442": { - "id": 2442, "category": "Math & Geometry", - "title": "Count Number of Distinct Integers After Reverse Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-distinct-integers-after-reverse-operations/" + "id": 2442, + "link": "https://leetcode.com/problems/count-number-of-distinct-integers-after-reverse-operations/", + "title": "Count Number of Distinct Integers After Reverse Operations" }, "2443": { - "id": 2443, "category": "Math & Geometry", - "title": "Sum of Number and Its Reverse", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-number-and-its-reverse/" + "id": 2443, + "link": "https://leetcode.com/problems/sum-of-number-and-its-reverse/", + "title": "Sum of Number and Its Reverse" }, "2444": { - "id": 2444, "category": "Sliding Window", - "title": "Count Subarrays With Fixed Bounds", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-subarrays-with-fixed-bounds/" + "id": 2444, + "link": "https://leetcode.com/problems/count-subarrays-with-fixed-bounds/", + "title": "Count Subarrays With Fixed Bounds" }, "2445": { - "id": 2445, "category": "Tree", - "title": "Number of Nodes With Value One", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-nodes-with-value-one/" + "id": 2445, + "link": "https://leetcode.com/problems/number-of-nodes-with-value-one/", + "title": "Number of Nodes With Value One" }, "2446": { - "id": 2446, "category": "Array & Hashing", - "title": "Determine if Two Events Have Conflict", "difficulty": "Easy", - "link": "https://leetcode.com/problems/determine-if-two-events-have-conflict/" + "id": 2446, + "link": "https://leetcode.com/problems/determine-if-two-events-have-conflict/", + "title": "Determine if Two Events Have Conflict" }, "2447": { - "id": 2447, "category": "Math & Geometry", - "title": "Number of Subarrays With GCD Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subarrays-with-gcd-equal-to-k/" + "id": 2447, + "link": "https://leetcode.com/problems/number-of-subarrays-with-gcd-equal-to-k/", + "title": "Number of Subarrays With GCD Equal to K" }, "2448": { - "id": 2448, "category": "Binary Search", - "title": "Minimum Cost to Make Array Equal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-make-array-equal/" + "id": 2448, + "link": "https://leetcode.com/problems/minimum-cost-to-make-array-equal/", + "title": "Minimum Cost to Make Array Equal" }, "2449": { - "id": 2449, "category": "Greedy", - "title": "Minimum Number of Operations to Make Arrays Similar", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-arrays-similar/" + "id": 2449, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-arrays-similar/", + "title": "Minimum Number of Operations to Make Arrays Similar" }, "2450": { - "id": 2450, "category": "Math & Geometry", - "title": "Number of Distinct Binary Strings After Applying Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-distinct-binary-strings-after-applying-operations/" + "id": 2450, + "link": "https://leetcode.com/problems/number-of-distinct-binary-strings-after-applying-operations/", + "title": "Number of Distinct Binary Strings After Applying Operations" }, "2451": { - "id": 2451, "category": "Array & Hashing", - "title": "Odd String Difference", "difficulty": "Easy", - "link": "https://leetcode.com/problems/odd-string-difference/" + "id": 2451, + "link": "https://leetcode.com/problems/odd-string-difference/", + "title": "Odd String Difference" }, "2452": { - "id": 2452, "category": "Trie", - "title": "Words Within Two Edits of Dictionary", "difficulty": "Medium", - "link": "https://leetcode.com/problems/words-within-two-edits-of-dictionary/" + "id": 2452, + "link": "https://leetcode.com/problems/words-within-two-edits-of-dictionary/", + "title": "Words Within Two Edits of Dictionary" }, "2453": { - "id": 2453, "category": "Array & Hashing", - "title": "Destroy Sequential Targets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/destroy-sequential-targets/" + "id": 2453, + "link": "https://leetcode.com/problems/destroy-sequential-targets/", + "title": "Destroy Sequential Targets" }, "2454": { - "id": 2454, "category": "Binary Search", - "title": "Next Greater Element IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/next-greater-element-iv/" + "id": 2454, + "link": "https://leetcode.com/problems/next-greater-element-iv/", + "title": "Next Greater Element IV" }, "2455": { - "id": 2455, "category": "Math & Geometry", - "title": "Average Value of Even Numbers That Are Divisible by Three", "difficulty": "Easy", - "link": "https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/" + "id": 2455, + "link": "https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/", + "title": "Average Value of Even Numbers That Are Divisible by Three" }, "2456": { - "id": 2456, "category": "Heap (Priority Queue)", - "title": "Most Popular Video Creator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-popular-video-creator/" + "id": 2456, + "link": "https://leetcode.com/problems/most-popular-video-creator/", + "title": "Most Popular Video Creator" }, "2457": { - "id": 2457, "category": "Greedy", - "title": "Minimum Addition to Make Integer Beautiful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-addition-to-make-integer-beautiful/" + "id": 2457, + "link": "https://leetcode.com/problems/minimum-addition-to-make-integer-beautiful/", + "title": "Minimum Addition to Make Integer Beautiful" }, "2458": { - "id": 2458, "category": "Tree", - "title": "Height of Binary Tree After Subtree Removal Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries/" + "id": 2458, + "link": "https://leetcode.com/problems/height-of-binary-tree-after-subtree-removal-queries/", + "title": "Height of Binary Tree After Subtree Removal Queries" }, "2459": { - "id": 2459, "category": "Greedy", - "title": "Sort Array by Moving Items to Empty Space", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sort-array-by-moving-items-to-empty-space/" + "id": 2459, + "link": "https://leetcode.com/problems/sort-array-by-moving-items-to-empty-space/", + "title": "Sort Array by Moving Items to Empty Space" }, "2460": { - "id": 2460, "category": "Two Pointers", - "title": "Apply Operations to an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/apply-operations-to-an-array/" + "id": 2460, + "link": "https://leetcode.com/problems/apply-operations-to-an-array/", + "title": "Apply Operations to an Array" }, "2461": { - "id": 2461, "category": "Sliding Window", - "title": "Maximum Sum of Distinct Subarrays With Length K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-of-distinct-subarrays-with-length-k/" + "id": 2461, + "link": "https://leetcode.com/problems/maximum-sum-of-distinct-subarrays-with-length-k/", + "title": "Maximum Sum of Distinct Subarrays With Length K" }, "2462": { - "id": 2462, "category": "Heap (Priority Queue)", - "title": "Total Cost to Hire K Workers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/total-cost-to-hire-k-workers/" + "id": 2462, + "link": "https://leetcode.com/problems/total-cost-to-hire-k-workers/", + "title": "Total Cost to Hire K Workers" }, "2463": { - "id": 2463, "category": "Dynamic Programming", - "title": "Minimum Total Distance Traveled", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-total-distance-traveled/" + "id": 2463, + "link": "https://leetcode.com/problems/minimum-total-distance-traveled/", + "title": "Minimum Total Distance Traveled" }, "2464": { - "id": 2464, "category": "Dynamic Programming", - "title": "Minimum Subarrays in a Valid Split", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-subarrays-in-a-valid-split/" + "id": 2464, + "link": "https://leetcode.com/problems/minimum-subarrays-in-a-valid-split/", + "title": "Minimum Subarrays in a Valid Split" }, "2465": { - "id": 2465, "category": "Two Pointers", - "title": "Number of Distinct Averages", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-distinct-averages/" + "id": 2465, + "link": "https://leetcode.com/problems/number-of-distinct-averages/", + "title": "Number of Distinct Averages" }, "2466": { - "id": 2466, "category": "Dynamic Programming", - "title": "Count Ways To Build Good Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-ways-to-build-good-strings/" + "id": 2466, + "link": "https://leetcode.com/problems/count-ways-to-build-good-strings/", + "title": "Count Ways To Build Good Strings" }, "2467": { - "id": 2467, "category": "Tree", - "title": "Most Profitable Path in a Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-profitable-path-in-a-tree/" + "id": 2467, + "link": "https://leetcode.com/problems/most-profitable-path-in-a-tree/", + "title": "Most Profitable Path in a Tree" }, "2468": { - "id": 2468, "category": "Binary Search", - "title": "Split Message Based on Limit", "difficulty": "Hard", - "link": "https://leetcode.com/problems/split-message-based-on-limit/" + "id": 2468, + "link": "https://leetcode.com/problems/split-message-based-on-limit/", + "title": "Split Message Based on Limit" }, "2469": { - "id": 2469, "category": "Math & Geometry", - "title": "Convert the Temperature", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-the-temperature/" + "id": 2469, + "link": "https://leetcode.com/problems/convert-the-temperature/", + "title": "Convert the Temperature" }, "2470": { - "id": 2470, "category": "Math & Geometry", - "title": "Number of Subarrays With LCM Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subarrays-with-lcm-equal-to-k/" + "id": 2470, + "link": "https://leetcode.com/problems/number-of-subarrays-with-lcm-equal-to-k/", + "title": "Number of Subarrays With LCM Equal to K" }, "2471": { - "id": 2471, "category": "Tree", - "title": "Minimum Number of Operations to Sort a Binary Tree by Level", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-sort-a-binary-tree-by-level/" + "id": 2471, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-sort-a-binary-tree-by-level/", + "title": "Minimum Number of Operations to Sort a Binary Tree by Level" }, "2472": { - "id": 2472, "category": "Dynamic Programming", - "title": "Maximum Number of Non-overlapping Palindrome Substrings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-palindrome-substrings/" + "id": 2472, + "link": "https://leetcode.com/problems/maximum-number-of-non-overlapping-palindrome-substrings/", + "title": "Maximum Number of Non-overlapping Palindrome Substrings" }, "2473": { - "id": 2473, "category": "Graph Traversal", - "title": "Minimum Cost to Buy Apples", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-buy-apples/" + "id": 2473, + "link": "https://leetcode.com/problems/minimum-cost-to-buy-apples/", + "title": "Minimum Cost to Buy Apples" }, "2474": { - "id": 2474, "category": "Database", - "title": "Customers With Strictly Increasing Purchases", "difficulty": "Hard", - "link": "https://leetcode.com/problems/customers-with-strictly-increasing-purchases/" + "id": 2474, + "link": "https://leetcode.com/problems/customers-with-strictly-increasing-purchases/", + "title": "Customers With Strictly Increasing Purchases" }, "2475": { - "id": 2475, "category": "Array & Hashing", - "title": "Number of Unequal Triplets in Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-unequal-triplets-in-array/" + "id": 2475, + "link": "https://leetcode.com/problems/number-of-unequal-triplets-in-array/", + "title": "Number of Unequal Triplets in Array" }, "2476": { - "id": 2476, "category": "Tree", - "title": "Closest Nodes Queries in a Binary Search Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-nodes-queries-in-a-binary-search-tree/" + "id": 2476, + "link": "https://leetcode.com/problems/closest-nodes-queries-in-a-binary-search-tree/", + "title": "Closest Nodes Queries in a Binary Search Tree" }, "2477": { - "id": 2477, "category": "Tree", - "title": "Minimum Fuel Cost to Report to the Capital", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-fuel-cost-to-report-to-the-capital/" + "id": 2477, + "link": "https://leetcode.com/problems/minimum-fuel-cost-to-report-to-the-capital/", + "title": "Minimum Fuel Cost to Report to the Capital" }, "2478": { - "id": 2478, "category": "Dynamic Programming", - "title": "Number of Beautiful Partitions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-beautiful-partitions/" + "id": 2478, + "link": "https://leetcode.com/problems/number-of-beautiful-partitions/", + "title": "Number of Beautiful Partitions" }, "2479": { - "id": 2479, "category": "Tree", - "title": "Maximum XOR of Two Non-Overlapping Subtrees", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-xor-of-two-non-overlapping-subtrees/" + "id": 2479, + "link": "https://leetcode.com/problems/maximum-xor-of-two-non-overlapping-subtrees/", + "title": "Maximum XOR of Two Non-Overlapping Subtrees" }, "2480": { - "id": 2480, "category": "Database", - "title": "Form a Chemical Bond", "difficulty": "Easy", - "link": "https://leetcode.com/problems/form-a-chemical-bond/" + "id": 2480, + "link": "https://leetcode.com/problems/form-a-chemical-bond/", + "title": "Form a Chemical Bond" }, "2481": { - "id": 2481, "category": "Math & Geometry", - "title": "Minimum Cuts to Divide a Circle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-cuts-to-divide-a-circle/" + "id": 2481, + "link": "https://leetcode.com/problems/minimum-cuts-to-divide-a-circle/", + "title": "Minimum Cuts to Divide a Circle" }, "2482": { - "id": 2482, "category": "Array & Hashing", - "title": "Difference Between Ones and Zeros in Row and Column", "difficulty": "Medium", - "link": "https://leetcode.com/problems/difference-between-ones-and-zeros-in-row-and-column/" + "id": 2482, + "link": "https://leetcode.com/problems/difference-between-ones-and-zeros-in-row-and-column/", + "title": "Difference Between Ones and Zeros in Row and Column" }, "2483": { - "id": 2483, "category": "Array & Hashing", - "title": "Minimum Penalty for a Shop", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-penalty-for-a-shop/" + "id": 2483, + "link": "https://leetcode.com/problems/minimum-penalty-for-a-shop/", + "title": "Minimum Penalty for a Shop" }, "2484": { - "id": 2484, "category": "Dynamic Programming", - "title": "Count Palindromic Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-palindromic-subsequences/" + "id": 2484, + "link": "https://leetcode.com/problems/count-palindromic-subsequences/", + "title": "Count Palindromic Subsequences" }, "2485": { - "id": 2485, "category": "Math & Geometry", - "title": "Find the Pivot Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-pivot-integer/" + "id": 2485, + "link": "https://leetcode.com/problems/find-the-pivot-integer/", + "title": "Find the Pivot Integer" }, "2486": { - "id": 2486, "category": "Greedy", - "title": "Append Characters to String to Make Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/append-characters-to-string-to-make-subsequence/" + "id": 2486, + "link": "https://leetcode.com/problems/append-characters-to-string-to-make-subsequence/", + "title": "Append Characters to String to Make Subsequence" }, "2487": { - "id": 2487, "category": "Stack", - "title": "Remove Nodes From Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-nodes-from-linked-list/" + "id": 2487, + "link": "https://leetcode.com/problems/remove-nodes-from-linked-list/", + "title": "Remove Nodes From Linked List" }, "2488": { - "id": 2488, "category": "Array & Hashing", - "title": "Count Subarrays With Median K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-subarrays-with-median-k/" + "id": 2488, + "link": "https://leetcode.com/problems/count-subarrays-with-median-k/", + "title": "Count Subarrays With Median K" }, "2489": { - "id": 2489, "category": "Math & Geometry", - "title": "Number of Substrings With Fixed Ratio", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-substrings-with-fixed-ratio/" + "id": 2489, + "link": "https://leetcode.com/problems/number-of-substrings-with-fixed-ratio/", + "title": "Number of Substrings With Fixed Ratio" }, "2490": { - "id": 2490, "category": "Array & Hashing", - "title": "Circular Sentence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/circular-sentence/" + "id": 2490, + "link": "https://leetcode.com/problems/circular-sentence/", + "title": "Circular Sentence" }, "2491": { - "id": 2491, "category": "Two Pointers", - "title": "Divide Players Into Teams of Equal Skill", "difficulty": "Medium", - "link": "https://leetcode.com/problems/divide-players-into-teams-of-equal-skill/" + "id": 2491, + "link": "https://leetcode.com/problems/divide-players-into-teams-of-equal-skill/", + "title": "Divide Players Into Teams of Equal Skill" }, "2492": { - "id": 2492, "category": "Graph Traversal", - "title": "Minimum Score of a Path Between Two Cities", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities/" + "id": 2492, + "link": "https://leetcode.com/problems/minimum-score-of-a-path-between-two-cities/", + "title": "Minimum Score of a Path Between Two Cities" }, "2493": { - "id": 2493, "category": "Graph Traversal", - "title": "Divide Nodes Into the Maximum Number of Groups", "difficulty": "Hard", - "link": "https://leetcode.com/problems/divide-nodes-into-the-maximum-number-of-groups/" + "id": 2493, + "link": "https://leetcode.com/problems/divide-nodes-into-the-maximum-number-of-groups/", + "title": "Divide Nodes Into the Maximum Number of Groups" }, "2494": { - "id": 2494, "category": "Database", - "title": "Merge Overlapping Events in the Same Hall", "difficulty": "Hard", - "link": "https://leetcode.com/problems/merge-overlapping-events-in-the-same-hall/" + "id": 2494, + "link": "https://leetcode.com/problems/merge-overlapping-events-in-the-same-hall/", + "title": "Merge Overlapping Events in the Same Hall" }, "2495": { - "id": 2495, "category": "Dynamic Programming", - "title": "Number of Subarrays Having Even Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subarrays-having-even-product/" + "id": 2495, + "link": "https://leetcode.com/problems/number-of-subarrays-having-even-product/", + "title": "Number of Subarrays Having Even Product" }, "2496": { - "id": 2496, "category": "Array & Hashing", - "title": "Maximum Value of a String in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-value-of-a-string-in-an-array/" + "id": 2496, + "link": "https://leetcode.com/problems/maximum-value-of-a-string-in-an-array/", + "title": "Maximum Value of a String in an Array" }, "2497": { - "id": 2497, "category": "Graph Traversal", - "title": "Maximum Star Sum of a Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-star-sum-of-a-graph/" + "id": 2497, + "link": "https://leetcode.com/problems/maximum-star-sum-of-a-graph/", + "title": "Maximum Star Sum of a Graph" }, "2498": { - "id": 2498, "category": "Binary Search", - "title": "Frog Jump II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/frog-jump-ii/" + "id": 2498, + "link": "https://leetcode.com/problems/frog-jump-ii/", + "title": "Frog Jump II" }, "2499": { - "id": 2499, "category": "Greedy", - "title": "Minimum Total Cost to Make Arrays Unequal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-total-cost-to-make-arrays-unequal/" + "id": 2499, + "link": "https://leetcode.com/problems/minimum-total-cost-to-make-arrays-unequal/", + "title": "Minimum Total Cost to Make Arrays Unequal" }, "2500": { - "id": 2500, "category": "Heap (Priority Queue)", - "title": "Delete Greatest Value in Each Row", "difficulty": "Easy", - "link": "https://leetcode.com/problems/delete-greatest-value-in-each-row/" + "id": 2500, + "link": "https://leetcode.com/problems/delete-greatest-value-in-each-row/", + "title": "Delete Greatest Value in Each Row" }, "2501": { - "id": 2501, "category": "Dynamic Programming", - "title": "Longest Square Streak in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-square-streak-in-an-array/" + "id": 2501, + "link": "https://leetcode.com/problems/longest-square-streak-in-an-array/", + "title": "Longest Square Streak in an Array" }, "2502": { - "id": 2502, "category": "Array & Hashing", - "title": "Design Memory Allocator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-memory-allocator/" + "id": 2502, + "link": "https://leetcode.com/problems/design-memory-allocator/", + "title": "Design Memory Allocator" }, "2503": { - "id": 2503, "category": "Graph Traversal", - "title": "Maximum Number of Points From Grid Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-points-from-grid-queries/" + "id": 2503, + "link": "https://leetcode.com/problems/maximum-number-of-points-from-grid-queries/", + "title": "Maximum Number of Points From Grid Queries" }, "2504": { - "id": 2504, "category": "Database", - "title": "Concatenate the Name and the Profession", "difficulty": "Easy", - "link": "https://leetcode.com/problems/concatenate-the-name-and-the-profession/" + "id": 2504, + "link": "https://leetcode.com/problems/concatenate-the-name-and-the-profession/", + "title": "Concatenate the Name and the Profession" }, "2505": { - "id": 2505, "category": "Bit Manipulation", - "title": "Bitwise OR of All Subsequence Sums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bitwise-or-of-all-subsequence-sums/" + "id": 2505, + "link": "https://leetcode.com/problems/bitwise-or-of-all-subsequence-sums/", + "title": "Bitwise OR of All Subsequence Sums" }, "2506": { - "id": 2506, "category": "Bit Manipulation", - "title": "Count Pairs Of Similar Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-pairs-of-similar-strings/" + "id": 2506, + "link": "https://leetcode.com/problems/count-pairs-of-similar-strings/", + "title": "Count Pairs Of Similar Strings" }, "2507": { - "id": 2507, "category": "Math & Geometry", - "title": "Smallest Value After Replacing With Sum of Prime Factors", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-value-after-replacing-with-sum-of-prime-factors/" + "id": 2507, + "link": "https://leetcode.com/problems/smallest-value-after-replacing-with-sum-of-prime-factors/", + "title": "Smallest Value After Replacing With Sum of Prime Factors" }, "2508": { - "id": 2508, "category": "Graph Traversal", - "title": "Add Edges to Make Degrees of All Nodes Even", "difficulty": "Hard", - "link": "https://leetcode.com/problems/add-edges-to-make-degrees-of-all-nodes-even/" + "id": 2508, + "link": "https://leetcode.com/problems/add-edges-to-make-degrees-of-all-nodes-even/", + "title": "Add Edges to Make Degrees of All Nodes Even" }, "2509": { - "id": 2509, "category": "Tree", - "title": "Cycle Length Queries in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/cycle-length-queries-in-a-tree/" + "id": 2509, + "link": "https://leetcode.com/problems/cycle-length-queries-in-a-tree/", + "title": "Cycle Length Queries in a Tree" }, "2510": { - "id": 2510, "category": "Dynamic Programming", - "title": "Check if There is a Path With Equal Number of 0's And 1's", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-there-is-a-path-with-equal-number-of-0s-and-1s/" + "id": 2510, + "link": "https://leetcode.com/problems/check-if-there-is-a-path-with-equal-number-of-0s-and-1s/", + "title": "Check if There is a Path With Equal Number of 0's And 1's" }, "2511": { - "id": 2511, "category": "Two Pointers", - "title": "Maximum Enemy Forts That Can Be Captured", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-enemy-forts-that-can-be-captured/" + "id": 2511, + "link": "https://leetcode.com/problems/maximum-enemy-forts-that-can-be-captured/", + "title": "Maximum Enemy Forts That Can Be Captured" }, "2512": { - "id": 2512, "category": "Heap (Priority Queue)", - "title": "Reward Top K Students", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reward-top-k-students/" + "id": 2512, + "link": "https://leetcode.com/problems/reward-top-k-students/", + "title": "Reward Top K Students" }, "2513": { - "id": 2513, "category": "Binary Search", - "title": "Minimize the Maximum of Two Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-the-maximum-of-two-arrays/" + "id": 2513, + "link": "https://leetcode.com/problems/minimize-the-maximum-of-two-arrays/", + "title": "Minimize the Maximum of Two Arrays" }, "2514": { - "id": 2514, "category": "Math & Geometry", - "title": "Count Anagrams", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-anagrams/" + "id": 2514, + "link": "https://leetcode.com/problems/count-anagrams/", + "title": "Count Anagrams" }, "2515": { - "id": 2515, "category": "Array & Hashing", - "title": "Shortest Distance to Target String in a Circular Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-distance-to-target-string-in-a-circular-array/" + "id": 2515, + "link": "https://leetcode.com/problems/shortest-distance-to-target-string-in-a-circular-array/", + "title": "Shortest Distance to Target String in a Circular Array" }, "2516": { - "id": 2516, "category": "Sliding Window", - "title": "Take K of Each Character From Left and Right", "difficulty": "Medium", - "link": "https://leetcode.com/problems/take-k-of-each-character-from-left-and-right/" + "id": 2516, + "link": "https://leetcode.com/problems/take-k-of-each-character-from-left-and-right/", + "title": "Take K of Each Character From Left and Right" }, "2517": { - "id": 2517, "category": "Binary Search", - "title": "Maximum Tastiness of Candy Basket", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-tastiness-of-candy-basket/" + "id": 2517, + "link": "https://leetcode.com/problems/maximum-tastiness-of-candy-basket/", + "title": "Maximum Tastiness of Candy Basket" }, "2518": { - "id": 2518, "category": "Dynamic Programming", - "title": "Number of Great Partitions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-great-partitions/" + "id": 2518, + "link": "https://leetcode.com/problems/number-of-great-partitions/", + "title": "Number of Great Partitions" }, "2519": { - "id": 2519, "category": "Tree", - "title": "Count the Number of K-Big Indices", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-k-big-indices/" + "id": 2519, + "link": "https://leetcode.com/problems/count-the-number-of-k-big-indices/", + "title": "Count the Number of K-Big Indices" }, "2520": { - "id": 2520, "category": "Math & Geometry", - "title": "Count the Digits That Divide a Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-the-digits-that-divide-a-number/" + "id": 2520, + "link": "https://leetcode.com/problems/count-the-digits-that-divide-a-number/", + "title": "Count the Digits That Divide a Number" }, "2521": { - "id": 2521, "category": "Math & Geometry", - "title": "Distinct Prime Factors of Product of Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distinct-prime-factors-of-product-of-array/" + "id": 2521, + "link": "https://leetcode.com/problems/distinct-prime-factors-of-product-of-array/", + "title": "Distinct Prime Factors of Product of Array" }, "2522": { - "id": 2522, "category": "Dynamic Programming", - "title": "Partition String Into Substrings With Values at Most K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-string-into-substrings-with-values-at-most-k/" + "id": 2522, + "link": "https://leetcode.com/problems/partition-string-into-substrings-with-values-at-most-k/", + "title": "Partition String Into Substrings With Values at Most K" }, "2523": { - "id": 2523, "category": "Math & Geometry", - "title": "Closest Prime Numbers in Range", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-prime-numbers-in-range/" + "id": 2523, + "link": "https://leetcode.com/problems/closest-prime-numbers-in-range/", + "title": "Closest Prime Numbers in Range" }, "2524": { - "id": 2524, "category": "Sliding Window", - "title": "Maximum Frequency Score of a Subarray", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-frequency-score-of-a-subarray/" + "id": 2524, + "link": "https://leetcode.com/problems/maximum-frequency-score-of-a-subarray/", + "title": "Maximum Frequency Score of a Subarray" }, "2525": { - "id": 2525, "category": "Math & Geometry", - "title": "Categorize Box According to Criteria", "difficulty": "Easy", - "link": "https://leetcode.com/problems/categorize-box-according-to-criteria/" + "id": 2525, + "link": "https://leetcode.com/problems/categorize-box-according-to-criteria/", + "title": "Categorize Box According to Criteria" }, "2526": { - "id": 2526, "category": "Array & Hashing", - "title": "Find Consecutive Integers from a Data Stream", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-consecutive-integers-from-a-data-stream/" + "id": 2526, + "link": "https://leetcode.com/problems/find-consecutive-integers-from-a-data-stream/", + "title": "Find Consecutive Integers from a Data Stream" }, "2527": { - "id": 2527, "category": "Bit Manipulation", - "title": "Find Xor-Beauty of Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-xor-beauty-of-array/" + "id": 2527, + "link": "https://leetcode.com/problems/find-xor-beauty-of-array/", + "title": "Find Xor-Beauty of Array" }, "2528": { - "id": 2528, "category": "Sliding Window", - "title": "Maximize the Minimum Powered City", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-minimum-powered-city/" + "id": 2528, + "link": "https://leetcode.com/problems/maximize-the-minimum-powered-city/", + "title": "Maximize the Minimum Powered City" }, "2529": { - "id": 2529, "category": "Binary Search", - "title": "Maximum Count of Positive Integer and Negative Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-count-of-positive-integer-and-negative-integer/" + "id": 2529, + "link": "https://leetcode.com/problems/maximum-count-of-positive-integer-and-negative-integer/", + "title": "Maximum Count of Positive Integer and Negative Integer" }, "2530": { - "id": 2530, "category": "Heap (Priority Queue)", - "title": "Maximal Score After Applying K Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximal-score-after-applying-k-operations/" + "id": 2530, + "link": "https://leetcode.com/problems/maximal-score-after-applying-k-operations/", + "title": "Maximal Score After Applying K Operations" }, "2531": { - "id": 2531, "category": "Array & Hashing", - "title": "Make Number of Distinct Characters Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-number-of-distinct-characters-equal/" + "id": 2531, + "link": "https://leetcode.com/problems/make-number-of-distinct-characters-equal/", + "title": "Make Number of Distinct Characters Equal" }, "2532": { - "id": 2532, "category": "Heap (Priority Queue)", - "title": "Time to Cross a Bridge", "difficulty": "Hard", - "link": "https://leetcode.com/problems/time-to-cross-a-bridge/" + "id": 2532, + "link": "https://leetcode.com/problems/time-to-cross-a-bridge/", + "title": "Time to Cross a Bridge" }, "2533": { - "id": 2533, "category": "Dynamic Programming", - "title": "Number of Good Binary Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-good-binary-strings/" + "id": 2533, + "link": "https://leetcode.com/problems/number-of-good-binary-strings/", + "title": "Number of Good Binary Strings" }, "2534": { - "id": 2534, "category": "Array & Hashing", - "title": "Time Taken to Cross the Door", "difficulty": "Hard", - "link": "https://leetcode.com/problems/time-taken-to-cross-the-door/" + "id": 2534, + "link": "https://leetcode.com/problems/time-taken-to-cross-the-door/", + "title": "Time Taken to Cross the Door" }, "2535": { - "id": 2535, "category": "Math & Geometry", - "title": "Difference Between Element Sum and Digit Sum of an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/difference-between-element-sum-and-digit-sum-of-an-array/" + "id": 2535, + "link": "https://leetcode.com/problems/difference-between-element-sum-and-digit-sum-of-an-array/", + "title": "Difference Between Element Sum and Digit Sum of an Array" }, "2536": { - "id": 2536, "category": "Array & Hashing", - "title": "Increment Submatrices by One", "difficulty": "Medium", - "link": "https://leetcode.com/problems/increment-submatrices-by-one/" + "id": 2536, + "link": "https://leetcode.com/problems/increment-submatrices-by-one/", + "title": "Increment Submatrices by One" }, "2537": { - "id": 2537, "category": "Sliding Window", - "title": "Count the Number of Good Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-good-subarrays/" + "id": 2537, + "link": "https://leetcode.com/problems/count-the-number-of-good-subarrays/", + "title": "Count the Number of Good Subarrays" }, "2538": { - "id": 2538, "category": "Tree", - "title": "Difference Between Maximum and Minimum Price Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/difference-between-maximum-and-minimum-price-sum/" + "id": 2538, + "link": "https://leetcode.com/problems/difference-between-maximum-and-minimum-price-sum/", + "title": "Difference Between Maximum and Minimum Price Sum" }, "2539": { - "id": 2539, "category": "Math & Geometry", - "title": "Count the Number of Good Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-good-subsequences/" + "id": 2539, + "link": "https://leetcode.com/problems/count-the-number-of-good-subsequences/", + "title": "Count the Number of Good Subsequences" }, "2540": { - "id": 2540, "category": "Binary Search", - "title": "Minimum Common Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-common-value/" + "id": 2540, + "link": "https://leetcode.com/problems/minimum-common-value/", + "title": "Minimum Common Value" }, "2541": { - "id": 2541, "category": "Greedy", - "title": "Minimum Operations to Make Array Equal II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal-ii/" + "id": 2541, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal-ii/", + "title": "Minimum Operations to Make Array Equal II" }, "2542": { - "id": 2542, "category": "Heap (Priority Queue)", - "title": "Maximum Subsequence Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subsequence-score/" + "id": 2542, + "link": "https://leetcode.com/problems/maximum-subsequence-score/", + "title": "Maximum Subsequence Score" }, "2543": { - "id": 2543, "category": "Math & Geometry", - "title": "Check if Point Is Reachable", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-point-is-reachable/" + "id": 2543, + "link": "https://leetcode.com/problems/check-if-point-is-reachable/", + "title": "Check if Point Is Reachable" }, "2544": { - "id": 2544, "category": "Math & Geometry", - "title": "Alternating Digit Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/alternating-digit-sum/" + "id": 2544, + "link": "https://leetcode.com/problems/alternating-digit-sum/", + "title": "Alternating Digit Sum" }, "2545": { - "id": 2545, "category": "Array & Hashing", - "title": "Sort the Students by Their Kth Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-the-students-by-their-kth-score/" + "id": 2545, + "link": "https://leetcode.com/problems/sort-the-students-by-their-kth-score/", + "title": "Sort the Students by Their Kth Score" }, "2546": { - "id": 2546, "category": "Bit Manipulation", - "title": "Apply Bitwise Operations to Make Strings Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-bitwise-operations-to-make-strings-equal/" + "id": 2546, + "link": "https://leetcode.com/problems/apply-bitwise-operations-to-make-strings-equal/", + "title": "Apply Bitwise Operations to Make Strings Equal" }, "2547": { - "id": 2547, "category": "Dynamic Programming", - "title": "Minimum Cost to Split an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-split-an-array/" + "id": 2547, + "link": "https://leetcode.com/problems/minimum-cost-to-split-an-array/", + "title": "Minimum Cost to Split an Array" }, "2548": { - "id": 2548, "category": "Greedy", - "title": "Maximum Price to Fill a Bag", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-price-to-fill-a-bag/" + "id": 2548, + "link": "https://leetcode.com/problems/maximum-price-to-fill-a-bag/", + "title": "Maximum Price to Fill a Bag" }, "2549": { - "id": 2549, "category": "Math & Geometry", - "title": "Count Distinct Numbers on Board", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-distinct-numbers-on-board/" + "id": 2549, + "link": "https://leetcode.com/problems/count-distinct-numbers-on-board/", + "title": "Count Distinct Numbers on Board" }, "2550": { - "id": 2550, "category": "Math & Geometry", - "title": "Count Collisions of Monkeys on a Polygon", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-collisions-of-monkeys-on-a-polygon/" + "id": 2550, + "link": "https://leetcode.com/problems/count-collisions-of-monkeys-on-a-polygon/", + "title": "Count Collisions of Monkeys on a Polygon" }, "2551": { - "id": 2551, "category": "Heap (Priority Queue)", - "title": "Put Marbles in Bags", "difficulty": "Hard", - "link": "https://leetcode.com/problems/put-marbles-in-bags/" + "id": 2551, + "link": "https://leetcode.com/problems/put-marbles-in-bags/", + "title": "Put Marbles in Bags" }, "2552": { - "id": 2552, "category": "Tree", - "title": "Count Increasing Quadruplets", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-increasing-quadruplets/" + "id": 2552, + "link": "https://leetcode.com/problems/count-increasing-quadruplets/", + "title": "Count Increasing Quadruplets" }, "2553": { - "id": 2553, "category": "Array & Hashing", - "title": "Separate the Digits in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/separate-the-digits-in-an-array/" + "id": 2553, + "link": "https://leetcode.com/problems/separate-the-digits-in-an-array/", + "title": "Separate the Digits in an Array" }, "2554": { - "id": 2554, "category": "Binary Search", - "title": "Maximum Number of Integers to Choose From a Range I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-integers-to-choose-from-a-range-i/" + "id": 2554, + "link": "https://leetcode.com/problems/maximum-number-of-integers-to-choose-from-a-range-i/", + "title": "Maximum Number of Integers to Choose From a Range I" }, "2555": { - "id": 2555, "category": "Sliding Window", - "title": "Maximize Win From Two Segments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-win-from-two-segments/" + "id": 2555, + "link": "https://leetcode.com/problems/maximize-win-from-two-segments/", + "title": "Maximize Win From Two Segments" }, "2556": { - "id": 2556, "category": "Graph Traversal", - "title": "Disconnect Path in a Binary Matrix by at Most One Flip", "difficulty": "Medium", - "link": "https://leetcode.com/problems/disconnect-path-in-a-binary-matrix-by-at-most-one-flip/" + "id": 2556, + "link": "https://leetcode.com/problems/disconnect-path-in-a-binary-matrix-by-at-most-one-flip/", + "title": "Disconnect Path in a Binary Matrix by at Most One Flip" }, "2557": { - "id": 2557, "category": "Binary Search", - "title": "Maximum Number of Integers to Choose From a Range II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-integers-to-choose-from-a-range-ii/" + "id": 2557, + "link": "https://leetcode.com/problems/maximum-number-of-integers-to-choose-from-a-range-ii/", + "title": "Maximum Number of Integers to Choose From a Range II" }, "2558": { - "id": 2558, "category": "Heap (Priority Queue)", - "title": "Take Gifts From the Richest Pile", "difficulty": "Easy", - "link": "https://leetcode.com/problems/take-gifts-from-the-richest-pile/" + "id": 2558, + "link": "https://leetcode.com/problems/take-gifts-from-the-richest-pile/", + "title": "Take Gifts From the Richest Pile" }, "2559": { - "id": 2559, "category": "Array & Hashing", - "title": "Count Vowel Strings in Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-vowel-strings-in-ranges/" + "id": 2559, + "link": "https://leetcode.com/problems/count-vowel-strings-in-ranges/", + "title": "Count Vowel Strings in Ranges" }, "2560": { - "id": 2560, "category": "Dynamic Programming", - "title": "House Robber IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/house-robber-iv/" + "id": 2560, + "link": "https://leetcode.com/problems/house-robber-iv/", + "title": "House Robber IV" }, "2561": { - "id": 2561, "category": "Greedy", - "title": "Rearranging Fruits", "difficulty": "Hard", - "link": "https://leetcode.com/problems/rearranging-fruits/" + "id": 2561, + "link": "https://leetcode.com/problems/rearranging-fruits/", + "title": "Rearranging Fruits" }, "2562": { - "id": 2562, "category": "Two Pointers", - "title": "Find the Array Concatenation Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-array-concatenation-value/" + "id": 2562, + "link": "https://leetcode.com/problems/find-the-array-concatenation-value/", + "title": "Find the Array Concatenation Value" }, "2563": { - "id": 2563, "category": "Binary Search", - "title": "Count the Number of Fair Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-fair-pairs/" + "id": 2563, + "link": "https://leetcode.com/problems/count-the-number-of-fair-pairs/", + "title": "Count the Number of Fair Pairs" }, "2564": { - "id": 2564, "category": "Bit Manipulation", - "title": "Substring XOR Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/substring-xor-queries/" + "id": 2564, + "link": "https://leetcode.com/problems/substring-xor-queries/", + "title": "Substring XOR Queries" }, "2565": { - "id": 2565, "category": "Binary Search", - "title": "Subsequence With the Minimum Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subsequence-with-the-minimum-score/" + "id": 2565, + "link": "https://leetcode.com/problems/subsequence-with-the-minimum-score/", + "title": "Subsequence With the Minimum Score" }, "2566": { - "id": 2566, "category": "Greedy", - "title": "Maximum Difference by Remapping a Digit", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-difference-by-remapping-a-digit/" + "id": 2566, + "link": "https://leetcode.com/problems/maximum-difference-by-remapping-a-digit/", + "title": "Maximum Difference by Remapping a Digit" }, "2567": { - "id": 2567, "category": "Greedy", - "title": "Minimum Score by Changing Two Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-score-by-changing-two-elements/" + "id": 2567, + "link": "https://leetcode.com/problems/minimum-score-by-changing-two-elements/", + "title": "Minimum Score by Changing Two Elements" }, "2568": { - "id": 2568, "category": "Bit Manipulation", - "title": "Minimum Impossible OR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-impossible-or/" + "id": 2568, + "link": "https://leetcode.com/problems/minimum-impossible-or/", + "title": "Minimum Impossible OR" }, "2569": { - "id": 2569, "category": "Tree", - "title": "Handling Sum Queries After Update", "difficulty": "Hard", - "link": "https://leetcode.com/problems/handling-sum-queries-after-update/" + "id": 2569, + "link": "https://leetcode.com/problems/handling-sum-queries-after-update/", + "title": "Handling Sum Queries After Update" }, "2570": { - "id": 2570, "category": "Two Pointers", - "title": "Merge Two 2D Arrays by Summing Values", "difficulty": "Easy", - "link": "https://leetcode.com/problems/merge-two-2d-arrays-by-summing-values/" + "id": 2570, + "link": "https://leetcode.com/problems/merge-two-2d-arrays-by-summing-values/", + "title": "Merge Two 2D Arrays by Summing Values" }, "2571": { - "id": 2571, "category": "Dynamic Programming", - "title": "Minimum Operations to Reduce an Integer to 0", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-reduce-an-integer-to-0/" + "id": 2571, + "link": "https://leetcode.com/problems/minimum-operations-to-reduce-an-integer-to-0/", + "title": "Minimum Operations to Reduce an Integer to 0" }, "2572": { - "id": 2572, "category": "Dynamic Programming", - "title": "Count the Number of Square-Free Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-square-free-subsets/" + "id": 2572, + "link": "https://leetcode.com/problems/count-the-number-of-square-free-subsets/", + "title": "Count the Number of Square-Free Subsets" }, "2573": { - "id": 2573, "category": "Graph Traversal", - "title": "Find the String with LCP", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-string-with-lcp/" + "id": 2573, + "link": "https://leetcode.com/problems/find-the-string-with-lcp/", + "title": "Find the String with LCP" }, "2574": { - "id": 2574, "category": "Array & Hashing", - "title": "Left and Right Sum Differences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/left-and-right-sum-differences/" + "id": 2574, + "link": "https://leetcode.com/problems/left-and-right-sum-differences/", + "title": "Left and Right Sum Differences" }, "2575": { - "id": 2575, "category": "Math & Geometry", - "title": "Find the Divisibility Array of a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-divisibility-array-of-a-string/" + "id": 2575, + "link": "https://leetcode.com/problems/find-the-divisibility-array-of-a-string/", + "title": "Find the Divisibility Array of a String" }, "2576": { - "id": 2576, "category": "Binary Search", - "title": "Find the Maximum Number of Marked Indices", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-number-of-marked-indices/" + "id": 2576, + "link": "https://leetcode.com/problems/find-the-maximum-number-of-marked-indices/", + "title": "Find the Maximum Number of Marked Indices" }, "2577": { - "id": 2577, "category": "Graph Traversal", - "title": "Minimum Time to Visit a Cell In a Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-visit-a-cell-in-a-grid/" + "id": 2577, + "link": "https://leetcode.com/problems/minimum-time-to-visit-a-cell-in-a-grid/", + "title": "Minimum Time to Visit a Cell In a Grid" }, "2578": { - "id": 2578, "category": "Greedy", - "title": "Split With Minimum Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/split-with-minimum-sum/" + "id": 2578, + "link": "https://leetcode.com/problems/split-with-minimum-sum/", + "title": "Split With Minimum Sum" }, "2579": { - "id": 2579, "category": "Math & Geometry", - "title": "Count Total Number of Colored Cells", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-total-number-of-colored-cells/" + "id": 2579, + "link": "https://leetcode.com/problems/count-total-number-of-colored-cells/", + "title": "Count Total Number of Colored Cells" }, "2580": { - "id": 2580, "category": "Array & Hashing", - "title": "Count Ways to Group Overlapping Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-ways-to-group-overlapping-ranges/" + "id": 2580, + "link": "https://leetcode.com/problems/count-ways-to-group-overlapping-ranges/", + "title": "Count Ways to Group Overlapping Ranges" }, "2581": { - "id": 2581, "category": "Tree", - "title": "Count Number of Possible Root Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-number-of-possible-root-nodes/" + "id": 2581, + "link": "https://leetcode.com/problems/count-number-of-possible-root-nodes/", + "title": "Count Number of Possible Root Nodes" }, "2582": { - "id": 2582, "category": "Math & Geometry", - "title": "Pass the Pillow", "difficulty": "Easy", - "link": "https://leetcode.com/problems/pass-the-pillow/" + "id": 2582, + "link": "https://leetcode.com/problems/pass-the-pillow/", + "title": "Pass the Pillow" }, "2583": { - "id": 2583, "category": "Tree", - "title": "Kth Largest Sum in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/kth-largest-sum-in-a-binary-tree/" + "id": 2583, + "link": "https://leetcode.com/problems/kth-largest-sum-in-a-binary-tree/", + "title": "Kth Largest Sum in a Binary Tree" }, "2584": { - "id": 2584, "category": "Math & Geometry", - "title": "Split the Array to Make Coprime Products", "difficulty": "Hard", - "link": "https://leetcode.com/problems/split-the-array-to-make-coprime-products/" + "id": 2584, + "link": "https://leetcode.com/problems/split-the-array-to-make-coprime-products/", + "title": "Split the Array to Make Coprime Products" }, "2585": { - "id": 2585, "category": "Dynamic Programming", - "title": "Number of Ways to Earn Points", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-earn-points/" + "id": 2585, + "link": "https://leetcode.com/problems/number-of-ways-to-earn-points/", + "title": "Number of Ways to Earn Points" }, "2586": { - "id": 2586, "category": "Array & Hashing", - "title": "Count the Number of Vowel Strings in Range", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-the-number-of-vowel-strings-in-range/" + "id": 2586, + "link": "https://leetcode.com/problems/count-the-number-of-vowel-strings-in-range/", + "title": "Count the Number of Vowel Strings in Range" }, "2587": { - "id": 2587, "category": "Greedy", - "title": "Rearrange Array to Maximize Prefix Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rearrange-array-to-maximize-prefix-score/" + "id": 2587, + "link": "https://leetcode.com/problems/rearrange-array-to-maximize-prefix-score/", + "title": "Rearrange Array to Maximize Prefix Score" }, "2588": { - "id": 2588, "category": "Bit Manipulation", - "title": "Count the Number of Beautiful Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-beautiful-subarrays/" + "id": 2588, + "link": "https://leetcode.com/problems/count-the-number-of-beautiful-subarrays/", + "title": "Count the Number of Beautiful Subarrays" }, "2589": { - "id": 2589, "category": "Binary Search", - "title": "Minimum Time to Complete All Tasks", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-complete-all-tasks/" + "id": 2589, + "link": "https://leetcode.com/problems/minimum-time-to-complete-all-tasks/", + "title": "Minimum Time to Complete All Tasks" }, "2590": { - "id": 2590, "category": "Array & Hashing", - "title": "Design a Todo List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-todo-list/" + "id": 2590, + "link": "https://leetcode.com/problems/design-a-todo-list/", + "title": "Design a Todo List" }, "2591": { - "id": 2591, "category": "Greedy", - "title": "Distribute Money to Maximum Children", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distribute-money-to-maximum-children/" + "id": 2591, + "link": "https://leetcode.com/problems/distribute-money-to-maximum-children/", + "title": "Distribute Money to Maximum Children" }, "2592": { - "id": 2592, "category": "Greedy", - "title": "Maximize Greatness of an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-greatness-of-an-array/" + "id": 2592, + "link": "https://leetcode.com/problems/maximize-greatness-of-an-array/", + "title": "Maximize Greatness of an Array" }, "2593": { - "id": 2593, "category": "Heap (Priority Queue)", - "title": "Find Score of an Array After Marking All Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-score-of-an-array-after-marking-all-elements/" + "id": 2593, + "link": "https://leetcode.com/problems/find-score-of-an-array-after-marking-all-elements/", + "title": "Find Score of an Array After Marking All Elements" }, "2594": { - "id": 2594, "category": "Binary Search", - "title": "Minimum Time to Repair Cars", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-repair-cars/" + "id": 2594, + "link": "https://leetcode.com/problems/minimum-time-to-repair-cars/", + "title": "Minimum Time to Repair Cars" }, "2595": { - "id": 2595, "category": "Bit Manipulation", - "title": "Number of Even and Odd Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-even-and-odd-bits/" + "id": 2595, + "link": "https://leetcode.com/problems/number-of-even-and-odd-bits/", + "title": "Number of Even and Odd Bits" }, "2596": { - "id": 2596, "category": "Graph Traversal", - "title": "Check Knight Tour Configuration", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-knight-tour-configuration/" + "id": 2596, + "link": "https://leetcode.com/problems/check-knight-tour-configuration/", + "title": "Check Knight Tour Configuration" }, "2597": { - "id": 2597, "category": "Dynamic Programming", - "title": "The Number of Beautiful Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-beautiful-subsets/" + "id": 2597, + "link": "https://leetcode.com/problems/the-number-of-beautiful-subsets/", + "title": "The Number of Beautiful Subsets" }, "2598": { - "id": 2598, "category": "Greedy", - "title": "Smallest Missing Non-negative Integer After Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-missing-non-negative-integer-after-operations/" + "id": 2598, + "link": "https://leetcode.com/problems/smallest-missing-non-negative-integer-after-operations/", + "title": "Smallest Missing Non-negative Integer After Operations" }, "2599": { - "id": 2599, "category": "Heap (Priority Queue)", - "title": "Make the Prefix Sum Non-negative", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-the-prefix-sum-non-negative/" + "id": 2599, + "link": "https://leetcode.com/problems/make-the-prefix-sum-non-negative/", + "title": "Make the Prefix Sum Non-negative" }, "2600": { - "id": 2600, "category": "Greedy", - "title": "K Items With the Maximum Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/k-items-with-the-maximum-sum/" + "id": 2600, + "link": "https://leetcode.com/problems/k-items-with-the-maximum-sum/", + "title": "K Items With the Maximum Sum" }, "2601": { - "id": 2601, "category": "Binary Search", - "title": "Prime Subtraction Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/prime-subtraction-operation/" + "id": 2601, + "link": "https://leetcode.com/problems/prime-subtraction-operation/", + "title": "Prime Subtraction Operation" }, "2602": { - "id": 2602, "category": "Binary Search", - "title": "Minimum Operations to Make All Array Elements Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-all-array-elements-equal/" + "id": 2602, + "link": "https://leetcode.com/problems/minimum-operations-to-make-all-array-elements-equal/", + "title": "Minimum Operations to Make All Array Elements Equal" }, "2603": { - "id": 2603, "category": "Tree", - "title": "Collect Coins in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/collect-coins-in-a-tree/" + "id": 2603, + "link": "https://leetcode.com/problems/collect-coins-in-a-tree/", + "title": "Collect Coins in a Tree" }, "2604": { - "id": 2604, "category": "Binary Search", - "title": "Minimum Time to Eat All Grains", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-eat-all-grains/" + "id": 2604, + "link": "https://leetcode.com/problems/minimum-time-to-eat-all-grains/", + "title": "Minimum Time to Eat All Grains" }, "2605": { - "id": 2605, "category": "Array & Hashing", - "title": "Form Smallest Number From Two Digit Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/form-smallest-number-from-two-digit-arrays/" + "id": 2605, + "link": "https://leetcode.com/problems/form-smallest-number-from-two-digit-arrays/", + "title": "Form Smallest Number From Two Digit Arrays" }, "2606": { - "id": 2606, "category": "Dynamic Programming", - "title": "Find the Substring With Maximum Cost", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-substring-with-maximum-cost/" + "id": 2606, + "link": "https://leetcode.com/problems/find-the-substring-with-maximum-cost/", + "title": "Find the Substring With Maximum Cost" }, "2607": { - "id": 2607, "category": "Greedy", - "title": "Make K-Subarray Sums Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-k-subarray-sums-equal/" + "id": 2607, + "link": "https://leetcode.com/problems/make-k-subarray-sums-equal/", + "title": "Make K-Subarray Sums Equal" }, "2608": { - "id": 2608, "category": "Graph Traversal", - "title": "Shortest Cycle in a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-cycle-in-a-graph/" + "id": 2608, + "link": "https://leetcode.com/problems/shortest-cycle-in-a-graph/", + "title": "Shortest Cycle in a Graph" }, "2609": { - "id": 2609, "category": "Array & Hashing", - "title": "Find the Longest Balanced Substring of a Binary String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-longest-balanced-substring-of-a-binary-string/" + "id": 2609, + "link": "https://leetcode.com/problems/find-the-longest-balanced-substring-of-a-binary-string/", + "title": "Find the Longest Balanced Substring of a Binary String" }, "2610": { - "id": 2610, "category": "Array & Hashing", - "title": "Convert an Array Into a 2D Array With Conditions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-an-array-into-a-2d-array-with-conditions/" + "id": 2610, + "link": "https://leetcode.com/problems/convert-an-array-into-a-2d-array-with-conditions/", + "title": "Convert an Array Into a 2D Array With Conditions" }, "2611": { - "id": 2611, "category": "Heap (Priority Queue)", - "title": "Mice and Cheese", "difficulty": "Medium", - "link": "https://leetcode.com/problems/mice-and-cheese/" + "id": 2611, + "link": "https://leetcode.com/problems/mice-and-cheese/", + "title": "Mice and Cheese" }, "2612": { - "id": 2612, "category": "Graph Traversal", - "title": "Minimum Reverse Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-reverse-operations/" + "id": 2612, + "link": "https://leetcode.com/problems/minimum-reverse-operations/", + "title": "Minimum Reverse Operations" }, "2613": { - "id": 2613, "category": "Math & Geometry", - "title": "Beautiful Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/beautiful-pairs/" + "id": 2613, + "link": "https://leetcode.com/problems/beautiful-pairs/", + "title": "Beautiful Pairs" }, "2614": { - "id": 2614, "category": "Math & Geometry", - "title": "Prime In Diagonal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/prime-in-diagonal/" + "id": 2614, + "link": "https://leetcode.com/problems/prime-in-diagonal/", + "title": "Prime In Diagonal" }, "2615": { - "id": 2615, "category": "Array & Hashing", - "title": "Sum of Distances", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-distances/" + "id": 2615, + "link": "https://leetcode.com/problems/sum-of-distances/", + "title": "Sum of Distances" }, "2616": { - "id": 2616, "category": "Dynamic Programming", - "title": "Minimize the Maximum Difference of Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/" + "id": 2616, + "link": "https://leetcode.com/problems/minimize-the-maximum-difference-of-pairs/", + "title": "Minimize the Maximum Difference of Pairs" }, "2617": { - "id": 2617, "category": "Graph Traversal", - "title": "Minimum Number of Visited Cells in a Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-visited-cells-in-a-grid/" + "id": 2617, + "link": "https://leetcode.com/problems/minimum-number-of-visited-cells-in-a-grid/", + "title": "Minimum Number of Visited Cells in a Grid" }, "2618": { - "id": 2618, "category": "Array & Hashing", - "title": "Check if Object Instance of Class", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-object-instance-of-class/" + "id": 2618, + "link": "https://leetcode.com/problems/check-if-object-instance-of-class/", + "title": "Check if Object Instance of Class" }, "2619": { - "id": 2619, "category": "Array & Hashing", - "title": "Array Prototype Last", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-prototype-last/" - }, - "2620": { - "id": 2620, - "category": "Array & Hashing", - "title": "Counter", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/counter/" - }, - "2621": { - "id": 2621, - "category": "Array & Hashing", - "title": "Sleep", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/sleep/" + "id": 2619, + "link": "https://leetcode.com/problems/array-prototype-last/", + "title": "Array Prototype Last" }, + "2620": {"category": "Array & Hashing", "difficulty": "Easy", "id": 2620, "link": "https://leetcode.com/problems/counter/", "title": "Counter"}, + "2621": {"category": "Array & Hashing", "difficulty": "Easy", "id": 2621, "link": "https://leetcode.com/problems/sleep/", "title": "Sleep"}, "2622": { - "id": 2622, "category": "Array & Hashing", - "title": "Cache With Time Limit", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cache-with-time-limit/" - }, - "2623": { - "id": 2623, - "category": "Array & Hashing", - "title": "Memoize", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/memoize/" + "id": 2622, + "link": "https://leetcode.com/problems/cache-with-time-limit/", + "title": "Cache With Time Limit" }, + "2623": {"category": "Array & Hashing", "difficulty": "Medium", "id": 2623, "link": "https://leetcode.com/problems/memoize/", "title": "Memoize"}, "2624": { - "id": 2624, "category": "Array & Hashing", - "title": "Snail Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/snail-traversal/" + "id": 2624, + "link": "https://leetcode.com/problems/snail-traversal/", + "title": "Snail Traversal" }, "2625": { - "id": 2625, "category": "Array & Hashing", - "title": "Flatten Deeply Nested Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flatten-deeply-nested-array/" + "id": 2625, + "link": "https://leetcode.com/problems/flatten-deeply-nested-array/", + "title": "Flatten Deeply Nested Array" }, "2626": { - "id": 2626, "category": "Array & Hashing", - "title": "Array Reduce Transformation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-reduce-transformation/" - }, - "2627": { - "id": 2627, - "category": "Array & Hashing", - "title": "Debounce", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/debounce/" + "id": 2626, + "link": "https://leetcode.com/problems/array-reduce-transformation/", + "title": "Array Reduce Transformation" }, + "2627": {"category": "Array & Hashing", "difficulty": "Medium", "id": 2627, "link": "https://leetcode.com/problems/debounce/", "title": "Debounce"}, "2628": { - "id": 2628, "category": "Array & Hashing", - "title": "JSON Deep Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/json-deep-equal/" + "id": 2628, + "link": "https://leetcode.com/problems/json-deep-equal/", + "title": "JSON Deep Equal" }, "2629": { - "id": 2629, "category": "Array & Hashing", - "title": "Function Composition", "difficulty": "Easy", - "link": "https://leetcode.com/problems/function-composition/" + "id": 2629, + "link": "https://leetcode.com/problems/function-composition/", + "title": "Function Composition" }, "2630": { - "id": 2630, "category": "Array & Hashing", - "title": "Memoize II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/memoize-ii/" - }, - "2631": { - "id": 2631, - "category": "Array & Hashing", - "title": "Group By", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/group-by/" - }, - "2632": { - "id": 2632, - "category": "Array & Hashing", - "title": "Curry", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/curry/" + "id": 2630, + "link": "https://leetcode.com/problems/memoize-ii/", + "title": "Memoize II" }, + "2631": {"category": "Array & Hashing", "difficulty": "Medium", "id": 2631, "link": "https://leetcode.com/problems/group-by/", "title": "Group By"}, + "2632": {"category": "Array & Hashing", "difficulty": "Medium", "id": 2632, "link": "https://leetcode.com/problems/curry/", "title": "Curry"}, "2633": { - "id": 2633, "category": "Array & Hashing", - "title": "Convert Object to JSON String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-object-to-json-string/" + "id": 2633, + "link": "https://leetcode.com/problems/convert-object-to-json-string/", + "title": "Convert Object to JSON String" }, "2634": { - "id": 2634, "category": "Array & Hashing", - "title": "Filter Elements from Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/filter-elements-from-array/" + "id": 2634, + "link": "https://leetcode.com/problems/filter-elements-from-array/", + "title": "Filter Elements from Array" }, "2635": { - "id": 2635, "category": "Array & Hashing", - "title": "Apply Transform Over Each Element in Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/apply-transform-over-each-element-in-array/" + "id": 2635, + "link": "https://leetcode.com/problems/apply-transform-over-each-element-in-array/", + "title": "Apply Transform Over Each Element in Array" }, "2636": { - "id": 2636, "category": "Array & Hashing", - "title": "Promise Pool", "difficulty": "Medium", - "link": "https://leetcode.com/problems/promise-pool/" + "id": 2636, + "link": "https://leetcode.com/problems/promise-pool/", + "title": "Promise Pool" }, "2637": { - "id": 2637, "category": "Array & Hashing", - "title": "Promise Time Limit", "difficulty": "Medium", - "link": "https://leetcode.com/problems/promise-time-limit/" + "id": 2637, + "link": "https://leetcode.com/problems/promise-time-limit/", + "title": "Promise Time Limit" }, "2638": { - "id": 2638, "category": "Dynamic Programming", - "title": "Count the Number of K-Free Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-k-free-subsets/" + "id": 2638, + "link": "https://leetcode.com/problems/count-the-number-of-k-free-subsets/", + "title": "Count the Number of K-Free Subsets" }, "2639": { - "id": 2639, "category": "Array & Hashing", - "title": "Find the Width of Columns of a Grid", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-width-of-columns-of-a-grid/" + "id": 2639, + "link": "https://leetcode.com/problems/find-the-width-of-columns-of-a-grid/", + "title": "Find the Width of Columns of a Grid" }, "2640": { - "id": 2640, "category": "Array & Hashing", - "title": "Find the Score of All Prefixes of an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-score-of-all-prefixes-of-an-array/" + "id": 2640, + "link": "https://leetcode.com/problems/find-the-score-of-all-prefixes-of-an-array/", + "title": "Find the Score of All Prefixes of an Array" }, "2641": { - "id": 2641, "category": "Tree", - "title": "Cousins in Binary Tree II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/cousins-in-binary-tree-ii/" + "id": 2641, + "link": "https://leetcode.com/problems/cousins-in-binary-tree-ii/", + "title": "Cousins in Binary Tree II" }, "2642": { - "id": 2642, "category": "Graph Traversal", - "title": "Design Graph With Shortest Path Calculator", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-graph-with-shortest-path-calculator/" + "id": 2642, + "link": "https://leetcode.com/problems/design-graph-with-shortest-path-calculator/", + "title": "Design Graph With Shortest Path Calculator" }, "2643": { - "id": 2643, "category": "Array & Hashing", - "title": "Row With Maximum Ones", "difficulty": "Easy", - "link": "https://leetcode.com/problems/row-with-maximum-ones/" + "id": 2643, + "link": "https://leetcode.com/problems/row-with-maximum-ones/", + "title": "Row With Maximum Ones" }, "2644": { - "id": 2644, "category": "Array & Hashing", - "title": "Find the Maximum Divisibility Score", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-maximum-divisibility-score/" + "id": 2644, + "link": "https://leetcode.com/problems/find-the-maximum-divisibility-score/", + "title": "Find the Maximum Divisibility Score" }, "2645": { - "id": 2645, "category": "Dynamic Programming", - "title": "Minimum Additions to Make Valid String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-additions-to-make-valid-string/" + "id": 2645, + "link": "https://leetcode.com/problems/minimum-additions-to-make-valid-string/", + "title": "Minimum Additions to Make Valid String" }, "2646": { - "id": 2646, "category": "Tree", - "title": "Minimize the Total Price of the Trips", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-the-total-price-of-the-trips/" + "id": 2646, + "link": "https://leetcode.com/problems/minimize-the-total-price-of-the-trips/", + "title": "Minimize the Total Price of the Trips" }, "2647": { - "id": 2647, "category": "Math & Geometry", - "title": "Color the Triangle Red", "difficulty": "Hard", - "link": "https://leetcode.com/problems/color-the-triangle-red/" + "id": 2647, + "link": "https://leetcode.com/problems/color-the-triangle-red/", + "title": "Color the Triangle Red" }, "2648": { - "id": 2648, "category": "Array & Hashing", - "title": "Generate Fibonacci Sequence", "difficulty": "Easy", - "link": "https://leetcode.com/problems/generate-fibonacci-sequence/" + "id": 2648, + "link": "https://leetcode.com/problems/generate-fibonacci-sequence/", + "title": "Generate Fibonacci Sequence" }, "2649": { - "id": 2649, "category": "Array & Hashing", - "title": "Nested Array Generator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/nested-array-generator/" + "id": 2649, + "link": "https://leetcode.com/problems/nested-array-generator/", + "title": "Nested Array Generator" }, "2650": { - "id": 2650, "category": "Array & Hashing", - "title": "Design Cancellable Function", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-cancellable-function/" + "id": 2650, + "link": "https://leetcode.com/problems/design-cancellable-function/", + "title": "Design Cancellable Function" }, "2651": { - "id": 2651, "category": "Math & Geometry", - "title": "Calculate Delayed Arrival Time", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-delayed-arrival-time/" + "id": 2651, + "link": "https://leetcode.com/problems/calculate-delayed-arrival-time/", + "title": "Calculate Delayed Arrival Time" }, "2652": { - "id": 2652, "category": "Math & Geometry", - "title": "Sum Multiples", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-multiples/" + "id": 2652, + "link": "https://leetcode.com/problems/sum-multiples/", + "title": "Sum Multiples" }, "2653": { - "id": 2653, "category": "Sliding Window", - "title": "Sliding Subarray Beauty", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sliding-subarray-beauty/" + "id": 2653, + "link": "https://leetcode.com/problems/sliding-subarray-beauty/", + "title": "Sliding Subarray Beauty" }, "2654": { - "id": 2654, "category": "Math & Geometry", - "title": "Minimum Number of Operations to Make All Array Elements Equal to 1", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-all-array-elements-equal-to-1/" + "id": 2654, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-all-array-elements-equal-to-1/", + "title": "Minimum Number of Operations to Make All Array Elements Equal to 1" }, "2655": { - "id": 2655, "category": "Array & Hashing", - "title": "Find Maximal Uncovered Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-maximal-uncovered-ranges/" + "id": 2655, + "link": "https://leetcode.com/problems/find-maximal-uncovered-ranges/", + "title": "Find Maximal Uncovered Ranges" }, "2656": { - "id": 2656, "category": "Greedy", - "title": "Maximum Sum With Exactly K Elements ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-sum-with-exactly-k-elements/" + "id": 2656, + "link": "https://leetcode.com/problems/maximum-sum-with-exactly-k-elements/", + "title": "Maximum Sum With Exactly K Elements " }, "2657": { - "id": 2657, "category": "Bit Manipulation", - "title": "Find the Prefix Common Array of Two Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-prefix-common-array-of-two-arrays/" + "id": 2657, + "link": "https://leetcode.com/problems/find-the-prefix-common-array-of-two-arrays/", + "title": "Find the Prefix Common Array of Two Arrays" }, "2658": { - "id": 2658, "category": "Graph Traversal", - "title": "Maximum Number of Fish in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-fish-in-a-grid/" + "id": 2658, + "link": "https://leetcode.com/problems/maximum-number-of-fish-in-a-grid/", + "title": "Maximum Number of Fish in a Grid" }, "2659": { - "id": 2659, "category": "Tree", - "title": "Make Array Empty", "difficulty": "Hard", - "link": "https://leetcode.com/problems/make-array-empty/" + "id": 2659, + "link": "https://leetcode.com/problems/make-array-empty/", + "title": "Make Array Empty" }, "2660": { - "id": 2660, "category": "Array & Hashing", - "title": "Determine the Winner of a Bowling Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/determine-the-winner-of-a-bowling-game/" + "id": 2660, + "link": "https://leetcode.com/problems/determine-the-winner-of-a-bowling-game/", + "title": "Determine the Winner of a Bowling Game" }, "2661": { - "id": 2661, "category": "Array & Hashing", - "title": "First Completely Painted Row or Column", "difficulty": "Medium", - "link": "https://leetcode.com/problems/first-completely-painted-row-or-column/" + "id": 2661, + "link": "https://leetcode.com/problems/first-completely-painted-row-or-column/", + "title": "First Completely Painted Row or Column" }, "2662": { - "id": 2662, "category": "Graph Traversal", - "title": "Minimum Cost of a Path With Special Roads", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-of-a-path-with-special-roads/" + "id": 2662, + "link": "https://leetcode.com/problems/minimum-cost-of-a-path-with-special-roads/", + "title": "Minimum Cost of a Path With Special Roads" }, "2663": { - "id": 2663, "category": "Greedy", - "title": "Lexicographically Smallest Beautiful String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/lexicographically-smallest-beautiful-string/" + "id": 2663, + "link": "https://leetcode.com/problems/lexicographically-smallest-beautiful-string/", + "title": "Lexicographically Smallest Beautiful String" }, "2664": { - "id": 2664, "category": "Backtracking", - "title": "The Knight\u2019s Tour", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-knights-tour/" + "id": 2664, + "link": "https://leetcode.com/problems/the-knights-tour/", + "title": "The Knight’s Tour" }, "2665": { - "id": 2665, "category": "Array & Hashing", - "title": "Counter II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/counter-ii/" + "id": 2665, + "link": "https://leetcode.com/problems/counter-ii/", + "title": "Counter II" }, "2666": { - "id": 2666, "category": "Array & Hashing", - "title": "Allow One Function Call", "difficulty": "Easy", - "link": "https://leetcode.com/problems/allow-one-function-call/" + "id": 2666, + "link": "https://leetcode.com/problems/allow-one-function-call/", + "title": "Allow One Function Call" }, "2667": { - "id": 2667, "category": "Array & Hashing", - "title": "Create Hello World Function", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-hello-world-function/" + "id": 2667, + "link": "https://leetcode.com/problems/create-hello-world-function/", + "title": "Create Hello World Function" }, "2668": { - "id": 2668, "category": "Database", - "title": "Find Latest Salaries", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-latest-salaries/" + "id": 2668, + "link": "https://leetcode.com/problems/find-latest-salaries/", + "title": "Find Latest Salaries" }, "2669": { - "id": 2669, "category": "Database", - "title": "Count Artist Occurrences On Spotify Ranking List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-artist-occurrences-on-spotify-ranking-list/" + "id": 2669, + "link": "https://leetcode.com/problems/count-artist-occurrences-on-spotify-ranking-list/", + "title": "Count Artist Occurrences On Spotify Ranking List" }, "2670": { - "id": 2670, "category": "Array & Hashing", - "title": "Find the Distinct Difference Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-distinct-difference-array/" + "id": 2670, + "link": "https://leetcode.com/problems/find-the-distinct-difference-array/", + "title": "Find the Distinct Difference Array" }, "2671": { - "id": 2671, "category": "Array & Hashing", - "title": "Frequency Tracker", "difficulty": "Medium", - "link": "https://leetcode.com/problems/frequency-tracker/" + "id": 2671, + "link": "https://leetcode.com/problems/frequency-tracker/", + "title": "Frequency Tracker" }, "2672": { - "id": 2672, "category": "Array & Hashing", - "title": "Number of Adjacent Elements With the Same Color", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-adjacent-elements-with-the-same-color/" + "id": 2672, + "link": "https://leetcode.com/problems/number-of-adjacent-elements-with-the-same-color/", + "title": "Number of Adjacent Elements With the Same Color" }, "2673": { - "id": 2673, "category": "Tree", - "title": "Make Costs of Paths Equal in a Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-costs-of-paths-equal-in-a-binary-tree/" + "id": 2673, + "link": "https://leetcode.com/problems/make-costs-of-paths-equal-in-a-binary-tree/", + "title": "Make Costs of Paths Equal in a Binary Tree" }, "2674": { - "id": 2674, "category": "Linked List", - "title": "Split a Circular Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-a-circular-linked-list/" + "id": 2674, + "link": "https://leetcode.com/problems/split-a-circular-linked-list/", + "title": "Split a Circular Linked List" }, "2675": { - "id": 2675, "category": "Array & Hashing", - "title": "Array of Objects to Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/array-of-objects-to-matrix/" - }, - "2676": { - "id": 2676, - "category": "Array & Hashing", - "title": "Throttle", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/throttle/" + "id": 2675, + "link": "https://leetcode.com/problems/array-of-objects-to-matrix/", + "title": "Array of Objects to Matrix" }, + "2676": {"category": "Array & Hashing", "difficulty": "Medium", "id": 2676, "link": "https://leetcode.com/problems/throttle/", "title": "Throttle"}, "2677": { - "id": 2677, "category": "Array & Hashing", - "title": "Chunk Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/chunk-array/" + "id": 2677, + "link": "https://leetcode.com/problems/chunk-array/", + "title": "Chunk Array" }, "2678": { - "id": 2678, "category": "Array & Hashing", - "title": "Number of Senior Citizens", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-senior-citizens/" + "id": 2678, + "link": "https://leetcode.com/problems/number-of-senior-citizens/", + "title": "Number of Senior Citizens" }, "2679": { - "id": 2679, "category": "Heap (Priority Queue)", - "title": "Sum in a Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-in-a-matrix/" + "id": 2679, + "link": "https://leetcode.com/problems/sum-in-a-matrix/", + "title": "Sum in a Matrix" }, "2680": { - "id": 2680, "category": "Bit Manipulation", - "title": "Maximum OR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-or/" + "id": 2680, + "link": "https://leetcode.com/problems/maximum-or/", + "title": "Maximum OR" }, "2681": { - "id": 2681, "category": "Dynamic Programming", - "title": "Power of Heroes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/power-of-heroes/" + "id": 2681, + "link": "https://leetcode.com/problems/power-of-heroes/", + "title": "Power of Heroes" }, "2682": { - "id": 2682, "category": "Array & Hashing", - "title": "Find the Losers of the Circular Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-losers-of-the-circular-game/" + "id": 2682, + "link": "https://leetcode.com/problems/find-the-losers-of-the-circular-game/", + "title": "Find the Losers of the Circular Game" }, "2683": { - "id": 2683, "category": "Bit Manipulation", - "title": "Neighboring Bitwise XOR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/neighboring-bitwise-xor/" + "id": 2683, + "link": "https://leetcode.com/problems/neighboring-bitwise-xor/", + "title": "Neighboring Bitwise XOR" }, "2684": { - "id": 2684, "category": "Dynamic Programming", - "title": "Maximum Number of Moves in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-moves-in-a-grid/" + "id": 2684, + "link": "https://leetcode.com/problems/maximum-number-of-moves-in-a-grid/", + "title": "Maximum Number of Moves in a Grid" }, "2685": { - "id": 2685, "category": "Graph Traversal", - "title": "Count the Number of Complete Components", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-complete-components/" + "id": 2685, + "link": "https://leetcode.com/problems/count-the-number-of-complete-components/", + "title": "Count the Number of Complete Components" }, "2686": { - "id": 2686, "category": "Database", - "title": "Immediate Food Delivery III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/immediate-food-delivery-iii/" + "id": 2686, + "link": "https://leetcode.com/problems/immediate-food-delivery-iii/", + "title": "Immediate Food Delivery III" }, "2687": { - "id": 2687, "category": "Database", - "title": "Bikes Last Time Used ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/bikes-last-time-used/" + "id": 2687, + "link": "https://leetcode.com/problems/bikes-last-time-used/", + "title": "Bikes Last Time Used " }, "2688": { - "id": 2688, "category": "Database", - "title": "Find Active Users", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-active-users/" + "id": 2688, + "link": "https://leetcode.com/problems/find-active-users/", + "title": "Find Active Users" }, "2689": { - "id": 2689, "category": "Tree", - "title": "Extract Kth Character From The Rope Tree", "difficulty": "Easy", - "link": "https://leetcode.com/problems/extract-kth-character-from-the-rope-tree/" + "id": 2689, + "link": "https://leetcode.com/problems/extract-kth-character-from-the-rope-tree/", + "title": "Extract Kth Character From The Rope Tree" }, "2690": { - "id": 2690, "category": "Array & Hashing", - "title": "Infinite Method Object", "difficulty": "Easy", - "link": "https://leetcode.com/problems/infinite-method-object/" + "id": 2690, + "link": "https://leetcode.com/problems/infinite-method-object/", + "title": "Infinite Method Object" }, "2691": { - "id": 2691, "category": "Array & Hashing", - "title": "Immutability Helper", "difficulty": "Hard", - "link": "https://leetcode.com/problems/immutability-helper/" + "id": 2691, + "link": "https://leetcode.com/problems/immutability-helper/", + "title": "Immutability Helper" }, "2692": { - "id": 2692, "category": "Array & Hashing", - "title": "Make Object Immutable", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-object-immutable/" + "id": 2692, + "link": "https://leetcode.com/problems/make-object-immutable/", + "title": "Make Object Immutable" }, "2693": { - "id": 2693, "category": "Array & Hashing", - "title": "Call Function with Custom Context", "difficulty": "Medium", - "link": "https://leetcode.com/problems/call-function-with-custom-context/" + "id": 2693, + "link": "https://leetcode.com/problems/call-function-with-custom-context/", + "title": "Call Function with Custom Context" }, "2694": { - "id": 2694, "category": "Array & Hashing", - "title": "Event Emitter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/event-emitter/" + "id": 2694, + "link": "https://leetcode.com/problems/event-emitter/", + "title": "Event Emitter" }, "2695": { - "id": 2695, "category": "Array & Hashing", - "title": "Array Wrapper", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-wrapper/" + "id": 2695, + "link": "https://leetcode.com/problems/array-wrapper/", + "title": "Array Wrapper" }, "2696": { - "id": 2696, "category": "Stack", - "title": "Minimum String Length After Removing Substrings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-string-length-after-removing-substrings/" + "id": 2696, + "link": "https://leetcode.com/problems/minimum-string-length-after-removing-substrings/", + "title": "Minimum String Length After Removing Substrings" }, "2697": { - "id": 2697, "category": "Greedy", - "title": "Lexicographically Smallest Palindrome", "difficulty": "Easy", - "link": "https://leetcode.com/problems/lexicographically-smallest-palindrome/" + "id": 2697, + "link": "https://leetcode.com/problems/lexicographically-smallest-palindrome/", + "title": "Lexicographically Smallest Palindrome" }, "2698": { - "id": 2698, "category": "Backtracking", - "title": "Find the Punishment Number of an Integer", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-punishment-number-of-an-integer/" + "id": 2698, + "link": "https://leetcode.com/problems/find-the-punishment-number-of-an-integer/", + "title": "Find the Punishment Number of an Integer" }, "2699": { - "id": 2699, "category": "Graph Traversal", - "title": "Modify Graph Edge Weights", "difficulty": "Hard", - "link": "https://leetcode.com/problems/modify-graph-edge-weights/" + "id": 2699, + "link": "https://leetcode.com/problems/modify-graph-edge-weights/", + "title": "Modify Graph Edge Weights" }, "2700": { - "id": 2700, "category": "Array & Hashing", - "title": "Differences Between Two Objects", "difficulty": "Medium", - "link": "https://leetcode.com/problems/differences-between-two-objects/" + "id": 2700, + "link": "https://leetcode.com/problems/differences-between-two-objects/", + "title": "Differences Between Two Objects" }, "2701": { - "id": 2701, "category": "Database", - "title": "Consecutive Transactions with Increasing Amounts", "difficulty": "Hard", - "link": "https://leetcode.com/problems/consecutive-transactions-with-increasing-amounts/" + "id": 2701, + "link": "https://leetcode.com/problems/consecutive-transactions-with-increasing-amounts/", + "title": "Consecutive Transactions with Increasing Amounts" }, "2702": { - "id": 2702, "category": "Binary Search", - "title": "Minimum Operations to Make Numbers Non-positive", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-numbers-non-positive/" + "id": 2702, + "link": "https://leetcode.com/problems/minimum-operations-to-make-numbers-non-positive/", + "title": "Minimum Operations to Make Numbers Non-positive" }, "2703": { - "id": 2703, "category": "Array & Hashing", - "title": "Return Length of Arguments Passed", "difficulty": "Easy", - "link": "https://leetcode.com/problems/return-length-of-arguments-passed/" + "id": 2703, + "link": "https://leetcode.com/problems/return-length-of-arguments-passed/", + "title": "Return Length of Arguments Passed" }, "2704": { - "id": 2704, "category": "Array & Hashing", - "title": "To Be Or Not To Be", "difficulty": "Easy", - "link": "https://leetcode.com/problems/to-be-or-not-to-be/" + "id": 2704, + "link": "https://leetcode.com/problems/to-be-or-not-to-be/", + "title": "To Be Or Not To Be" }, "2705": { - "id": 2705, "category": "Array & Hashing", - "title": "Compact Object", "difficulty": "Medium", - "link": "https://leetcode.com/problems/compact-object/" + "id": 2705, + "link": "https://leetcode.com/problems/compact-object/", + "title": "Compact Object" }, "2706": { - "id": 2706, "category": "Greedy", - "title": "Buy Two Chocolates", "difficulty": "Easy", - "link": "https://leetcode.com/problems/buy-two-chocolates/" + "id": 2706, + "link": "https://leetcode.com/problems/buy-two-chocolates/", + "title": "Buy Two Chocolates" }, "2707": { - "id": 2707, "category": "Dynamic Programming", - "title": "Extra Characters in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/extra-characters-in-a-string/" + "id": 2707, + "link": "https://leetcode.com/problems/extra-characters-in-a-string/", + "title": "Extra Characters in a String" }, "2708": { - "id": 2708, "category": "Dynamic Programming", - "title": "Maximum Strength of a Group", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-strength-of-a-group/" + "id": 2708, + "link": "https://leetcode.com/problems/maximum-strength-of-a-group/", + "title": "Maximum Strength of a Group" }, "2709": { - "id": 2709, "category": "Graph Traversal", - "title": "Greatest Common Divisor Traversal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/greatest-common-divisor-traversal/" + "id": 2709, + "link": "https://leetcode.com/problems/greatest-common-divisor-traversal/", + "title": "Greatest Common Divisor Traversal" }, "2710": { - "id": 2710, "category": "Array & Hashing", - "title": "Remove Trailing Zeros From a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-trailing-zeros-from-a-string/" + "id": 2710, + "link": "https://leetcode.com/problems/remove-trailing-zeros-from-a-string/", + "title": "Remove Trailing Zeros From a String" }, "2711": { - "id": 2711, "category": "Array & Hashing", - "title": "Difference of Number of Distinct Values on Diagonals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/difference-of-number-of-distinct-values-on-diagonals/" + "id": 2711, + "link": "https://leetcode.com/problems/difference-of-number-of-distinct-values-on-diagonals/", + "title": "Difference of Number of Distinct Values on Diagonals" }, "2712": { - "id": 2712, "category": "Dynamic Programming", - "title": "Minimum Cost to Make All Characters Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-make-all-characters-equal/" + "id": 2712, + "link": "https://leetcode.com/problems/minimum-cost-to-make-all-characters-equal/", + "title": "Minimum Cost to Make All Characters Equal" }, "2713": { - "id": 2713, "category": "Dynamic Programming", - "title": "Maximum Strictly Increasing Cells in a Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-strictly-increasing-cells-in-a-matrix/" + "id": 2713, + "link": "https://leetcode.com/problems/maximum-strictly-increasing-cells-in-a-matrix/", + "title": "Maximum Strictly Increasing Cells in a Matrix" }, "2714": { - "id": 2714, "category": "Graph Traversal", - "title": "Find Shortest Path with K Hops", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-shortest-path-with-k-hops/" + "id": 2714, + "link": "https://leetcode.com/problems/find-shortest-path-with-k-hops/", + "title": "Find Shortest Path with K Hops" }, "2715": { - "id": 2715, "category": "Array & Hashing", - "title": "Timeout Cancellation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/timeout-cancellation/" + "id": 2715, + "link": "https://leetcode.com/problems/timeout-cancellation/", + "title": "Timeout Cancellation" }, "2716": { - "id": 2716, "category": "Array & Hashing", - "title": "Minimize String Length", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimize-string-length/" + "id": 2716, + "link": "https://leetcode.com/problems/minimize-string-length/", + "title": "Minimize String Length" }, "2717": { - "id": 2717, "category": "Array & Hashing", - "title": "Semi-Ordered Permutation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/semi-ordered-permutation/" + "id": 2717, + "link": "https://leetcode.com/problems/semi-ordered-permutation/", + "title": "Semi-Ordered Permutation" }, "2718": { - "id": 2718, "category": "Array & Hashing", - "title": "Sum of Matrix After Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-matrix-after-queries/" + "id": 2718, + "link": "https://leetcode.com/problems/sum-of-matrix-after-queries/", + "title": "Sum of Matrix After Queries" }, "2719": { - "id": 2719, "category": "Dynamic Programming", - "title": "Count of Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-of-integers/" + "id": 2719, + "link": "https://leetcode.com/problems/count-of-integers/", + "title": "Count of Integers" }, "2720": { - "id": 2720, "category": "Database", - "title": "Popularity Percentage", "difficulty": "Hard", - "link": "https://leetcode.com/problems/popularity-percentage/" + "id": 2720, + "link": "https://leetcode.com/problems/popularity-percentage/", + "title": "Popularity Percentage" }, "2721": { - "id": 2721, "category": "Array & Hashing", - "title": "Execute Asynchronous Functions in Parallel", "difficulty": "Medium", - "link": "https://leetcode.com/problems/execute-asynchronous-functions-in-parallel/" + "id": 2721, + "link": "https://leetcode.com/problems/execute-asynchronous-functions-in-parallel/", + "title": "Execute Asynchronous Functions in Parallel" }, "2722": { - "id": 2722, "category": "Array & Hashing", - "title": "Join Two Arrays by ID", "difficulty": "Medium", - "link": "https://leetcode.com/problems/join-two-arrays-by-id/" + "id": 2722, + "link": "https://leetcode.com/problems/join-two-arrays-by-id/", + "title": "Join Two Arrays by ID" }, "2723": { - "id": 2723, - "category": "Array & Hashing", - "title": "Add Two Promises", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/add-two-promises/" - }, - "2724": { - "id": 2724, "category": "Array & Hashing", - "title": "Sort By", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-by/" + "id": 2723, + "link": "https://leetcode.com/problems/add-two-promises/", + "title": "Add Two Promises" }, + "2724": {"category": "Array & Hashing", "difficulty": "Easy", "id": 2724, "link": "https://leetcode.com/problems/sort-by/", "title": "Sort By"}, "2725": { - "id": 2725, "category": "Array & Hashing", - "title": "Interval Cancellation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/interval-cancellation/" + "id": 2725, + "link": "https://leetcode.com/problems/interval-cancellation/", + "title": "Interval Cancellation" }, "2726": { - "id": 2726, "category": "Array & Hashing", - "title": "Calculator with Method Chaining", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculator-with-method-chaining/" + "id": 2726, + "link": "https://leetcode.com/problems/calculator-with-method-chaining/", + "title": "Calculator with Method Chaining" }, "2727": { - "id": 2727, "category": "Array & Hashing", - "title": "Is Object Empty", "difficulty": "Easy", - "link": "https://leetcode.com/problems/is-object-empty/" + "id": 2727, + "link": "https://leetcode.com/problems/is-object-empty/", + "title": "Is Object Empty" }, "2728": { - "id": 2728, "category": "Array & Hashing", - "title": "Count Houses in a Circular Street", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-houses-in-a-circular-street/" + "id": 2728, + "link": "https://leetcode.com/problems/count-houses-in-a-circular-street/", + "title": "Count Houses in a Circular Street" }, "2729": { - "id": 2729, "category": "Math & Geometry", - "title": "Check if The Number is Fascinating", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-the-number-is-fascinating/" + "id": 2729, + "link": "https://leetcode.com/problems/check-if-the-number-is-fascinating/", + "title": "Check if The Number is Fascinating" }, "2730": { - "id": 2730, "category": "Sliding Window", - "title": "Find the Longest Semi-Repetitive Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-longest-semi-repetitive-substring/" + "id": 2730, + "link": "https://leetcode.com/problems/find-the-longest-semi-repetitive-substring/", + "title": "Find the Longest Semi-Repetitive Substring" }, "2731": { - "id": 2731, "category": "Array & Hashing", - "title": "Movement of Robots", "difficulty": "Medium", - "link": "https://leetcode.com/problems/movement-of-robots/" + "id": 2731, + "link": "https://leetcode.com/problems/movement-of-robots/", + "title": "Movement of Robots" }, "2732": { - "id": 2732, "category": "Bit Manipulation", - "title": "Find a Good Subset of the Matrix", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-a-good-subset-of-the-matrix/" + "id": 2732, + "link": "https://leetcode.com/problems/find-a-good-subset-of-the-matrix/", + "title": "Find a Good Subset of the Matrix" }, "2733": { - "id": 2733, "category": "Array & Hashing", - "title": "Neither Minimum nor Maximum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/neither-minimum-nor-maximum/" + "id": 2733, + "link": "https://leetcode.com/problems/neither-minimum-nor-maximum/", + "title": "Neither Minimum nor Maximum" }, "2734": { - "id": 2734, "category": "Greedy", - "title": "Lexicographically Smallest String After Substring Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-substring-operation/" + "id": 2734, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-substring-operation/", + "title": "Lexicographically Smallest String After Substring Operation" }, "2735": { - "id": 2735, "category": "Array & Hashing", - "title": "Collecting Chocolates", "difficulty": "Medium", - "link": "https://leetcode.com/problems/collecting-chocolates/" + "id": 2735, + "link": "https://leetcode.com/problems/collecting-chocolates/", + "title": "Collecting Chocolates" }, "2736": { - "id": 2736, "category": "Tree", - "title": "Maximum Sum Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-sum-queries/" + "id": 2736, + "link": "https://leetcode.com/problems/maximum-sum-queries/", + "title": "Maximum Sum Queries" }, "2737": { - "id": 2737, "category": "Graph Traversal", - "title": "Find the Closest Marked Node", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-closest-marked-node/" + "id": 2737, + "link": "https://leetcode.com/problems/find-the-closest-marked-node/", + "title": "Find the Closest Marked Node" }, "2738": { - "id": 2738, "category": "Database", - "title": "Count Occurrences in Text", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-occurrences-in-text/" + "id": 2738, + "link": "https://leetcode.com/problems/count-occurrences-in-text/", + "title": "Count Occurrences in Text" }, "2739": { - "id": 2739, "category": "Math & Geometry", - "title": "Total Distance Traveled", "difficulty": "Easy", - "link": "https://leetcode.com/problems/total-distance-traveled/" + "id": 2739, + "link": "https://leetcode.com/problems/total-distance-traveled/", + "title": "Total Distance Traveled" }, "2740": { - "id": 2740, "category": "Array & Hashing", - "title": "Find the Value of the Partition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-value-of-the-partition/" + "id": 2740, + "link": "https://leetcode.com/problems/find-the-value-of-the-partition/", + "title": "Find the Value of the Partition" }, "2741": { - "id": 2741, "category": "Dynamic Programming", - "title": "Special Permutations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/special-permutations/" + "id": 2741, + "link": "https://leetcode.com/problems/special-permutations/", + "title": "Special Permutations" }, "2742": { - "id": 2742, "category": "Dynamic Programming", - "title": "Painting the Walls", "difficulty": "Hard", - "link": "https://leetcode.com/problems/painting-the-walls/" + "id": 2742, + "link": "https://leetcode.com/problems/painting-the-walls/", + "title": "Painting the Walls" }, "2743": { - "id": 2743, "category": "Sliding Window", - "title": "Count Substrings Without Repeating Character", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-substrings-without-repeating-character/" + "id": 2743, + "link": "https://leetcode.com/problems/count-substrings-without-repeating-character/", + "title": "Count Substrings Without Repeating Character" }, "2744": { - "id": 2744, "category": "Array & Hashing", - "title": "Find Maximum Number of String Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-maximum-number-of-string-pairs/" + "id": 2744, + "link": "https://leetcode.com/problems/find-maximum-number-of-string-pairs/", + "title": "Find Maximum Number of String Pairs" }, "2745": { - "id": 2745, "category": "Dynamic Programming", - "title": "Construct the Longest New String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-the-longest-new-string/" + "id": 2745, + "link": "https://leetcode.com/problems/construct-the-longest-new-string/", + "title": "Construct the Longest New String" }, "2746": { - "id": 2746, "category": "Dynamic Programming", - "title": "Decremental String Concatenation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/decremental-string-concatenation/" + "id": 2746, + "link": "https://leetcode.com/problems/decremental-string-concatenation/", + "title": "Decremental String Concatenation" }, "2747": { - "id": 2747, "category": "Sliding Window", - "title": "Count Zero Request Servers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-zero-request-servers/" + "id": 2747, + "link": "https://leetcode.com/problems/count-zero-request-servers/", + "title": "Count Zero Request Servers" }, "2748": { - "id": 2748, "category": "Math & Geometry", - "title": "Number of Beautiful Pairs", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-beautiful-pairs/" + "id": 2748, + "link": "https://leetcode.com/problems/number-of-beautiful-pairs/", + "title": "Number of Beautiful Pairs" }, "2749": { - "id": 2749, "category": "Bit Manipulation", - "title": "Minimum Operations to Make the Integer Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-the-integer-zero/" + "id": 2749, + "link": "https://leetcode.com/problems/minimum-operations-to-make-the-integer-zero/", + "title": "Minimum Operations to Make the Integer Zero" }, "2750": { - "id": 2750, "category": "Dynamic Programming", - "title": "Ways to Split Array Into Good Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ways-to-split-array-into-good-subarrays/" + "id": 2750, + "link": "https://leetcode.com/problems/ways-to-split-array-into-good-subarrays/", + "title": "Ways to Split Array Into Good Subarrays" }, "2751": { - "id": 2751, "category": "Stack", - "title": "Robot Collisions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/robot-collisions/" + "id": 2751, + "link": "https://leetcode.com/problems/robot-collisions/", + "title": "Robot Collisions" }, "2752": { - "id": 2752, "category": "Database", - "title": "Customers with Maximum Number of Transactions on Consecutive Days", "difficulty": "Hard", - "link": "https://leetcode.com/problems/customers-with-maximum-number-of-transactions-on-consecutive-days/" + "id": 2752, + "link": "https://leetcode.com/problems/customers-with-maximum-number-of-transactions-on-consecutive-days/", + "title": "Customers with Maximum Number of Transactions on Consecutive Days" }, "2753": { - "id": 2753, "category": "Array & Hashing", - "title": "Count Houses in a Circular Street II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-houses-in-a-circular-street-ii/" + "id": 2753, + "link": "https://leetcode.com/problems/count-houses-in-a-circular-street-ii/", + "title": "Count Houses in a Circular Street II" }, "2754": { - "id": 2754, "category": "Array & Hashing", - "title": "Bind Function to Context", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bind-function-to-context/" + "id": 2754, + "link": "https://leetcode.com/problems/bind-function-to-context/", + "title": "Bind Function to Context" }, "2755": { - "id": 2755, "category": "Array & Hashing", - "title": "Deep Merge of Two Objects", "difficulty": "Medium", - "link": "https://leetcode.com/problems/deep-merge-of-two-objects/" + "id": 2755, + "link": "https://leetcode.com/problems/deep-merge-of-two-objects/", + "title": "Deep Merge of Two Objects" }, "2756": { - "id": 2756, "category": "Array & Hashing", - "title": "Query Batching", "difficulty": "Hard", - "link": "https://leetcode.com/problems/query-batching/" + "id": 2756, + "link": "https://leetcode.com/problems/query-batching/", + "title": "Query Batching" }, "2757": { - "id": 2757, "category": "Array & Hashing", - "title": "Generate Circular Array Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generate-circular-array-values/" - }, - "2758": { - "id": 2758, - "category": "Array & Hashing", - "title": "Next Day", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/next-day/" + "id": 2757, + "link": "https://leetcode.com/problems/generate-circular-array-values/", + "title": "Generate Circular Array Values" }, + "2758": {"category": "Array & Hashing", "difficulty": "Easy", "id": 2758, "link": "https://leetcode.com/problems/next-day/", "title": "Next Day"}, "2759": { - "id": 2759, "category": "Array & Hashing", - "title": "Convert JSON String to Object", "difficulty": "Hard", - "link": "https://leetcode.com/problems/convert-json-string-to-object/" + "id": 2759, + "link": "https://leetcode.com/problems/convert-json-string-to-object/", + "title": "Convert JSON String to Object" }, "2760": { - "id": 2760, "category": "Sliding Window", - "title": "Longest Even Odd Subarray With Threshold", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-even-odd-subarray-with-threshold/" + "id": 2760, + "link": "https://leetcode.com/problems/longest-even-odd-subarray-with-threshold/", + "title": "Longest Even Odd Subarray With Threshold" }, "2761": { - "id": 2761, "category": "Math & Geometry", - "title": "Prime Pairs With Target Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/prime-pairs-with-target-sum/" + "id": 2761, + "link": "https://leetcode.com/problems/prime-pairs-with-target-sum/", + "title": "Prime Pairs With Target Sum" }, "2762": { - "id": 2762, "category": "Sliding Window", - "title": "Continuous Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/continuous-subarrays/" + "id": 2762, + "link": "https://leetcode.com/problems/continuous-subarrays/", + "title": "Continuous Subarrays" }, "2763": { - "id": 2763, "category": "Array & Hashing", - "title": "Sum of Imbalance Numbers of All Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-imbalance-numbers-of-all-subarrays/" + "id": 2763, + "link": "https://leetcode.com/problems/sum-of-imbalance-numbers-of-all-subarrays/", + "title": "Sum of Imbalance Numbers of All Subarrays" }, "2764": { - "id": 2764, "category": "Tree", - "title": "Is Array a Preorder of Some \u200cBinary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/is-array-a-preorder-of-some-binary-tree/" + "id": 2764, + "link": "https://leetcode.com/problems/is-array-a-preorder-of-some-binary-tree/", + "title": "Is Array a Preorder of Some ‌Binary Tree" }, "2765": { - "id": 2765, "category": "Array & Hashing", - "title": "Longest Alternating Subarray", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-alternating-subarray/" + "id": 2765, + "link": "https://leetcode.com/problems/longest-alternating-subarray/", + "title": "Longest Alternating Subarray" }, "2766": { - "id": 2766, "category": "Array & Hashing", - "title": "Relocate Marbles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/relocate-marbles/" + "id": 2766, + "link": "https://leetcode.com/problems/relocate-marbles/", + "title": "Relocate Marbles" }, "2767": { - "id": 2767, "category": "Dynamic Programming", - "title": "Partition String Into Minimum Beautiful Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-string-into-minimum-beautiful-substrings/" + "id": 2767, + "link": "https://leetcode.com/problems/partition-string-into-minimum-beautiful-substrings/", + "title": "Partition String Into Minimum Beautiful Substrings" }, "2768": { - "id": 2768, "category": "Array & Hashing", - "title": "Number of Black Blocks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-black-blocks/" + "id": 2768, + "link": "https://leetcode.com/problems/number-of-black-blocks/", + "title": "Number of Black Blocks" }, "2769": { - "id": 2769, "category": "Math & Geometry", - "title": "Find the Maximum Achievable Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-maximum-achievable-number/" + "id": 2769, + "link": "https://leetcode.com/problems/find-the-maximum-achievable-number/", + "title": "Find the Maximum Achievable Number" }, "2770": { - "id": 2770, "category": "Dynamic Programming", - "title": "Maximum Number of Jumps to Reach the Last Index", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-jumps-to-reach-the-last-index/" + "id": 2770, + "link": "https://leetcode.com/problems/maximum-number-of-jumps-to-reach-the-last-index/", + "title": "Maximum Number of Jumps to Reach the Last Index" }, "2771": { - "id": 2771, "category": "Dynamic Programming", - "title": "Longest Non-decreasing Subarray From Two Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-non-decreasing-subarray-from-two-arrays/" + "id": 2771, + "link": "https://leetcode.com/problems/longest-non-decreasing-subarray-from-two-arrays/", + "title": "Longest Non-decreasing Subarray From Two Arrays" }, "2772": { - "id": 2772, "category": "Array & Hashing", - "title": "Apply Operations to Make All Array Elements Equal to Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-operations-to-make-all-array-elements-equal-to-zero/" + "id": 2772, + "link": "https://leetcode.com/problems/apply-operations-to-make-all-array-elements-equal-to-zero/", + "title": "Apply Operations to Make All Array Elements Equal to Zero" }, "2773": { - "id": 2773, "category": "Tree", - "title": "Height of Special Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/height-of-special-binary-tree/" + "id": 2773, + "link": "https://leetcode.com/problems/height-of-special-binary-tree/", + "title": "Height of Special Binary Tree" }, "2774": { - "id": 2774, "category": "Array & Hashing", - "title": "Array Upper Bound", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-upper-bound/" + "id": 2774, + "link": "https://leetcode.com/problems/array-upper-bound/", + "title": "Array Upper Bound" }, "2775": { - "id": 2775, "category": "Array & Hashing", - "title": "Undefined to Null", "difficulty": "Medium", - "link": "https://leetcode.com/problems/undefined-to-null/" + "id": 2775, + "link": "https://leetcode.com/problems/undefined-to-null/", + "title": "Undefined to Null" }, "2776": { - "id": 2776, "category": "Array & Hashing", - "title": "Convert Callback Based Function to Promise Based Function", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-callback-based-function-to-promise-based-function/" + "id": 2776, + "link": "https://leetcode.com/problems/convert-callback-based-function-to-promise-based-function/", + "title": "Convert Callback Based Function to Promise Based Function" }, "2777": { - "id": 2777, "category": "Array & Hashing", - "title": "Date Range Generator", "difficulty": "Medium", - "link": "https://leetcode.com/problems/date-range-generator/" + "id": 2777, + "link": "https://leetcode.com/problems/date-range-generator/", + "title": "Date Range Generator" }, "2778": { - "id": 2778, "category": "Array & Hashing", - "title": "Sum of Squares of Special Elements ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-squares-of-special-elements/" + "id": 2778, + "link": "https://leetcode.com/problems/sum-of-squares-of-special-elements/", + "title": "Sum of Squares of Special Elements " }, "2779": { - "id": 2779, "category": "Sliding Window", - "title": "Maximum Beauty of an Array After Applying Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-beauty-of-an-array-after-applying-operation/" + "id": 2779, + "link": "https://leetcode.com/problems/maximum-beauty-of-an-array-after-applying-operation/", + "title": "Maximum Beauty of an Array After Applying Operation" }, "2780": { - "id": 2780, "category": "Array & Hashing", - "title": "Minimum Index of a Valid Split", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-index-of-a-valid-split/" + "id": 2780, + "link": "https://leetcode.com/problems/minimum-index-of-a-valid-split/", + "title": "Minimum Index of a Valid Split" }, "2781": { - "id": 2781, "category": "Sliding Window", - "title": "Length of the Longest Valid Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/length-of-the-longest-valid-substring/" + "id": 2781, + "link": "https://leetcode.com/problems/length-of-the-longest-valid-substring/", + "title": "Length of the Longest Valid Substring" }, "2782": { - "id": 2782, "category": "Graph Traversal", - "title": "Number of Unique Categories", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-unique-categories/" + "id": 2782, + "link": "https://leetcode.com/problems/number-of-unique-categories/", + "title": "Number of Unique Categories" }, "2783": { - "id": 2783, "category": "Database", - "title": "Flight Occupancy and Waitlist Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/flight-occupancy-and-waitlist-analysis/" + "id": 2783, + "link": "https://leetcode.com/problems/flight-occupancy-and-waitlist-analysis/", + "title": "Flight Occupancy and Waitlist Analysis" }, "2784": { - "id": 2784, "category": "Array & Hashing", - "title": "Check if Array is Good", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-array-is-good/" + "id": 2784, + "link": "https://leetcode.com/problems/check-if-array-is-good/", + "title": "Check if Array is Good" }, "2785": { - "id": 2785, "category": "Array & Hashing", - "title": "Sort Vowels in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-vowels-in-a-string/" + "id": 2785, + "link": "https://leetcode.com/problems/sort-vowels-in-a-string/", + "title": "Sort Vowels in a String" }, "2786": { - "id": 2786, "category": "Dynamic Programming", - "title": "Visit Array Positions to Maximize Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/visit-array-positions-to-maximize-score/" + "id": 2786, + "link": "https://leetcode.com/problems/visit-array-positions-to-maximize-score/", + "title": "Visit Array Positions to Maximize Score" }, "2787": { - "id": 2787, "category": "Dynamic Programming", - "title": "Ways to Express an Integer as Sum of Powers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/ways-to-express-an-integer-as-sum-of-powers/" + "id": 2787, + "link": "https://leetcode.com/problems/ways-to-express-an-integer-as-sum-of-powers/", + "title": "Ways to Express an Integer as Sum of Powers" }, "2788": { - "id": 2788, "category": "Array & Hashing", - "title": "Split Strings by Separator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/split-strings-by-separator/" + "id": 2788, + "link": "https://leetcode.com/problems/split-strings-by-separator/", + "title": "Split Strings by Separator" }, "2789": { - "id": 2789, "category": "Greedy", - "title": "Largest Element in an Array after Merge Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-element-in-an-array-after-merge-operations/" + "id": 2789, + "link": "https://leetcode.com/problems/largest-element-in-an-array-after-merge-operations/", + "title": "Largest Element in an Array after Merge Operations" }, "2790": { - "id": 2790, "category": "Binary Search", - "title": "Maximum Number of Groups With Increasing Length", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-groups-with-increasing-length/" + "id": 2790, + "link": "https://leetcode.com/problems/maximum-number-of-groups-with-increasing-length/", + "title": "Maximum Number of Groups With Increasing Length" }, "2791": { - "id": 2791, "category": "Tree", - "title": "Count Paths That Can Form a Palindrome in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-paths-that-can-form-a-palindrome-in-a-tree/" + "id": 2791, + "link": "https://leetcode.com/problems/count-paths-that-can-form-a-palindrome-in-a-tree/", + "title": "Count Paths That Can Form a Palindrome in a Tree" }, "2792": { - "id": 2792, "category": "Tree", - "title": "Count Nodes That Are Great Enough", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-nodes-that-are-great-enough/" + "id": 2792, + "link": "https://leetcode.com/problems/count-nodes-that-are-great-enough/", + "title": "Count Nodes That Are Great Enough" }, "2793": { - "id": 2793, "category": "Array & Hashing", - "title": "Status of Flight Tickets", "difficulty": "Hard", - "link": "https://leetcode.com/problems/status-of-flight-tickets/" + "id": 2793, + "link": "https://leetcode.com/problems/status-of-flight-tickets/", + "title": "Status of Flight Tickets" }, "2794": { - "id": 2794, "category": "Array & Hashing", - "title": "Create Object from Two Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-object-from-two-arrays/" + "id": 2794, + "link": "https://leetcode.com/problems/create-object-from-two-arrays/", + "title": "Create Object from Two Arrays" }, "2795": { - "id": 2795, "category": "Array & Hashing", - "title": "Parallel Execution of Promises for Individual Results Retrieval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/parallel-execution-of-promises-for-individual-results-retrieval/" + "id": 2795, + "link": "https://leetcode.com/problems/parallel-execution-of-promises-for-individual-results-retrieval/", + "title": "Parallel Execution of Promises for Individual Results Retrieval" }, "2796": { - "id": 2796, "category": "Array & Hashing", - "title": "Repeat String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/repeat-string/" + "id": 2796, + "link": "https://leetcode.com/problems/repeat-string/", + "title": "Repeat String" }, "2797": { - "id": 2797, "category": "Array & Hashing", - "title": "Partial Function with Placeholders", "difficulty": "Easy", - "link": "https://leetcode.com/problems/partial-function-with-placeholders/" + "id": 2797, + "link": "https://leetcode.com/problems/partial-function-with-placeholders/", + "title": "Partial Function with Placeholders" }, "2798": { - "id": 2798, "category": "Array & Hashing", - "title": "Number of Employees Who Met the Target", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-employees-who-met-the-target/" + "id": 2798, + "link": "https://leetcode.com/problems/number-of-employees-who-met-the-target/", + "title": "Number of Employees Who Met the Target" }, "2799": { - "id": 2799, "category": "Sliding Window", - "title": "Count Complete Subarrays in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-complete-subarrays-in-an-array/" + "id": 2799, + "link": "https://leetcode.com/problems/count-complete-subarrays-in-an-array/", + "title": "Count Complete Subarrays in an Array" }, "2800": { - "id": 2800, "category": "Greedy", - "title": "Shortest String That Contains Three Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-string-that-contains-three-strings/" + "id": 2800, + "link": "https://leetcode.com/problems/shortest-string-that-contains-three-strings/", + "title": "Shortest String That Contains Three Strings" }, "2801": { - "id": 2801, "category": "Dynamic Programming", - "title": "Count Stepping Numbers in Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-stepping-numbers-in-range/" + "id": 2801, + "link": "https://leetcode.com/problems/count-stepping-numbers-in-range/", + "title": "Count Stepping Numbers in Range" }, "2802": { - "id": 2802, "category": "Bit Manipulation", - "title": "Find The K-th Lucky Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-k-th-lucky-number/" + "id": 2802, + "link": "https://leetcode.com/problems/find-the-k-th-lucky-number/", + "title": "Find The K-th Lucky Number" }, "2803": { - "id": 2803, "category": "Array & Hashing", - "title": "Factorial Generator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/factorial-generator/" + "id": 2803, + "link": "https://leetcode.com/problems/factorial-generator/", + "title": "Factorial Generator" }, "2804": { - "id": 2804, "category": "Array & Hashing", - "title": "Array Prototype ForEach", "difficulty": "Easy", - "link": "https://leetcode.com/problems/array-prototype-foreach/" + "id": 2804, + "link": "https://leetcode.com/problems/array-prototype-foreach/", + "title": "Array Prototype ForEach" }, "2805": { - "id": 2805, "category": "Array & Hashing", - "title": "Custom Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/custom-interval/" + "id": 2805, + "link": "https://leetcode.com/problems/custom-interval/", + "title": "Custom Interval" }, "2806": { - "id": 2806, "category": "Math & Geometry", - "title": "Account Balance After Rounded Purchase", "difficulty": "Easy", - "link": "https://leetcode.com/problems/account-balance-after-rounded-purchase/" + "id": 2806, + "link": "https://leetcode.com/problems/account-balance-after-rounded-purchase/", + "title": "Account Balance After Rounded Purchase" }, "2807": { - "id": 2807, "category": "Linked List", - "title": "Insert Greatest Common Divisors in Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/insert-greatest-common-divisors-in-linked-list/" + "id": 2807, + "link": "https://leetcode.com/problems/insert-greatest-common-divisors-in-linked-list/", + "title": "Insert Greatest Common Divisors in Linked List" }, "2808": { - "id": 2808, "category": "Array & Hashing", - "title": "Minimum Seconds to Equalize a Circular Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-seconds-to-equalize-a-circular-array/" + "id": 2808, + "link": "https://leetcode.com/problems/minimum-seconds-to-equalize-a-circular-array/", + "title": "Minimum Seconds to Equalize a Circular Array" }, "2809": { - "id": 2809, "category": "Dynamic Programming", - "title": "Minimum Time to Make Array Sum At Most x", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-make-array-sum-at-most-x/" + "id": 2809, + "link": "https://leetcode.com/problems/minimum-time-to-make-array-sum-at-most-x/", + "title": "Minimum Time to Make Array Sum At Most x" }, "2810": { - "id": 2810, "category": "Array & Hashing", - "title": "Faulty Keyboard", "difficulty": "Easy", - "link": "https://leetcode.com/problems/faulty-keyboard/" + "id": 2810, + "link": "https://leetcode.com/problems/faulty-keyboard/", + "title": "Faulty Keyboard" }, "2811": { - "id": 2811, "category": "Dynamic Programming", - "title": "Check if it is Possible to Split Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-it-is-possible-to-split-array/" + "id": 2811, + "link": "https://leetcode.com/problems/check-if-it-is-possible-to-split-array/", + "title": "Check if it is Possible to Split Array" }, "2812": { - "id": 2812, "category": "Graph Traversal", - "title": "Find the Safest Path in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-safest-path-in-a-grid/" + "id": 2812, + "link": "https://leetcode.com/problems/find-the-safest-path-in-a-grid/", + "title": "Find the Safest Path in a Grid" }, "2813": { - "id": 2813, "category": "Heap (Priority Queue)", - "title": "Maximum Elegance of a K-Length Subsequence", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-elegance-of-a-k-length-subsequence/" + "id": 2813, + "link": "https://leetcode.com/problems/maximum-elegance-of-a-k-length-subsequence/", + "title": "Maximum Elegance of a K-Length Subsequence" }, "2814": { - "id": 2814, "category": "Graph Traversal", - "title": "Minimum Time Takes to Reach Destination Without Drowning", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-takes-to-reach-destination-without-drowning/" + "id": 2814, + "link": "https://leetcode.com/problems/minimum-time-takes-to-reach-destination-without-drowning/", + "title": "Minimum Time Takes to Reach Destination Without Drowning" }, "2815": { - "id": 2815, "category": "Array & Hashing", - "title": "Max Pair Sum in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/max-pair-sum-in-an-array/" + "id": 2815, + "link": "https://leetcode.com/problems/max-pair-sum-in-an-array/", + "title": "Max Pair Sum in an Array" }, "2816": { - "id": 2816, "category": "Stack", - "title": "Double a Number Represented as a Linked List", "difficulty": "Medium", - "link": "https://leetcode.com/problems/double-a-number-represented-as-a-linked-list/" + "id": 2816, + "link": "https://leetcode.com/problems/double-a-number-represented-as-a-linked-list/", + "title": "Double a Number Represented as a Linked List" }, "2817": { - "id": 2817, "category": "Binary Search", - "title": "Minimum Absolute Difference Between Elements With Constraint", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-absolute-difference-between-elements-with-constraint/" + "id": 2817, + "link": "https://leetcode.com/problems/minimum-absolute-difference-between-elements-with-constraint/", + "title": "Minimum Absolute Difference Between Elements With Constraint" }, "2818": { - "id": 2818, "category": "Stack", - "title": "Apply Operations to Maximize Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/apply-operations-to-maximize-score/" + "id": 2818, + "link": "https://leetcode.com/problems/apply-operations-to-maximize-score/", + "title": "Apply Operations to Maximize Score" }, "2819": { - "id": 2819, "category": "Binary Search", - "title": "Minimum Relative Loss After Buying Chocolates", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-relative-loss-after-buying-chocolates/" + "id": 2819, + "link": "https://leetcode.com/problems/minimum-relative-loss-after-buying-chocolates/", + "title": "Minimum Relative Loss After Buying Chocolates" }, "2820": { - "id": 2820, "category": "Array & Hashing", - "title": "Election Results", "difficulty": "Medium", - "link": "https://leetcode.com/problems/election-results/" + "id": 2820, + "link": "https://leetcode.com/problems/election-results/", + "title": "Election Results" }, "2821": { - "id": 2821, "category": "Array & Hashing", - "title": "Delay the Resolution of Each Promise", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delay-the-resolution-of-each-promise/" + "id": 2821, + "link": "https://leetcode.com/problems/delay-the-resolution-of-each-promise/", + "title": "Delay the Resolution of Each Promise" }, "2822": { - "id": 2822, "category": "Array & Hashing", - "title": "Inversion of Object", "difficulty": "Easy", - "link": "https://leetcode.com/problems/inversion-of-object/" + "id": 2822, + "link": "https://leetcode.com/problems/inversion-of-object/", + "title": "Inversion of Object" }, "2823": { - "id": 2823, "category": "Array & Hashing", - "title": "Deep Object Filter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/deep-object-filter/" + "id": 2823, + "link": "https://leetcode.com/problems/deep-object-filter/", + "title": "Deep Object Filter" }, "2824": { - "id": 2824, "category": "Binary Search", - "title": "Count Pairs Whose Sum is Less than Target", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-pairs-whose-sum-is-less-than-target/" + "id": 2824, + "link": "https://leetcode.com/problems/count-pairs-whose-sum-is-less-than-target/", + "title": "Count Pairs Whose Sum is Less than Target" }, "2825": { - "id": 2825, "category": "Two Pointers", - "title": "Make String a Subsequence Using Cyclic Increments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/" + "id": 2825, + "link": "https://leetcode.com/problems/make-string-a-subsequence-using-cyclic-increments/", + "title": "Make String a Subsequence Using Cyclic Increments" }, "2826": { - "id": 2826, "category": "Dynamic Programming", - "title": "Sorting Three Groups", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sorting-three-groups/" + "id": 2826, + "link": "https://leetcode.com/problems/sorting-three-groups/", + "title": "Sorting Three Groups" }, "2827": { - "id": 2827, "category": "Dynamic Programming", - "title": "Number of Beautiful Integers in the Range", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-beautiful-integers-in-the-range/" + "id": 2827, + "link": "https://leetcode.com/problems/number-of-beautiful-integers-in-the-range/", + "title": "Number of Beautiful Integers in the Range" }, "2828": { - "id": 2828, "category": "Array & Hashing", - "title": "Check if a String Is an Acronym of Words", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/" + "id": 2828, + "link": "https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/", + "title": "Check if a String Is an Acronym of Words" }, "2829": { - "id": 2829, "category": "Greedy", - "title": "Determine the Minimum Sum of a k-avoiding Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/determine-the-minimum-sum-of-a-k-avoiding-array/" + "id": 2829, + "link": "https://leetcode.com/problems/determine-the-minimum-sum-of-a-k-avoiding-array/", + "title": "Determine the Minimum Sum of a k-avoiding Array" }, "2830": { - "id": 2830, "category": "Dynamic Programming", - "title": "Maximize the Profit as the Salesman", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-the-profit-as-the-salesman/" + "id": 2830, + "link": "https://leetcode.com/problems/maximize-the-profit-as-the-salesman/", + "title": "Maximize the Profit as the Salesman" }, "2831": { - "id": 2831, "category": "Sliding Window", - "title": "Find the Longest Equal Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-longest-equal-subarray/" + "id": 2831, + "link": "https://leetcode.com/problems/find-the-longest-equal-subarray/", + "title": "Find the Longest Equal Subarray" }, "2832": { - "id": 2832, "category": "Stack", - "title": "Maximal Range That Each Element Is Maximum in It", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximal-range-that-each-element-is-maximum-in-it/" + "id": 2832, + "link": "https://leetcode.com/problems/maximal-range-that-each-element-is-maximum-in-it/", + "title": "Maximal Range That Each Element Is Maximum in It" }, "2833": { - "id": 2833, "category": "Array & Hashing", - "title": "Furthest Point From Origin", "difficulty": "Easy", - "link": "https://leetcode.com/problems/furthest-point-from-origin/" + "id": 2833, + "link": "https://leetcode.com/problems/furthest-point-from-origin/", + "title": "Furthest Point From Origin" }, "2834": { - "id": 2834, "category": "Greedy", - "title": "Find the Minimum Possible Sum of a Beautiful Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-minimum-possible-sum-of-a-beautiful-array/" + "id": 2834, + "link": "https://leetcode.com/problems/find-the-minimum-possible-sum-of-a-beautiful-array/", + "title": "Find the Minimum Possible Sum of a Beautiful Array" }, "2835": { - "id": 2835, "category": "Bit Manipulation", - "title": "Minimum Operations to Form Subsequence With Target Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-form-subsequence-with-target-sum/" + "id": 2835, + "link": "https://leetcode.com/problems/minimum-operations-to-form-subsequence-with-target-sum/", + "title": "Minimum Operations to Form Subsequence With Target Sum" }, "2836": { - "id": 2836, "category": "Dynamic Programming", - "title": "Maximize Value of Function in a Ball Passing Game", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-value-of-function-in-a-ball-passing-game/" + "id": 2836, + "link": "https://leetcode.com/problems/maximize-value-of-function-in-a-ball-passing-game/", + "title": "Maximize Value of Function in a Ball Passing Game" }, "2837": { - "id": 2837, "category": "Database", - "title": "Total Traveled Distance", "difficulty": "Easy", - "link": "https://leetcode.com/problems/total-traveled-distance/" + "id": 2837, + "link": "https://leetcode.com/problems/total-traveled-distance/", + "title": "Total Traveled Distance" }, "2838": { - "id": 2838, "category": "Binary Search", - "title": "Maximum Coins Heroes Can Collect", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-coins-heroes-can-collect/" + "id": 2838, + "link": "https://leetcode.com/problems/maximum-coins-heroes-can-collect/", + "title": "Maximum Coins Heroes Can Collect" }, "2839": { - "id": 2839, "category": "Array & Hashing", - "title": "Check if Strings Can be Made Equal With Operations I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-i/" + "id": 2839, + "link": "https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-i/", + "title": "Check if Strings Can be Made Equal With Operations I" }, "2840": { - "id": 2840, "category": "Array & Hashing", - "title": "Check if Strings Can be Made Equal With Operations II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/" + "id": 2840, + "link": "https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/", + "title": "Check if Strings Can be Made Equal With Operations II" }, "2841": { - "id": 2841, "category": "Sliding Window", - "title": "Maximum Sum of Almost Unique Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-of-almost-unique-subarray/" + "id": 2841, + "link": "https://leetcode.com/problems/maximum-sum-of-almost-unique-subarray/", + "title": "Maximum Sum of Almost Unique Subarray" }, "2842": { - "id": 2842, "category": "Greedy", - "title": "Count K-Subsequences of a String With Maximum Beauty", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-k-subsequences-of-a-string-with-maximum-beauty/" + "id": 2842, + "link": "https://leetcode.com/problems/count-k-subsequences-of-a-string-with-maximum-beauty/", + "title": "Count K-Subsequences of a String With Maximum Beauty" }, "2843": { - "id": 2843, "category": "Math & Geometry", - "title": " Count Symmetric Integers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-symmetric-integers/" + "id": 2843, + "link": "https://leetcode.com/problems/count-symmetric-integers/", + "title": " Count Symmetric Integers" }, "2844": { - "id": 2844, "category": "Greedy", - "title": "Minimum Operations to Make a Special Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-a-special-number/" + "id": 2844, + "link": "https://leetcode.com/problems/minimum-operations-to-make-a-special-number/", + "title": "Minimum Operations to Make a Special Number" }, "2845": { - "id": 2845, "category": "Array & Hashing", - "title": "Count of Interesting Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-of-interesting-subarrays/" + "id": 2845, + "link": "https://leetcode.com/problems/count-of-interesting-subarrays/", + "title": "Count of Interesting Subarrays" }, "2846": { - "id": 2846, "category": "Tree", - "title": "Minimum Edge Weight Equilibrium Queries in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-edge-weight-equilibrium-queries-in-a-tree/" + "id": 2846, + "link": "https://leetcode.com/problems/minimum-edge-weight-equilibrium-queries-in-a-tree/", + "title": "Minimum Edge Weight Equilibrium Queries in a Tree" }, "2847": { - "id": 2847, "category": "Greedy", - "title": "Smallest Number With Given Digit Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-number-with-given-digit-product/" + "id": 2847, + "link": "https://leetcode.com/problems/smallest-number-with-given-digit-product/", + "title": "Smallest Number With Given Digit Product" }, "2848": { - "id": 2848, "category": "Array & Hashing", - "title": "Points That Intersect With Cars", "difficulty": "Easy", - "link": "https://leetcode.com/problems/points-that-intersect-with-cars/" + "id": 2848, + "link": "https://leetcode.com/problems/points-that-intersect-with-cars/", + "title": "Points That Intersect With Cars" }, "2849": { - "id": 2849, "category": "Math & Geometry", - "title": "Determine if a Cell Is Reachable at a Given Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/determine-if-a-cell-is-reachable-at-a-given-time/" + "id": 2849, + "link": "https://leetcode.com/problems/determine-if-a-cell-is-reachable-at-a-given-time/", + "title": "Determine if a Cell Is Reachable at a Given Time" }, "2850": { - "id": 2850, "category": "Graph Traversal", - "title": "Minimum Moves to Spread Stones Over Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-spread-stones-over-grid/" + "id": 2850, + "link": "https://leetcode.com/problems/minimum-moves-to-spread-stones-over-grid/", + "title": "Minimum Moves to Spread Stones Over Grid" }, "2851": { - "id": 2851, "category": "Dynamic Programming", - "title": "String Transformation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/string-transformation/" + "id": 2851, + "link": "https://leetcode.com/problems/string-transformation/", + "title": "String Transformation" }, "2852": { - "id": 2852, "category": "Graph Traversal", - "title": "Sum of Remoteness of All Cells", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-remoteness-of-all-cells/" + "id": 2852, + "link": "https://leetcode.com/problems/sum-of-remoteness-of-all-cells/", + "title": "Sum of Remoteness of All Cells" }, "2853": { - "id": 2853, "category": "Database", - "title": "Highest Salaries Difference", "difficulty": "Easy", - "link": "https://leetcode.com/problems/highest-salaries-difference/" + "id": 2853, + "link": "https://leetcode.com/problems/highest-salaries-difference/", + "title": "Highest Salaries Difference" }, "2854": { - "id": 2854, "category": "Database", - "title": "Rolling Average Steps", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rolling-average-steps/" + "id": 2854, + "link": "https://leetcode.com/problems/rolling-average-steps/", + "title": "Rolling Average Steps" }, "2855": { - "id": 2855, "category": "Array & Hashing", - "title": "Minimum Right Shifts to Sort the Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-right-shifts-to-sort-the-array/" + "id": 2855, + "link": "https://leetcode.com/problems/minimum-right-shifts-to-sort-the-array/", + "title": "Minimum Right Shifts to Sort the Array" }, "2856": { - "id": 2856, "category": "Binary Search", - "title": "Minimum Array Length After Pair Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-array-length-after-pair-removals/" + "id": 2856, + "link": "https://leetcode.com/problems/minimum-array-length-after-pair-removals/", + "title": "Minimum Array Length After Pair Removals" }, "2857": { - "id": 2857, "category": "Bit Manipulation", - "title": "Count Pairs of Points With Distance k", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-pairs-of-points-with-distance-k/" + "id": 2857, + "link": "https://leetcode.com/problems/count-pairs-of-points-with-distance-k/", + "title": "Count Pairs of Points With Distance k" }, "2858": { - "id": 2858, "category": "Graph Traversal", - "title": "Minimum Edge Reversals So Every Node Is Reachable", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-edge-reversals-so-every-node-is-reachable/" + "id": 2858, + "link": "https://leetcode.com/problems/minimum-edge-reversals-so-every-node-is-reachable/", + "title": "Minimum Edge Reversals So Every Node Is Reachable" }, "2859": { - "id": 2859, "category": "Bit Manipulation", - "title": "Sum of Values at Indices With K Set Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-values-at-indices-with-k-set-bits/" + "id": 2859, + "link": "https://leetcode.com/problems/sum-of-values-at-indices-with-k-set-bits/", + "title": "Sum of Values at Indices With K Set Bits" }, "2860": { - "id": 2860, "category": "Array & Hashing", - "title": "Happy Students", "difficulty": "Medium", - "link": "https://leetcode.com/problems/happy-students/" + "id": 2860, + "link": "https://leetcode.com/problems/happy-students/", + "title": "Happy Students" }, "2861": { - "id": 2861, "category": "Binary Search", - "title": "Maximum Number of Alloys", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-alloys/" + "id": 2861, + "link": "https://leetcode.com/problems/maximum-number-of-alloys/", + "title": "Maximum Number of Alloys" }, "2862": { - "id": 2862, "category": "Math & Geometry", - "title": "Maximum Element-Sum of a Complete Subset of Indices", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-element-sum-of-a-complete-subset-of-indices/" + "id": 2862, + "link": "https://leetcode.com/problems/maximum-element-sum-of-a-complete-subset-of-indices/", + "title": "Maximum Element-Sum of a Complete Subset of Indices" }, "2863": { - "id": 2863, "category": "Stack", - "title": "Maximum Length of Semi-Decreasing Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-length-of-semi-decreasing-subarrays/" + "id": 2863, + "link": "https://leetcode.com/problems/maximum-length-of-semi-decreasing-subarrays/", + "title": "Maximum Length of Semi-Decreasing Subarrays" }, "2864": { - "id": 2864, "category": "Greedy", - "title": "Maximum Odd Binary Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-odd-binary-number/" + "id": 2864, + "link": "https://leetcode.com/problems/maximum-odd-binary-number/", + "title": "Maximum Odd Binary Number" }, "2865": { - "id": 2865, "category": "Stack", - "title": "Beautiful Towers I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/beautiful-towers-i/" + "id": 2865, + "link": "https://leetcode.com/problems/beautiful-towers-i/", + "title": "Beautiful Towers I" }, "2866": { - "id": 2866, "category": "Stack", - "title": "Beautiful Towers II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/beautiful-towers-ii/" + "id": 2866, + "link": "https://leetcode.com/problems/beautiful-towers-ii/", + "title": "Beautiful Towers II" }, "2867": { - "id": 2867, "category": "Tree", - "title": "Count Valid Paths in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-valid-paths-in-a-tree/" + "id": 2867, + "link": "https://leetcode.com/problems/count-valid-paths-in-a-tree/", + "title": "Count Valid Paths in a Tree" }, "2868": { - "id": 2868, "category": "Greedy", - "title": "The Wording Game", "difficulty": "Hard", - "link": "https://leetcode.com/problems/the-wording-game/" + "id": 2868, + "link": "https://leetcode.com/problems/the-wording-game/", + "title": "The Wording Game" }, "2869": { - "id": 2869, "category": "Bit Manipulation", - "title": "Minimum Operations to Collect Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-collect-elements/" + "id": 2869, + "link": "https://leetcode.com/problems/minimum-operations-to-collect-elements/", + "title": "Minimum Operations to Collect Elements" }, "2870": { - "id": 2870, "category": "Greedy", - "title": "Minimum Number of Operations to Make Array Empty", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-empty/" + "id": 2870, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-empty/", + "title": "Minimum Number of Operations to Make Array Empty" }, "2871": { - "id": 2871, "category": "Bit Manipulation", - "title": "Split Array Into Maximum Number of Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-array-into-maximum-number-of-subarrays/" + "id": 2871, + "link": "https://leetcode.com/problems/split-array-into-maximum-number-of-subarrays/", + "title": "Split Array Into Maximum Number of Subarrays" }, "2872": { - "id": 2872, "category": "Tree", - "title": "Maximum Number of K-Divisible Components", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-k-divisible-components/" + "id": 2872, + "link": "https://leetcode.com/problems/maximum-number-of-k-divisible-components/", + "title": "Maximum Number of K-Divisible Components" }, "2873": { - "id": 2873, "category": "Array & Hashing", - "title": "Maximum Value of an Ordered Triplet I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-i/" + "id": 2873, + "link": "https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-i/", + "title": "Maximum Value of an Ordered Triplet I" }, "2874": { - "id": 2874, "category": "Array & Hashing", - "title": "Maximum Value of an Ordered Triplet II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-ii/" + "id": 2874, + "link": "https://leetcode.com/problems/maximum-value-of-an-ordered-triplet-ii/", + "title": "Maximum Value of an Ordered Triplet II" }, "2875": { - "id": 2875, "category": "Sliding Window", - "title": "Minimum Size Subarray in Infinite Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-size-subarray-in-infinite-array/" + "id": 2875, + "link": "https://leetcode.com/problems/minimum-size-subarray-in-infinite-array/", + "title": "Minimum Size Subarray in Infinite Array" }, "2876": { - "id": 2876, "category": "Graph Traversal", - "title": "Count Visited Nodes in a Directed Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-visited-nodes-in-a-directed-graph/" + "id": 2876, + "link": "https://leetcode.com/problems/count-visited-nodes-in-a-directed-graph/", + "title": "Count Visited Nodes in a Directed Graph" }, "2877": { - "id": 2877, "category": "Array & Hashing", - "title": "Create a DataFrame from List", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-a-dataframe-from-list/" + "id": 2877, + "link": "https://leetcode.com/problems/create-a-dataframe-from-list/", + "title": "Create a DataFrame from List" }, "2878": { - "id": 2878, "category": "Array & Hashing", - "title": "Get the Size of a DataFrame", "difficulty": "Easy", - "link": "https://leetcode.com/problems/get-the-size-of-a-dataframe/" + "id": 2878, + "link": "https://leetcode.com/problems/get-the-size-of-a-dataframe/", + "title": "Get the Size of a DataFrame" }, "2879": { - "id": 2879, "category": "Array & Hashing", - "title": "Display the First Three Rows", "difficulty": "Easy", - "link": "https://leetcode.com/problems/display-the-first-three-rows/" + "id": 2879, + "link": "https://leetcode.com/problems/display-the-first-three-rows/", + "title": "Display the First Three Rows" }, "2880": { - "id": 2880, "category": "Array & Hashing", - "title": "Select Data", "difficulty": "Easy", - "link": "https://leetcode.com/problems/select-data/" + "id": 2880, + "link": "https://leetcode.com/problems/select-data/", + "title": "Select Data" }, "2881": { - "id": 2881, "category": "Array & Hashing", - "title": "Create a New Column", "difficulty": "Easy", - "link": "https://leetcode.com/problems/create-a-new-column/" + "id": 2881, + "link": "https://leetcode.com/problems/create-a-new-column/", + "title": "Create a New Column" }, "2882": { - "id": 2882, "category": "Array & Hashing", - "title": "Drop Duplicate Rows", "difficulty": "Easy", - "link": "https://leetcode.com/problems/drop-duplicate-rows/" + "id": 2882, + "link": "https://leetcode.com/problems/drop-duplicate-rows/", + "title": "Drop Duplicate Rows" }, "2883": { - "id": 2883, "category": "Array & Hashing", - "title": "Drop Missing Data", "difficulty": "Easy", - "link": "https://leetcode.com/problems/drop-missing-data/" + "id": 2883, + "link": "https://leetcode.com/problems/drop-missing-data/", + "title": "Drop Missing Data" }, "2884": { - "id": 2884, "category": "Array & Hashing", - "title": "Modify Columns", "difficulty": "Easy", - "link": "https://leetcode.com/problems/modify-columns/" + "id": 2884, + "link": "https://leetcode.com/problems/modify-columns/", + "title": "Modify Columns" }, "2885": { - "id": 2885, "category": "Array & Hashing", - "title": "Rename Columns", "difficulty": "Easy", - "link": "https://leetcode.com/problems/rename-columns/" + "id": 2885, + "link": "https://leetcode.com/problems/rename-columns/", + "title": "Rename Columns" }, "2886": { - "id": 2886, "category": "Array & Hashing", - "title": "Change Data Type", "difficulty": "Easy", - "link": "https://leetcode.com/problems/change-data-type/" + "id": 2886, + "link": "https://leetcode.com/problems/change-data-type/", + "title": "Change Data Type" }, "2887": { - "id": 2887, "category": "Array & Hashing", - "title": "Fill Missing Data", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fill-missing-data/" + "id": 2887, + "link": "https://leetcode.com/problems/fill-missing-data/", + "title": "Fill Missing Data" }, "2888": { - "id": 2888, "category": "Array & Hashing", - "title": "Reshape Data: Concatenate", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reshape-data-concatenate/" + "id": 2888, + "link": "https://leetcode.com/problems/reshape-data-concatenate/", + "title": "Reshape Data: Concatenate" }, "2889": { - "id": 2889, "category": "Array & Hashing", - "title": "Reshape Data: Pivot", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reshape-data-pivot/" + "id": 2889, + "link": "https://leetcode.com/problems/reshape-data-pivot/", + "title": "Reshape Data: Pivot" }, "2890": { - "id": 2890, "category": "Array & Hashing", - "title": "Reshape Data: Melt", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reshape-data-melt/" + "id": 2890, + "link": "https://leetcode.com/problems/reshape-data-melt/", + "title": "Reshape Data: Melt" }, "2891": { - "id": 2891, "category": "Array & Hashing", - "title": "Method Chaining", "difficulty": "Easy", - "link": "https://leetcode.com/problems/method-chaining/" + "id": 2891, + "link": "https://leetcode.com/problems/method-chaining/", + "title": "Method Chaining" }, "2892": { - "id": 2892, "category": "Dynamic Programming", - "title": "Minimizing Array After Replacing Pairs With Their Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimizing-array-after-replacing-pairs-with-their-product/" + "id": 2892, + "link": "https://leetcode.com/problems/minimizing-array-after-replacing-pairs-with-their-product/", + "title": "Minimizing Array After Replacing Pairs With Their Product" }, "2893": { - "id": 2893, "category": "Database", - "title": "Calculate Orders Within Each Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-orders-within-each-interval/" + "id": 2893, + "link": "https://leetcode.com/problems/calculate-orders-within-each-interval/", + "title": "Calculate Orders Within Each Interval" }, "2894": { - "id": 2894, "category": "Math & Geometry", - "title": "Divisible and Non-divisible Sums Difference", "difficulty": "Easy", - "link": "https://leetcode.com/problems/divisible-and-non-divisible-sums-difference/" + "id": 2894, + "link": "https://leetcode.com/problems/divisible-and-non-divisible-sums-difference/", + "title": "Divisible and Non-divisible Sums Difference" }, "2895": { - "id": 2895, "category": "Greedy", - "title": "Minimum Processing Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-processing-time/" + "id": 2895, + "link": "https://leetcode.com/problems/minimum-processing-time/", + "title": "Minimum Processing Time" }, "2896": { - "id": 2896, "category": "Dynamic Programming", - "title": "Apply Operations to Make Two Strings Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-operations-to-make-two-strings-equal/" + "id": 2896, + "link": "https://leetcode.com/problems/apply-operations-to-make-two-strings-equal/", + "title": "Apply Operations to Make Two Strings Equal" }, "2897": { - "id": 2897, "category": "Bit Manipulation", - "title": "Apply Operations on Array to Maximize Sum of Squares", "difficulty": "Hard", - "link": "https://leetcode.com/problems/apply-operations-on-array-to-maximize-sum-of-squares/" + "id": 2897, + "link": "https://leetcode.com/problems/apply-operations-on-array-to-maximize-sum-of-squares/", + "title": "Apply Operations on Array to Maximize Sum of Squares" }, "2898": { - "id": 2898, "category": "Array & Hashing", - "title": "Maximum Linear Stock Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-linear-stock-score/" + "id": 2898, + "link": "https://leetcode.com/problems/maximum-linear-stock-score/", + "title": "Maximum Linear Stock Score" }, "2899": { - "id": 2899, "category": "Array & Hashing", - "title": "Last Visited Integers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/last-visited-integers/" + "id": 2899, + "link": "https://leetcode.com/problems/last-visited-integers/", + "title": "Last Visited Integers" }, "2900": { - "id": 2900, "category": "Dynamic Programming", - "title": "Longest Unequal Adjacent Groups Subsequence I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-i/" + "id": 2900, + "link": "https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-i/", + "title": "Longest Unequal Adjacent Groups Subsequence I" }, "2901": { - "id": 2901, "category": "Dynamic Programming", - "title": "Longest Unequal Adjacent Groups Subsequence II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-ii/" + "id": 2901, + "link": "https://leetcode.com/problems/longest-unequal-adjacent-groups-subsequence-ii/", + "title": "Longest Unequal Adjacent Groups Subsequence II" }, "2902": { - "id": 2902, "category": "Dynamic Programming", - "title": "Count of Sub-Multisets With Bounded Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-of-sub-multisets-with-bounded-sum/" + "id": 2902, + "link": "https://leetcode.com/problems/count-of-sub-multisets-with-bounded-sum/", + "title": "Count of Sub-Multisets With Bounded Sum" }, "2903": { - "id": 2903, "category": "Two Pointers", - "title": "Find Indices With Index and Value Difference I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-indices-with-index-and-value-difference-i/" + "id": 2903, + "link": "https://leetcode.com/problems/find-indices-with-index-and-value-difference-i/", + "title": "Find Indices With Index and Value Difference I" }, "2904": { - "id": 2904, "category": "Sliding Window", - "title": "Shortest and Lexicographically Smallest Beautiful String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-and-lexicographically-smallest-beautiful-string/" + "id": 2904, + "link": "https://leetcode.com/problems/shortest-and-lexicographically-smallest-beautiful-string/", + "title": "Shortest and Lexicographically Smallest Beautiful String" }, "2905": { - "id": 2905, "category": "Two Pointers", - "title": "Find Indices With Index and Value Difference II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-indices-with-index-and-value-difference-ii/" + "id": 2905, + "link": "https://leetcode.com/problems/find-indices-with-index-and-value-difference-ii/", + "title": "Find Indices With Index and Value Difference II" }, "2906": { - "id": 2906, "category": "Array & Hashing", - "title": "Construct Product Matrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-product-matrix/" + "id": 2906, + "link": "https://leetcode.com/problems/construct-product-matrix/", + "title": "Construct Product Matrix" }, "2907": { - "id": 2907, "category": "Tree", - "title": "Maximum Profitable Triplets With Increasing Prices I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-profitable-triplets-with-increasing-prices-i/" + "id": 2907, + "link": "https://leetcode.com/problems/maximum-profitable-triplets-with-increasing-prices-i/", + "title": "Maximum Profitable Triplets With Increasing Prices I" }, "2908": { - "id": 2908, "category": "Array & Hashing", - "title": "Minimum Sum of Mountain Triplets I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i/" + "id": 2908, + "link": "https://leetcode.com/problems/minimum-sum-of-mountain-triplets-i/", + "title": "Minimum Sum of Mountain Triplets I" }, "2909": { - "id": 2909, "category": "Array & Hashing", - "title": "Minimum Sum of Mountain Triplets II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-sum-of-mountain-triplets-ii/" + "id": 2909, + "link": "https://leetcode.com/problems/minimum-sum-of-mountain-triplets-ii/", + "title": "Minimum Sum of Mountain Triplets II" }, "2910": { - "id": 2910, "category": "Greedy", - "title": "Minimum Number of Groups to Create a Valid Assignment", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-groups-to-create-a-valid-assignment/" + "id": 2910, + "link": "https://leetcode.com/problems/minimum-number-of-groups-to-create-a-valid-assignment/", + "title": "Minimum Number of Groups to Create a Valid Assignment" }, "2911": { - "id": 2911, "category": "Dynamic Programming", - "title": "Minimum Changes to Make K Semi-palindromes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-changes-to-make-k-semi-palindromes/" + "id": 2911, + "link": "https://leetcode.com/problems/minimum-changes-to-make-k-semi-palindromes/", + "title": "Minimum Changes to Make K Semi-palindromes" }, "2912": { - "id": 2912, "category": "Dynamic Programming", - "title": "Number of Ways to Reach Destination in the Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-reach-destination-in-the-grid/" + "id": 2912, + "link": "https://leetcode.com/problems/number-of-ways-to-reach-destination-in-the-grid/", + "title": "Number of Ways to Reach Destination in the Grid" }, "2913": { - "id": 2913, "category": "Array & Hashing", - "title": "Subarrays Distinct Element Sum of Squares I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/subarrays-distinct-element-sum-of-squares-i/" + "id": 2913, + "link": "https://leetcode.com/problems/subarrays-distinct-element-sum-of-squares-i/", + "title": "Subarrays Distinct Element Sum of Squares I" }, "2914": { - "id": 2914, "category": "Array & Hashing", - "title": "Minimum Number of Changes to Make Binary String Beautiful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful/" + "id": 2914, + "link": "https://leetcode.com/problems/minimum-number-of-changes-to-make-binary-string-beautiful/", + "title": "Minimum Number of Changes to Make Binary String Beautiful" }, "2915": { - "id": 2915, "category": "Dynamic Programming", - "title": "Length of the Longest Subsequence That Sums to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/length-of-the-longest-subsequence-that-sums-to-target/" + "id": 2915, + "link": "https://leetcode.com/problems/length-of-the-longest-subsequence-that-sums-to-target/", + "title": "Length of the Longest Subsequence That Sums to Target" }, "2916": { - "id": 2916, "category": "Tree", - "title": "Subarrays Distinct Element Sum of Squares II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subarrays-distinct-element-sum-of-squares-ii/" + "id": 2916, + "link": "https://leetcode.com/problems/subarrays-distinct-element-sum-of-squares-ii/", + "title": "Subarrays Distinct Element Sum of Squares II" }, "2917": { - "id": 2917, "category": "Bit Manipulation", - "title": "Find the K-or of an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-k-or-of-an-array/" + "id": 2917, + "link": "https://leetcode.com/problems/find-the-k-or-of-an-array/", + "title": "Find the K-or of an Array" }, "2918": { - "id": 2918, "category": "Greedy", - "title": "Minimum Equal Sum of Two Arrays After Replacing Zeros", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-equal-sum-of-two-arrays-after-replacing-zeros/" + "id": 2918, + "link": "https://leetcode.com/problems/minimum-equal-sum-of-two-arrays-after-replacing-zeros/", + "title": "Minimum Equal Sum of Two Arrays After Replacing Zeros" }, "2919": { - "id": 2919, "category": "Dynamic Programming", - "title": "Minimum Increment Operations to Make Array Beautiful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-increment-operations-to-make-array-beautiful/" + "id": 2919, + "link": "https://leetcode.com/problems/minimum-increment-operations-to-make-array-beautiful/", + "title": "Minimum Increment Operations to Make Array Beautiful" }, "2920": { - "id": 2920, "category": "Tree", - "title": "Maximum Points After Collecting Coins From All Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-points-after-collecting-coins-from-all-nodes/" + "id": 2920, + "link": "https://leetcode.com/problems/maximum-points-after-collecting-coins-from-all-nodes/", + "title": "Maximum Points After Collecting Coins From All Nodes" }, "2921": { - "id": 2921, "category": "Tree", - "title": "Maximum Profitable Triplets With Increasing Prices II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-profitable-triplets-with-increasing-prices-ii/" + "id": 2921, + "link": "https://leetcode.com/problems/maximum-profitable-triplets-with-increasing-prices-ii/", + "title": "Maximum Profitable Triplets With Increasing Prices II" }, "2922": { - "id": 2922, "category": "Database", - "title": "Market Analysis III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/market-analysis-iii/" + "id": 2922, + "link": "https://leetcode.com/problems/market-analysis-iii/", + "title": "Market Analysis III" }, "2923": { - "id": 2923, "category": "Array & Hashing", - "title": "Find Champion I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-champion-i/" + "id": 2923, + "link": "https://leetcode.com/problems/find-champion-i/", + "title": "Find Champion I" }, "2924": { - "id": 2924, "category": "Graph Traversal", - "title": "Find Champion II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-champion-ii/" + "id": 2924, + "link": "https://leetcode.com/problems/find-champion-ii/", + "title": "Find Champion II" }, "2925": { - "id": 2925, "category": "Tree", - "title": "Maximum Score After Applying Operations on a Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-score-after-applying-operations-on-a-tree/" + "id": 2925, + "link": "https://leetcode.com/problems/maximum-score-after-applying-operations-on-a-tree/", + "title": "Maximum Score After Applying Operations on a Tree" }, "2926": { - "id": 2926, "category": "Tree", - "title": "Maximum Balanced Subsequence Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-balanced-subsequence-sum/" + "id": 2926, + "link": "https://leetcode.com/problems/maximum-balanced-subsequence-sum/", + "title": "Maximum Balanced Subsequence Sum" }, "2927": { - "id": 2927, "category": "Math & Geometry", - "title": "Distribute Candies Among Children III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distribute-candies-among-children-iii/" + "id": 2927, + "link": "https://leetcode.com/problems/distribute-candies-among-children-iii/", + "title": "Distribute Candies Among Children III" }, "2928": { - "id": 2928, "category": "Math & Geometry", - "title": "Distribute Candies Among Children I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distribute-candies-among-children-i/" + "id": 2928, + "link": "https://leetcode.com/problems/distribute-candies-among-children-i/", + "title": "Distribute Candies Among Children I" }, "2929": { - "id": 2929, "category": "Math & Geometry", - "title": "Distribute Candies Among Children II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distribute-candies-among-children-ii/" + "id": 2929, + "link": "https://leetcode.com/problems/distribute-candies-among-children-ii/", + "title": "Distribute Candies Among Children II" }, "2930": { - "id": 2930, "category": "Dynamic Programming", - "title": "Number of Strings Which Can Be Rearranged to Contain Substring", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-strings-which-can-be-rearranged-to-contain-substring/" + "id": 2930, + "link": "https://leetcode.com/problems/number-of-strings-which-can-be-rearranged-to-contain-substring/", + "title": "Number of Strings Which Can Be Rearranged to Contain Substring" }, "2931": { - "id": 2931, "category": "Heap (Priority Queue)", - "title": "Maximum Spending After Buying Items", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-spending-after-buying-items/" + "id": 2931, + "link": "https://leetcode.com/problems/maximum-spending-after-buying-items/", + "title": "Maximum Spending After Buying Items" }, "2932": { - "id": 2932, "category": "Sliding Window", - "title": "Maximum Strong Pair XOR I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-strong-pair-xor-i/" + "id": 2932, + "link": "https://leetcode.com/problems/maximum-strong-pair-xor-i/", + "title": "Maximum Strong Pair XOR I" }, "2933": { - "id": 2933, "category": "Array & Hashing", - "title": "High-Access Employees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/high-access-employees/" + "id": 2933, + "link": "https://leetcode.com/problems/high-access-employees/", + "title": "High-Access Employees" }, "2934": { - "id": 2934, "category": "Array & Hashing", - "title": "Minimum Operations to Maximize Last Elements in Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-maximize-last-elements-in-arrays/" + "id": 2934, + "link": "https://leetcode.com/problems/minimum-operations-to-maximize-last-elements-in-arrays/", + "title": "Minimum Operations to Maximize Last Elements in Arrays" }, "2935": { - "id": 2935, "category": "Sliding Window", - "title": "Maximum Strong Pair XOR II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-strong-pair-xor-ii/" + "id": 2935, + "link": "https://leetcode.com/problems/maximum-strong-pair-xor-ii/", + "title": "Maximum Strong Pair XOR II" }, "2936": { - "id": 2936, "category": "Binary Search", - "title": "Number of Equal Numbers Blocks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-equal-numbers-blocks/" + "id": 2936, + "link": "https://leetcode.com/problems/number-of-equal-numbers-blocks/", + "title": "Number of Equal Numbers Blocks" }, "2937": { - "id": 2937, "category": "Array & Hashing", - "title": "Make Three Strings Equal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-three-strings-equal/" + "id": 2937, + "link": "https://leetcode.com/problems/make-three-strings-equal/", + "title": "Make Three Strings Equal" }, "2938": { - "id": 2938, "category": "Greedy", - "title": "Separate Black and White Balls", "difficulty": "Medium", - "link": "https://leetcode.com/problems/separate-black-and-white-balls/" + "id": 2938, + "link": "https://leetcode.com/problems/separate-black-and-white-balls/", + "title": "Separate Black and White Balls" }, "2939": { - "id": 2939, "category": "Bit Manipulation", - "title": "Maximum Xor Product", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-xor-product/" + "id": 2939, + "link": "https://leetcode.com/problems/maximum-xor-product/", + "title": "Maximum Xor Product" }, "2940": { - "id": 2940, "category": "Tree", - "title": "Find Building Where Alice and Bob Can Meet", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-building-where-alice-and-bob-can-meet/" + "id": 2940, + "link": "https://leetcode.com/problems/find-building-where-alice-and-bob-can-meet/", + "title": "Find Building Where Alice and Bob Can Meet" }, "2941": { - "id": 2941, "category": "Binary Search", - "title": "Maximum GCD-Sum of a Subarray", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-gcd-sum-of-a-subarray/" + "id": 2941, + "link": "https://leetcode.com/problems/maximum-gcd-sum-of-a-subarray/", + "title": "Maximum GCD-Sum of a Subarray" }, "2942": { - "id": 2942, "category": "Array & Hashing", - "title": "Find Words Containing Character", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-words-containing-character/" + "id": 2942, + "link": "https://leetcode.com/problems/find-words-containing-character/", + "title": "Find Words Containing Character" }, "2943": { - "id": 2943, "category": "Array & Hashing", - "title": "Maximize Area of Square Hole in Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-area-of-square-hole-in-grid/" + "id": 2943, + "link": "https://leetcode.com/problems/maximize-area-of-square-hole-in-grid/", + "title": "Maximize Area of Square Hole in Grid" }, "2944": { - "id": 2944, "category": "Dynamic Programming", - "title": "Minimum Number of Coins for Fruits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-coins-for-fruits/" + "id": 2944, + "link": "https://leetcode.com/problems/minimum-number-of-coins-for-fruits/", + "title": "Minimum Number of Coins for Fruits" }, "2945": { - "id": 2945, "category": "Dynamic Programming", - "title": "Find Maximum Non-decreasing Array Length", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-maximum-non-decreasing-array-length/" + "id": 2945, + "link": "https://leetcode.com/problems/find-maximum-non-decreasing-array-length/", + "title": "Find Maximum Non-decreasing Array Length" }, "2946": { - "id": 2946, "category": "Math & Geometry", - "title": "Matrix Similarity After Cyclic Shifts", "difficulty": "Easy", - "link": "https://leetcode.com/problems/matrix-similarity-after-cyclic-shifts/" + "id": 2946, + "link": "https://leetcode.com/problems/matrix-similarity-after-cyclic-shifts/", + "title": "Matrix Similarity After Cyclic Shifts" }, "2947": { - "id": 2947, "category": "Math & Geometry", - "title": "Count Beautiful Substrings I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-beautiful-substrings-i/" + "id": 2947, + "link": "https://leetcode.com/problems/count-beautiful-substrings-i/", + "title": "Count Beautiful Substrings I" }, "2948": { - "id": 2948, "category": "Graph Traversal", - "title": "Make Lexicographically Smallest Array by Swapping Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-lexicographically-smallest-array-by-swapping-elements/" + "id": 2948, + "link": "https://leetcode.com/problems/make-lexicographically-smallest-array-by-swapping-elements/", + "title": "Make Lexicographically Smallest Array by Swapping Elements" }, "2949": { - "id": 2949, "category": "Math & Geometry", - "title": "Count Beautiful Substrings II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-beautiful-substrings-ii/" + "id": 2949, + "link": "https://leetcode.com/problems/count-beautiful-substrings-ii/", + "title": "Count Beautiful Substrings II" }, "2950": { - "id": 2950, "category": "Array & Hashing", - "title": "Number of Divisible Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-divisible-substrings/" + "id": 2950, + "link": "https://leetcode.com/problems/number-of-divisible-substrings/", + "title": "Number of Divisible Substrings" }, "2951": { - "id": 2951, "category": "Array & Hashing", - "title": "Find the Peaks", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-peaks/" + "id": 2951, + "link": "https://leetcode.com/problems/find-the-peaks/", + "title": "Find the Peaks" }, "2952": { - "id": 2952, "category": "Greedy", - "title": "Minimum Number of Coins to be Added", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-coins-to-be-added/" + "id": 2952, + "link": "https://leetcode.com/problems/minimum-number-of-coins-to-be-added/", + "title": "Minimum Number of Coins to be Added" }, "2953": { - "id": 2953, "category": "Sliding Window", - "title": "Count Complete Substrings", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-complete-substrings/" + "id": 2953, + "link": "https://leetcode.com/problems/count-complete-substrings/", + "title": "Count Complete Substrings" }, "2954": { - "id": 2954, "category": "Math & Geometry", - "title": "Count the Number of Infection Sequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-infection-sequences/" + "id": 2954, + "link": "https://leetcode.com/problems/count-the-number-of-infection-sequences/", + "title": "Count the Number of Infection Sequences" }, "2955": { - "id": 2955, "category": "Array & Hashing", - "title": "Number of Same-End Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-same-end-substrings/" + "id": 2955, + "link": "https://leetcode.com/problems/number-of-same-end-substrings/", + "title": "Number of Same-End Substrings" }, "2956": { - "id": 2956, "category": "Array & Hashing", - "title": "Find Common Elements Between Two Arrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-common-elements-between-two-arrays/" + "id": 2956, + "link": "https://leetcode.com/problems/find-common-elements-between-two-arrays/", + "title": "Find Common Elements Between Two Arrays" }, "2957": { - "id": 2957, "category": "Dynamic Programming", - "title": "Remove Adjacent Almost-Equal Characters", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-adjacent-almost-equal-characters/" + "id": 2957, + "link": "https://leetcode.com/problems/remove-adjacent-almost-equal-characters/", + "title": "Remove Adjacent Almost-Equal Characters" }, "2958": { - "id": 2958, "category": "Sliding Window", - "title": "Length of Longest Subarray With at Most K Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/length-of-longest-subarray-with-at-most-k-frequency/" + "id": 2958, + "link": "https://leetcode.com/problems/length-of-longest-subarray-with-at-most-k-frequency/", + "title": "Length of Longest Subarray With at Most K Frequency" }, "2959": { - "id": 2959, "category": "Graph Traversal", - "title": "Number of Possible Sets of Closing Branches", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-possible-sets-of-closing-branches/" + "id": 2959, + "link": "https://leetcode.com/problems/number-of-possible-sets-of-closing-branches/", + "title": "Number of Possible Sets of Closing Branches" }, "2960": { - "id": 2960, "category": "Array & Hashing", - "title": "Count Tested Devices After Test Operations", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-tested-devices-after-test-operations/" + "id": 2960, + "link": "https://leetcode.com/problems/count-tested-devices-after-test-operations/", + "title": "Count Tested Devices After Test Operations" }, "2961": { - "id": 2961, "category": "Math & Geometry", - "title": "Double Modular Exponentiation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/double-modular-exponentiation/" + "id": 2961, + "link": "https://leetcode.com/problems/double-modular-exponentiation/", + "title": "Double Modular Exponentiation" }, "2962": { - "id": 2962, "category": "Sliding Window", - "title": "Count Subarrays Where Max Element Appears at Least K Times", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-subarrays-where-max-element-appears-at-least-k-times/" + "id": 2962, + "link": "https://leetcode.com/problems/count-subarrays-where-max-element-appears-at-least-k-times/", + "title": "Count Subarrays Where Max Element Appears at Least K Times" }, "2963": { - "id": 2963, "category": "Math & Geometry", - "title": "Count the Number of Good Partitions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-good-partitions/" + "id": 2963, + "link": "https://leetcode.com/problems/count-the-number-of-good-partitions/", + "title": "Count the Number of Good Partitions" }, "2964": { - "id": 2964, "category": "Array & Hashing", - "title": "Number of Divisible Triplet Sums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-divisible-triplet-sums/" + "id": 2964, + "link": "https://leetcode.com/problems/number-of-divisible-triplet-sums/", + "title": "Number of Divisible Triplet Sums" }, "2965": { - "id": 2965, "category": "Math & Geometry", - "title": "Find Missing and Repeated Values", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-missing-and-repeated-values/" + "id": 2965, + "link": "https://leetcode.com/problems/find-missing-and-repeated-values/", + "title": "Find Missing and Repeated Values" }, "2966": { - "id": 2966, "category": "Greedy", - "title": "Divide Array Into Arrays With Max Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/divide-array-into-arrays-with-max-difference/" + "id": 2966, + "link": "https://leetcode.com/problems/divide-array-into-arrays-with-max-difference/", + "title": "Divide Array Into Arrays With Max Difference" }, "2967": { - "id": 2967, "category": "Binary Search", - "title": "Minimum Cost to Make Array Equalindromic", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-make-array-equalindromic/" + "id": 2967, + "link": "https://leetcode.com/problems/minimum-cost-to-make-array-equalindromic/", + "title": "Minimum Cost to Make Array Equalindromic" }, "2968": { - "id": 2968, "category": "Sliding Window", - "title": "Apply Operations to Maximize Frequency Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/apply-operations-to-maximize-frequency-score/" + "id": 2968, + "link": "https://leetcode.com/problems/apply-operations-to-maximize-frequency-score/", + "title": "Apply Operations to Maximize Frequency Score" }, "2969": { - "id": 2969, "category": "Dynamic Programming", - "title": "Minimum Number of Coins for Fruits II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-coins-for-fruits-ii/" + "id": 2969, + "link": "https://leetcode.com/problems/minimum-number-of-coins-for-fruits-ii/", + "title": "Minimum Number of Coins for Fruits II" }, "2970": { - "id": 2970, "category": "Binary Search", - "title": "Count the Number of Incremovable Subarrays I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i/" + "id": 2970, + "link": "https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i/", + "title": "Count the Number of Incremovable Subarrays I" }, "2971": { - "id": 2971, "category": "Greedy", - "title": "Find Polygon With the Largest Perimeter", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-polygon-with-the-largest-perimeter/" + "id": 2971, + "link": "https://leetcode.com/problems/find-polygon-with-the-largest-perimeter/", + "title": "Find Polygon With the Largest Perimeter" }, "2972": { - "id": 2972, "category": "Binary Search", - "title": "Count the Number of Incremovable Subarrays II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-ii/" + "id": 2972, + "link": "https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-ii/", + "title": "Count the Number of Incremovable Subarrays II" }, "2973": { - "id": 2973, "category": "Tree", - "title": "Find Number of Coins to Place in Tree Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-number-of-coins-to-place-in-tree-nodes/" + "id": 2973, + "link": "https://leetcode.com/problems/find-number-of-coins-to-place-in-tree-nodes/", + "title": "Find Number of Coins to Place in Tree Nodes" }, "2974": { - "id": 2974, "category": "Heap (Priority Queue)", - "title": "Minimum Number Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-game/" + "id": 2974, + "link": "https://leetcode.com/problems/minimum-number-game/", + "title": "Minimum Number Game" }, "2975": { - "id": 2975, "category": "Array & Hashing", - "title": "Maximum Square Area by Removing Fences From a Field", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-square-area-by-removing-fences-from-a-field/" + "id": 2975, + "link": "https://leetcode.com/problems/maximum-square-area-by-removing-fences-from-a-field/", + "title": "Maximum Square Area by Removing Fences From a Field" }, "2976": { - "id": 2976, "category": "Graph Traversal", - "title": "Minimum Cost to Convert String I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-i/" + "id": 2976, + "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-i/", + "title": "Minimum Cost to Convert String I" }, "2977": { - "id": 2977, "category": "Graph Traversal", - "title": "Minimum Cost to Convert String II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-ii/" + "id": 2977, + "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-ii/", + "title": "Minimum Cost to Convert String II" }, "2978": { - "id": 2978, "category": "Database", - "title": "Symmetric Coordinates", "difficulty": "Medium", - "link": "https://leetcode.com/problems/symmetric-coordinates/" + "id": 2978, + "link": "https://leetcode.com/problems/symmetric-coordinates/", + "title": "Symmetric Coordinates" }, "2979": { - "id": 2979, "category": "Dynamic Programming", - "title": "Most Expensive Item That Can Not Be Bought", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-expensive-item-that-can-not-be-bought/" + "id": 2979, + "link": "https://leetcode.com/problems/most-expensive-item-that-can-not-be-bought/", + "title": "Most Expensive Item That Can Not Be Bought" }, "2980": { - "id": 2980, "category": "Bit Manipulation", - "title": "Check if Bitwise OR Has Trailing Zeros", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-bitwise-or-has-trailing-zeros/" + "id": 2980, + "link": "https://leetcode.com/problems/check-if-bitwise-or-has-trailing-zeros/", + "title": "Check if Bitwise OR Has Trailing Zeros" }, "2981": { - "id": 2981, "category": "Sliding Window", - "title": "Find Longest Special Substring That Occurs Thrice I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-i/" + "id": 2981, + "link": "https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-i/", + "title": "Find Longest Special Substring That Occurs Thrice I" }, "2982": { - "id": 2982, "category": "Sliding Window", - "title": "Find Longest Special Substring That Occurs Thrice II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-ii/" + "id": 2982, + "link": "https://leetcode.com/problems/find-longest-special-substring-that-occurs-thrice-ii/", + "title": "Find Longest Special Substring That Occurs Thrice II" }, "2983": { - "id": 2983, "category": "Array & Hashing", - "title": "Palindrome Rearrangement Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/palindrome-rearrangement-queries/" + "id": 2983, + "link": "https://leetcode.com/problems/palindrome-rearrangement-queries/", + "title": "Palindrome Rearrangement Queries" }, "2984": { - "id": 2984, "category": "Database", - "title": "Find Peak Calling Hours for Each City", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-peak-calling-hours-for-each-city/" + "id": 2984, + "link": "https://leetcode.com/problems/find-peak-calling-hours-for-each-city/", + "title": "Find Peak Calling Hours for Each City" }, "2985": { - "id": 2985, "category": "Database", - "title": "Calculate Compressed Mean", "difficulty": "Easy", - "link": "https://leetcode.com/problems/calculate-compressed-mean/" + "id": 2985, + "link": "https://leetcode.com/problems/calculate-compressed-mean/", + "title": "Calculate Compressed Mean" }, "2986": { - "id": 2986, "category": "Database", - "title": "Find Third Transaction", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-third-transaction/" + "id": 2986, + "link": "https://leetcode.com/problems/find-third-transaction/", + "title": "Find Third Transaction" }, "2987": { - "id": 2987, "category": "Database", - "title": "Find Expensive Cities", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-expensive-cities/" + "id": 2987, + "link": "https://leetcode.com/problems/find-expensive-cities/", + "title": "Find Expensive Cities" }, "2988": { - "id": 2988, "category": "Database", - "title": "Manager of the Largest Department", "difficulty": "Medium", - "link": "https://leetcode.com/problems/manager-of-the-largest-department/" + "id": 2988, + "link": "https://leetcode.com/problems/manager-of-the-largest-department/", + "title": "Manager of the Largest Department" }, "2989": { - "id": 2989, "category": "Database", - "title": "Class Performance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/class-performance/" - }, - "2990": { - "id": 2990, - "category": "Database", - "title": "Loan Types", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/loan-types/" + "id": 2989, + "link": "https://leetcode.com/problems/class-performance/", + "title": "Class Performance" }, + "2990": {"category": "Database", "difficulty": "Easy", "id": 2990, "link": "https://leetcode.com/problems/loan-types/", "title": "Loan Types"}, "2991": { - "id": 2991, "category": "Database", - "title": "Top Three Wineries ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/top-three-wineries/" + "id": 2991, + "link": "https://leetcode.com/problems/top-three-wineries/", + "title": "Top Three Wineries " }, "2992": { - "id": 2992, "category": "Dynamic Programming", - "title": "Number of Self-Divisible Permutations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-self-divisible-permutations/" + "id": 2992, + "link": "https://leetcode.com/problems/number-of-self-divisible-permutations/", + "title": "Number of Self-Divisible Permutations" }, "2993": { - "id": 2993, "category": "Database", - "title": "Friday Purchases I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/friday-purchases-i/" + "id": 2993, + "link": "https://leetcode.com/problems/friday-purchases-i/", + "title": "Friday Purchases I" }, "2994": { - "id": 2994, "category": "Database", - "title": "Friday Purchases II ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/friday-purchases-ii/" + "id": 2994, + "link": "https://leetcode.com/problems/friday-purchases-ii/", + "title": "Friday Purchases II " }, "2995": { - "id": 2995, "category": "Database", - "title": "Viewers Turned Streamers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/viewers-turned-streamers/" + "id": 2995, + "link": "https://leetcode.com/problems/viewers-turned-streamers/", + "title": "Viewers Turned Streamers" }, "2996": { - "id": 2996, "category": "Array & Hashing", - "title": "Smallest Missing Integer Greater Than Sequential Prefix Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-missing-integer-greater-than-sequential-prefix-sum/" + "id": 2996, + "link": "https://leetcode.com/problems/smallest-missing-integer-greater-than-sequential-prefix-sum/", + "title": "Smallest Missing Integer Greater Than Sequential Prefix Sum" }, "2997": { - "id": 2997, "category": "Bit Manipulation", - "title": "Minimum Number of Operations to Make Array XOR Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-xor-equal-to-k/" + "id": 2997, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-array-xor-equal-to-k/", + "title": "Minimum Number of Operations to Make Array XOR Equal to K" }, "2998": { - "id": 2998, "category": "Graph Traversal", - "title": "Minimum Number of Operations to Make X and Y Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-x-and-y-equal/" + "id": 2998, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-x-and-y-equal/", + "title": "Minimum Number of Operations to Make X and Y Equal" }, "2999": { - "id": 2999, "category": "Dynamic Programming", - "title": "Count the Number of Powerful Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-powerful-integers/" + "id": 2999, + "link": "https://leetcode.com/problems/count-the-number-of-powerful-integers/", + "title": "Count the Number of Powerful Integers" }, "3000": { - "id": 3000, "category": "Array & Hashing", - "title": "Maximum Area of Longest Diagonal Rectangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle/" + "id": 3000, + "link": "https://leetcode.com/problems/maximum-area-of-longest-diagonal-rectangle/", + "title": "Maximum Area of Longest Diagonal Rectangle" }, "3001": { - "id": 3001, "category": "Math & Geometry", - "title": "Minimum Moves to Capture The Queen", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-capture-the-queen/" + "id": 3001, + "link": "https://leetcode.com/problems/minimum-moves-to-capture-the-queen/", + "title": "Minimum Moves to Capture The Queen" }, "3002": { - "id": 3002, "category": "Greedy", - "title": "Maximum Size of a Set After Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-size-of-a-set-after-removals/" + "id": 3002, + "link": "https://leetcode.com/problems/maximum-size-of-a-set-after-removals/", + "title": "Maximum Size of a Set After Removals" }, "3003": { - "id": 3003, "category": "Dynamic Programming", - "title": "Maximize the Number of Partitions After Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-number-of-partitions-after-operations/" + "id": 3003, + "link": "https://leetcode.com/problems/maximize-the-number-of-partitions-after-operations/", + "title": "Maximize the Number of Partitions After Operations" }, "3004": { - "id": 3004, "category": "Tree", - "title": "Maximum Subtree of the Same Color", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subtree-of-the-same-color/" + "id": 3004, + "link": "https://leetcode.com/problems/maximum-subtree-of-the-same-color/", + "title": "Maximum Subtree of the Same Color" }, "3005": { - "id": 3005, "category": "Array & Hashing", - "title": "Count Elements With Maximum Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-elements-with-maximum-frequency/" + "id": 3005, + "link": "https://leetcode.com/problems/count-elements-with-maximum-frequency/", + "title": "Count Elements With Maximum Frequency" }, "3006": { - "id": 3006, "category": "Binary Search", - "title": "Find Beautiful Indices in the Given Array I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/" + "id": 3006, + "link": "https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/", + "title": "Find Beautiful Indices in the Given Array I" }, "3007": { - "id": 3007, "category": "Dynamic Programming", - "title": "Maximum Number That Sum of the Prices Is Less Than or Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k/" + "id": 3007, + "link": "https://leetcode.com/problems/maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k/", + "title": "Maximum Number That Sum of the Prices Is Less Than or Equal to K" }, "3008": { - "id": 3008, "category": "Binary Search", - "title": "Find Beautiful Indices in the Given Array II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-ii/" + "id": 3008, + "link": "https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-ii/", + "title": "Find Beautiful Indices in the Given Array II" }, "3009": { - "id": 3009, "category": "Tree", - "title": "Maximum Number of Intersections on the Chart", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-intersections-on-the-chart/" + "id": 3009, + "link": "https://leetcode.com/problems/maximum-number-of-intersections-on-the-chart/", + "title": "Maximum Number of Intersections on the Chart" }, "3010": { - "id": 3010, "category": "Array & Hashing", - "title": "Divide an Array Into Subarrays With Minimum Cost I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/" + "id": 3010, + "link": "https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/", + "title": "Divide an Array Into Subarrays With Minimum Cost I" }, "3011": { - "id": 3011, "category": "Bit Manipulation", - "title": "Find if Array Can Be Sorted", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-if-array-can-be-sorted/" + "id": 3011, + "link": "https://leetcode.com/problems/find-if-array-can-be-sorted/", + "title": "Find if Array Can Be Sorted" }, "3012": { - "id": 3012, "category": "Greedy", - "title": "Minimize Length of Array Using Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-length-of-array-using-operations/" + "id": 3012, + "link": "https://leetcode.com/problems/minimize-length-of-array-using-operations/", + "title": "Minimize Length of Array Using Operations" }, "3013": { - "id": 3013, "category": "Sliding Window", - "title": "Divide an Array Into Subarrays With Minimum Cost II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-ii/" + "id": 3013, + "link": "https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-ii/", + "title": "Divide an Array Into Subarrays With Minimum Cost II" }, "3014": { - "id": 3014, "category": "Greedy", - "title": "Minimum Number of Pushes to Type Word I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i/" + "id": 3014, + "link": "https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i/", + "title": "Minimum Number of Pushes to Type Word I" }, "3015": { - "id": 3015, "category": "Graph Traversal", - "title": "Count the Number of Houses at a Certain Distance I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-i/" + "id": 3015, + "link": "https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-i/", + "title": "Count the Number of Houses at a Certain Distance I" }, "3016": { - "id": 3016, "category": "Greedy", - "title": "Minimum Number of Pushes to Type Word II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii/" + "id": 3016, + "link": "https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii/", + "title": "Minimum Number of Pushes to Type Word II" }, "3017": { - "id": 3017, "category": "Graph Traversal", - "title": "Count the Number of Houses at a Certain Distance II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-ii/" + "id": 3017, + "link": "https://leetcode.com/problems/count-the-number-of-houses-at-a-certain-distance-ii/", + "title": "Count the Number of Houses at a Certain Distance II" }, "3018": { - "id": 3018, "category": "Dynamic Programming", - "title": "Maximum Number of Removal Queries That Can Be Processed I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-removal-queries-that-can-be-processed-i/" + "id": 3018, + "link": "https://leetcode.com/problems/maximum-number-of-removal-queries-that-can-be-processed-i/", + "title": "Maximum Number of Removal Queries That Can Be Processed I" }, "3019": { - "id": 3019, "category": "Array & Hashing", - "title": "Number of Changing Keys", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-changing-keys/" + "id": 3019, + "link": "https://leetcode.com/problems/number-of-changing-keys/", + "title": "Number of Changing Keys" }, "3020": { - "id": 3020, "category": "Array & Hashing", - "title": "Find the Maximum Number of Elements in Subset", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/" + "id": 3020, + "link": "https://leetcode.com/problems/find-the-maximum-number-of-elements-in-subset/", + "title": "Find the Maximum Number of Elements in Subset" }, "3021": { - "id": 3021, "category": "Math & Geometry", - "title": "Alice and Bob Playing Flower Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/alice-and-bob-playing-flower-game/" + "id": 3021, + "link": "https://leetcode.com/problems/alice-and-bob-playing-flower-game/", + "title": "Alice and Bob Playing Flower Game" }, "3022": { - "id": 3022, "category": "Bit Manipulation", - "title": "Minimize OR of Remaining Elements Using Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-or-of-remaining-elements-using-operations/" + "id": 3022, + "link": "https://leetcode.com/problems/minimize-or-of-remaining-elements-using-operations/", + "title": "Minimize OR of Remaining Elements Using Operations" }, "3023": { - "id": 3023, "category": "Sliding Window", - "title": "Find Pattern in Infinite Stream I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-pattern-in-infinite-stream-i/" + "id": 3023, + "link": "https://leetcode.com/problems/find-pattern-in-infinite-stream-i/", + "title": "Find Pattern in Infinite Stream I" }, "3024": { - "id": 3024, "category": "Math & Geometry", - "title": "Type of Triangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/type-of-triangle/" + "id": 3024, + "link": "https://leetcode.com/problems/type-of-triangle/", + "title": "Type of Triangle" }, "3025": { - "id": 3025, "category": "Math & Geometry", - "title": "Find the Number of Ways to Place People I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-number-of-ways-to-place-people-i/" + "id": 3025, + "link": "https://leetcode.com/problems/find-the-number-of-ways-to-place-people-i/", + "title": "Find the Number of Ways to Place People I" }, "3026": { - "id": 3026, "category": "Array & Hashing", - "title": "Maximum Good Subarray Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-good-subarray-sum/" + "id": 3026, + "link": "https://leetcode.com/problems/maximum-good-subarray-sum/", + "title": "Maximum Good Subarray Sum" }, "3027": { - "id": 3027, "category": "Math & Geometry", - "title": "Find the Number of Ways to Place People II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-number-of-ways-to-place-people-ii/" + "id": 3027, + "link": "https://leetcode.com/problems/find-the-number-of-ways-to-place-people-ii/", + "title": "Find the Number of Ways to Place People II" }, "3028": { - "id": 3028, "category": "Array & Hashing", - "title": "Ant on the Boundary", "difficulty": "Easy", - "link": "https://leetcode.com/problems/ant-on-the-boundary/" + "id": 3028, + "link": "https://leetcode.com/problems/ant-on-the-boundary/", + "title": "Ant on the Boundary" }, "3029": { - "id": 3029, "category": "Array & Hashing", - "title": "Minimum Time to Revert Word to Initial State I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-i/" + "id": 3029, + "link": "https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-i/", + "title": "Minimum Time to Revert Word to Initial State I" }, "3030": { - "id": 3030, "category": "Array & Hashing", - "title": "Find the Grid of Region Average", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-grid-of-region-average/" + "id": 3030, + "link": "https://leetcode.com/problems/find-the-grid-of-region-average/", + "title": "Find the Grid of Region Average" }, "3031": { - "id": 3031, "category": "Array & Hashing", - "title": "Minimum Time to Revert Word to Initial State II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-ii/" + "id": 3031, + "link": "https://leetcode.com/problems/minimum-time-to-revert-word-to-initial-state-ii/", + "title": "Minimum Time to Revert Word to Initial State II" }, "3032": { - "id": 3032, "category": "Dynamic Programming", - "title": "Count Numbers With Unique Digits II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-numbers-with-unique-digits-ii/" + "id": 3032, + "link": "https://leetcode.com/problems/count-numbers-with-unique-digits-ii/", + "title": "Count Numbers With Unique Digits II" }, "3033": { - "id": 3033, "category": "Array & Hashing", - "title": "Modify the Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/modify-the-matrix/" + "id": 3033, + "link": "https://leetcode.com/problems/modify-the-matrix/", + "title": "Modify the Matrix" }, "3034": { - "id": 3034, "category": "Array & Hashing", - "title": "Number of Subarrays That Match a Pattern I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-i/" + "id": 3034, + "link": "https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-i/", + "title": "Number of Subarrays That Match a Pattern I" }, "3035": { - "id": 3035, "category": "Greedy", - "title": "Maximum Palindromes After Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-palindromes-after-operations/" + "id": 3035, + "link": "https://leetcode.com/problems/maximum-palindromes-after-operations/", + "title": "Maximum Palindromes After Operations" }, "3036": { - "id": 3036, "category": "Array & Hashing", - "title": "Number of Subarrays That Match a Pattern II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-ii/" + "id": 3036, + "link": "https://leetcode.com/problems/number-of-subarrays-that-match-a-pattern-ii/", + "title": "Number of Subarrays That Match a Pattern II" }, "3037": { - "id": 3037, "category": "Sliding Window", - "title": "Find Pattern in Infinite Stream II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-pattern-in-infinite-stream-ii/" + "id": 3037, + "link": "https://leetcode.com/problems/find-pattern-in-infinite-stream-ii/", + "title": "Find Pattern in Infinite Stream II" }, "3038": { - "id": 3038, "category": "Array & Hashing", - "title": "Maximum Number of Operations With the Same Score I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/" + "id": 3038, + "link": "https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/", + "title": "Maximum Number of Operations With the Same Score I" }, "3039": { - "id": 3039, "category": "Array & Hashing", - "title": "Apply Operations to Make String Empty", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-operations-to-make-string-empty/" + "id": 3039, + "link": "https://leetcode.com/problems/apply-operations-to-make-string-empty/", + "title": "Apply Operations to Make String Empty" }, "3040": { - "id": 3040, "category": "Dynamic Programming", - "title": "Maximum Number of Operations With the Same Score II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-ii/" + "id": 3040, + "link": "https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-ii/", + "title": "Maximum Number of Operations With the Same Score II" }, "3041": { - "id": 3041, "category": "Dynamic Programming", - "title": "Maximize Consecutive Elements in an Array After Modification", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-consecutive-elements-in-an-array-after-modification/" + "id": 3041, + "link": "https://leetcode.com/problems/maximize-consecutive-elements-in-an-array-after-modification/", + "title": "Maximize Consecutive Elements in an Array After Modification" }, "3042": { - "id": 3042, "category": "Trie", - "title": "Count Prefix and Suffix Pairs I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/" + "id": 3042, + "link": "https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/", + "title": "Count Prefix and Suffix Pairs I" }, "3043": { - "id": 3043, "category": "Trie", - "title": "Find the Length of the Longest Common Prefix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix/" + "id": 3043, + "link": "https://leetcode.com/problems/find-the-length-of-the-longest-common-prefix/", + "title": "Find the Length of the Longest Common Prefix" }, "3044": { - "id": 3044, "category": "Math & Geometry", - "title": "Most Frequent Prime", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-frequent-prime/" + "id": 3044, + "link": "https://leetcode.com/problems/most-frequent-prime/", + "title": "Most Frequent Prime" }, "3045": { - "id": 3045, "category": "Trie", - "title": "Count Prefix and Suffix Pairs II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-prefix-and-suffix-pairs-ii/" + "id": 3045, + "link": "https://leetcode.com/problems/count-prefix-and-suffix-pairs-ii/", + "title": "Count Prefix and Suffix Pairs II" }, "3046": { - "id": 3046, "category": "Array & Hashing", - "title": "Split the Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/split-the-array/" + "id": 3046, + "link": "https://leetcode.com/problems/split-the-array/", + "title": "Split the Array" }, "3047": { - "id": 3047, "category": "Math & Geometry", - "title": "Find the Largest Area of Square Inside Two Rectangles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-largest-area-of-square-inside-two-rectangles/" + "id": 3047, + "link": "https://leetcode.com/problems/find-the-largest-area-of-square-inside-two-rectangles/", + "title": "Find the Largest Area of Square Inside Two Rectangles" }, "3048": { - "id": 3048, "category": "Binary Search", - "title": "Earliest Second to Mark Indices I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/earliest-second-to-mark-indices-i/" + "id": 3048, + "link": "https://leetcode.com/problems/earliest-second-to-mark-indices-i/", + "title": "Earliest Second to Mark Indices I" }, "3049": { - "id": 3049, "category": "Binary Search", - "title": "Earliest Second to Mark Indices II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/earliest-second-to-mark-indices-ii/" + "id": 3049, + "link": "https://leetcode.com/problems/earliest-second-to-mark-indices-ii/", + "title": "Earliest Second to Mark Indices II" }, "3050": { - "id": 3050, "category": "Database", - "title": "Pizza Toppings Cost Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/pizza-toppings-cost-analysis/" + "id": 3050, + "link": "https://leetcode.com/problems/pizza-toppings-cost-analysis/", + "title": "Pizza Toppings Cost Analysis" }, "3051": { - "id": 3051, "category": "Database", - "title": "Find Candidates for Data Scientist Position", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-candidates-for-data-scientist-position/" + "id": 3051, + "link": "https://leetcode.com/problems/find-candidates-for-data-scientist-position/", + "title": "Find Candidates for Data Scientist Position" }, "3052": { - "id": 3052, "category": "Database", - "title": "Maximize Items", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-items/" + "id": 3052, + "link": "https://leetcode.com/problems/maximize-items/", + "title": "Maximize Items" }, "3053": { - "id": 3053, "category": "Database", - "title": "Classifying Triangles by Lengths", "difficulty": "Easy", - "link": "https://leetcode.com/problems/classifying-triangles-by-lengths/" + "id": 3053, + "link": "https://leetcode.com/problems/classifying-triangles-by-lengths/", + "title": "Classifying Triangles by Lengths" }, "3054": { - "id": 3054, "category": "Database", - "title": "Binary Tree Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/binary-tree-nodes/" + "id": 3054, + "link": "https://leetcode.com/problems/binary-tree-nodes/", + "title": "Binary Tree Nodes" }, "3055": { - "id": 3055, "category": "Database", - "title": "Top Percentile Fraud", "difficulty": "Medium", - "link": "https://leetcode.com/problems/top-percentile-fraud/" + "id": 3055, + "link": "https://leetcode.com/problems/top-percentile-fraud/", + "title": "Top Percentile Fraud" }, "3056": { - "id": 3056, "category": "Database", - "title": "Snaps Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/snaps-analysis/" + "id": 3056, + "link": "https://leetcode.com/problems/snaps-analysis/", + "title": "Snaps Analysis" }, "3057": { - "id": 3057, "category": "Database", - "title": "Employees Project Allocation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/employees-project-allocation/" + "id": 3057, + "link": "https://leetcode.com/problems/employees-project-allocation/", + "title": "Employees Project Allocation" }, "3058": { - "id": 3058, "category": "Database", - "title": "Friends With No Mutual Friends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/friends-with-no-mutual-friends/" + "id": 3058, + "link": "https://leetcode.com/problems/friends-with-no-mutual-friends/", + "title": "Friends With No Mutual Friends" }, "3059": { - "id": 3059, "category": "Database", - "title": "Find All Unique Email Domains", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-all-unique-email-domains/" + "id": 3059, + "link": "https://leetcode.com/problems/find-all-unique-email-domains/", + "title": "Find All Unique Email Domains" }, "3060": { - "id": 3060, "category": "Database", - "title": "User Activities within Time Bounds", "difficulty": "Hard", - "link": "https://leetcode.com/problems/user-activities-within-time-bounds/" + "id": 3060, + "link": "https://leetcode.com/problems/user-activities-within-time-bounds/", + "title": "User Activities within Time Bounds" }, "3061": { - "id": 3061, "category": "Database", - "title": "Calculate Trapping Rain Water", "difficulty": "Hard", - "link": "https://leetcode.com/problems/calculate-trapping-rain-water/" + "id": 3061, + "link": "https://leetcode.com/problems/calculate-trapping-rain-water/", + "title": "Calculate Trapping Rain Water" }, "3062": { - "id": 3062, "category": "Linked List", - "title": "Winner of the Linked List Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/winner-of-the-linked-list-game/" + "id": 3062, + "link": "https://leetcode.com/problems/winner-of-the-linked-list-game/", + "title": "Winner of the Linked List Game" }, "3063": { - "id": 3063, "category": "Linked List", - "title": "Linked List Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/linked-list-frequency/" + "id": 3063, + "link": "https://leetcode.com/problems/linked-list-frequency/", + "title": "Linked List Frequency" }, "3064": { - "id": 3064, "category": "Bit Manipulation", - "title": "Guess the Number Using Bitwise Questions I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/guess-the-number-using-bitwise-questions-i/" + "id": 3064, + "link": "https://leetcode.com/problems/guess-the-number-using-bitwise-questions-i/", + "title": "Guess the Number Using Bitwise Questions I" }, "3065": { - "id": 3065, "category": "Array & Hashing", - "title": "Minimum Operations to Exceed Threshold Value I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/" + "id": 3065, + "link": "https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-i/", + "title": "Minimum Operations to Exceed Threshold Value I" }, "3066": { - "id": 3066, "category": "Heap (Priority Queue)", - "title": "Minimum Operations to Exceed Threshold Value II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/" + "id": 3066, + "link": "https://leetcode.com/problems/minimum-operations-to-exceed-threshold-value-ii/", + "title": "Minimum Operations to Exceed Threshold Value II" }, "3067": { - "id": 3067, "category": "Tree", - "title": "Count Pairs of Connectable Servers in a Weighted Tree Network", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-pairs-of-connectable-servers-in-a-weighted-tree-network/" + "id": 3067, + "link": "https://leetcode.com/problems/count-pairs-of-connectable-servers-in-a-weighted-tree-network/", + "title": "Count Pairs of Connectable Servers in a Weighted Tree Network" }, "3068": { - "id": 3068, "category": "Tree", - "title": "Find the Maximum Sum of Node Values", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-maximum-sum-of-node-values/" + "id": 3068, + "link": "https://leetcode.com/problems/find-the-maximum-sum-of-node-values/", + "title": "Find the Maximum Sum of Node Values" }, "3069": { - "id": 3069, "category": "Array & Hashing", - "title": "Distribute Elements Into Two Arrays I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/distribute-elements-into-two-arrays-i/" + "id": 3069, + "link": "https://leetcode.com/problems/distribute-elements-into-two-arrays-i/", + "title": "Distribute Elements Into Two Arrays I" }, "3070": { - "id": 3070, "category": "Array & Hashing", - "title": "Count Submatrices with Top-Left Element and Sum Less Than k", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-submatrices-with-top-left-element-and-sum-less-than-k/" + "id": 3070, + "link": "https://leetcode.com/problems/count-submatrices-with-top-left-element-and-sum-less-than-k/", + "title": "Count Submatrices with Top-Left Element and Sum Less Than k" }, "3071": { - "id": 3071, "category": "Array & Hashing", - "title": "Minimum Operations to Write the Letter Y on a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-write-the-letter-y-on-a-grid/" + "id": 3071, + "link": "https://leetcode.com/problems/minimum-operations-to-write-the-letter-y-on-a-grid/", + "title": "Minimum Operations to Write the Letter Y on a Grid" }, "3072": { - "id": 3072, "category": "Tree", - "title": "Distribute Elements Into Two Arrays II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/distribute-elements-into-two-arrays-ii/" + "id": 3072, + "link": "https://leetcode.com/problems/distribute-elements-into-two-arrays-ii/", + "title": "Distribute Elements Into Two Arrays II" }, "3073": { - "id": 3073, "category": "Array & Hashing", - "title": "Maximum Increasing Triplet Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-increasing-triplet-value/" + "id": 3073, + "link": "https://leetcode.com/problems/maximum-increasing-triplet-value/", + "title": "Maximum Increasing Triplet Value" }, "3074": { - "id": 3074, "category": "Greedy", - "title": "Apple Redistribution into Boxes", "difficulty": "Easy", - "link": "https://leetcode.com/problems/apple-redistribution-into-boxes/" + "id": 3074, + "link": "https://leetcode.com/problems/apple-redistribution-into-boxes/", + "title": "Apple Redistribution into Boxes" }, "3075": { - "id": 3075, "category": "Greedy", - "title": "Maximize Happiness of Selected Children", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-happiness-of-selected-children/" + "id": 3075, + "link": "https://leetcode.com/problems/maximize-happiness-of-selected-children/", + "title": "Maximize Happiness of Selected Children" }, "3076": { - "id": 3076, "category": "Trie", - "title": "Shortest Uncommon Substring in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-uncommon-substring-in-an-array/" + "id": 3076, + "link": "https://leetcode.com/problems/shortest-uncommon-substring-in-an-array/", + "title": "Shortest Uncommon Substring in an Array" }, "3077": { - "id": 3077, "category": "Dynamic Programming", - "title": "Maximum Strength of K Disjoint Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-strength-of-k-disjoint-subarrays/" + "id": 3077, + "link": "https://leetcode.com/problems/maximum-strength-of-k-disjoint-subarrays/", + "title": "Maximum Strength of K Disjoint Subarrays" }, "3078": { - "id": 3078, "category": "Array & Hashing", - "title": "Match Alphanumerical Pattern in Matrix I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/match-alphanumerical-pattern-in-matrix-i/" + "id": 3078, + "link": "https://leetcode.com/problems/match-alphanumerical-pattern-in-matrix-i/", + "title": "Match Alphanumerical Pattern in Matrix I" }, "3079": { - "id": 3079, "category": "Math & Geometry", - "title": "Find the Sum of Encrypted Integers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-sum-of-encrypted-integers/" + "id": 3079, + "link": "https://leetcode.com/problems/find-the-sum-of-encrypted-integers/", + "title": "Find the Sum of Encrypted Integers" }, "3080": { - "id": 3080, "category": "Heap (Priority Queue)", - "title": "Mark Elements on Array by Performing Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/" + "id": 3080, + "link": "https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/", + "title": "Mark Elements on Array by Performing Queries" }, "3081": { - "id": 3081, "category": "Heap (Priority Queue)", - "title": "Replace Question Marks in String to Minimize Its Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/replace-question-marks-in-string-to-minimize-its-value/" + "id": 3081, + "link": "https://leetcode.com/problems/replace-question-marks-in-string-to-minimize-its-value/", + "title": "Replace Question Marks in String to Minimize Its Value" }, "3082": { - "id": 3082, "category": "Dynamic Programming", - "title": "Find the Sum of the Power of All Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-sum-of-the-power-of-all-subsequences/" + "id": 3082, + "link": "https://leetcode.com/problems/find-the-sum-of-the-power-of-all-subsequences/", + "title": "Find the Sum of the Power of All Subsequences" }, "3083": { - "id": 3083, "category": "Array & Hashing", - "title": "Existence of a Substring in a String and Its Reverse", "difficulty": "Easy", - "link": "https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/" + "id": 3083, + "link": "https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/", + "title": "Existence of a Substring in a String and Its Reverse" }, "3084": { - "id": 3084, "category": "Math & Geometry", - "title": "Count Substrings Starting and Ending with Given Character", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-substrings-starting-and-ending-with-given-character/" + "id": 3084, + "link": "https://leetcode.com/problems/count-substrings-starting-and-ending-with-given-character/", + "title": "Count Substrings Starting and Ending with Given Character" }, "3085": { - "id": 3085, "category": "Greedy", - "title": "Minimum Deletions to Make String K-Special", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/" + "id": 3085, + "link": "https://leetcode.com/problems/minimum-deletions-to-make-string-k-special/", + "title": "Minimum Deletions to Make String K-Special" }, "3086": { - "id": 3086, "category": "Sliding Window", - "title": "Minimum Moves to Pick K Ones", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-moves-to-pick-k-ones/" + "id": 3086, + "link": "https://leetcode.com/problems/minimum-moves-to-pick-k-ones/", + "title": "Minimum Moves to Pick K Ones" }, "3087": { - "id": 3087, "category": "Database", - "title": "Find Trending Hashtags", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-trending-hashtags/" + "id": 3087, + "link": "https://leetcode.com/problems/find-trending-hashtags/", + "title": "Find Trending Hashtags" }, "3088": { - "id": 3088, "category": "Greedy", - "title": "Make String Anti-palindrome", "difficulty": "Hard", - "link": "https://leetcode.com/problems/make-string-anti-palindrome/" + "id": 3088, + "link": "https://leetcode.com/problems/make-string-anti-palindrome/", + "title": "Make String Anti-palindrome" }, "3089": { - "id": 3089, "category": "Database", - "title": "Find Bursty Behavior", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-bursty-behavior/" + "id": 3089, + "link": "https://leetcode.com/problems/find-bursty-behavior/", + "title": "Find Bursty Behavior" }, "3090": { - "id": 3090, "category": "Sliding Window", - "title": "Maximum Length Substring With Two Occurrences", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/" + "id": 3090, + "link": "https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/", + "title": "Maximum Length Substring With Two Occurrences" }, "3091": { - "id": 3091, "category": "Greedy", - "title": "Apply Operations to Make Sum of Array Greater Than or Equal to k", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k/" + "id": 3091, + "link": "https://leetcode.com/problems/apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k/", + "title": "Apply Operations to Make Sum of Array Greater Than or Equal to k" }, "3092": { - "id": 3092, "category": "Heap (Priority Queue)", - "title": "Most Frequent IDs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/most-frequent-ids/" + "id": 3092, + "link": "https://leetcode.com/problems/most-frequent-ids/", + "title": "Most Frequent IDs" }, "3093": { - "id": 3093, "category": "Trie", - "title": "Longest Common Suffix Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-common-suffix-queries/" + "id": 3093, + "link": "https://leetcode.com/problems/longest-common-suffix-queries/", + "title": "Longest Common Suffix Queries" }, "3094": { - "id": 3094, "category": "Bit Manipulation", - "title": "Guess the Number Using Bitwise Questions II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/guess-the-number-using-bitwise-questions-ii/" + "id": 3094, + "link": "https://leetcode.com/problems/guess-the-number-using-bitwise-questions-ii/", + "title": "Guess the Number Using Bitwise Questions II" }, "3095": { - "id": 3095, "category": "Sliding Window", - "title": "Shortest Subarray With OR at Least K I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-i/" + "id": 3095, + "link": "https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-i/", + "title": "Shortest Subarray With OR at Least K I" }, "3096": { - "id": 3096, "category": "Array & Hashing", - "title": "Minimum Levels to Gain More Points", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-levels-to-gain-more-points/" + "id": 3096, + "link": "https://leetcode.com/problems/minimum-levels-to-gain-more-points/", + "title": "Minimum Levels to Gain More Points" }, "3097": { - "id": 3097, "category": "Sliding Window", - "title": "Shortest Subarray With OR at Least K II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-ii/" + "id": 3097, + "link": "https://leetcode.com/problems/shortest-subarray-with-or-at-least-k-ii/", + "title": "Shortest Subarray With OR at Least K II" }, "3098": { - "id": 3098, "category": "Dynamic Programming", - "title": "Find the Sum of Subsequence Powers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-sum-of-subsequence-powers/" + "id": 3098, + "link": "https://leetcode.com/problems/find-the-sum-of-subsequence-powers/", + "title": "Find the Sum of Subsequence Powers" }, "3099": { - "id": 3099, "category": "Math & Geometry", - "title": "Harshad Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/harshad-number/" + "id": 3099, + "link": "https://leetcode.com/problems/harshad-number/", + "title": "Harshad Number" }, "3100": { - "id": 3100, "category": "Math & Geometry", - "title": "Water Bottles II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/water-bottles-ii/" + "id": 3100, + "link": "https://leetcode.com/problems/water-bottles-ii/", + "title": "Water Bottles II" }, "3101": { - "id": 3101, "category": "Math & Geometry", - "title": "Count Alternating Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-alternating-subarrays/" + "id": 3101, + "link": "https://leetcode.com/problems/count-alternating-subarrays/", + "title": "Count Alternating Subarrays" }, "3102": { - "id": 3102, "category": "Math & Geometry", - "title": "Minimize Manhattan Distances", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-manhattan-distances/" + "id": 3102, + "link": "https://leetcode.com/problems/minimize-manhattan-distances/", + "title": "Minimize Manhattan Distances" }, "3103": { - "id": 3103, "category": "Database", - "title": "Find Trending Hashtags II ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-trending-hashtags-ii/" + "id": 3103, + "link": "https://leetcode.com/problems/find-trending-hashtags-ii/", + "title": "Find Trending Hashtags II " }, "3104": { - "id": 3104, "category": "Binary Search", - "title": "Find Longest Self-Contained Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-longest-self-contained-substring/" + "id": 3104, + "link": "https://leetcode.com/problems/find-longest-self-contained-substring/", + "title": "Find Longest Self-Contained Substring" }, "3105": { - "id": 3105, "category": "Array & Hashing", - "title": "Longest Strictly Increasing or Strictly Decreasing Subarray", "difficulty": "Easy", - "link": "https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/" + "id": 3105, + "link": "https://leetcode.com/problems/longest-strictly-increasing-or-strictly-decreasing-subarray/", + "title": "Longest Strictly Increasing or Strictly Decreasing Subarray" }, "3106": { - "id": 3106, "category": "Greedy", - "title": "Lexicographically Smallest String After Operations With Constraint", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-operations-with-constraint/" + "id": 3106, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-operations-with-constraint/", + "title": "Lexicographically Smallest String After Operations With Constraint" }, "3107": { - "id": 3107, "category": "Greedy", - "title": "Minimum Operations to Make Median of Array Equal to K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-median-of-array-equal-to-k/" + "id": 3107, + "link": "https://leetcode.com/problems/minimum-operations-to-make-median-of-array-equal-to-k/", + "title": "Minimum Operations to Make Median of Array Equal to K" }, "3108": { - "id": 3108, "category": "Graph Traversal", - "title": "Minimum Cost Walk in Weighted Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-walk-in-weighted-graph/" + "id": 3108, + "link": "https://leetcode.com/problems/minimum-cost-walk-in-weighted-graph/", + "title": "Minimum Cost Walk in Weighted Graph" }, "3109": { - "id": 3109, "category": "Tree", - "title": "Find the Index of Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-index-of-permutation/" + "id": 3109, + "link": "https://leetcode.com/problems/find-the-index-of-permutation/", + "title": "Find the Index of Permutation" }, "3110": { - "id": 3110, "category": "Array & Hashing", - "title": "Score of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/score-of-a-string/" + "id": 3110, + "link": "https://leetcode.com/problems/score-of-a-string/", + "title": "Score of a String" }, "3111": { - "id": 3111, "category": "Greedy", - "title": "Minimum Rectangles to Cover Points", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-rectangles-to-cover-points/" + "id": 3111, + "link": "https://leetcode.com/problems/minimum-rectangles-to-cover-points/", + "title": "Minimum Rectangles to Cover Points" }, "3112": { - "id": 3112, "category": "Graph Traversal", - "title": "Minimum Time to Visit Disappearing Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-visit-disappearing-nodes/" + "id": 3112, + "link": "https://leetcode.com/problems/minimum-time-to-visit-disappearing-nodes/", + "title": "Minimum Time to Visit Disappearing Nodes" }, "3113": { - "id": 3113, "category": "Binary Search", - "title": "Find the Number of Subarrays Where Boundary Elements Are Maximum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-number-of-subarrays-where-boundary-elements-are-maximum/" + "id": 3113, + "link": "https://leetcode.com/problems/find-the-number-of-subarrays-where-boundary-elements-are-maximum/", + "title": "Find the Number of Subarrays Where Boundary Elements Are Maximum" }, "3114": { - "id": 3114, "category": "Array & Hashing", - "title": "Latest Time You Can Obtain After Replacing Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/" + "id": 3114, + "link": "https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/", + "title": "Latest Time You Can Obtain After Replacing Characters" }, "3115": { - "id": 3115, "category": "Math & Geometry", - "title": "Maximum Prime Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-prime-difference/" + "id": 3115, + "link": "https://leetcode.com/problems/maximum-prime-difference/", + "title": "Maximum Prime Difference" }, "3116": { - "id": 3116, "category": "Binary Search", - "title": "Kth Smallest Amount With Single Denomination Combination", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-smallest-amount-with-single-denomination-combination/" + "id": 3116, + "link": "https://leetcode.com/problems/kth-smallest-amount-with-single-denomination-combination/", + "title": "Kth Smallest Amount With Single Denomination Combination" }, "3117": { - "id": 3117, "category": "Tree", - "title": "Minimum Sum of Values by Dividing Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-sum-of-values-by-dividing-array/" + "id": 3117, + "link": "https://leetcode.com/problems/minimum-sum-of-values-by-dividing-array/", + "title": "Minimum Sum of Values by Dividing Array" }, "3118": { - "id": 3118, "category": "Database", - "title": "Friday Purchase III ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/friday-purchase-iii/" + "id": 3118, + "link": "https://leetcode.com/problems/friday-purchase-iii/", + "title": "Friday Purchase III " }, "3119": { - "id": 3119, "category": "Greedy", - "title": "Maximum Number of Potholes That Can Be Fixed", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-potholes-that-can-be-fixed/" + "id": 3119, + "link": "https://leetcode.com/problems/maximum-number-of-potholes-that-can-be-fixed/", + "title": "Maximum Number of Potholes That Can Be Fixed" }, "3120": { - "id": 3120, "category": "Array & Hashing", - "title": "Count the Number of Special Characters I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-the-number-of-special-characters-i/" + "id": 3120, + "link": "https://leetcode.com/problems/count-the-number-of-special-characters-i/", + "title": "Count the Number of Special Characters I" }, "3121": { - "id": 3121, "category": "Array & Hashing", - "title": "Count the Number of Special Characters II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-special-characters-ii/" + "id": 3121, + "link": "https://leetcode.com/problems/count-the-number-of-special-characters-ii/", + "title": "Count the Number of Special Characters II" }, "3122": { - "id": 3122, "category": "Dynamic Programming", - "title": "Minimum Number of Operations to Satisfy Conditions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-satisfy-conditions/" + "id": 3122, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-satisfy-conditions/", + "title": "Minimum Number of Operations to Satisfy Conditions" }, "3123": { - "id": 3123, "category": "Graph Traversal", - "title": "Find Edges in Shortest Paths", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-edges-in-shortest-paths/" + "id": 3123, + "link": "https://leetcode.com/problems/find-edges-in-shortest-paths/", + "title": "Find Edges in Shortest Paths" }, "3124": { - "id": 3124, "category": "Database", - "title": "Find Longest Calls", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-longest-calls/" + "id": 3124, + "link": "https://leetcode.com/problems/find-longest-calls/", + "title": "Find Longest Calls" }, "3125": { - "id": 3125, "category": "Greedy", - "title": "Maximum Number That Makes Result of Bitwise AND Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-that-makes-result-of-bitwise-and-zero/" + "id": 3125, + "link": "https://leetcode.com/problems/maximum-number-that-makes-result-of-bitwise-and-zero/", + "title": "Maximum Number That Makes Result of Bitwise AND Zero" }, "3126": { - "id": 3126, "category": "Database", - "title": "Server Utilization Time", "difficulty": "Medium", - "link": "https://leetcode.com/problems/server-utilization-time/" + "id": 3126, + "link": "https://leetcode.com/problems/server-utilization-time/", + "title": "Server Utilization Time" }, "3127": { - "id": 3127, "category": "Array & Hashing", - "title": "Make a Square with the Same Color", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-a-square-with-the-same-color/" + "id": 3127, + "link": "https://leetcode.com/problems/make-a-square-with-the-same-color/", + "title": "Make a Square with the Same Color" }, "3128": { - "id": 3128, "category": "Math & Geometry", - "title": "Right Triangles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/right-triangles/" + "id": 3128, + "link": "https://leetcode.com/problems/right-triangles/", + "title": "Right Triangles" }, "3129": { - "id": 3129, "category": "Dynamic Programming", - "title": "Find All Possible Stable Binary Arrays I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-all-possible-stable-binary-arrays-i/" + "id": 3129, + "link": "https://leetcode.com/problems/find-all-possible-stable-binary-arrays-i/", + "title": "Find All Possible Stable Binary Arrays I" }, "3130": { - "id": 3130, "category": "Dynamic Programming", - "title": "Find All Possible Stable Binary Arrays II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-all-possible-stable-binary-arrays-ii/" + "id": 3130, + "link": "https://leetcode.com/problems/find-all-possible-stable-binary-arrays-ii/", + "title": "Find All Possible Stable Binary Arrays II" }, "3131": { - "id": 3131, "category": "Array & Hashing", - "title": "Find the Integer Added to Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-integer-added-to-array-i/" + "id": 3131, + "link": "https://leetcode.com/problems/find-the-integer-added-to-array-i/", + "title": "Find the Integer Added to Array I" }, "3132": { - "id": 3132, "category": "Two Pointers", - "title": "Find the Integer Added to Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-integer-added-to-array-ii/" + "id": 3132, + "link": "https://leetcode.com/problems/find-the-integer-added-to-array-ii/", + "title": "Find the Integer Added to Array II" }, "3133": { - "id": 3133, "category": "Bit Manipulation", - "title": "Minimum Array End", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-array-end/" + "id": 3133, + "link": "https://leetcode.com/problems/minimum-array-end/", + "title": "Minimum Array End" }, "3134": { - "id": 3134, "category": "Sliding Window", - "title": "Find the Median of the Uniqueness Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-median-of-the-uniqueness-array/" + "id": 3134, + "link": "https://leetcode.com/problems/find-the-median-of-the-uniqueness-array/", + "title": "Find the Median of the Uniqueness Array" }, "3135": { - "id": 3135, "category": "Dynamic Programming", - "title": "Equalize Strings by Adding or Removing Characters at Ends", "difficulty": "Medium", - "link": "https://leetcode.com/problems/equalize-strings-by-adding-or-removing-characters-at-ends/" + "id": 3135, + "link": "https://leetcode.com/problems/equalize-strings-by-adding-or-removing-characters-at-ends/", + "title": "Equalize Strings by Adding or Removing Characters at Ends" }, "3136": { - "id": 3136, "category": "Array & Hashing", - "title": "Valid Word", "difficulty": "Easy", - "link": "https://leetcode.com/problems/valid-word/" + "id": 3136, + "link": "https://leetcode.com/problems/valid-word/", + "title": "Valid Word" }, "3137": { - "id": 3137, "category": "Array & Hashing", - "title": "Minimum Number of Operations to Make Word K-Periodic", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-word-k-periodic/" + "id": 3137, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-word-k-periodic/", + "title": "Minimum Number of Operations to Make Word K-Periodic" }, "3138": { - "id": 3138, "category": "Array & Hashing", - "title": "Minimum Length of Anagram Concatenation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-length-of-anagram-concatenation/" + "id": 3138, + "link": "https://leetcode.com/problems/minimum-length-of-anagram-concatenation/", + "title": "Minimum Length of Anagram Concatenation" }, "3139": { - "id": 3139, "category": "Greedy", - "title": "Minimum Cost to Equalize Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-equalize-array/" + "id": 3139, + "link": "https://leetcode.com/problems/minimum-cost-to-equalize-array/", + "title": "Minimum Cost to Equalize Array" }, "3140": { - "id": 3140, "category": "Database", - "title": "Consecutive Available Seats II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/consecutive-available-seats-ii/" + "id": 3140, + "link": "https://leetcode.com/problems/consecutive-available-seats-ii/", + "title": "Consecutive Available Seats II" }, "3141": { - "id": 3141, "category": "Graph Traversal", - "title": "Maximum Hamming Distances", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-hamming-distances/" + "id": 3141, + "link": "https://leetcode.com/problems/maximum-hamming-distances/", + "title": "Maximum Hamming Distances" }, "3142": { - "id": 3142, "category": "Array & Hashing", - "title": "Check if Grid Satisfies Conditions", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-grid-satisfies-conditions/" + "id": 3142, + "link": "https://leetcode.com/problems/check-if-grid-satisfies-conditions/", + "title": "Check if Grid Satisfies Conditions" }, "3143": { - "id": 3143, "category": "Binary Search", - "title": "Maximum Points Inside the Square", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-points-inside-the-square/" + "id": 3143, + "link": "https://leetcode.com/problems/maximum-points-inside-the-square/", + "title": "Maximum Points Inside the Square" }, "3144": { - "id": 3144, "category": "Dynamic Programming", - "title": "Minimum Substring Partition of Equal Character Frequency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-substring-partition-of-equal-character-frequency/" + "id": 3144, + "link": "https://leetcode.com/problems/minimum-substring-partition-of-equal-character-frequency/", + "title": "Minimum Substring Partition of Equal Character Frequency" }, "3145": { - "id": 3145, "category": "Binary Search", - "title": "Find Products of Elements of Big Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-products-of-elements-of-big-array/" + "id": 3145, + "link": "https://leetcode.com/problems/find-products-of-elements-of-big-array/", + "title": "Find Products of Elements of Big Array" }, "3146": { - "id": 3146, "category": "Array & Hashing", - "title": "Permutation Difference between Two Strings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/permutation-difference-between-two-strings/" + "id": 3146, + "link": "https://leetcode.com/problems/permutation-difference-between-two-strings/", + "title": "Permutation Difference between Two Strings" }, "3147": { - "id": 3147, "category": "Array & Hashing", - "title": "Taking Maximum Energy From the Mystic Dungeon", "difficulty": "Medium", - "link": "https://leetcode.com/problems/taking-maximum-energy-from-the-mystic-dungeon/" + "id": 3147, + "link": "https://leetcode.com/problems/taking-maximum-energy-from-the-mystic-dungeon/", + "title": "Taking Maximum Energy From the Mystic Dungeon" }, "3148": { - "id": 3148, "category": "Dynamic Programming", - "title": "Maximum Difference Score in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-difference-score-in-a-grid/" + "id": 3148, + "link": "https://leetcode.com/problems/maximum-difference-score-in-a-grid/", + "title": "Maximum Difference Score in a Grid" }, "3149": { - "id": 3149, "category": "Dynamic Programming", - "title": "Find the Minimum Cost Array Permutation", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-minimum-cost-array-permutation/" + "id": 3149, + "link": "https://leetcode.com/problems/find-the-minimum-cost-array-permutation/", + "title": "Find the Minimum Cost Array Permutation" }, "3150": { - "id": 3150, "category": "Database", - "title": "Invalid Tweets II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/invalid-tweets-ii/" + "id": 3150, + "link": "https://leetcode.com/problems/invalid-tweets-ii/", + "title": "Invalid Tweets II" }, "3151": { - "id": 3151, "category": "Array & Hashing", - "title": "Special Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/special-array-i/" + "id": 3151, + "link": "https://leetcode.com/problems/special-array-i/", + "title": "Special Array I" }, "3152": { - "id": 3152, "category": "Binary Search", - "title": "Special Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/special-array-ii/" + "id": 3152, + "link": "https://leetcode.com/problems/special-array-ii/", + "title": "Special Array II" }, "3153": { - "id": 3153, "category": "Math & Geometry", - "title": "Sum of Digit Differences of All Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-digit-differences-of-all-pairs/" + "id": 3153, + "link": "https://leetcode.com/problems/sum-of-digit-differences-of-all-pairs/", + "title": "Sum of Digit Differences of All Pairs" }, "3154": { - "id": 3154, "category": "Dynamic Programming", - "title": "Find Number of Ways to Reach the K-th Stair", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-number-of-ways-to-reach-the-k-th-stair/" + "id": 3154, + "link": "https://leetcode.com/problems/find-number-of-ways-to-reach-the-k-th-stair/", + "title": "Find Number of Ways to Reach the K-th Stair" }, "3155": { - "id": 3155, "category": "Binary Search", - "title": "Maximum Number of Upgradable Servers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-upgradable-servers/" + "id": 3155, + "link": "https://leetcode.com/problems/maximum-number-of-upgradable-servers/", + "title": "Maximum Number of Upgradable Servers" }, "3156": { - "id": 3156, "category": "Database", - "title": "Employee Task Duration and Concurrent Tasks", "difficulty": "Hard", - "link": "https://leetcode.com/problems/employee-task-duration-and-concurrent-tasks/" + "id": 3156, + "link": "https://leetcode.com/problems/employee-task-duration-and-concurrent-tasks/", + "title": "Employee Task Duration and Concurrent Tasks" }, "3157": { - "id": 3157, "category": "Tree", - "title": "Find the Level of Tree with Minimum Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-level-of-tree-with-minimum-sum/" + "id": 3157, + "link": "https://leetcode.com/problems/find-the-level-of-tree-with-minimum-sum/", + "title": "Find the Level of Tree with Minimum Sum" }, "3158": { - "id": 3158, "category": "Bit Manipulation", - "title": "Find the XOR of Numbers Which Appear Twice", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-xor-of-numbers-which-appear-twice/" + "id": 3158, + "link": "https://leetcode.com/problems/find-the-xor-of-numbers-which-appear-twice/", + "title": "Find the XOR of Numbers Which Appear Twice" }, "3159": { - "id": 3159, "category": "Array & Hashing", - "title": "Find Occurrences of an Element in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-occurrences-of-an-element-in-an-array/" + "id": 3159, + "link": "https://leetcode.com/problems/find-occurrences-of-an-element-in-an-array/", + "title": "Find Occurrences of an Element in an Array" }, "3160": { - "id": 3160, "category": "Array & Hashing", - "title": "Find the Number of Distinct Colors Among the Balls", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/" + "id": 3160, + "link": "https://leetcode.com/problems/find-the-number-of-distinct-colors-among-the-balls/", + "title": "Find the Number of Distinct Colors Among the Balls" }, "3161": { - "id": 3161, "category": "Tree", - "title": "Block Placement Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/block-placement-queries/" + "id": 3161, + "link": "https://leetcode.com/problems/block-placement-queries/", + "title": "Block Placement Queries" }, "3162": { - "id": 3162, "category": "Array & Hashing", - "title": "Find the Number of Good Pairs I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-number-of-good-pairs-i/" + "id": 3162, + "link": "https://leetcode.com/problems/find-the-number-of-good-pairs-i/", + "title": "Find the Number of Good Pairs I" }, "3163": { - "id": 3163, "category": "Array & Hashing", - "title": "String Compression III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/string-compression-iii/" + "id": 3163, + "link": "https://leetcode.com/problems/string-compression-iii/", + "title": "String Compression III" }, "3164": { - "id": 3164, "category": "Array & Hashing", - "title": "Find the Number of Good Pairs II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-number-of-good-pairs-ii/" + "id": 3164, + "link": "https://leetcode.com/problems/find-the-number-of-good-pairs-ii/", + "title": "Find the Number of Good Pairs II" }, "3165": { - "id": 3165, "category": "Tree", - "title": "Maximum Sum of Subsequence With Non-adjacent Elements", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-sum-of-subsequence-with-non-adjacent-elements/" + "id": 3165, + "link": "https://leetcode.com/problems/maximum-sum-of-subsequence-with-non-adjacent-elements/", + "title": "Maximum Sum of Subsequence With Non-adjacent Elements" }, "3166": { - "id": 3166, "category": "Database", - "title": "Calculate Parking Fees and Duration", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-parking-fees-and-duration/" + "id": 3166, + "link": "https://leetcode.com/problems/calculate-parking-fees-and-duration/", + "title": "Calculate Parking Fees and Duration" }, "3167": { - "id": 3167, "category": "Array & Hashing", - "title": "Better Compression of String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/better-compression-of-string/" + "id": 3167, + "link": "https://leetcode.com/problems/better-compression-of-string/", + "title": "Better Compression of String" }, "3168": { - "id": 3168, "category": "Array & Hashing", - "title": "Minimum Number of Chairs in a Waiting Room", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-chairs-in-a-waiting-room/" + "id": 3168, + "link": "https://leetcode.com/problems/minimum-number-of-chairs-in-a-waiting-room/", + "title": "Minimum Number of Chairs in a Waiting Room" }, "3169": { - "id": 3169, "category": "Array & Hashing", - "title": "Count Days Without Meetings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-days-without-meetings/" + "id": 3169, + "link": "https://leetcode.com/problems/count-days-without-meetings/", + "title": "Count Days Without Meetings" }, "3170": { - "id": 3170, "category": "Heap (Priority Queue)", - "title": "Lexicographically Minimum String After Removing Stars", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/" + "id": 3170, + "link": "https://leetcode.com/problems/lexicographically-minimum-string-after-removing-stars/", + "title": "Lexicographically Minimum String After Removing Stars" }, "3171": { - "id": 3171, "category": "Tree", - "title": "Find Subarray With Bitwise OR Closest to K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-subarray-with-bitwise-or-closest-to-k/" + "id": 3171, + "link": "https://leetcode.com/problems/find-subarray-with-bitwise-or-closest-to-k/", + "title": "Find Subarray With Bitwise OR Closest to K" }, "3172": { - "id": 3172, "category": "Database", - "title": "Second Day Verification", "difficulty": "Easy", - "link": "https://leetcode.com/problems/second-day-verification/" + "id": 3172, + "link": "https://leetcode.com/problems/second-day-verification/", + "title": "Second Day Verification" }, "3173": { - "id": 3173, "category": "Bit Manipulation", - "title": "Bitwise OR of Adjacent Elements", - "difficulty": "Easy", - "link": "https://leetcode.com/problems/bitwise-or-of-adjacent-elements/" - }, - "3174": { - "id": 3174, - "category": "Stack", - "title": "Clear Digits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/clear-digits/" + "id": 3173, + "link": "https://leetcode.com/problems/bitwise-or-of-adjacent-elements/", + "title": "Bitwise OR of Adjacent Elements" }, + "3174": {"category": "Stack", "difficulty": "Easy", "id": 3174, "link": "https://leetcode.com/problems/clear-digits/", "title": "Clear Digits"}, "3175": { - "id": 3175, "category": "Array & Hashing", - "title": "Find The First Player to win K Games in a Row", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-first-player-to-win-k-games-in-a-row/" + "id": 3175, + "link": "https://leetcode.com/problems/find-the-first-player-to-win-k-games-in-a-row/", + "title": "Find The First Player to win K Games in a Row" }, "3176": { - "id": 3176, "category": "Dynamic Programming", - "title": "Find the Maximum Length of a Good Subsequence I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-i/" + "id": 3176, + "link": "https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-i/", + "title": "Find the Maximum Length of a Good Subsequence I" }, "3177": { - "id": 3177, "category": "Dynamic Programming", - "title": "Find the Maximum Length of a Good Subsequence II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-ii/" + "id": 3177, + "link": "https://leetcode.com/problems/find-the-maximum-length-of-a-good-subsequence-ii/", + "title": "Find the Maximum Length of a Good Subsequence II" }, "3178": { - "id": 3178, "category": "Math & Geometry", - "title": "Find the Child Who Has the Ball After K Seconds", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/" + "id": 3178, + "link": "https://leetcode.com/problems/find-the-child-who-has-the-ball-after-k-seconds/", + "title": "Find the Child Who Has the Ball After K Seconds" }, "3179": { - "id": 3179, "category": "Math & Geometry", - "title": "Find the N-th Value After K Seconds", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-n-th-value-after-k-seconds/" + "id": 3179, + "link": "https://leetcode.com/problems/find-the-n-th-value-after-k-seconds/", + "title": "Find the N-th Value After K Seconds" }, "3180": { - "id": 3180, "category": "Dynamic Programming", - "title": "Maximum Total Reward Using Operations I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-i/" + "id": 3180, + "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-i/", + "title": "Maximum Total Reward Using Operations I" }, "3181": { - "id": 3181, "category": "Dynamic Programming", - "title": "Maximum Total Reward Using Operations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-ii/" + "id": 3181, + "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-ii/", + "title": "Maximum Total Reward Using Operations II" }, "3182": { - "id": 3182, "category": "Database", - "title": "Find Top Scoring Students", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-top-scoring-students/" + "id": 3182, + "link": "https://leetcode.com/problems/find-top-scoring-students/", + "title": "Find Top Scoring Students" }, "3183": { - "id": 3183, "category": "Dynamic Programming", - "title": "The Number of Ways to Make the Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/the-number-of-ways-to-make-the-sum/" + "id": 3183, + "link": "https://leetcode.com/problems/the-number-of-ways-to-make-the-sum/", + "title": "The Number of Ways to Make the Sum" }, "3184": { - "id": 3184, "category": "Array & Hashing", - "title": "Count Pairs That Form a Complete Day I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-pairs-that-form-a-complete-day-i/" + "id": 3184, + "link": "https://leetcode.com/problems/count-pairs-that-form-a-complete-day-i/", + "title": "Count Pairs That Form a Complete Day I" }, "3185": { - "id": 3185, "category": "Array & Hashing", - "title": "Count Pairs That Form a Complete Day II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-pairs-that-form-a-complete-day-ii/" + "id": 3185, + "link": "https://leetcode.com/problems/count-pairs-that-form-a-complete-day-ii/", + "title": "Count Pairs That Form a Complete Day II" }, "3186": { - "id": 3186, "category": "Dynamic Programming", - "title": "Maximum Total Damage With Spell Casting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-total-damage-with-spell-casting/" - }, - "3187": { - "id": 3187, - "category": "Tree", - "title": "Peaks in Array", - "difficulty": "Hard", - "link": "https://leetcode.com/problems/peaks-in-array/" + "id": 3186, + "link": "https://leetcode.com/problems/maximum-total-damage-with-spell-casting/", + "title": "Maximum Total Damage With Spell Casting" }, + "3187": {"category": "Tree", "difficulty": "Hard", "id": 3187, "link": "https://leetcode.com/problems/peaks-in-array/", "title": "Peaks in Array"}, "3188": { - "id": 3188, "category": "Database", - "title": "Find Top Scoring Students II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-top-scoring-students-ii/" + "id": 3188, + "link": "https://leetcode.com/problems/find-top-scoring-students-ii/", + "title": "Find Top Scoring Students II" }, "3189": { - "id": 3189, "category": "Greedy", - "title": "Minimum Moves to Get a Peaceful Board", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-get-a-peaceful-board/" + "id": 3189, + "link": "https://leetcode.com/problems/minimum-moves-to-get-a-peaceful-board/", + "title": "Minimum Moves to Get a Peaceful Board" }, "3190": { - "id": 3190, "category": "Math & Geometry", - "title": "Find Minimum Operations to Make All Elements Divisible by Three", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three/" + "id": 3190, + "link": "https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three/", + "title": "Find Minimum Operations to Make All Elements Divisible by Three" }, "3191": { - "id": 3191, "category": "Sliding Window", - "title": "Minimum Operations to Make Binary Array Elements Equal to One I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-i/" + "id": 3191, + "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-i/", + "title": "Minimum Operations to Make Binary Array Elements Equal to One I" }, "3192": { - "id": 3192, "category": "Dynamic Programming", - "title": "Minimum Operations to Make Binary Array Elements Equal to One II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-ii/" + "id": 3192, + "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-array-elements-equal-to-one-ii/", + "title": "Minimum Operations to Make Binary Array Elements Equal to One II" }, "3193": { - "id": 3193, "category": "Dynamic Programming", - "title": "Count the Number of Inversions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-inversions/" + "id": 3193, + "link": "https://leetcode.com/problems/count-the-number-of-inversions/", + "title": "Count the Number of Inversions" }, "3194": { - "id": 3194, "category": "Two Pointers", - "title": "Minimum Average of Smallest and Largest Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/" + "id": 3194, + "link": "https://leetcode.com/problems/minimum-average-of-smallest-and-largest-elements/", + "title": "Minimum Average of Smallest and Largest Elements" }, "3195": { - "id": 3195, "category": "Array & Hashing", - "title": "Find the Minimum Area to Cover All Ones I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-i/" + "id": 3195, + "link": "https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-i/", + "title": "Find the Minimum Area to Cover All Ones I" }, "3196": { - "id": 3196, "category": "Dynamic Programming", - "title": "Maximize Total Cost of Alternating Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-total-cost-of-alternating-subarrays/" + "id": 3196, + "link": "https://leetcode.com/problems/maximize-total-cost-of-alternating-subarrays/", + "title": "Maximize Total Cost of Alternating Subarrays" }, "3197": { - "id": 3197, "category": "Array & Hashing", - "title": "Find the Minimum Area to Cover All Ones II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-ii/" + "id": 3197, + "link": "https://leetcode.com/problems/find-the-minimum-area-to-cover-all-ones-ii/", + "title": "Find the Minimum Area to Cover All Ones II" }, "3198": { - "id": 3198, "category": "Database", - "title": "Find Cities in Each State", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-cities-in-each-state/" + "id": 3198, + "link": "https://leetcode.com/problems/find-cities-in-each-state/", + "title": "Find Cities in Each State" }, "3199": { - "id": 3199, "category": "Bit Manipulation", - "title": "Count Triplets with Even XOR Set Bits I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-i/" + "id": 3199, + "link": "https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-i/", + "title": "Count Triplets with Even XOR Set Bits I" }, "3200": { - "id": 3200, "category": "Array & Hashing", - "title": "Maximum Height of a Triangle", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-height-of-a-triangle/" + "id": 3200, + "link": "https://leetcode.com/problems/maximum-height-of-a-triangle/", + "title": "Maximum Height of a Triangle" }, "3201": { - "id": 3201, "category": "Dynamic Programming", - "title": "Find the Maximum Length of Valid Subsequence I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-i/" + "id": 3201, + "link": "https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-i/", + "title": "Find the Maximum Length of Valid Subsequence I" }, "3202": { - "id": 3202, "category": "Dynamic Programming", - "title": "Find the Maximum Length of Valid Subsequence II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-ii/" + "id": 3202, + "link": "https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-ii/", + "title": "Find the Maximum Length of Valid Subsequence II" }, "3203": { - "id": 3203, "category": "Tree", - "title": "Find Minimum Diameter After Merging Two Trees", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-minimum-diameter-after-merging-two-trees/" + "id": 3203, + "link": "https://leetcode.com/problems/find-minimum-diameter-after-merging-two-trees/", + "title": "Find Minimum Diameter After Merging Two Trees" }, "3204": { - "id": 3204, "category": "Database", - "title": "Bitwise User Permissions Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/bitwise-user-permissions-analysis/" + "id": 3204, + "link": "https://leetcode.com/problems/bitwise-user-permissions-analysis/", + "title": "Bitwise User Permissions Analysis" }, "3205": { - "id": 3205, "category": "Dynamic Programming", - "title": "Maximum Array Hopping Score I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-array-hopping-score-i/" + "id": 3205, + "link": "https://leetcode.com/problems/maximum-array-hopping-score-i/", + "title": "Maximum Array Hopping Score I" }, "3206": { - "id": 3206, "category": "Sliding Window", - "title": "Alternating Groups I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/alternating-groups-i/" + "id": 3206, + "link": "https://leetcode.com/problems/alternating-groups-i/", + "title": "Alternating Groups I" }, "3207": { - "id": 3207, "category": "Greedy", - "title": "Maximum Points After Enemy Battles", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-points-after-enemy-battles/" + "id": 3207, + "link": "https://leetcode.com/problems/maximum-points-after-enemy-battles/", + "title": "Maximum Points After Enemy Battles" }, "3208": { - "id": 3208, "category": "Sliding Window", - "title": "Alternating Groups II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/alternating-groups-ii/" + "id": 3208, + "link": "https://leetcode.com/problems/alternating-groups-ii/", + "title": "Alternating Groups II" }, "3209": { - "id": 3209, "category": "Tree", - "title": "Number of Subarrays With AND Value of K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-subarrays-with-and-value-of-k/" + "id": 3209, + "link": "https://leetcode.com/problems/number-of-subarrays-with-and-value-of-k/", + "title": "Number of Subarrays With AND Value of K" }, "3210": { - "id": 3210, "category": "Array & Hashing", - "title": "Find the Encrypted String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-encrypted-string/" + "id": 3210, + "link": "https://leetcode.com/problems/find-the-encrypted-string/", + "title": "Find the Encrypted String" }, "3211": { - "id": 3211, "category": "Backtracking", - "title": "Generate Binary Strings Without Adjacent Zeros", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/" + "id": 3211, + "link": "https://leetcode.com/problems/generate-binary-strings-without-adjacent-zeros/", + "title": "Generate Binary Strings Without Adjacent Zeros" }, "3212": { - "id": 3212, "category": "Array & Hashing", - "title": "Count Submatrices With Equal Frequency of X and Y", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-submatrices-with-equal-frequency-of-x-and-y/" + "id": 3212, + "link": "https://leetcode.com/problems/count-submatrices-with-equal-frequency-of-x-and-y/", + "title": "Count Submatrices With Equal Frequency of X and Y" }, "3213": { - "id": 3213, "category": "Dynamic Programming", - "title": "Construct String with Minimum Cost", "difficulty": "Hard", - "link": "https://leetcode.com/problems/construct-string-with-minimum-cost/" + "id": 3213, + "link": "https://leetcode.com/problems/construct-string-with-minimum-cost/", + "title": "Construct String with Minimum Cost" }, "3214": { - "id": 3214, "category": "Database", - "title": "Year on Year Growth Rate", "difficulty": "Hard", - "link": "https://leetcode.com/problems/year-on-year-growth-rate/" + "id": 3214, + "link": "https://leetcode.com/problems/year-on-year-growth-rate/", + "title": "Year on Year Growth Rate" }, "3215": { - "id": 3215, "category": "Bit Manipulation", - "title": "Count Triplets with Even XOR Set Bits II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-ii/" + "id": 3215, + "link": "https://leetcode.com/problems/count-triplets-with-even-xor-set-bits-ii/", + "title": "Count Triplets with Even XOR Set Bits II" }, "3216": { - "id": 3216, "category": "Greedy", - "title": "Lexicographically Smallest String After a Swap", "difficulty": "Easy", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap/" + "id": 3216, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-a-swap/", + "title": "Lexicographically Smallest String After a Swap" }, "3217": { - "id": 3217, "category": "Linked List", - "title": "Delete Nodes From Linked List Present in Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/" + "id": 3217, + "link": "https://leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/", + "title": "Delete Nodes From Linked List Present in Array" }, "3218": { - "id": 3218, "category": "Dynamic Programming", - "title": "Minimum Cost for Cutting Cake I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-i/" + "id": 3218, + "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-i/", + "title": "Minimum Cost for Cutting Cake I" }, "3219": { - "id": 3219, "category": "Greedy", - "title": "Minimum Cost for Cutting Cake II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-ii/" + "id": 3219, + "link": "https://leetcode.com/problems/minimum-cost-for-cutting-cake-ii/", + "title": "Minimum Cost for Cutting Cake II" }, "3220": { - "id": 3220, "category": "Database", - "title": "Odd and Even Transactions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/odd-and-even-transactions/" + "id": 3220, + "link": "https://leetcode.com/problems/odd-and-even-transactions/", + "title": "Odd and Even Transactions" }, "3221": { - "id": 3221, "category": "Stack", - "title": "Maximum Array Hopping Score II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-array-hopping-score-ii/" + "id": 3221, + "link": "https://leetcode.com/problems/maximum-array-hopping-score-ii/", + "title": "Maximum Array Hopping Score II" }, "3222": { - "id": 3222, "category": "Math & Geometry", - "title": "Find the Winning Player in Coin Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-winning-player-in-coin-game/" + "id": 3222, + "link": "https://leetcode.com/problems/find-the-winning-player-in-coin-game/", + "title": "Find the Winning Player in Coin Game" }, "3223": { - "id": 3223, "category": "Array & Hashing", - "title": "Minimum Length of String After Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-length-of-string-after-operations/" + "id": 3223, + "link": "https://leetcode.com/problems/minimum-length-of-string-after-operations/", + "title": "Minimum Length of String After Operations" }, "3224": { - "id": 3224, "category": "Array & Hashing", - "title": "Minimum Array Changes to Make Differences Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-array-changes-to-make-differences-equal/" + "id": 3224, + "link": "https://leetcode.com/problems/minimum-array-changes-to-make-differences-equal/", + "title": "Minimum Array Changes to Make Differences Equal" }, "3225": { - "id": 3225, "category": "Dynamic Programming", - "title": "Maximum Score From Grid Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-from-grid-operations/" + "id": 3225, + "link": "https://leetcode.com/problems/maximum-score-from-grid-operations/", + "title": "Maximum Score From Grid Operations" }, "3226": { - "id": 3226, "category": "Bit Manipulation", - "title": "Number of Bit Changes to Make Two Integers Equal", "difficulty": "Easy", - "link": "https://leetcode.com/problems/number-of-bit-changes-to-make-two-integers-equal/" + "id": 3226, + "link": "https://leetcode.com/problems/number-of-bit-changes-to-make-two-integers-equal/", + "title": "Number of Bit Changes to Make Two Integers Equal" }, "3227": { - "id": 3227, "category": "Math & Geometry", - "title": "Vowels Game in a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/vowels-game-in-a-string/" + "id": 3227, + "link": "https://leetcode.com/problems/vowels-game-in-a-string/", + "title": "Vowels Game in a String" }, "3228": { - "id": 3228, "category": "Greedy", - "title": "Maximum Number of Operations to Move Ones to the End", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-operations-to-move-ones-to-the-end/" + "id": 3228, + "link": "https://leetcode.com/problems/maximum-number-of-operations-to-move-ones-to-the-end/", + "title": "Maximum Number of Operations to Move Ones to the End" }, "3229": { - "id": 3229, "category": "Dynamic Programming", - "title": "Minimum Operations to Make Array Equal to Target", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal-to-target/" + "id": 3229, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-equal-to-target/", + "title": "Minimum Operations to Make Array Equal to Target" }, "3230": { - "id": 3230, "category": "Database", - "title": "Customer Purchasing Behavior Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/customer-purchasing-behavior-analysis/" + "id": 3230, + "link": "https://leetcode.com/problems/customer-purchasing-behavior-analysis/", + "title": "Customer Purchasing Behavior Analysis" }, "3231": { - "id": 3231, "category": "Binary Search", - "title": "Minimum Number of Increasing Subsequence to Be Removed", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-increasing-subsequence-to-be-removed/" + "id": 3231, + "link": "https://leetcode.com/problems/minimum-number-of-increasing-subsequence-to-be-removed/", + "title": "Minimum Number of Increasing Subsequence to Be Removed" }, "3232": { - "id": 3232, "category": "Math & Geometry", - "title": "Find if Digit Game Can Be Won", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-if-digit-game-can-be-won/" + "id": 3232, + "link": "https://leetcode.com/problems/find-if-digit-game-can-be-won/", + "title": "Find if Digit Game Can Be Won" }, "3233": { - "id": 3233, "category": "Math & Geometry", - "title": "Find the Count of Numbers Which Are Not Special", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-count-of-numbers-which-are-not-special/" + "id": 3233, + "link": "https://leetcode.com/problems/find-the-count-of-numbers-which-are-not-special/", + "title": "Find the Count of Numbers Which Are Not Special" }, "3234": { - "id": 3234, "category": "Array & Hashing", - "title": "Count the Number of Substrings With Dominant Ones", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-substrings-with-dominant-ones/" + "id": 3234, + "link": "https://leetcode.com/problems/count-the-number-of-substrings-with-dominant-ones/", + "title": "Count the Number of Substrings With Dominant Ones" }, "3235": { - "id": 3235, "category": "Graph Traversal", - "title": "Check if the Rectangle Corner Is Reachable", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/" + "id": 3235, + "link": "https://leetcode.com/problems/check-if-the-rectangle-corner-is-reachable/", + "title": "Check if the Rectangle Corner Is Reachable" }, "3236": { - "id": 3236, "category": "Database", - "title": "CEO Subordinate Hierarchy", "difficulty": "Hard", - "link": "https://leetcode.com/problems/ceo-subordinate-hierarchy/" + "id": 3236, + "link": "https://leetcode.com/problems/ceo-subordinate-hierarchy/", + "title": "CEO Subordinate Hierarchy" }, "3237": { - "id": 3237, "category": "Array & Hashing", - "title": "Alt and Tab Simulation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/alt-and-tab-simulation/" + "id": 3237, + "link": "https://leetcode.com/problems/alt-and-tab-simulation/", + "title": "Alt and Tab Simulation" }, "3238": { - "id": 3238, "category": "Array & Hashing", - "title": "Find the Number of Winning Players", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-number-of-winning-players/" + "id": 3238, + "link": "https://leetcode.com/problems/find-the-number-of-winning-players/", + "title": "Find the Number of Winning Players" }, "3239": { - "id": 3239, "category": "Two Pointers", - "title": "Minimum Number of Flips to Make Binary Grid Palindromic I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-i/" + "id": 3239, + "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-i/", + "title": "Minimum Number of Flips to Make Binary Grid Palindromic I" }, "3240": { - "id": 3240, "category": "Two Pointers", - "title": "Minimum Number of Flips to Make Binary Grid Palindromic II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-ii/" + "id": 3240, + "link": "https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-ii/", + "title": "Minimum Number of Flips to Make Binary Grid Palindromic II" }, "3241": { - "id": 3241, "category": "Tree", - "title": "Time Taken to Mark All Nodes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/time-taken-to-mark-all-nodes/" + "id": 3241, + "link": "https://leetcode.com/problems/time-taken-to-mark-all-nodes/", + "title": "Time Taken to Mark All Nodes" }, "3242": { - "id": 3242, "category": "Array & Hashing", - "title": "Design Neighbor Sum Service", "difficulty": "Easy", - "link": "https://leetcode.com/problems/design-neighbor-sum-service/" + "id": 3242, + "link": "https://leetcode.com/problems/design-neighbor-sum-service/", + "title": "Design Neighbor Sum Service" }, "3243": { - "id": 3243, "category": "Graph Traversal", - "title": "Shortest Distance After Road Addition Queries I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/" + "id": 3243, + "link": "https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/", + "title": "Shortest Distance After Road Addition Queries I" }, "3244": { - "id": 3244, "category": "Graph Traversal", - "title": "Shortest Distance After Road Addition Queries II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-distance-after-road-addition-queries-ii/" + "id": 3244, + "link": "https://leetcode.com/problems/shortest-distance-after-road-addition-queries-ii/", + "title": "Shortest Distance After Road Addition Queries II" }, "3245": { - "id": 3245, "category": "Tree", - "title": "Alternating Groups III", "difficulty": "Hard", - "link": "https://leetcode.com/problems/alternating-groups-iii/" + "id": 3245, + "link": "https://leetcode.com/problems/alternating-groups-iii/", + "title": "Alternating Groups III" }, "3246": { - "id": 3246, "category": "Database", - "title": "Premier League Table Ranking", "difficulty": "Easy", - "link": "https://leetcode.com/problems/premier-league-table-ranking/" + "id": 3246, + "link": "https://leetcode.com/problems/premier-league-table-ranking/", + "title": "Premier League Table Ranking" }, "3247": { - "id": 3247, "category": "Dynamic Programming", - "title": "Number of Subsequences with Odd Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-subsequences-with-odd-sum/" + "id": 3247, + "link": "https://leetcode.com/problems/number-of-subsequences-with-odd-sum/", + "title": "Number of Subsequences with Odd Sum" }, "3248": { - "id": 3248, "category": "Array & Hashing", - "title": "Snake in Matrix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/snake-in-matrix/" + "id": 3248, + "link": "https://leetcode.com/problems/snake-in-matrix/", + "title": "Snake in Matrix" }, "3249": { - "id": 3249, "category": "Tree", - "title": "Count the Number of Good Nodes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-good-nodes/" + "id": 3249, + "link": "https://leetcode.com/problems/count-the-number-of-good-nodes/", + "title": "Count the Number of Good Nodes" }, "3250": { - "id": 3250, "category": "Dynamic Programming", - "title": "Find the Count of Monotonic Pairs I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/" + "id": 3250, + "link": "https://leetcode.com/problems/find-the-count-of-monotonic-pairs-i/", + "title": "Find the Count of Monotonic Pairs I" }, "3251": { - "id": 3251, "category": "Dynamic Programming", - "title": "Find the Count of Monotonic Pairs II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-count-of-monotonic-pairs-ii/" + "id": 3251, + "link": "https://leetcode.com/problems/find-the-count-of-monotonic-pairs-ii/", + "title": "Find the Count of Monotonic Pairs II" }, "3252": { - "id": 3252, "category": "Database", - "title": "Premier League Table Ranking II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/premier-league-table-ranking-ii/" + "id": 3252, + "link": "https://leetcode.com/problems/premier-league-table-ranking-ii/", + "title": "Premier League Table Ranking II" }, "3253": { - "id": 3253, "category": "Array & Hashing", - "title": "Construct String with Minimum Cost (Easy)", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-string-with-minimum-cost-easy/" + "id": 3253, + "link": "https://leetcode.com/problems/construct-string-with-minimum-cost-easy/", + "title": "Construct String with Minimum Cost (Easy)" }, "3254": { - "id": 3254, "category": "Sliding Window", - "title": "Find the Power of K-Size Subarrays I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/" + "id": 3254, + "link": "https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/", + "title": "Find the Power of K-Size Subarrays I" }, "3255": { - "id": 3255, "category": "Sliding Window", - "title": "Find the Power of K-Size Subarrays II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-power-of-k-size-subarrays-ii/" + "id": 3255, + "link": "https://leetcode.com/problems/find-the-power-of-k-size-subarrays-ii/", + "title": "Find the Power of K-Size Subarrays II" }, "3256": { - "id": 3256, "category": "Dynamic Programming", - "title": "Maximum Value Sum by Placing Three Rooks I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-i/" + "id": 3256, + "link": "https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-i/", + "title": "Maximum Value Sum by Placing Three Rooks I" }, "3257": { - "id": 3257, "category": "Dynamic Programming", - "title": "Maximum Value Sum by Placing Three Rooks II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-ii/" + "id": 3257, + "link": "https://leetcode.com/problems/maximum-value-sum-by-placing-three-rooks-ii/", + "title": "Maximum Value Sum by Placing Three Rooks II" }, "3258": { - "id": 3258, "category": "Sliding Window", - "title": "Count Substrings That Satisfy K-Constraint I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-i/" + "id": 3258, + "link": "https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-i/", + "title": "Count Substrings That Satisfy K-Constraint I" }, "3259": { - "id": 3259, "category": "Dynamic Programming", - "title": "Maximum Energy Boost From Two Drinks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-energy-boost-from-two-drinks/" + "id": 3259, + "link": "https://leetcode.com/problems/maximum-energy-boost-from-two-drinks/", + "title": "Maximum Energy Boost From Two Drinks" }, "3260": { - "id": 3260, "category": "Dynamic Programming", - "title": "Find the Largest Palindrome Divisible by K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-largest-palindrome-divisible-by-k/" + "id": 3260, + "link": "https://leetcode.com/problems/find-the-largest-palindrome-divisible-by-k/", + "title": "Find the Largest Palindrome Divisible by K" }, "3261": { - "id": 3261, "category": "Sliding Window", - "title": "Count Substrings That Satisfy K-Constraint II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-ii/" + "id": 3261, + "link": "https://leetcode.com/problems/count-substrings-that-satisfy-k-constraint-ii/", + "title": "Count Substrings That Satisfy K-Constraint II" }, "3262": { - "id": 3262, "category": "Database", - "title": "Find Overlapping Shifts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-overlapping-shifts/" + "id": 3262, + "link": "https://leetcode.com/problems/find-overlapping-shifts/", + "title": "Find Overlapping Shifts" }, "3263": { - "id": 3263, "category": "Linked List", - "title": "Convert Doubly Linked List to Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/" + "id": 3263, + "link": "https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/", + "title": "Convert Doubly Linked List to Array I" }, "3264": { - "id": 3264, "category": "Heap (Priority Queue)", - "title": "Final Array State After K Multiplication Operations I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/" + "id": 3264, + "link": "https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/", + "title": "Final Array State After K Multiplication Operations I" }, "3265": { - "id": 3265, "category": "Array & Hashing", - "title": "Count Almost Equal Pairs I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-almost-equal-pairs-i/" + "id": 3265, + "link": "https://leetcode.com/problems/count-almost-equal-pairs-i/", + "title": "Count Almost Equal Pairs I" }, "3266": { - "id": 3266, "category": "Heap (Priority Queue)", - "title": "Final Array State After K Multiplication Operations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-ii/" + "id": 3266, + "link": "https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-ii/", + "title": "Final Array State After K Multiplication Operations II" }, "3267": { - "id": 3267, "category": "Array & Hashing", - "title": "Count Almost Equal Pairs II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-almost-equal-pairs-ii/" + "id": 3267, + "link": "https://leetcode.com/problems/count-almost-equal-pairs-ii/", + "title": "Count Almost Equal Pairs II" }, "3268": { - "id": 3268, "category": "Database", - "title": "Find Overlapping Shifts II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-overlapping-shifts-ii/" + "id": 3268, + "link": "https://leetcode.com/problems/find-overlapping-shifts-ii/", + "title": "Find Overlapping Shifts II" }, "3269": { - "id": 3269, "category": "Dynamic Programming", - "title": "Constructing Two Increasing Arrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/constructing-two-increasing-arrays/" + "id": 3269, + "link": "https://leetcode.com/problems/constructing-two-increasing-arrays/", + "title": "Constructing Two Increasing Arrays" }, "3270": { - "id": 3270, "category": "Math & Geometry", - "title": "Find the Key of the Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-key-of-the-numbers/" + "id": 3270, + "link": "https://leetcode.com/problems/find-the-key-of-the-numbers/", + "title": "Find the Key of the Numbers" }, "3271": { - "id": 3271, "category": "Array & Hashing", - "title": "Hash Divided String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/hash-divided-string/" + "id": 3271, + "link": "https://leetcode.com/problems/hash-divided-string/", + "title": "Hash Divided String" }, "3272": { - "id": 3272, "category": "Math & Geometry", - "title": "Find the Count of Good Integers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-count-of-good-integers/" + "id": 3272, + "link": "https://leetcode.com/problems/find-the-count-of-good-integers/", + "title": "Find the Count of Good Integers" }, "3273": { - "id": 3273, "category": "Greedy", - "title": "Minimum Amount of Damage Dealt to Bob", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-amount-of-damage-dealt-to-bob/" + "id": 3273, + "link": "https://leetcode.com/problems/minimum-amount-of-damage-dealt-to-bob/", + "title": "Minimum Amount of Damage Dealt to Bob" }, "3274": { - "id": 3274, "category": "Math & Geometry", - "title": "Check if Two Chessboard Squares Have the Same Color", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/" + "id": 3274, + "link": "https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/", + "title": "Check if Two Chessboard Squares Have the Same Color" }, "3275": { - "id": 3275, "category": "Heap (Priority Queue)", - "title": "K-th Nearest Obstacle Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-th-nearest-obstacle-queries/" + "id": 3275, + "link": "https://leetcode.com/problems/k-th-nearest-obstacle-queries/", + "title": "K-th Nearest Obstacle Queries" }, "3276": { - "id": 3276, "category": "Dynamic Programming", - "title": "Select Cells in Grid With Maximum Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/select-cells-in-grid-with-maximum-score/" + "id": 3276, + "link": "https://leetcode.com/problems/select-cells-in-grid-with-maximum-score/", + "title": "Select Cells in Grid With Maximum Score" }, "3277": { - "id": 3277, "category": "Dynamic Programming", - "title": "Maximum XOR Score Subarray Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-xor-score-subarray-queries/" + "id": 3277, + "link": "https://leetcode.com/problems/maximum-xor-score-subarray-queries/", + "title": "Maximum XOR Score Subarray Queries" }, "3278": { - "id": 3278, "category": "Database", - "title": "Find Candidates for Data Scientist Position II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-candidates-for-data-scientist-position-ii/" + "id": 3278, + "link": "https://leetcode.com/problems/find-candidates-for-data-scientist-position-ii/", + "title": "Find Candidates for Data Scientist Position II" }, "3279": { - "id": 3279, "category": "Array & Hashing", - "title": "Maximum Total Area Occupied by Pistons", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-total-area-occupied-by-pistons/" + "id": 3279, + "link": "https://leetcode.com/problems/maximum-total-area-occupied-by-pistons/", + "title": "Maximum Total Area Occupied by Pistons" }, "3280": { - "id": 3280, "category": "Math & Geometry", - "title": "Convert Date to Binary", "difficulty": "Easy", - "link": "https://leetcode.com/problems/convert-date-to-binary/" + "id": 3280, + "link": "https://leetcode.com/problems/convert-date-to-binary/", + "title": "Convert Date to Binary" }, "3281": { - "id": 3281, "category": "Binary Search", - "title": "Maximize Score of Numbers in Ranges", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-score-of-numbers-in-ranges/" + "id": 3281, + "link": "https://leetcode.com/problems/maximize-score-of-numbers-in-ranges/", + "title": "Maximize Score of Numbers in Ranges" }, "3282": { - "id": 3282, "category": "Greedy", - "title": "Reach End of Array With Max Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reach-end-of-array-with-max-score/" + "id": 3282, + "link": "https://leetcode.com/problems/reach-end-of-array-with-max-score/", + "title": "Reach End of Array With Max Score" }, "3283": { - "id": 3283, "category": "Graph Traversal", - "title": "Maximum Number of Moves to Kill All Pawns", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-number-of-moves-to-kill-all-pawns/" + "id": 3283, + "link": "https://leetcode.com/problems/maximum-number-of-moves-to-kill-all-pawns/", + "title": "Maximum Number of Moves to Kill All Pawns" }, "3284": { - "id": 3284, "category": "Dynamic Programming", - "title": "Sum of Consecutive Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-consecutive-subarrays/" + "id": 3284, + "link": "https://leetcode.com/problems/sum-of-consecutive-subarrays/", + "title": "Sum of Consecutive Subarrays" }, "3285": { - "id": 3285, "category": "Array & Hashing", - "title": "Find Indices of Stable Mountains", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-indices-of-stable-mountains/" + "id": 3285, + "link": "https://leetcode.com/problems/find-indices-of-stable-mountains/", + "title": "Find Indices of Stable Mountains" }, "3286": { - "id": 3286, "category": "Graph Traversal", - "title": "Find a Safe Walk Through a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-a-safe-walk-through-a-grid/" + "id": 3286, + "link": "https://leetcode.com/problems/find-a-safe-walk-through-a-grid/", + "title": "Find a Safe Walk Through a Grid" }, "3287": { - "id": 3287, "category": "Dynamic Programming", - "title": "Find the Maximum Sequence Value of Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-maximum-sequence-value-of-array/" + "id": 3287, + "link": "https://leetcode.com/problems/find-the-maximum-sequence-value-of-array/", + "title": "Find the Maximum Sequence Value of Array" }, "3288": { - "id": 3288, "category": "Binary Search", - "title": "Length of the Longest Increasing Path", "difficulty": "Hard", - "link": "https://leetcode.com/problems/length-of-the-longest-increasing-path/" + "id": 3288, + "link": "https://leetcode.com/problems/length-of-the-longest-increasing-path/", + "title": "Length of the Longest Increasing Path" }, "3289": { - "id": 3289, "category": "Math & Geometry", - "title": "The Two Sneaky Numbers of Digitville", "difficulty": "Easy", - "link": "https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/" + "id": 3289, + "link": "https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/", + "title": "The Two Sneaky Numbers of Digitville" }, "3290": { - "id": 3290, "category": "Dynamic Programming", - "title": "Maximum Multiplication Score", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-multiplication-score/" + "id": 3290, + "link": "https://leetcode.com/problems/maximum-multiplication-score/", + "title": "Maximum Multiplication Score" }, "3291": { - "id": 3291, "category": "Tree", - "title": "Minimum Number of Valid Strings to Form Target I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-i/" + "id": 3291, + "link": "https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-i/", + "title": "Minimum Number of Valid Strings to Form Target I" }, "3292": { - "id": 3292, "category": "Tree", - "title": "Minimum Number of Valid Strings to Form Target II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-ii/" + "id": 3292, + "link": "https://leetcode.com/problems/minimum-number-of-valid-strings-to-form-target-ii/", + "title": "Minimum Number of Valid Strings to Form Target II" }, "3293": { - "id": 3293, "category": "Database", - "title": "Calculate Product Final Price", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-product-final-price/" + "id": 3293, + "link": "https://leetcode.com/problems/calculate-product-final-price/", + "title": "Calculate Product Final Price" }, "3294": { - "id": 3294, "category": "Linked List", - "title": "Convert Doubly Linked List to Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-doubly-linked-list-to-array-ii/" + "id": 3294, + "link": "https://leetcode.com/problems/convert-doubly-linked-list-to-array-ii/", + "title": "Convert Doubly Linked List to Array II" }, "3295": { - "id": 3295, "category": "Array & Hashing", - "title": "Report Spam Message", "difficulty": "Medium", - "link": "https://leetcode.com/problems/report-spam-message/" + "id": 3295, + "link": "https://leetcode.com/problems/report-spam-message/", + "title": "Report Spam Message" }, "3296": { - "id": 3296, "category": "Binary Search", - "title": "Minimum Number of Seconds to Make Mountain Height Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-seconds-to-make-mountain-height-zero/" + "id": 3296, + "link": "https://leetcode.com/problems/minimum-number-of-seconds-to-make-mountain-height-zero/", + "title": "Minimum Number of Seconds to Make Mountain Height Zero" }, "3297": { - "id": 3297, "category": "Sliding Window", - "title": "Count Substrings That Can Be Rearranged to Contain a String I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-i/" + "id": 3297, + "link": "https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-i/", + "title": "Count Substrings That Can Be Rearranged to Contain a String I" }, "3298": { - "id": 3298, "category": "Sliding Window", - "title": "Count Substrings That Can Be Rearranged to Contain a String II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-ii/" + "id": 3298, + "link": "https://leetcode.com/problems/count-substrings-that-can-be-rearranged-to-contain-a-string-ii/", + "title": "Count Substrings That Can Be Rearranged to Contain a String II" }, "3299": { - "id": 3299, "category": "Dynamic Programming", - "title": "Sum of Consecutive Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-consecutive-subsequences/" + "id": 3299, + "link": "https://leetcode.com/problems/sum-of-consecutive-subsequences/", + "title": "Sum of Consecutive Subsequences" }, "3300": { - "id": 3300, "category": "Math & Geometry", - "title": "Minimum Element After Replacement With Digit Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/" + "id": 3300, + "link": "https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/", + "title": "Minimum Element After Replacement With Digit Sum" }, "3301": { - "id": 3301, "category": "Greedy", - "title": "Maximize the Total Height of Unique Towers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-the-total-height-of-unique-towers/" + "id": 3301, + "link": "https://leetcode.com/problems/maximize-the-total-height-of-unique-towers/", + "title": "Maximize the Total Height of Unique Towers" }, "3302": { - "id": 3302, "category": "Dynamic Programming", - "title": "Find the Lexicographically Smallest Valid Sequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-lexicographically-smallest-valid-sequence/" + "id": 3302, + "link": "https://leetcode.com/problems/find-the-lexicographically-smallest-valid-sequence/", + "title": "Find the Lexicographically Smallest Valid Sequence" }, "3303": { - "id": 3303, "category": "Array & Hashing", - "title": "Find the Occurrence of First Almost Equal Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-occurrence-of-first-almost-equal-substring/" + "id": 3303, + "link": "https://leetcode.com/problems/find-the-occurrence-of-first-almost-equal-substring/", + "title": "Find the Occurrence of First Almost Equal Substring" }, "3304": { - "id": 3304, "category": "Bit Manipulation", - "title": "Find the K-th Character in String Game I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/" + "id": 3304, + "link": "https://leetcode.com/problems/find-the-k-th-character-in-string-game-i/", + "title": "Find the K-th Character in String Game I" }, "3305": { - "id": 3305, "category": "Sliding Window", - "title": "Count of Substrings Containing Every Vowel and K Consonants I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-i/" + "id": 3305, + "link": "https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-i/", + "title": "Count of Substrings Containing Every Vowel and K Consonants I" }, "3306": { - "id": 3306, "category": "Sliding Window", - "title": "Count of Substrings Containing Every Vowel and K Consonants II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii/" + "id": 3306, + "link": "https://leetcode.com/problems/count-of-substrings-containing-every-vowel-and-k-consonants-ii/", + "title": "Count of Substrings Containing Every Vowel and K Consonants II" }, "3307": { - "id": 3307, "category": "Bit Manipulation", - "title": "Find the K-th Character in String Game II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-k-th-character-in-string-game-ii/" + "id": 3307, + "link": "https://leetcode.com/problems/find-the-k-th-character-in-string-game-ii/", + "title": "Find the K-th Character in String Game II" }, "3308": { - "id": 3308, "category": "Database", - "title": "Find Top Performing Driver", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-top-performing-driver/" + "id": 3308, + "link": "https://leetcode.com/problems/find-top-performing-driver/", + "title": "Find Top Performing Driver" }, "3309": { - "id": 3309, "category": "Bit Manipulation", - "title": "Maximum Possible Number by Binary Concatenation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-possible-number-by-binary-concatenation/" + "id": 3309, + "link": "https://leetcode.com/problems/maximum-possible-number-by-binary-concatenation/", + "title": "Maximum Possible Number by Binary Concatenation" }, "3310": { - "id": 3310, "category": "Graph Traversal", - "title": "Remove Methods From Project", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-methods-from-project/" + "id": 3310, + "link": "https://leetcode.com/problems/remove-methods-from-project/", + "title": "Remove Methods From Project" }, "3311": { - "id": 3311, "category": "Graph Traversal", - "title": "Construct 2D Grid Matching Graph Layout", "difficulty": "Hard", - "link": "https://leetcode.com/problems/construct-2d-grid-matching-graph-layout/" + "id": 3311, + "link": "https://leetcode.com/problems/construct-2d-grid-matching-graph-layout/", + "title": "Construct 2D Grid Matching Graph Layout" }, "3312": { - "id": 3312, "category": "Binary Search", - "title": "Sorted GCD Pair Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sorted-gcd-pair-queries/" + "id": 3312, + "link": "https://leetcode.com/problems/sorted-gcd-pair-queries/", + "title": "Sorted GCD Pair Queries" }, "3313": { - "id": 3313, "category": "Tree", - "title": "Find the Last Marked Nodes in Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-last-marked-nodes-in-tree/" + "id": 3313, + "link": "https://leetcode.com/problems/find-the-last-marked-nodes-in-tree/", + "title": "Find the Last Marked Nodes in Tree" }, "3314": { - "id": 3314, "category": "Bit Manipulation", - "title": "Construct the Minimum Bitwise Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/construct-the-minimum-bitwise-array-i/" + "id": 3314, + "link": "https://leetcode.com/problems/construct-the-minimum-bitwise-array-i/", + "title": "Construct the Minimum Bitwise Array I" }, "3315": { - "id": 3315, "category": "Bit Manipulation", - "title": "Construct the Minimum Bitwise Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii/" + "id": 3315, + "link": "https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii/", + "title": "Construct the Minimum Bitwise Array II" }, "3316": { - "id": 3316, "category": "Dynamic Programming", - "title": "Find Maximum Removals From Source String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-maximum-removals-from-source-string/" + "id": 3316, + "link": "https://leetcode.com/problems/find-maximum-removals-from-source-string/", + "title": "Find Maximum Removals From Source String" }, "3317": { - "id": 3317, "category": "Dynamic Programming", - "title": "Find the Number of Possible Ways for an Event", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-number-of-possible-ways-for-an-event/" + "id": 3317, + "link": "https://leetcode.com/problems/find-the-number-of-possible-ways-for-an-event/", + "title": "Find the Number of Possible Ways for an Event" }, "3318": { - "id": 3318, "category": "Sliding Window", - "title": "Find X-Sum of All K-Long Subarrays I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/" + "id": 3318, + "link": "https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-i/", + "title": "Find X-Sum of All K-Long Subarrays I" }, "3319": { - "id": 3319, "category": "Tree", - "title": "K-th Largest Perfect Subtree Size in Binary Tree", "difficulty": "Medium", - "link": "https://leetcode.com/problems/k-th-largest-perfect-subtree-size-in-binary-tree/" + "id": 3319, + "link": "https://leetcode.com/problems/k-th-largest-perfect-subtree-size-in-binary-tree/", + "title": "K-th Largest Perfect Subtree Size in Binary Tree" }, "3320": { - "id": 3320, "category": "Dynamic Programming", - "title": "Count The Number of Winning Sequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-winning-sequences/" + "id": 3320, + "link": "https://leetcode.com/problems/count-the-number-of-winning-sequences/", + "title": "Count The Number of Winning Sequences" }, "3321": { - "id": 3321, "category": "Sliding Window", - "title": "Find X-Sum of All K-Long Subarrays II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-ii/" + "id": 3321, + "link": "https://leetcode.com/problems/find-x-sum-of-all-k-long-subarrays-ii/", + "title": "Find X-Sum of All K-Long Subarrays II" }, "3322": { - "id": 3322, "category": "Database", - "title": "Premier League Table Ranking III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/premier-league-table-ranking-iii/" + "id": 3322, + "link": "https://leetcode.com/problems/premier-league-table-ranking-iii/", + "title": "Premier League Table Ranking III" }, "3323": { - "id": 3323, "category": "Sliding Window", - "title": "Minimize Connected Groups by Inserting Interval", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-connected-groups-by-inserting-interval/" + "id": 3323, + "link": "https://leetcode.com/problems/minimize-connected-groups-by-inserting-interval/", + "title": "Minimize Connected Groups by Inserting Interval" }, "3324": { - "id": 3324, "category": "Array & Hashing", - "title": "Find the Sequence of Strings Appeared on the Screen", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/" + "id": 3324, + "link": "https://leetcode.com/problems/find-the-sequence-of-strings-appeared-on-the-screen/", + "title": "Find the Sequence of Strings Appeared on the Screen" }, "3325": { - "id": 3325, "category": "Sliding Window", - "title": "Count Substrings With K-Frequency Characters I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-substrings-with-k-frequency-characters-i/" + "id": 3325, + "link": "https://leetcode.com/problems/count-substrings-with-k-frequency-characters-i/", + "title": "Count Substrings With K-Frequency Characters I" }, "3326": { - "id": 3326, "category": "Greedy", - "title": "Minimum Division Operations to Make Array Non Decreasing", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-division-operations-to-make-array-non-decreasing/" + "id": 3326, + "link": "https://leetcode.com/problems/minimum-division-operations-to-make-array-non-decreasing/", + "title": "Minimum Division Operations to Make Array Non Decreasing" }, "3327": { - "id": 3327, "category": "Tree", - "title": "Check if DFS Strings Are Palindromes", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-dfs-strings-are-palindromes/" + "id": 3327, + "link": "https://leetcode.com/problems/check-if-dfs-strings-are-palindromes/", + "title": "Check if DFS Strings Are Palindromes" }, "3328": { - "id": 3328, "category": "Database", - "title": "Find Cities in Each State II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-cities-in-each-state-ii/" + "id": 3328, + "link": "https://leetcode.com/problems/find-cities-in-each-state-ii/", + "title": "Find Cities in Each State II" }, "3329": { - "id": 3329, "category": "Sliding Window", - "title": "Count Substrings With K-Frequency Characters II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-substrings-with-k-frequency-characters-ii/" + "id": 3329, + "link": "https://leetcode.com/problems/count-substrings-with-k-frequency-characters-ii/", + "title": "Count Substrings With K-Frequency Characters II" }, "3330": { - "id": 3330, "category": "Array & Hashing", - "title": "Find the Original Typed String I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-original-typed-string-i/" + "id": 3330, + "link": "https://leetcode.com/problems/find-the-original-typed-string-i/", + "title": "Find the Original Typed String I" }, "3331": { - "id": 3331, "category": "Tree", - "title": "Find Subtree Sizes After Changes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-subtree-sizes-after-changes/" + "id": 3331, + "link": "https://leetcode.com/problems/find-subtree-sizes-after-changes/", + "title": "Find Subtree Sizes After Changes" }, "3332": { - "id": 3332, "category": "Dynamic Programming", - "title": "Maximum Points Tourist Can Earn", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-points-tourist-can-earn/" + "id": 3332, + "link": "https://leetcode.com/problems/maximum-points-tourist-can-earn/", + "title": "Maximum Points Tourist Can Earn" }, "3333": { - "id": 3333, "category": "Dynamic Programming", - "title": "Find the Original Typed String II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-original-typed-string-ii/" + "id": 3333, + "link": "https://leetcode.com/problems/find-the-original-typed-string-ii/", + "title": "Find the Original Typed String II" }, "3334": { - "id": 3334, "category": "Math & Geometry", - "title": "Find the Maximum Factor Score of Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-maximum-factor-score-of-array/" + "id": 3334, + "link": "https://leetcode.com/problems/find-the-maximum-factor-score-of-array/", + "title": "Find the Maximum Factor Score of Array" }, "3335": { - "id": 3335, "category": "Dynamic Programming", - "title": "Total Characters in String After Transformations I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/total-characters-in-string-after-transformations-i/" + "id": 3335, + "link": "https://leetcode.com/problems/total-characters-in-string-after-transformations-i/", + "title": "Total Characters in String After Transformations I" }, "3336": { - "id": 3336, "category": "Dynamic Programming", - "title": "Find the Number of Subsequences With Equal GCD", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-number-of-subsequences-with-equal-gcd/" + "id": 3336, + "link": "https://leetcode.com/problems/find-the-number-of-subsequences-with-equal-gcd/", + "title": "Find the Number of Subsequences With Equal GCD" }, "3337": { - "id": 3337, "category": "Dynamic Programming", - "title": "Total Characters in String After Transformations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/total-characters-in-string-after-transformations-ii/" + "id": 3337, + "link": "https://leetcode.com/problems/total-characters-in-string-after-transformations-ii/", + "title": "Total Characters in String After Transformations II" }, "3338": { - "id": 3338, "category": "Database", - "title": "Second Highest Salary II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/second-highest-salary-ii/" + "id": 3338, + "link": "https://leetcode.com/problems/second-highest-salary-ii/", + "title": "Second Highest Salary II" }, "3339": { - "id": 3339, "category": "Dynamic Programming", - "title": "Find the Number of K-Even Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-number-of-k-even-arrays/" + "id": 3339, + "link": "https://leetcode.com/problems/find-the-number-of-k-even-arrays/", + "title": "Find the Number of K-Even Arrays" }, "3340": { - "id": 3340, "category": "Array & Hashing", - "title": "Check Balanced String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-balanced-string/" + "id": 3340, + "link": "https://leetcode.com/problems/check-balanced-string/", + "title": "Check Balanced String" }, "3341": { - "id": 3341, "category": "Graph Traversal", - "title": "Find Minimum Time to Reach Last Room I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/" + "id": 3341, + "link": "https://leetcode.com/problems/find-minimum-time-to-reach-last-room-i/", + "title": "Find Minimum Time to Reach Last Room I" }, "3342": { - "id": 3342, "category": "Graph Traversal", - "title": "Find Minimum Time to Reach Last Room II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/" + "id": 3342, + "link": "https://leetcode.com/problems/find-minimum-time-to-reach-last-room-ii/", + "title": "Find Minimum Time to Reach Last Room II" }, "3343": { - "id": 3343, "category": "Dynamic Programming", - "title": "Count Number of Balanced Permutations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-number-of-balanced-permutations/" + "id": 3343, + "link": "https://leetcode.com/problems/count-number-of-balanced-permutations/", + "title": "Count Number of Balanced Permutations" }, "3344": { - "id": 3344, "category": "Binary Search", - "title": "Maximum Sized Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sized-array/" + "id": 3344, + "link": "https://leetcode.com/problems/maximum-sized-array/", + "title": "Maximum Sized Array" }, "3345": { - "id": 3345, "category": "Math & Geometry", - "title": "Smallest Divisible Digit Product I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-divisible-digit-product-i/" + "id": 3345, + "link": "https://leetcode.com/problems/smallest-divisible-digit-product-i/", + "title": "Smallest Divisible Digit Product I" }, "3346": { - "id": 3346, "category": "Sliding Window", - "title": "Maximum Frequency of an Element After Performing Operations I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-i/" + "id": 3346, + "link": "https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-i/", + "title": "Maximum Frequency of an Element After Performing Operations I" }, "3347": { - "id": 3347, "category": "Sliding Window", - "title": "Maximum Frequency of an Element After Performing Operations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-ii/" + "id": 3347, + "link": "https://leetcode.com/problems/maximum-frequency-of-an-element-after-performing-operations-ii/", + "title": "Maximum Frequency of an Element After Performing Operations II" }, "3348": { - "id": 3348, "category": "Backtracking", - "title": "Smallest Divisible Digit Product II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-divisible-digit-product-ii/" + "id": 3348, + "link": "https://leetcode.com/problems/smallest-divisible-digit-product-ii/", + "title": "Smallest Divisible Digit Product II" }, "3349": { - "id": 3349, "category": "Array & Hashing", - "title": "Adjacent Increasing Subarrays Detection I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/" + "id": 3349, + "link": "https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/", + "title": "Adjacent Increasing Subarrays Detection I" }, "3350": { - "id": 3350, "category": "Binary Search", - "title": "Adjacent Increasing Subarrays Detection II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/adjacent-increasing-subarrays-detection-ii/" + "id": 3350, + "link": "https://leetcode.com/problems/adjacent-increasing-subarrays-detection-ii/", + "title": "Adjacent Increasing Subarrays Detection II" }, "3351": { - "id": 3351, "category": "Dynamic Programming", - "title": "Sum of Good Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-good-subsequences/" + "id": 3351, + "link": "https://leetcode.com/problems/sum-of-good-subsequences/", + "title": "Sum of Good Subsequences" }, "3352": { - "id": 3352, "category": "Dynamic Programming", - "title": "Count K-Reducible Numbers Less Than N", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-k-reducible-numbers-less-than-n/" + "id": 3352, + "link": "https://leetcode.com/problems/count-k-reducible-numbers-less-than-n/", + "title": "Count K-Reducible Numbers Less Than N" }, "3353": { - "id": 3353, "category": "Array & Hashing", - "title": "Minimum Total Operations", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-total-operations/" + "id": 3353, + "link": "https://leetcode.com/problems/minimum-total-operations/", + "title": "Minimum Total Operations" }, "3354": { - "id": 3354, "category": "Array & Hashing", - "title": "Make Array Elements Equal to Zero", "difficulty": "Easy", - "link": "https://leetcode.com/problems/make-array-elements-equal-to-zero/" + "id": 3354, + "link": "https://leetcode.com/problems/make-array-elements-equal-to-zero/", + "title": "Make Array Elements Equal to Zero" }, "3355": { - "id": 3355, "category": "Array & Hashing", - "title": "Zero Array Transformation I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zero-array-transformation-i/" + "id": 3355, + "link": "https://leetcode.com/problems/zero-array-transformation-i/", + "title": "Zero Array Transformation I" }, "3356": { - "id": 3356, "category": "Binary Search", - "title": "Zero Array Transformation II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zero-array-transformation-ii/" + "id": 3356, + "link": "https://leetcode.com/problems/zero-array-transformation-ii/", + "title": "Zero Array Transformation II" }, "3357": { - "id": 3357, "category": "Binary Search", - "title": "Minimize the Maximum Adjacent Element Difference", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimize-the-maximum-adjacent-element-difference/" + "id": 3357, + "link": "https://leetcode.com/problems/minimize-the-maximum-adjacent-element-difference/", + "title": "Minimize the Maximum Adjacent Element Difference" }, "3358": { - "id": 3358, "category": "Database", - "title": "Books with NULL Ratings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/books-with-null-ratings/" + "id": 3358, + "link": "https://leetcode.com/problems/books-with-null-ratings/", + "title": "Books with NULL Ratings" }, "3359": { - "id": 3359, "category": "Stack", - "title": "Find Sorted Submatrices With Maximum Element at Most K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-sorted-submatrices-with-maximum-element-at-most-k/" + "id": 3359, + "link": "https://leetcode.com/problems/find-sorted-submatrices-with-maximum-element-at-most-k/", + "title": "Find Sorted Submatrices With Maximum Element at Most K" }, "3360": { - "id": 3360, "category": "Math & Geometry", - "title": "Stone Removal Game", "difficulty": "Easy", - "link": "https://leetcode.com/problems/stone-removal-game/" + "id": 3360, + "link": "https://leetcode.com/problems/stone-removal-game/", + "title": "Stone Removal Game" }, "3361": { - "id": 3361, "category": "Array & Hashing", - "title": "Shift Distance Between Two Strings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/shift-distance-between-two-strings/" + "id": 3361, + "link": "https://leetcode.com/problems/shift-distance-between-two-strings/", + "title": "Shift Distance Between Two Strings" }, "3362": { - "id": 3362, "category": "Heap (Priority Queue)", - "title": "Zero Array Transformation III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zero-array-transformation-iii/" + "id": 3362, + "link": "https://leetcode.com/problems/zero-array-transformation-iii/", + "title": "Zero Array Transformation III" }, "3363": { - "id": 3363, "category": "Dynamic Programming", - "title": "Find the Maximum Number of Fruits Collected", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-maximum-number-of-fruits-collected/" + "id": 3363, + "link": "https://leetcode.com/problems/find-the-maximum-number-of-fruits-collected/", + "title": "Find the Maximum Number of Fruits Collected" }, "3364": { - "id": 3364, "category": "Sliding Window", - "title": "Minimum Positive Sum Subarray ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-positive-sum-subarray/" + "id": 3364, + "link": "https://leetcode.com/problems/minimum-positive-sum-subarray/", + "title": "Minimum Positive Sum Subarray " }, "3365": { - "id": 3365, "category": "Array & Hashing", - "title": "Rearrange K Substrings to Form Target String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/rearrange-k-substrings-to-form-target-string/" + "id": 3365, + "link": "https://leetcode.com/problems/rearrange-k-substrings-to-form-target-string/", + "title": "Rearrange K Substrings to Form Target String" }, "3366": { - "id": 3366, "category": "Dynamic Programming", - "title": "Minimum Array Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-array-sum/" + "id": 3366, + "link": "https://leetcode.com/problems/minimum-array-sum/", + "title": "Minimum Array Sum" }, "3367": { - "id": 3367, "category": "Tree", - "title": "Maximize Sum of Weights after Edge Removals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-sum-of-weights-after-edge-removals/" + "id": 3367, + "link": "https://leetcode.com/problems/maximize-sum-of-weights-after-edge-removals/", + "title": "Maximize Sum of Weights after Edge Removals" }, "3368": { - "id": 3368, "category": "Database", - "title": "First Letter Capitalization", "difficulty": "Hard", - "link": "https://leetcode.com/problems/first-letter-capitalization/" + "id": 3368, + "link": "https://leetcode.com/problems/first-letter-capitalization/", + "title": "First Letter Capitalization" }, "3369": { - "id": 3369, "category": "Binary Search", - "title": "Design an Array Statistics Tracker ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/design-an-array-statistics-tracker/" + "id": 3369, + "link": "https://leetcode.com/problems/design-an-array-statistics-tracker/", + "title": "Design an Array Statistics Tracker " }, "3370": { - "id": 3370, "category": "Bit Manipulation", - "title": "Smallest Number With All Set Bits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-number-with-all-set-bits/" + "id": 3370, + "link": "https://leetcode.com/problems/smallest-number-with-all-set-bits/", + "title": "Smallest Number With All Set Bits" }, "3371": { - "id": 3371, "category": "Array & Hashing", - "title": "Identify the Largest Outlier in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/identify-the-largest-outlier-in-an-array/" + "id": 3371, + "link": "https://leetcode.com/problems/identify-the-largest-outlier-in-an-array/", + "title": "Identify the Largest Outlier in an Array" }, "3372": { - "id": 3372, "category": "Tree", - "title": "Maximize the Number of Target Nodes After Connecting Trees I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-i/" + "id": 3372, + "link": "https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-i/", + "title": "Maximize the Number of Target Nodes After Connecting Trees I" }, "3373": { - "id": 3373, "category": "Tree", - "title": "Maximize the Number of Target Nodes After Connecting Trees II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-ii/" + "id": 3373, + "link": "https://leetcode.com/problems/maximize-the-number-of-target-nodes-after-connecting-trees-ii/", + "title": "Maximize the Number of Target Nodes After Connecting Trees II" }, "3374": { - "id": 3374, "category": "Database", - "title": "First Letter Capitalization II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/first-letter-capitalization-ii/" + "id": 3374, + "link": "https://leetcode.com/problems/first-letter-capitalization-ii/", + "title": "First Letter Capitalization II" }, "3375": { - "id": 3375, "category": "Array & Hashing", - "title": "Minimum Operations to Make Array Values Equal to K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/" + "id": 3375, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/", + "title": "Minimum Operations to Make Array Values Equal to K" }, "3376": { - "id": 3376, "category": "Graph Traversal", - "title": "Minimum Time to Break Locks I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-break-locks-i/" + "id": 3376, + "link": "https://leetcode.com/problems/minimum-time-to-break-locks-i/", + "title": "Minimum Time to Break Locks I" }, "3377": { - "id": 3377, "category": "Graph Traversal", - "title": "Digit Operations to Make Two Integers Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/digit-operations-to-make-two-integers-equal/" + "id": 3377, + "link": "https://leetcode.com/problems/digit-operations-to-make-two-integers-equal/", + "title": "Digit Operations to Make Two Integers Equal" }, "3378": { - "id": 3378, "category": "Graph Traversal", - "title": "Count Connected Components in LCM Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-connected-components-in-lcm-graph/" + "id": 3378, + "link": "https://leetcode.com/problems/count-connected-components-in-lcm-graph/", + "title": "Count Connected Components in LCM Graph" }, "3379": { - "id": 3379, "category": "Array & Hashing", - "title": "Transformed Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/transformed-array/" + "id": 3379, + "link": "https://leetcode.com/problems/transformed-array/", + "title": "Transformed Array" }, "3380": { - "id": 3380, "category": "Tree", - "title": "Maximum Area Rectangle With Point Constraints I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-i/" + "id": 3380, + "link": "https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-i/", + "title": "Maximum Area Rectangle With Point Constraints I" }, "3381": { - "id": 3381, "category": "Array & Hashing", - "title": "Maximum Subarray Sum With Length Divisible by K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-subarray-sum-with-length-divisible-by-k/" + "id": 3381, + "link": "https://leetcode.com/problems/maximum-subarray-sum-with-length-divisible-by-k/", + "title": "Maximum Subarray Sum With Length Divisible by K" }, "3382": { - "id": 3382, "category": "Tree", - "title": "Maximum Area Rectangle With Point Constraints II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-ii/" + "id": 3382, + "link": "https://leetcode.com/problems/maximum-area-rectangle-with-point-constraints-ii/", + "title": "Maximum Area Rectangle With Point Constraints II" }, "3383": { - "id": 3383, "category": "Graph Traversal", - "title": "Minimum Runes to Add to Cast Spell", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-runes-to-add-to-cast-spell/" + "id": 3383, + "link": "https://leetcode.com/problems/minimum-runes-to-add-to-cast-spell/", + "title": "Minimum Runes to Add to Cast Spell" }, "3384": { - "id": 3384, "category": "Database", - "title": "Team Dominance by Pass Success", "difficulty": "Hard", - "link": "https://leetcode.com/problems/team-dominance-by-pass-success/" + "id": 3384, + "link": "https://leetcode.com/problems/team-dominance-by-pass-success/", + "title": "Team Dominance by Pass Success" }, "3385": { - "id": 3385, "category": "Graph Traversal", - "title": "Minimum Time to Break Locks II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-break-locks-ii/" + "id": 3385, + "link": "https://leetcode.com/problems/minimum-time-to-break-locks-ii/", + "title": "Minimum Time to Break Locks II" }, "3386": { - "id": 3386, "category": "Array & Hashing", - "title": "Button with Longest Push Time", "difficulty": "Easy", - "link": "https://leetcode.com/problems/button-with-longest-push-time/" + "id": 3386, + "link": "https://leetcode.com/problems/button-with-longest-push-time/", + "title": "Button with Longest Push Time" }, "3387": { - "id": 3387, "category": "Graph Traversal", - "title": "Maximize Amount After Two Days of Conversions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-amount-after-two-days-of-conversions/" + "id": 3387, + "link": "https://leetcode.com/problems/maximize-amount-after-two-days-of-conversions/", + "title": "Maximize Amount After Two Days of Conversions" }, "3388": { - "id": 3388, "category": "Dynamic Programming", - "title": "Count Beautiful Splits in an Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-beautiful-splits-in-an-array/" + "id": 3388, + "link": "https://leetcode.com/problems/count-beautiful-splits-in-an-array/", + "title": "Count Beautiful Splits in an Array" }, "3389": { - "id": 3389, "category": "Dynamic Programming", - "title": "Minimum Operations to Make Character Frequencies Equal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-character-frequencies-equal/" + "id": 3389, + "link": "https://leetcode.com/problems/minimum-operations-to-make-character-frequencies-equal/", + "title": "Minimum Operations to Make Character Frequencies Equal" }, "3390": { - "id": 3390, "category": "Database", - "title": "Longest Team Pass Streak", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-team-pass-streak/" + "id": 3390, + "link": "https://leetcode.com/problems/longest-team-pass-streak/", + "title": "Longest Team Pass Streak" }, "3391": { - "id": 3391, "category": "Heap (Priority Queue)", - "title": "Design a 3D Binary Matrix with Efficient Layer Tracking", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking/" + "id": 3391, + "link": "https://leetcode.com/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking/", + "title": "Design a 3D Binary Matrix with Efficient Layer Tracking" }, "3392": { - "id": 3392, "category": "Array & Hashing", - "title": "Count Subarrays of Length Three With a Condition", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition/" + "id": 3392, + "link": "https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition/", + "title": "Count Subarrays of Length Three With a Condition" }, "3393": { - "id": 3393, "category": "Dynamic Programming", - "title": "Count Paths With the Given XOR Value", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-paths-with-the-given-xor-value/" + "id": 3393, + "link": "https://leetcode.com/problems/count-paths-with-the-given-xor-value/", + "title": "Count Paths With the Given XOR Value" }, "3394": { - "id": 3394, "category": "Array & Hashing", - "title": "Check if Grid can be Cut into Sections", "difficulty": "Medium", - "link": "https://leetcode.com/problems/check-if-grid-can-be-cut-into-sections/" + "id": 3394, + "link": "https://leetcode.com/problems/check-if-grid-can-be-cut-into-sections/", + "title": "Check if Grid can be Cut into Sections" }, "3395": { - "id": 3395, "category": "Math & Geometry", - "title": "Subsequences with a Unique Middle Mode I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-i/" + "id": 3395, + "link": "https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-i/", + "title": "Subsequences with a Unique Middle Mode I" }, "3396": { - "id": 3396, "category": "Array & Hashing", - "title": "Minimum Number of Operations to Make Elements in Array Distinct", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/" + "id": 3396, + "link": "https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/", + "title": "Minimum Number of Operations to Make Elements in Array Distinct" }, "3397": { - "id": 3397, "category": "Greedy", - "title": "Maximum Number of Distinct Elements After Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-distinct-elements-after-operations/" + "id": 3397, + "link": "https://leetcode.com/problems/maximum-number-of-distinct-elements-after-operations/", + "title": "Maximum Number of Distinct Elements After Operations" }, "3398": { - "id": 3398, "category": "Binary Search", - "title": "Smallest Substring With Identical Characters I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-substring-with-identical-characters-i/" + "id": 3398, + "link": "https://leetcode.com/problems/smallest-substring-with-identical-characters-i/", + "title": "Smallest Substring With Identical Characters I" }, "3399": { - "id": 3399, "category": "Binary Search", - "title": "Smallest Substring With Identical Characters II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-substring-with-identical-characters-ii/" + "id": 3399, + "link": "https://leetcode.com/problems/smallest-substring-with-identical-characters-ii/", + "title": "Smallest Substring With Identical Characters II" }, "3400": { - "id": 3400, "category": "Two Pointers", - "title": "Maximum Number of Matching Indices After Right Shifts", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-matching-indices-after-right-shifts/" + "id": 3400, + "link": "https://leetcode.com/problems/maximum-number-of-matching-indices-after-right-shifts/", + "title": "Maximum Number of Matching Indices After Right Shifts" }, "3401": { - "id": 3401, "category": "Database", - "title": "Find Circular Gift Exchange Chains", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-circular-gift-exchange-chains/" + "id": 3401, + "link": "https://leetcode.com/problems/find-circular-gift-exchange-chains/", + "title": "Find Circular Gift Exchange Chains" }, "3402": { - "id": 3402, "category": "Greedy", - "title": "Minimum Operations to Make Columns Strictly Increasing", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/" + "id": 3402, + "link": "https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/", + "title": "Minimum Operations to Make Columns Strictly Increasing" }, "3403": { - "id": 3403, "category": "Two Pointers", - "title": "Find the Lexicographically Largest String From the Box I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/" + "id": 3403, + "link": "https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/", + "title": "Find the Lexicographically Largest String From the Box I" }, "3404": { - "id": 3404, "category": "Math & Geometry", - "title": "Count Special Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-special-subsequences/" + "id": 3404, + "link": "https://leetcode.com/problems/count-special-subsequences/", + "title": "Count Special Subsequences" }, "3405": { - "id": 3405, "category": "Math & Geometry", - "title": "Count the Number of Arrays with K Matching Adjacent Elements", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-the-number-of-arrays-with-k-matching-adjacent-elements/" + "id": 3405, + "link": "https://leetcode.com/problems/count-the-number-of-arrays-with-k-matching-adjacent-elements/", + "title": "Count the Number of Arrays with K Matching Adjacent Elements" }, "3406": { - "id": 3406, "category": "Two Pointers", - "title": "Find the Lexicographically Largest String From the Box II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-ii/" + "id": 3406, + "link": "https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-ii/", + "title": "Find the Lexicographically Largest String From the Box II" }, "3407": { - "id": 3407, "category": "Array & Hashing", - "title": "Substring Matching Pattern", "difficulty": "Easy", - "link": "https://leetcode.com/problems/substring-matching-pattern/" + "id": 3407, + "link": "https://leetcode.com/problems/substring-matching-pattern/", + "title": "Substring Matching Pattern" }, "3408": { - "id": 3408, "category": "Heap (Priority Queue)", - "title": "Design Task Manager", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-task-manager/" + "id": 3408, + "link": "https://leetcode.com/problems/design-task-manager/", + "title": "Design Task Manager" }, "3409": { - "id": 3409, "category": "Dynamic Programming", - "title": "Longest Subsequence With Decreasing Adjacent Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-subsequence-with-decreasing-adjacent-difference/" + "id": 3409, + "link": "https://leetcode.com/problems/longest-subsequence-with-decreasing-adjacent-difference/", + "title": "Longest Subsequence With Decreasing Adjacent Difference" }, "3410": { - "id": 3410, "category": "Tree", - "title": "Maximize Subarray Sum After Removing All Occurrences of One Element", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-subarray-sum-after-removing-all-occurrences-of-one-element/" + "id": 3410, + "link": "https://leetcode.com/problems/maximize-subarray-sum-after-removing-all-occurrences-of-one-element/", + "title": "Maximize Subarray Sum After Removing All Occurrences of One Element" }, "3411": { - "id": 3411, "category": "Sliding Window", - "title": "Maximum Subarray With Equal Products", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-subarray-with-equal-products/" + "id": 3411, + "link": "https://leetcode.com/problems/maximum-subarray-with-equal-products/", + "title": "Maximum Subarray With Equal Products" }, "3412": { - "id": 3412, "category": "Stack", - "title": "Find Mirror Score of a String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-mirror-score-of-a-string/" + "id": 3412, + "link": "https://leetcode.com/problems/find-mirror-score-of-a-string/", + "title": "Find Mirror Score of a String" }, "3413": { - "id": 3413, "category": "Sliding Window", - "title": "Maximum Coins From K Consecutive Bags", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-coins-from-k-consecutive-bags/" + "id": 3413, + "link": "https://leetcode.com/problems/maximum-coins-from-k-consecutive-bags/", + "title": "Maximum Coins From K Consecutive Bags" }, "3414": { - "id": 3414, "category": "Dynamic Programming", - "title": "Maximum Score of Non-overlapping Intervals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-score-of-non-overlapping-intervals/" + "id": 3414, + "link": "https://leetcode.com/problems/maximum-score-of-non-overlapping-intervals/", + "title": "Maximum Score of Non-overlapping Intervals" }, "3415": { - "id": 3415, "category": "Database", - "title": "Find Products with Three Consecutive Digits ", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-products-with-three-consecutive-digits/" + "id": 3415, + "link": "https://leetcode.com/problems/find-products-with-three-consecutive-digits/", + "title": "Find Products with Three Consecutive Digits " }, "3416": { - "id": 3416, "category": "Math & Geometry", - "title": "Subsequences with a Unique Middle Mode II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-ii/" + "id": 3416, + "link": "https://leetcode.com/problems/subsequences-with-a-unique-middle-mode-ii/", + "title": "Subsequences with a Unique Middle Mode II" }, "3417": { - "id": 3417, "category": "Array & Hashing", - "title": "Zigzag Grid Traversal With Skip", "difficulty": "Easy", - "link": "https://leetcode.com/problems/zigzag-grid-traversal-with-skip/" + "id": 3417, + "link": "https://leetcode.com/problems/zigzag-grid-traversal-with-skip/", + "title": "Zigzag Grid Traversal With Skip" }, "3418": { - "id": 3418, "category": "Dynamic Programming", - "title": "Maximum Amount of Money Robot Can Earn", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-amount-of-money-robot-can-earn/" + "id": 3418, + "link": "https://leetcode.com/problems/maximum-amount-of-money-robot-can-earn/", + "title": "Maximum Amount of Money Robot Can Earn" }, "3419": { - "id": 3419, "category": "Graph Traversal", - "title": "Minimize the Maximum Edge Weight of Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-the-maximum-edge-weight-of-graph/" + "id": 3419, + "link": "https://leetcode.com/problems/minimize-the-maximum-edge-weight-of-graph/", + "title": "Minimize the Maximum Edge Weight of Graph" }, "3420": { - "id": 3420, "category": "Tree", - "title": "Count Non-Decreasing Subarrays After K Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-non-decreasing-subarrays-after-k-operations/" + "id": 3420, + "link": "https://leetcode.com/problems/count-non-decreasing-subarrays-after-k-operations/", + "title": "Count Non-Decreasing Subarrays After K Operations" }, "3421": { - "id": 3421, "category": "Database", - "title": "Find Students Who Improved", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-students-who-improved/" + "id": 3421, + "link": "https://leetcode.com/problems/find-students-who-improved/", + "title": "Find Students Who Improved" }, "3422": { - "id": 3422, "category": "Sliding Window", - "title": "Minimum Operations to Make Subarray Elements Equal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-subarray-elements-equal/" + "id": 3422, + "link": "https://leetcode.com/problems/minimum-operations-to-make-subarray-elements-equal/", + "title": "Minimum Operations to Make Subarray Elements Equal" }, "3423": { - "id": 3423, "category": "Array & Hashing", - "title": "Maximum Difference Between Adjacent Elements in a Circular Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/" + "id": 3423, + "link": "https://leetcode.com/problems/maximum-difference-between-adjacent-elements-in-a-circular-array/", + "title": "Maximum Difference Between Adjacent Elements in a Circular Array" }, "3424": { - "id": 3424, "category": "Greedy", - "title": "Minimum Cost to Make Arrays Identical", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-to-make-arrays-identical/" + "id": 3424, + "link": "https://leetcode.com/problems/minimum-cost-to-make-arrays-identical/", + "title": "Minimum Cost to Make Arrays Identical" }, "3425": { - "id": 3425, "category": "Tree", - "title": "Longest Special Path", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-special-path/" + "id": 3425, + "link": "https://leetcode.com/problems/longest-special-path/", + "title": "Longest Special Path" }, "3426": { - "id": 3426, "category": "Math & Geometry", - "title": "Manhattan Distances of All Arrangements of Pieces", "difficulty": "Hard", - "link": "https://leetcode.com/problems/manhattan-distances-of-all-arrangements-of-pieces/" + "id": 3426, + "link": "https://leetcode.com/problems/manhattan-distances-of-all-arrangements-of-pieces/", + "title": "Manhattan Distances of All Arrangements of Pieces" }, "3427": { - "id": 3427, "category": "Array & Hashing", - "title": "Sum of Variable Length Subarrays", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-variable-length-subarrays/" + "id": 3427, + "link": "https://leetcode.com/problems/sum-of-variable-length-subarrays/", + "title": "Sum of Variable Length Subarrays" }, "3428": { - "id": 3428, "category": "Dynamic Programming", - "title": "Maximum and Minimum Sums of at Most Size K Subsequences", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/" + "id": 3428, + "link": "https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subsequences/", + "title": "Maximum and Minimum Sums of at Most Size K Subsequences" }, "3429": { - "id": 3429, "category": "Dynamic Programming", - "title": "Paint House IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/paint-house-iv/" + "id": 3429, + "link": "https://leetcode.com/problems/paint-house-iv/", + "title": "Paint House IV" }, "3430": { - "id": 3430, "category": "Stack", - "title": "Maximum and Minimum Sums of at Most Size K Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subarrays/" + "id": 3430, + "link": "https://leetcode.com/problems/maximum-and-minimum-sums-of-at-most-size-k-subarrays/", + "title": "Maximum and Minimum Sums of at Most Size K Subarrays" }, "3431": { - "id": 3431, "category": "Array & Hashing", - "title": "Minimum Unlocked Indices to Sort Nums", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-unlocked-indices-to-sort-nums/" + "id": 3431, + "link": "https://leetcode.com/problems/minimum-unlocked-indices-to-sort-nums/", + "title": "Minimum Unlocked Indices to Sort Nums" }, "3432": { - "id": 3432, "category": "Array & Hashing", - "title": "Find the Power of K-Size Subarrays I", "difficulty": "Medium", + "id": 3432, "link": "https://leetcode.com/problems/find-the-power-of-k-size-subarrays-i/", - "tags": ["array", "sliding-window"] + "tags": ["array", "sliding-window"], + "title": "Find the Power of K-Size Subarrays I" }, "3433": { - "id": 3433, "category": "Math & Geometry", - "title": "Count Mentions Per User", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-mentions-per-user/" + "id": 3433, + "link": "https://leetcode.com/problems/count-mentions-per-user/", + "title": "Count Mentions Per User" }, "3434": { - "id": 3434, "category": "Dynamic Programming", - "title": "Maximum Frequency After Subarray Operation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-frequency-after-subarray-operation/" + "id": 3434, + "link": "https://leetcode.com/problems/maximum-frequency-after-subarray-operation/", + "title": "Maximum Frequency After Subarray Operation" }, "3435": { - "id": 3435, "category": "Graph Traversal", - "title": "Frequencies of Shortest Supersequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/frequencies-of-shortest-supersequences/" + "id": 3435, + "link": "https://leetcode.com/problems/frequencies-of-shortest-supersequences/", + "title": "Frequencies of Shortest Supersequences" }, "3436": { - "id": 3436, "category": "Database", - "title": "Find Valid Emails", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-valid-emails/" + "id": 3436, + "link": "https://leetcode.com/problems/find-valid-emails/", + "title": "Find Valid Emails" }, "3437": { - "id": 3437, "category": "Backtracking", - "title": "Permutations III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/permutations-iii/" + "id": 3437, + "link": "https://leetcode.com/problems/permutations-iii/", + "title": "Permutations III" }, "3438": { - "id": 3438, "category": "Array & Hashing", - "title": "Find Valid Pair of Adjacent Digits in String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-valid-pair-of-adjacent-digits-in-string/" + "id": 3438, + "link": "https://leetcode.com/problems/find-valid-pair-of-adjacent-digits-in-string/", + "title": "Find Valid Pair of Adjacent Digits in String" }, "3439": { - "id": 3439, "category": "Sliding Window", - "title": "Reschedule Meetings for Maximum Free Time I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-i/" + "id": 3439, + "link": "https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-i/", + "title": "Reschedule Meetings for Maximum Free Time I" }, "3440": { - "id": 3440, "category": "Greedy", - "title": "Reschedule Meetings for Maximum Free Time II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-ii/" + "id": 3440, + "link": "https://leetcode.com/problems/reschedule-meetings-for-maximum-free-time-ii/", + "title": "Reschedule Meetings for Maximum Free Time II" }, "3441": { - "id": 3441, "category": "Dynamic Programming", - "title": "Minimum Cost Good Caption", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-good-caption/" + "id": 3441, + "link": "https://leetcode.com/problems/minimum-cost-good-caption/", + "title": "Minimum Cost Good Caption" }, "3442": { - "id": 3442, "category": "Array & Hashing", - "title": "Maximum Difference Between Even and Odd Frequency I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/" + "id": 3442, + "link": "https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-i/", + "title": "Maximum Difference Between Even and Odd Frequency I" }, "3443": { - "id": 3443, "category": "Math & Geometry", - "title": "Maximum Manhattan Distance After K Changes", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-manhattan-distance-after-k-changes/" + "id": 3443, + "link": "https://leetcode.com/problems/maximum-manhattan-distance-after-k-changes/", + "title": "Maximum Manhattan Distance After K Changes" }, "3444": { - "id": 3444, "category": "Dynamic Programming", - "title": "Minimum Increments for Target Multiples in an Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-increments-for-target-multiples-in-an-array/" + "id": 3444, + "link": "https://leetcode.com/problems/minimum-increments-for-target-multiples-in-an-array/", + "title": "Minimum Increments for Target Multiples in an Array" }, "3445": { - "id": 3445, "category": "Sliding Window", - "title": "Maximum Difference Between Even and Odd Frequency II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-ii/" + "id": 3445, + "link": "https://leetcode.com/problems/maximum-difference-between-even-and-odd-frequency-ii/", + "title": "Maximum Difference Between Even and Odd Frequency II" }, "3446": { - "id": 3446, "category": "Array & Hashing", - "title": "Sort Matrix by Diagonals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-matrix-by-diagonals/" + "id": 3446, + "link": "https://leetcode.com/problems/sort-matrix-by-diagonals/", + "title": "Sort Matrix by Diagonals" }, "3447": { - "id": 3447, "category": "Array & Hashing", - "title": "Assign Elements to Groups with Constraints", "difficulty": "Medium", - "link": "https://leetcode.com/problems/assign-elements-to-groups-with-constraints/" + "id": 3447, + "link": "https://leetcode.com/problems/assign-elements-to-groups-with-constraints/", + "title": "Assign Elements to Groups with Constraints" }, "3448": { - "id": 3448, "category": "Dynamic Programming", - "title": "Count Substrings Divisible By Last Digit", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-substrings-divisible-by-last-digit/" + "id": 3448, + "link": "https://leetcode.com/problems/count-substrings-divisible-by-last-digit/", + "title": "Count Substrings Divisible By Last Digit" }, "3449": { - "id": 3449, "category": "Binary Search", - "title": "Maximize the Minimum Game Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-minimum-game-score/" + "id": 3449, + "link": "https://leetcode.com/problems/maximize-the-minimum-game-score/", + "title": "Maximize the Minimum Game Score" }, "3450": { - "id": 3450, "category": "Array & Hashing", - "title": "Maximum Students on a Single Bench", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-students-on-a-single-bench/" + "id": 3450, + "link": "https://leetcode.com/problems/maximum-students-on-a-single-bench/", + "title": "Maximum Students on a Single Bench" }, "3451": { - "id": 3451, "category": "Database", - "title": "Find Invalid IP Addresses", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-invalid-ip-addresses/" + "id": 3451, + "link": "https://leetcode.com/problems/find-invalid-ip-addresses/", + "title": "Find Invalid IP Addresses" }, "3452": { - "id": 3452, "category": "Array & Hashing", - "title": "Sum of Good Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-good-numbers/" + "id": 3452, + "link": "https://leetcode.com/problems/sum-of-good-numbers/", + "title": "Sum of Good Numbers" }, "3453": { - "id": 3453, "category": "Binary Search", - "title": "Separate Squares I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/separate-squares-i/" + "id": 3453, + "link": "https://leetcode.com/problems/separate-squares-i/", + "title": "Separate Squares I" }, "3454": { - "id": 3454, "category": "Tree", - "title": "Separate Squares II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/separate-squares-ii/" + "id": 3454, + "link": "https://leetcode.com/problems/separate-squares-ii/", + "title": "Separate Squares II" }, "3455": { - "id": 3455, "category": "Binary Search", - "title": "Shortest Matching Substring", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-matching-substring/" + "id": 3455, + "link": "https://leetcode.com/problems/shortest-matching-substring/", + "title": "Shortest Matching Substring" }, "3456": { - "id": 3456, "category": "Array & Hashing", - "title": "Find Special Substring of Length K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-special-substring-of-length-k/" - }, - "3457": { - "id": 3457, - "category": "Greedy", - "title": "Eat Pizzas!", - "difficulty": "Medium", - "link": "https://leetcode.com/problems/eat-pizzas/" + "id": 3456, + "link": "https://leetcode.com/problems/find-special-substring-of-length-k/", + "title": "Find Special Substring of Length K" }, + "3457": {"category": "Greedy", "difficulty": "Medium", "id": 3457, "link": "https://leetcode.com/problems/eat-pizzas/", "title": "Eat Pizzas!"}, "3458": { - "id": 3458, "category": "Dynamic Programming", - "title": "Select K Disjoint Special Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/select-k-disjoint-special-substrings/" + "id": 3458, + "link": "https://leetcode.com/problems/select-k-disjoint-special-substrings/", + "title": "Select K Disjoint Special Substrings" }, "3459": { - "id": 3459, "category": "Dynamic Programming", - "title": "Length of Longest V-Shaped Diagonal Segment", "difficulty": "Hard", - "link": "https://leetcode.com/problems/length-of-longest-v-shaped-diagonal-segment/" + "id": 3459, + "link": "https://leetcode.com/problems/length-of-longest-v-shaped-diagonal-segment/", + "title": "Length of Longest V-Shaped Diagonal Segment" }, "3460": { - "id": 3460, "category": "Two Pointers", - "title": "Longest Common Prefix After at Most One Removal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-common-prefix-after-at-most-one-removal/" + "id": 3460, + "link": "https://leetcode.com/problems/longest-common-prefix-after-at-most-one-removal/", + "title": "Longest Common Prefix After at Most One Removal" }, "3461": { - "id": 3461, "category": "Math & Geometry", - "title": "Check If Digits Are Equal in String After Operations I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-i/" + "id": 3461, + "link": "https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-i/", + "title": "Check If Digits Are Equal in String After Operations I" }, "3462": { - "id": 3462, "category": "Heap (Priority Queue)", - "title": "Maximum Sum With at Most K Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-sum-with-at-most-k-elements/" + "id": 3462, + "link": "https://leetcode.com/problems/maximum-sum-with-at-most-k-elements/", + "title": "Maximum Sum With at Most K Elements" }, "3463": { - "id": 3463, "category": "Math & Geometry", - "title": "Check If Digits Are Equal in String After Operations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-ii/" + "id": 3463, + "link": "https://leetcode.com/problems/check-if-digits-are-equal-in-string-after-operations-ii/", + "title": "Check If Digits Are Equal in String After Operations II" }, "3464": { - "id": 3464, "category": "Binary Search", - "title": "Maximize the Distance Between Points on a Square", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-the-distance-between-points-on-a-square/" + "id": 3464, + "link": "https://leetcode.com/problems/maximize-the-distance-between-points-on-a-square/", + "title": "Maximize the Distance Between Points on a Square" }, "3465": { - "id": 3465, "category": "Database", - "title": "Find Products with Valid Serial Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-products-with-valid-serial-numbers/" + "id": 3465, + "link": "https://leetcode.com/problems/find-products-with-valid-serial-numbers/", + "title": "Find Products with Valid Serial Numbers" }, "3466": { - "id": 3466, "category": "Dynamic Programming", - "title": "Maximum Coin Collection ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-coin-collection/" + "id": 3466, + "link": "https://leetcode.com/problems/maximum-coin-collection/", + "title": "Maximum Coin Collection " }, "3467": { - "id": 3467, "category": "Array & Hashing", - "title": "Transform Array by Parity", "difficulty": "Easy", - "link": "https://leetcode.com/problems/transform-array-by-parity/" + "id": 3467, + "link": "https://leetcode.com/problems/transform-array-by-parity/", + "title": "Transform Array by Parity" }, "3468": { - "id": 3468, "category": "Math & Geometry", - "title": "Find the Number of Copy Arrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-number-of-copy-arrays/" + "id": 3468, + "link": "https://leetcode.com/problems/find-the-number-of-copy-arrays/", + "title": "Find the Number of Copy Arrays" }, "3469": { - "id": 3469, "category": "Dynamic Programming", - "title": "Find Minimum Cost to Remove Array Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-minimum-cost-to-remove-array-elements/" + "id": 3469, + "link": "https://leetcode.com/problems/find-minimum-cost-to-remove-array-elements/", + "title": "Find Minimum Cost to Remove Array Elements" }, "3470": { - "id": 3470, "category": "Math & Geometry", - "title": "Permutations IV", "difficulty": "Hard", - "link": "https://leetcode.com/problems/permutations-iv/" + "id": 3470, + "link": "https://leetcode.com/problems/permutations-iv/", + "title": "Permutations IV" }, "3471": { - "id": 3471, "category": "Array & Hashing", - "title": "Find the Largest Almost Missing Integer", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-largest-almost-missing-integer/" + "id": 3471, + "link": "https://leetcode.com/problems/find-the-largest-almost-missing-integer/", + "title": "Find the Largest Almost Missing Integer" }, "3472": { - "id": 3472, "category": "Dynamic Programming", - "title": "Longest Palindromic Subsequence After at Most K Operations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindromic-subsequence-after-at-most-k-operations/" + "id": 3472, + "link": "https://leetcode.com/problems/longest-palindromic-subsequence-after-at-most-k-operations/", + "title": "Longest Palindromic Subsequence After at Most K Operations" }, "3473": { - "id": 3473, "category": "Dynamic Programming", - "title": "Sum of K Subarrays With Length at Least M", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-k-subarrays-with-length-at-least-m/" + "id": 3473, + "link": "https://leetcode.com/problems/sum-of-k-subarrays-with-length-at-least-m/", + "title": "Sum of K Subarrays With Length at Least M" }, "3474": { - "id": 3474, "category": "Greedy", - "title": "Lexicographically Smallest Generated String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/lexicographically-smallest-generated-string/" + "id": 3474, + "link": "https://leetcode.com/problems/lexicographically-smallest-generated-string/", + "title": "Lexicographically Smallest Generated String" }, "3475": { - "id": 3475, "category": "Database", - "title": "DNA Pattern Recognition ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/dna-pattern-recognition/" + "id": 3475, + "link": "https://leetcode.com/problems/dna-pattern-recognition/", + "title": "DNA Pattern Recognition " }, "3476": { - "id": 3476, "category": "Heap (Priority Queue)", - "title": "Maximize Profit from Task Assignment", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-profit-from-task-assignment/" + "id": 3476, + "link": "https://leetcode.com/problems/maximize-profit-from-task-assignment/", + "title": "Maximize Profit from Task Assignment" }, "3477": { - "id": 3477, "category": "Tree", - "title": "Fruits Into Baskets II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/fruits-into-baskets-ii/" + "id": 3477, + "link": "https://leetcode.com/problems/fruits-into-baskets-ii/", + "title": "Fruits Into Baskets II" }, "3478": { - "id": 3478, "category": "Heap (Priority Queue)", - "title": "Choose K Elements With Maximum Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/choose-k-elements-with-maximum-sum/" + "id": 3478, + "link": "https://leetcode.com/problems/choose-k-elements-with-maximum-sum/", + "title": "Choose K Elements With Maximum Sum" }, "3479": { - "id": 3479, "category": "Tree", - "title": "Fruits Into Baskets III", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fruits-into-baskets-iii/" + "id": 3479, + "link": "https://leetcode.com/problems/fruits-into-baskets-iii/", + "title": "Fruits Into Baskets III" }, "3480": { - "id": 3480, "category": "Tree", - "title": "Maximize Subarrays After Removing One Conflicting Pair", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-subarrays-after-removing-one-conflicting-pair/" + "id": 3480, + "link": "https://leetcode.com/problems/maximize-subarrays-after-removing-one-conflicting-pair/", + "title": "Maximize Subarrays After Removing One Conflicting Pair" }, "3481": { - "id": 3481, "category": "Graph Traversal", - "title": "Apply Substitutions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/apply-substitutions/" + "id": 3481, + "link": "https://leetcode.com/problems/apply-substitutions/", + "title": "Apply Substitutions" }, "3482": { - "id": 3482, "category": "Database", - "title": "Analyze Organization Hierarchy", "difficulty": "Hard", - "link": "https://leetcode.com/problems/analyze-organization-hierarchy/" + "id": 3482, + "link": "https://leetcode.com/problems/analyze-organization-hierarchy/", + "title": "Analyze Organization Hierarchy" }, "3483": { - "id": 3483, "category": "Array & Hashing", - "title": "Unique 3-Digit Even Numbers", "difficulty": "Easy", - "link": "https://leetcode.com/problems/unique-3-digit-even-numbers/" + "id": 3483, + "link": "https://leetcode.com/problems/unique-3-digit-even-numbers/", + "title": "Unique 3-Digit Even Numbers" }, "3484": { - "id": 3484, "category": "Array & Hashing", - "title": "Design Spreadsheet", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-spreadsheet/" + "id": 3484, + "link": "https://leetcode.com/problems/design-spreadsheet/", + "title": "Design Spreadsheet" }, "3485": { - "id": 3485, "category": "Trie", - "title": "Longest Common Prefix of K Strings After Removal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-common-prefix-of-k-strings-after-removal/" + "id": 3485, + "link": "https://leetcode.com/problems/longest-common-prefix-of-k-strings-after-removal/", + "title": "Longest Common Prefix of K Strings After Removal" }, "3486": { - "id": 3486, "category": "Tree", - "title": "Longest Special Path II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-special-path-ii/" + "id": 3486, + "link": "https://leetcode.com/problems/longest-special-path-ii/", + "title": "Longest Special Path II" }, "3487": { - "id": 3487, "category": "Greedy", - "title": "Maximum Unique Subarray Sum After Deletion", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion/" + "id": 3487, + "link": "https://leetcode.com/problems/maximum-unique-subarray-sum-after-deletion/", + "title": "Maximum Unique Subarray Sum After Deletion" }, "3488": { - "id": 3488, "category": "Binary Search", - "title": "Closest Equal Element Queries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/closest-equal-element-queries/" + "id": 3488, + "link": "https://leetcode.com/problems/closest-equal-element-queries/", + "title": "Closest Equal Element Queries" }, "3489": { - "id": 3489, "category": "Dynamic Programming", - "title": "Zero Array Transformation IV", "difficulty": "Medium", - "link": "https://leetcode.com/problems/zero-array-transformation-iv/" + "id": 3489, + "link": "https://leetcode.com/problems/zero-array-transformation-iv/", + "title": "Zero Array Transformation IV" }, "3490": { - "id": 3490, "category": "Dynamic Programming", - "title": "Count Beautiful Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-beautiful-numbers/" + "id": 3490, + "link": "https://leetcode.com/problems/count-beautiful-numbers/", + "title": "Count Beautiful Numbers" }, "3491": { - "id": 3491, "category": "Trie", - "title": "Phone Number Prefix", "difficulty": "Easy", - "link": "https://leetcode.com/problems/phone-number-prefix/" + "id": 3491, + "link": "https://leetcode.com/problems/phone-number-prefix/", + "title": "Phone Number Prefix" }, "3492": { - "id": 3492, "category": "Math & Geometry", - "title": "Maximum Containers on a Ship", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-containers-on-a-ship/" + "id": 3492, + "link": "https://leetcode.com/problems/maximum-containers-on-a-ship/", + "title": "Maximum Containers on a Ship" }, "3493": { - "id": 3493, "category": "Graph Traversal", - "title": "Properties Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/properties-graph/" + "id": 3493, + "link": "https://leetcode.com/problems/properties-graph/", + "title": "Properties Graph" }, "3494": { - "id": 3494, "category": "Array & Hashing", - "title": "Find the Minimum Amount of Time to Brew Potions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-minimum-amount-of-time-to-brew-potions/" + "id": 3494, + "link": "https://leetcode.com/problems/find-the-minimum-amount-of-time-to-brew-potions/", + "title": "Find the Minimum Amount of Time to Brew Potions" }, "3495": { - "id": 3495, "category": "Bit Manipulation", - "title": "Minimum Operations to Make Array Elements Zero", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero/" + "id": 3495, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-elements-zero/", + "title": "Minimum Operations to Make Array Elements Zero" }, "3496": { - "id": 3496, "category": "Greedy", - "title": "Maximize Score After Pair Deletions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-score-after-pair-deletions/" + "id": 3496, + "link": "https://leetcode.com/problems/maximize-score-after-pair-deletions/", + "title": "Maximize Score After Pair Deletions" }, "3497": { - "id": 3497, "category": "Database", - "title": "Analyze Subscription Conversion ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/analyze-subscription-conversion/" + "id": 3497, + "link": "https://leetcode.com/problems/analyze-subscription-conversion/", + "title": "Analyze Subscription Conversion " }, "3498": { - "id": 3498, "category": "Array & Hashing", - "title": "Reverse Degree of a String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/reverse-degree-of-a-string/" + "id": 3498, + "link": "https://leetcode.com/problems/reverse-degree-of-a-string/", + "title": "Reverse Degree of a String" }, "3499": { - "id": 3499, "category": "Array & Hashing", - "title": "Maximize Active Section with Trade I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-active-section-with-trade-i/" + "id": 3499, + "link": "https://leetcode.com/problems/maximize-active-section-with-trade-i/", + "title": "Maximize Active Section with Trade I" }, "3500": { - "id": 3500, "category": "Dynamic Programming", - "title": "Minimum Cost to Divide Array Into Subarrays", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-to-divide-array-into-subarrays/" + "id": 3500, + "link": "https://leetcode.com/problems/minimum-cost-to-divide-array-into-subarrays/", + "title": "Minimum Cost to Divide Array Into Subarrays" }, "3501": { - "id": 3501, "category": "Tree", - "title": "Maximize Active Section with Trade II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-active-section-with-trade-ii/" + "id": 3501, + "link": "https://leetcode.com/problems/maximize-active-section-with-trade-ii/", + "title": "Maximize Active Section with Trade II" }, "3502": { - "id": 3502, "category": "Array & Hashing", - "title": "Minimum Cost to Reach Every Position", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-cost-to-reach-every-position/" + "id": 3502, + "link": "https://leetcode.com/problems/minimum-cost-to-reach-every-position/", + "title": "Minimum Cost to Reach Every Position" }, "3503": { - "id": 3503, "category": "Dynamic Programming", - "title": "Longest Palindrome After Substring Concatenation I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-i/" + "id": 3503, + "link": "https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-i/", + "title": "Longest Palindrome After Substring Concatenation I" }, "3504": { - "id": 3504, "category": "Dynamic Programming", - "title": "Longest Palindrome After Substring Concatenation II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-ii/" + "id": 3504, + "link": "https://leetcode.com/problems/longest-palindrome-after-substring-concatenation-ii/", + "title": "Longest Palindrome After Substring Concatenation II" }, "3505": { - "id": 3505, "category": "Dynamic Programming", - "title": "Minimum Operations to Make Elements Within K Subarrays Equal", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-make-elements-within-k-subarrays-equal/" + "id": 3505, + "link": "https://leetcode.com/problems/minimum-operations-to-make-elements-within-k-subarrays-equal/", + "title": "Minimum Operations to Make Elements Within K Subarrays Equal" }, "3506": { - "id": 3506, "category": "Heap (Priority Queue)", - "title": "Find Time Required to Eliminate Bacterial Strains", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-time-required-to-eliminate-bacterial-strains/" + "id": 3506, + "link": "https://leetcode.com/problems/find-time-required-to-eliminate-bacterial-strains/", + "title": "Find Time Required to Eliminate Bacterial Strains" }, "3507": { - "id": 3507, "category": "Heap (Priority Queue)", - "title": "Minimum Pair Removal to Sort Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-pair-removal-to-sort-array-i/" + "id": 3507, + "link": "https://leetcode.com/problems/minimum-pair-removal-to-sort-array-i/", + "title": "Minimum Pair Removal to Sort Array I" }, "3508": { - "id": 3508, "category": "Binary Search", - "title": "Implement Router", "difficulty": "Medium", - "link": "https://leetcode.com/problems/implement-router/" + "id": 3508, + "link": "https://leetcode.com/problems/implement-router/", + "title": "Implement Router" }, "3509": { - "id": 3509, "category": "Dynamic Programming", - "title": "Maximum Product of Subsequences With an Alternating Sum Equal to K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k/" + "id": 3509, + "link": "https://leetcode.com/problems/maximum-product-of-subsequences-with-an-alternating-sum-equal-to-k/", + "title": "Maximum Product of Subsequences With an Alternating Sum Equal to K" }, "3510": { - "id": 3510, "category": "Heap (Priority Queue)", - "title": "Minimum Pair Removal to Sort Array II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-pair-removal-to-sort-array-ii/" + "id": 3510, + "link": "https://leetcode.com/problems/minimum-pair-removal-to-sort-array-ii/", + "title": "Minimum Pair Removal to Sort Array II" }, "3511": { - "id": 3511, "category": "Greedy", - "title": "Make a Positive Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-a-positive-array/" + "id": 3511, + "link": "https://leetcode.com/problems/make-a-positive-array/", + "title": "Make a Positive Array" }, "3512": { - "id": 3512, "category": "Math & Geometry", - "title": "Minimum Operations to Make Array Sum Divisible by K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-make-array-sum-divisible-by-k/" + "id": 3512, + "link": "https://leetcode.com/problems/minimum-operations-to-make-array-sum-divisible-by-k/", + "title": "Minimum Operations to Make Array Sum Divisible by K" }, "3513": { - "id": 3513, "category": "Bit Manipulation", - "title": "Number of Unique XOR Triplets I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-unique-xor-triplets-i/" + "id": 3513, + "link": "https://leetcode.com/problems/number-of-unique-xor-triplets-i/", + "title": "Number of Unique XOR Triplets I" }, "3514": { - "id": 3514, "category": "Bit Manipulation", - "title": "Number of Unique XOR Triplets II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-unique-xor-triplets-ii/" + "id": 3514, + "link": "https://leetcode.com/problems/number-of-unique-xor-triplets-ii/", + "title": "Number of Unique XOR Triplets II" }, "3515": { - "id": 3515, "category": "Tree", - "title": "Shortest Path in a Weighted Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/shortest-path-in-a-weighted-tree/" + "id": 3515, + "link": "https://leetcode.com/problems/shortest-path-in-a-weighted-tree/", + "title": "Shortest Path in a Weighted Tree" }, "3516": { - "id": 3516, "category": "Math & Geometry", - "title": "Find Closest Person", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-closest-person/" + "id": 3516, + "link": "https://leetcode.com/problems/find-closest-person/", + "title": "Find Closest Person" }, "3517": { - "id": 3517, "category": "Array & Hashing", - "title": "Smallest Palindromic Rearrangement I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-palindromic-rearrangement-i/" + "id": 3517, + "link": "https://leetcode.com/problems/smallest-palindromic-rearrangement-i/", + "title": "Smallest Palindromic Rearrangement I" }, "3518": { - "id": 3518, "category": "Math & Geometry", - "title": "Smallest Palindromic Rearrangement II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/smallest-palindromic-rearrangement-ii/" + "id": 3518, + "link": "https://leetcode.com/problems/smallest-palindromic-rearrangement-ii/", + "title": "Smallest Palindromic Rearrangement II" }, "3519": { - "id": 3519, "category": "Dynamic Programming", - "title": "Count Numbers with Non-Decreasing Digits ", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-numbers-with-non-decreasing-digits/" + "id": 3519, + "link": "https://leetcode.com/problems/count-numbers-with-non-decreasing-digits/", + "title": "Count Numbers with Non-Decreasing Digits " }, "3520": { - "id": 3520, "category": "Tree", - "title": "Minimum Threshold for Inversion Pairs Count", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-threshold-for-inversion-pairs-count/" + "id": 3520, + "link": "https://leetcode.com/problems/minimum-threshold-for-inversion-pairs-count/", + "title": "Minimum Threshold for Inversion Pairs Count" }, "3521": { - "id": 3521, "category": "Database", - "title": "Find Product Recommendation Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-product-recommendation-pairs/" + "id": 3521, + "link": "https://leetcode.com/problems/find-product-recommendation-pairs/", + "title": "Find Product Recommendation Pairs" }, "3522": { - "id": 3522, "category": "Array & Hashing", - "title": "Calculate Score After Performing Instructions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/calculate-score-after-performing-instructions/" + "id": 3522, + "link": "https://leetcode.com/problems/calculate-score-after-performing-instructions/", + "title": "Calculate Score After Performing Instructions" }, "3523": { - "id": 3523, "category": "Stack", - "title": "Make Array Non-decreasing", "difficulty": "Medium", - "link": "https://leetcode.com/problems/make-array-non-decreasing/" + "id": 3523, + "link": "https://leetcode.com/problems/make-array-non-decreasing/", + "title": "Make Array Non-decreasing" }, "3524": { - "id": 3524, "category": "Dynamic Programming", - "title": "Find X Value of Array I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-x-value-of-array-i/" + "id": 3524, + "link": "https://leetcode.com/problems/find-x-value-of-array-i/", + "title": "Find X Value of Array I" }, "3525": { - "id": 3525, "category": "Tree", - "title": "Find X Value of Array II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-x-value-of-array-ii/" + "id": 3525, + "link": "https://leetcode.com/problems/find-x-value-of-array-ii/", + "title": "Find X Value of Array II" }, "3526": { - "id": 3526, "category": "Tree", - "title": "Range XOR Queries with Subarray Reversals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/range-xor-queries-with-subarray-reversals/" + "id": 3526, + "link": "https://leetcode.com/problems/range-xor-queries-with-subarray-reversals/", + "title": "Range XOR Queries with Subarray Reversals" }, "3527": { - "id": 3527, "category": "Array & Hashing", - "title": "Find the Most Common Response", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-the-most-common-response/" + "id": 3527, + "link": "https://leetcode.com/problems/find-the-most-common-response/", + "title": "Find the Most Common Response" }, "3528": { - "id": 3528, "category": "Graph Traversal", - "title": "Unit Conversion I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unit-conversion-i/" + "id": 3528, + "link": "https://leetcode.com/problems/unit-conversion-i/", + "title": "Unit Conversion I" }, "3529": { - "id": 3529, "category": "Array & Hashing", - "title": "Count Cells in Overlapping Horizontal and Vertical Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-cells-in-overlapping-horizontal-and-vertical-substrings/" + "id": 3529, + "link": "https://leetcode.com/problems/count-cells-in-overlapping-horizontal-and-vertical-substrings/", + "title": "Count Cells in Overlapping Horizontal and Vertical Substrings" }, "3530": { - "id": 3530, "category": "Graph Traversal", - "title": "Maximum Profit from Valid Topological Order in DAG", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-profit-from-valid-topological-order-in-dag/" + "id": 3530, + "link": "https://leetcode.com/problems/maximum-profit-from-valid-topological-order-in-dag/", + "title": "Maximum Profit from Valid Topological Order in DAG" }, "3531": { - "id": 3531, "category": "Array & Hashing", - "title": "Count Covered Buildings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-covered-buildings/" + "id": 3531, + "link": "https://leetcode.com/problems/count-covered-buildings/", + "title": "Count Covered Buildings" }, "3532": { - "id": 3532, "category": "Graph Traversal", - "title": "Path Existence Queries in a Graph I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/path-existence-queries-in-a-graph-i/" + "id": 3532, + "link": "https://leetcode.com/problems/path-existence-queries-in-a-graph-i/", + "title": "Path Existence Queries in a Graph I" }, "3533": { - "id": 3533, "category": "Dynamic Programming", - "title": "Concatenated Divisibility", "difficulty": "Hard", - "link": "https://leetcode.com/problems/concatenated-divisibility/" + "id": 3533, + "link": "https://leetcode.com/problems/concatenated-divisibility/", + "title": "Concatenated Divisibility" }, "3534": { - "id": 3534, "category": "Graph Traversal", - "title": "Path Existence Queries in a Graph II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/path-existence-queries-in-a-graph-ii/" + "id": 3534, + "link": "https://leetcode.com/problems/path-existence-queries-in-a-graph-ii/", + "title": "Path Existence Queries in a Graph II" }, "3535": { - "id": 3535, "category": "Graph Traversal", - "title": "Unit Conversion II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/unit-conversion-ii/" + "id": 3535, + "link": "https://leetcode.com/problems/unit-conversion-ii/", + "title": "Unit Conversion II" }, "3536": { - "id": 3536, "category": "Math & Geometry", - "title": "Maximum Product of Two Digits", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-product-of-two-digits/" + "id": 3536, + "link": "https://leetcode.com/problems/maximum-product-of-two-digits/", + "title": "Maximum Product of Two Digits" }, "3537": { - "id": 3537, "category": "Array & Hashing", - "title": "Fill a Special Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/fill-a-special-grid/" + "id": 3537, + "link": "https://leetcode.com/problems/fill-a-special-grid/", + "title": "Fill a Special Grid" }, "3538": { - "id": 3538, "category": "Dynamic Programming", - "title": "Merge Operations for Minimum Travel Time", "difficulty": "Hard", - "link": "https://leetcode.com/problems/merge-operations-for-minimum-travel-time/" + "id": 3538, + "link": "https://leetcode.com/problems/merge-operations-for-minimum-travel-time/", + "title": "Merge Operations for Minimum Travel Time" }, "3539": { - "id": 3539, "category": "Dynamic Programming", - "title": "Find Sum of Array Product of Magical Sequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-sum-of-array-product-of-magical-sequences/" + "id": 3539, + "link": "https://leetcode.com/problems/find-sum-of-array-product-of-magical-sequences/", + "title": "Find Sum of Array Product of Magical Sequences" }, "3540": { - "id": 3540, "category": "Array & Hashing", - "title": "Minimum Time to Visit All Houses", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-visit-all-houses/" + "id": 3540, + "link": "https://leetcode.com/problems/minimum-time-to-visit-all-houses/", + "title": "Minimum Time to Visit All Houses" }, "3541": { - "id": 3541, "category": "Array & Hashing", - "title": "Find Most Frequent Vowel and Consonant", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-most-frequent-vowel-and-consonant/" + "id": 3541, + "link": "https://leetcode.com/problems/find-most-frequent-vowel-and-consonant/", + "title": "Find Most Frequent Vowel and Consonant" }, "3542": { - "id": 3542, "category": "Stack", - "title": "Minimum Operations to Convert All Elements to Zero", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-convert-all-elements-to-zero/" + "id": 3542, + "link": "https://leetcode.com/problems/minimum-operations-to-convert-all-elements-to-zero/", + "title": "Minimum Operations to Convert All Elements to Zero" }, "3543": { - "id": 3543, "category": "Graph Traversal", - "title": "Maximum Weighted K-Edge Path", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-weighted-k-edge-path/" + "id": 3543, + "link": "https://leetcode.com/problems/maximum-weighted-k-edge-path/", + "title": "Maximum Weighted K-Edge Path" }, "3544": { - "id": 3544, "category": "Tree", - "title": "Subtree Inversion Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subtree-inversion-sum/" + "id": 3544, + "link": "https://leetcode.com/problems/subtree-inversion-sum/", + "title": "Subtree Inversion Sum" }, "3545": { - "id": 3545, "category": "Greedy", - "title": "Minimum Deletions for At Most K Distinct Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-deletions-for-at-most-k-distinct-characters/" + "id": 3545, + "link": "https://leetcode.com/problems/minimum-deletions-for-at-most-k-distinct-characters/", + "title": "Minimum Deletions for At Most K Distinct Characters" }, "3546": { - "id": 3546, "category": "Array & Hashing", - "title": "Equal Sum Grid Partition I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/equal-sum-grid-partition-i/" + "id": 3546, + "link": "https://leetcode.com/problems/equal-sum-grid-partition-i/", + "title": "Equal Sum Grid Partition I" }, "3547": { - "id": 3547, "category": "Graph Traversal", - "title": "Maximum Sum of Edge Values in a Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-sum-of-edge-values-in-a-graph/" + "id": 3547, + "link": "https://leetcode.com/problems/maximum-sum-of-edge-values-in-a-graph/", + "title": "Maximum Sum of Edge Values in a Graph" }, "3548": { - "id": 3548, "category": "Array & Hashing", - "title": "Equal Sum Grid Partition II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/equal-sum-grid-partition-ii/" + "id": 3548, + "link": "https://leetcode.com/problems/equal-sum-grid-partition-ii/", + "title": "Equal Sum Grid Partition II" }, "3549": { - "id": 3549, "category": "Math & Geometry", - "title": "Multiply Two Polynomials", "difficulty": "Hard", - "link": "https://leetcode.com/problems/multiply-two-polynomials/" + "id": 3549, + "link": "https://leetcode.com/problems/multiply-two-polynomials/", + "title": "Multiply Two Polynomials" }, "3550": { - "id": 3550, "category": "Math & Geometry", - "title": "Smallest Index With Digit Sum Equal to Index", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-index-with-digit-sum-equal-to-index/" + "id": 3550, + "link": "https://leetcode.com/problems/smallest-index-with-digit-sum-equal-to-index/", + "title": "Smallest Index With Digit Sum Equal to Index" }, "3551": { - "id": 3551, "category": "Array & Hashing", - "title": "Minimum Swaps to Sort by Digit Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-swaps-to-sort-by-digit-sum/" + "id": 3551, + "link": "https://leetcode.com/problems/minimum-swaps-to-sort-by-digit-sum/", + "title": "Minimum Swaps to Sort by Digit Sum" }, "3552": { - "id": 3552, "category": "Graph Traversal", - "title": "Grid Teleportation Traversal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/grid-teleportation-traversal/" + "id": 3552, + "link": "https://leetcode.com/problems/grid-teleportation-traversal/", + "title": "Grid Teleportation Traversal" }, "3553": { - "id": 3553, "category": "Tree", - "title": "Minimum Weighted Subgraph With the Required Paths II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths-ii/" + "id": 3553, + "link": "https://leetcode.com/problems/minimum-weighted-subgraph-with-the-required-paths-ii/", + "title": "Minimum Weighted Subgraph With the Required Paths II" }, "3554": { - "id": 3554, "category": "Database", - "title": "Find Category Recommendation Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-category-recommendation-pairs/" + "id": 3554, + "link": "https://leetcode.com/problems/find-category-recommendation-pairs/", + "title": "Find Category Recommendation Pairs" }, "3555": { - "id": 3555, "category": "Stack", - "title": "Smallest Subarray to Sort in Every Sliding Window", "difficulty": "Medium", - "link": "https://leetcode.com/problems/smallest-subarray-to-sort-in-every-sliding-window/" + "id": 3555, + "link": "https://leetcode.com/problems/smallest-subarray-to-sort-in-every-sliding-window/", + "title": "Smallest Subarray to Sort in Every Sliding Window" }, "3556": { - "id": 3556, "category": "Math & Geometry", - "title": "Sum of Largest Prime Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-largest-prime-substrings/" + "id": 3556, + "link": "https://leetcode.com/problems/sum-of-largest-prime-substrings/", + "title": "Sum of Largest Prime Substrings" }, "3557": { - "id": 3557, "category": "Dynamic Programming", - "title": "Find Maximum Number of Non Intersecting Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-maximum-number-of-non-intersecting-substrings/" + "id": 3557, + "link": "https://leetcode.com/problems/find-maximum-number-of-non-intersecting-substrings/", + "title": "Find Maximum Number of Non Intersecting Substrings" }, "3558": { - "id": 3558, "category": "Tree", - "title": "Number of Ways to Assign Edge Weights I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-i/" + "id": 3558, + "link": "https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-i/", + "title": "Number of Ways to Assign Edge Weights I" }, "3559": { - "id": 3559, "category": "Tree", - "title": "Number of Ways to Assign Edge Weights II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-ii/" + "id": 3559, + "link": "https://leetcode.com/problems/number-of-ways-to-assign-edge-weights-ii/", + "title": "Number of Ways to Assign Edge Weights II" }, "3560": { - "id": 3560, "category": "Math & Geometry", - "title": "Find Minimum Log Transportation Cost", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-minimum-log-transportation-cost/" + "id": 3560, + "link": "https://leetcode.com/problems/find-minimum-log-transportation-cost/", + "title": "Find Minimum Log Transportation Cost" }, "3561": { - "id": 3561, "category": "Stack", - "title": "Resulting String After Adjacent Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/resulting-string-after-adjacent-removals/" + "id": 3561, + "link": "https://leetcode.com/problems/resulting-string-after-adjacent-removals/", + "title": "Resulting String After Adjacent Removals" }, "3562": { - "id": 3562, "category": "Tree", - "title": "Maximum Profit from Trading Stocks with Discounts", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-profit-from-trading-stocks-with-discounts/" + "id": 3562, + "link": "https://leetcode.com/problems/maximum-profit-from-trading-stocks-with-discounts/", + "title": "Maximum Profit from Trading Stocks with Discounts" }, "3563": { - "id": 3563, "category": "Dynamic Programming", - "title": "Lexicographically Smallest String After Adjacent Removals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-adjacent-removals/" + "id": 3563, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-adjacent-removals/", + "title": "Lexicographically Smallest String After Adjacent Removals" }, "3564": { - "id": 3564, "category": "Database", - "title": "Seasonal Sales Analysis", "difficulty": "Medium", - "link": "https://leetcode.com/problems/seasonal-sales-analysis/" + "id": 3564, + "link": "https://leetcode.com/problems/seasonal-sales-analysis/", + "title": "Seasonal Sales Analysis" }, "3565": { - "id": 3565, "category": "Array & Hashing", - "title": "Sequential Grid Path Cover", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sequential-grid-path-cover/" + "id": 3565, + "link": "https://leetcode.com/problems/sequential-grid-path-cover/", + "title": "Sequential Grid Path Cover" }, "3566": { - "id": 3566, "category": "Bit Manipulation", - "title": "Partition Array into Two Equal Product Subsets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-into-two-equal-product-subsets/" + "id": 3566, + "link": "https://leetcode.com/problems/partition-array-into-two-equal-product-subsets/", + "title": "Partition Array into Two Equal Product Subsets" }, "3567": { - "id": 3567, "category": "Array & Hashing", - "title": "Minimum Absolute Difference in Sliding Submatrix", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-absolute-difference-in-sliding-submatrix/" + "id": 3567, + "link": "https://leetcode.com/problems/minimum-absolute-difference-in-sliding-submatrix/", + "title": "Minimum Absolute Difference in Sliding Submatrix" }, "3568": { - "id": 3568, "category": "Graph Traversal", - "title": "Minimum Moves to Clean the Classroom", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-moves-to-clean-the-classroom/" + "id": 3568, + "link": "https://leetcode.com/problems/minimum-moves-to-clean-the-classroom/", + "title": "Minimum Moves to Clean the Classroom" }, "3569": { - "id": 3569, "category": "Tree", - "title": "Maximize Count of Distinct Primes After Split", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-count-of-distinct-primes-after-split/" + "id": 3569, + "link": "https://leetcode.com/problems/maximize-count-of-distinct-primes-after-split/", + "title": "Maximize Count of Distinct Primes After Split" }, "3570": { - "id": 3570, "category": "Database", - "title": "Find Books with No Available Copies", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-books-with-no-available-copies/" + "id": 3570, + "link": "https://leetcode.com/problems/find-books-with-no-available-copies/", + "title": "Find Books with No Available Copies" }, "3571": { - "id": 3571, "category": "Array & Hashing", - "title": "Find the Shortest Superstring II", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-shortest-superstring-ii/" + "id": 3571, + "link": "https://leetcode.com/problems/find-the-shortest-superstring-ii/", + "title": "Find the Shortest Superstring II" }, "3572": { - "id": 3572, "category": "Heap (Priority Queue)", - "title": "Maximize Y\u2011Sum by Picking a Triplet of Distinct X\u2011Values", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues/" + "id": 3572, + "link": "https://leetcode.com/problems/maximize-ysum-by-picking-a-triplet-of-distinct-xvalues/", + "title": "Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values" }, "3573": { - "id": 3573, "category": "Dynamic Programming", - "title": "Best Time to Buy and Sell Stock V", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-v/" + "id": 3573, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-v/", + "title": "Best Time to Buy and Sell Stock V" }, "3574": { - "id": 3574, "category": "Math & Geometry", - "title": "Maximize Subarray GCD Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-subarray-gcd-score/" + "id": 3574, + "link": "https://leetcode.com/problems/maximize-subarray-gcd-score/", + "title": "Maximize Subarray GCD Score" }, "3575": { - "id": 3575, "category": "Tree", - "title": "Maximum Good Subtree Score", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-good-subtree-score/" + "id": 3575, + "link": "https://leetcode.com/problems/maximum-good-subtree-score/", + "title": "Maximum Good Subtree Score" }, "3576": { - "id": 3576, "category": "Greedy", - "title": "Transform Array to All Equal Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/transform-array-to-all-equal-elements/" + "id": 3576, + "link": "https://leetcode.com/problems/transform-array-to-all-equal-elements/", + "title": "Transform Array to All Equal Elements" }, "3577": { - "id": 3577, "category": "Math & Geometry", - "title": "Count the Number of Computer Unlocking Permutations", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-the-number-of-computer-unlocking-permutations/" + "id": 3577, + "link": "https://leetcode.com/problems/count-the-number-of-computer-unlocking-permutations/", + "title": "Count the Number of Computer Unlocking Permutations" }, "3578": { - "id": 3578, "category": "Dynamic Programming", - "title": "Count Partitions With Max-Min Difference at Most K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-partitions-with-max-min-difference-at-most-k/" + "id": 3578, + "link": "https://leetcode.com/problems/count-partitions-with-max-min-difference-at-most-k/", + "title": "Count Partitions With Max-Min Difference at Most K" }, "3579": { - "id": 3579, "category": "Dynamic Programming", - "title": "Minimum Steps to Convert String with Operations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-steps-to-convert-string-with-operations/" + "id": 3579, + "link": "https://leetcode.com/problems/minimum-steps-to-convert-string-with-operations/", + "title": "Minimum Steps to Convert String with Operations" }, "3580": { - "id": 3580, "category": "Database", - "title": "Find Consistently Improving Employees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-consistently-improving-employees/" + "id": 3580, + "link": "https://leetcode.com/problems/find-consistently-improving-employees/", + "title": "Find Consistently Improving Employees" }, "3581": { - "id": 3581, "category": "Array & Hashing", - "title": "Count Odd Letters from Number", "difficulty": "Easy", - "link": "https://leetcode.com/problems/count-odd-letters-from-number/" + "id": 3581, + "link": "https://leetcode.com/problems/count-odd-letters-from-number/", + "title": "Count Odd Letters from Number" }, "3582": { - "id": 3582, "category": "Array & Hashing", - "title": "Generate Tag for Video Caption", "difficulty": "Easy", - "link": "https://leetcode.com/problems/generate-tag-for-video-caption/" + "id": 3582, + "link": "https://leetcode.com/problems/generate-tag-for-video-caption/", + "title": "Generate Tag for Video Caption" }, "3583": { - "id": 3583, "category": "Array & Hashing", - "title": "Count Special Triplets", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-special-triplets/" + "id": 3583, + "link": "https://leetcode.com/problems/count-special-triplets/", + "title": "Count Special Triplets" }, "3584": { - "id": 3584, "category": "Two Pointers", - "title": "Maximum Product of First and Last Elements of a Subsequence", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-first-and-last-elements-of-a-subsequence/" + "id": 3584, + "link": "https://leetcode.com/problems/maximum-product-of-first-and-last-elements-of-a-subsequence/", + "title": "Maximum Product of First and Last Elements of a Subsequence" }, "3585": { - "id": 3585, "category": "Tree", - "title": "Find Weighted Median Node in Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-weighted-median-node-in-tree/" + "id": 3585, + "link": "https://leetcode.com/problems/find-weighted-median-node-in-tree/", + "title": "Find Weighted Median Node in Tree" }, "3586": { - "id": 3586, "category": "Database", - "title": "Find COVID Recovery Patients", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-covid-recovery-patients/" + "id": 3586, + "link": "https://leetcode.com/problems/find-covid-recovery-patients/", + "title": "Find COVID Recovery Patients" }, "3587": { - "id": 3587, "category": "Greedy", - "title": "Minimum Adjacent Swaps to Alternate Parity", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-alternate-parity/" + "id": 3587, + "link": "https://leetcode.com/problems/minimum-adjacent-swaps-to-alternate-parity/", + "title": "Minimum Adjacent Swaps to Alternate Parity" }, "3588": { - "id": 3588, "category": "Greedy", - "title": "Find Maximum Area of a Triangle", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-maximum-area-of-a-triangle/" + "id": 3588, + "link": "https://leetcode.com/problems/find-maximum-area-of-a-triangle/", + "title": "Find Maximum Area of a Triangle" }, "3589": { - "id": 3589, "category": "Sliding Window", - "title": "Count Prime-Gap Balanced Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-prime-gap-balanced-subarrays/" + "id": 3589, + "link": "https://leetcode.com/problems/count-prime-gap-balanced-subarrays/", + "title": "Count Prime-Gap Balanced Subarrays" }, "3590": { - "id": 3590, "category": "Tree", - "title": "Kth Smallest Path XOR Sum", "difficulty": "Hard", - "link": "https://leetcode.com/problems/kth-smallest-path-xor-sum/" + "id": 3590, + "link": "https://leetcode.com/problems/kth-smallest-path-xor-sum/", + "title": "Kth Smallest Path XOR Sum" }, "3591": { - "id": 3591, "category": "Math & Geometry", - "title": "Check if Any Element Has Prime Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-if-any-element-has-prime-frequency/" + "id": 3591, + "link": "https://leetcode.com/problems/check-if-any-element-has-prime-frequency/", + "title": "Check if Any Element Has Prime Frequency" }, "3592": { - "id": 3592, "category": "Dynamic Programming", - "title": "Inverse Coin Change", "difficulty": "Medium", - "link": "https://leetcode.com/problems/inverse-coin-change/" + "id": 3592, + "link": "https://leetcode.com/problems/inverse-coin-change/", + "title": "Inverse Coin Change" }, "3593": { - "id": 3593, "category": "Tree", - "title": "Minimum Increments to Equalize Leaf Paths", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-increments-to-equalize-leaf-paths/" + "id": 3593, + "link": "https://leetcode.com/problems/minimum-increments-to-equalize-leaf-paths/", + "title": "Minimum Increments to Equalize Leaf Paths" }, "3594": { - "id": 3594, "category": "Graph Traversal", - "title": "Minimum Time to Transport All Individuals", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-time-to-transport-all-individuals/" + "id": 3594, + "link": "https://leetcode.com/problems/minimum-time-to-transport-all-individuals/", + "title": "Minimum Time to Transport All Individuals" }, "3595": { - "id": 3595, "category": "Bit Manipulation", - "title": "Once Twice", "difficulty": "Medium", - "link": "https://leetcode.com/problems/once-twice/" + "id": 3595, + "link": "https://leetcode.com/problems/once-twice/", + "title": "Once Twice" }, "3596": { - "id": 3596, "category": "Math & Geometry", - "title": "Minimum Cost Path with Alternating Directions I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-i/" + "id": 3596, + "link": "https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-i/", + "title": "Minimum Cost Path with Alternating Directions I" }, "3597": { - "id": 3597, "category": "Trie", - "title": "Partition String ", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-string/" + "id": 3597, + "link": "https://leetcode.com/problems/partition-string/", + "title": "Partition String " }, "3598": { - "id": 3598, "category": "Array & Hashing", - "title": "Longest Common Prefix Between Adjacent Strings After Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-common-prefix-between-adjacent-strings-after-removals/" + "id": 3598, + "link": "https://leetcode.com/problems/longest-common-prefix-between-adjacent-strings-after-removals/", + "title": "Longest Common Prefix Between Adjacent Strings After Removals" }, "3599": { - "id": 3599, "category": "Dynamic Programming", - "title": "Partition Array to Minimize XOR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-to-minimize-xor/" + "id": 3599, + "link": "https://leetcode.com/problems/partition-array-to-minimize-xor/", + "title": "Partition Array to Minimize XOR" }, "3600": { - "id": 3600, "category": "Tree", - "title": "Maximize Spanning Tree Stability with Upgrades", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-spanning-tree-stability-with-upgrades/" + "id": 3600, + "link": "https://leetcode.com/problems/maximize-spanning-tree-stability-with-upgrades/", + "title": "Maximize Spanning Tree Stability with Upgrades" }, "3601": { - "id": 3601, "category": "Database", - "title": "Find Drivers with Improved Fuel Efficiency", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-drivers-with-improved-fuel-efficiency/" + "id": 3601, + "link": "https://leetcode.com/problems/find-drivers-with-improved-fuel-efficiency/", + "title": "Find Drivers with Improved Fuel Efficiency" }, "3602": { - "id": 3602, "category": "Math & Geometry", - "title": "Hexadecimal and Hexatrigesimal Conversion", "difficulty": "Easy", - "link": "https://leetcode.com/problems/hexadecimal-and-hexatrigesimal-conversion/" + "id": 3602, + "link": "https://leetcode.com/problems/hexadecimal-and-hexatrigesimal-conversion/", + "title": "Hexadecimal and Hexatrigesimal Conversion" }, "3603": { - "id": 3603, "category": "Dynamic Programming", - "title": "Minimum Cost Path with Alternating Directions II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-ii/" + "id": 3603, + "link": "https://leetcode.com/problems/minimum-cost-path-with-alternating-directions-ii/", + "title": "Minimum Cost Path with Alternating Directions II" }, "3604": { - "id": 3604, "category": "Graph Traversal", - "title": "Minimum Time to Reach Destination in Directed Graph", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-reach-destination-in-directed-graph/" + "id": 3604, + "link": "https://leetcode.com/problems/minimum-time-to-reach-destination-in-directed-graph/", + "title": "Minimum Time to Reach Destination in Directed Graph" }, "3605": { - "id": 3605, "category": "Tree", - "title": "Minimum Stability Factor of Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-stability-factor-of-array/" + "id": 3605, + "link": "https://leetcode.com/problems/minimum-stability-factor-of-array/", + "title": "Minimum Stability Factor of Array" }, "3606": { - "id": 3606, "category": "Array & Hashing", - "title": "Coupon Code Validator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/coupon-code-validator/" + "id": 3606, + "link": "https://leetcode.com/problems/coupon-code-validator/", + "title": "Coupon Code Validator" }, "3607": { - "id": 3607, "category": "Graph Traversal", - "title": "Power Grid Maintenance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/power-grid-maintenance/" + "id": 3607, + "link": "https://leetcode.com/problems/power-grid-maintenance/", + "title": "Power Grid Maintenance" }, "3608": { - "id": 3608, "category": "Graph Traversal", - "title": "Minimum Time for K Connected Components", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-for-k-connected-components/" + "id": 3608, + "link": "https://leetcode.com/problems/minimum-time-for-k-connected-components/", + "title": "Minimum Time for K Connected Components" }, "3609": { - "id": 3609, "category": "Math & Geometry", - "title": "Minimum Moves to Reach Target in Grid", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-in-grid/" + "id": 3609, + "link": "https://leetcode.com/problems/minimum-moves-to-reach-target-in-grid/", + "title": "Minimum Moves to Reach Target in Grid" }, "3610": { - "id": 3610, "category": "Dynamic Programming", - "title": "Minimum Number of Primes to Sum to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-number-of-primes-to-sum-to-target/" + "id": 3610, + "link": "https://leetcode.com/problems/minimum-number-of-primes-to-sum-to-target/", + "title": "Minimum Number of Primes to Sum to Target" }, "3611": { - "id": 3611, "category": "Database", - "title": "Find Overbooked Employees", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-overbooked-employees/" + "id": 3611, + "link": "https://leetcode.com/problems/find-overbooked-employees/", + "title": "Find Overbooked Employees" }, "3612": { - "id": 3612, "category": "Array & Hashing", - "title": "Process String with Special Operations I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/process-string-with-special-operations-i/" + "id": 3612, + "link": "https://leetcode.com/problems/process-string-with-special-operations-i/", + "title": "Process String with Special Operations I" }, "3613": { - "id": 3613, "category": "Graph Traversal", - "title": "Minimize Maximum Component Cost", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimize-maximum-component-cost/" + "id": 3613, + "link": "https://leetcode.com/problems/minimize-maximum-component-cost/", + "title": "Minimize Maximum Component Cost" }, "3614": { - "id": 3614, "category": "Array & Hashing", - "title": "Process String with Special Operations II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/process-string-with-special-operations-ii/" + "id": 3614, + "link": "https://leetcode.com/problems/process-string-with-special-operations-ii/", + "title": "Process String with Special Operations II" }, "3615": { - "id": 3615, "category": "Graph Traversal", - "title": "Longest Palindromic Path in Graph", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-palindromic-path-in-graph/" + "id": 3615, + "link": "https://leetcode.com/problems/longest-palindromic-path-in-graph/", + "title": "Longest Palindromic Path in Graph" }, "3616": { - "id": 3616, "category": "Array & Hashing", - "title": "Number of Student Replacements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-student-replacements/" + "id": 3616, + "link": "https://leetcode.com/problems/number-of-student-replacements/", + "title": "Number of Student Replacements" }, "3617": { - "id": 3617, "category": "Array & Hashing", - "title": "Find Students with Study Spiral Pattern", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-students-with-study-spiral-pattern/" + "id": 3617, + "link": "https://leetcode.com/problems/find-students-with-study-spiral-pattern/", + "title": "Find Students with Study Spiral Pattern" }, "3618": { - "id": 3618, "category": "Math & Geometry", - "title": "Split Array by Prime Indices", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-array-by-prime-indices/" + "id": 3618, + "link": "https://leetcode.com/problems/split-array-by-prime-indices/", + "title": "Split Array by Prime Indices" }, "3619": { - "id": 3619, "category": "Graph Traversal", - "title": "Count Islands With Total Value Divisible by K", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-islands-with-total-value-divisible-by-k/" + "id": 3619, + "link": "https://leetcode.com/problems/count-islands-with-total-value-divisible-by-k/", + "title": "Count Islands With Total Value Divisible by K" }, "3620": { - "id": 3620, "category": "Graph Traversal", - "title": "Network Recovery Pathways", "difficulty": "Hard", - "link": "https://leetcode.com/problems/network-recovery-pathways/" + "id": 3620, + "link": "https://leetcode.com/problems/network-recovery-pathways/", + "title": "Network Recovery Pathways" }, "3621": { - "id": 3621, "category": "Dynamic Programming", - "title": "Number of Integers With Popcount-Depth Equal to K I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-i/" + "id": 3621, + "link": "https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-i/", + "title": "Number of Integers With Popcount-Depth Equal to K I" }, "3622": { - "id": 3622, "category": "Math & Geometry", - "title": "Check Divisibility by Digit Sum and Product", "difficulty": "Easy", - "link": "https://leetcode.com/problems/check-divisibility-by-digit-sum-and-product/" + "id": 3622, + "link": "https://leetcode.com/problems/check-divisibility-by-digit-sum-and-product/", + "title": "Check Divisibility by Digit Sum and Product" }, "3623": { - "id": 3623, "category": "Math & Geometry", - "title": "Count Number of Trapezoids I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-number-of-trapezoids-i/" + "id": 3623, + "link": "https://leetcode.com/problems/count-number-of-trapezoids-i/", + "title": "Count Number of Trapezoids I" }, "3624": { - "id": 3624, "category": "Tree", - "title": "Number of Integers With Popcount-Depth Equal to K II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-ii/" + "id": 3624, + "link": "https://leetcode.com/problems/number-of-integers-with-popcount-depth-equal-to-k-ii/", + "title": "Number of Integers With Popcount-Depth Equal to K II" }, "3625": { - "id": 3625, "category": "Math & Geometry", - "title": "Count Number of Trapezoids II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-number-of-trapezoids-ii/" + "id": 3625, + "link": "https://leetcode.com/problems/count-number-of-trapezoids-ii/", + "title": "Count Number of Trapezoids II" }, "3626": { - "id": 3626, "category": "Array & Hashing", - "title": "Find Stores with Inventory Imbalance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-stores-with-inventory-imbalance/" + "id": 3626, + "link": "https://leetcode.com/problems/find-stores-with-inventory-imbalance/", + "title": "Find Stores with Inventory Imbalance" }, "3627": { - "id": 3627, "category": "Greedy", - "title": "Maximum Median Sum of Subsequences of Size 3", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-median-sum-of-subsequences-of-size-3/" + "id": 3627, + "link": "https://leetcode.com/problems/maximum-median-sum-of-subsequences-of-size-3/", + "title": "Maximum Median Sum of Subsequences of Size 3" }, "3628": { - "id": 3628, "category": "Dynamic Programming", - "title": "Maximum Number of Subsequences After One Inserting", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-number-of-subsequences-after-one-inserting/" + "id": 3628, + "link": "https://leetcode.com/problems/maximum-number-of-subsequences-after-one-inserting/", + "title": "Maximum Number of Subsequences After One Inserting" }, "3629": { - "id": 3629, "category": "Graph Traversal", - "title": "Minimum Jumps to Reach End via Prime Teleportation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-jumps-to-reach-end-via-prime-teleportation/" + "id": 3629, + "link": "https://leetcode.com/problems/minimum-jumps-to-reach-end-via-prime-teleportation/", + "title": "Minimum Jumps to Reach End via Prime Teleportation" }, "3630": { - "id": 3630, "category": "Bit Manipulation", - "title": "Partition Array for Maximum XOR and AND", "difficulty": "Hard", - "link": "https://leetcode.com/problems/partition-array-for-maximum-xor-and-and/" + "id": 3630, + "link": "https://leetcode.com/problems/partition-array-for-maximum-xor-and-and/", + "title": "Partition Array for Maximum XOR and AND" }, "3631": { - "id": 3631, "category": "Array & Hashing", - "title": "Sort Threats by Severity and Exploitability", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sort-threats-by-severity-and-exploitability/" + "id": 3631, + "link": "https://leetcode.com/problems/sort-threats-by-severity-and-exploitability/", + "title": "Sort Threats by Severity and Exploitability" }, "3632": { - "id": 3632, "category": "Trie", - "title": "Subarrays with XOR at Least K", "difficulty": "Hard", - "link": "https://leetcode.com/problems/subarrays-with-xor-at-least-k/" + "id": 3632, + "link": "https://leetcode.com/problems/subarrays-with-xor-at-least-k/", + "title": "Subarrays with XOR at Least K" }, "3633": { - "id": 3633, "category": "Binary Search", - "title": "Earliest Finish Time for Land and Water Rides I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-i/" + "id": 3633, + "link": "https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-i/", + "title": "Earliest Finish Time for Land and Water Rides I" }, "3634": { - "id": 3634, "category": "Sliding Window", - "title": "Minimum Removals to Balance Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-removals-to-balance-array/" + "id": 3634, + "link": "https://leetcode.com/problems/minimum-removals-to-balance-array/", + "title": "Minimum Removals to Balance Array" }, "3635": { - "id": 3635, "category": "Binary Search", - "title": "Earliest Finish Time for Land and Water Rides II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-ii/" + "id": 3635, + "link": "https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-ii/", + "title": "Earliest Finish Time for Land and Water Rides II" }, "3636": { - "id": 3636, "category": "Binary Search", - "title": "Threshold Majority Queries", "difficulty": "Hard", - "link": "https://leetcode.com/problems/threshold-majority-queries/" + "id": 3636, + "link": "https://leetcode.com/problems/threshold-majority-queries/", + "title": "Threshold Majority Queries" }, "3637": { - "id": 3637, "category": "Array & Hashing", - "title": "Trionic Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/trionic-array-i/" + "id": 3637, + "link": "https://leetcode.com/problems/trionic-array-i/", + "title": "Trionic Array I" }, "3638": { - "id": 3638, "category": "Dynamic Programming", - "title": "Maximum Balanced Shipments", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-balanced-shipments/" + "id": 3638, + "link": "https://leetcode.com/problems/maximum-balanced-shipments/", + "title": "Maximum Balanced Shipments" }, "3639": { - "id": 3639, "category": "Binary Search", - "title": "Minimum Time to Activate String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-activate-string/" + "id": 3639, + "link": "https://leetcode.com/problems/minimum-time-to-activate-string/", + "title": "Minimum Time to Activate String" }, "3640": { - "id": 3640, "category": "Dynamic Programming", - "title": "Trionic Array II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/trionic-array-ii/" + "id": 3640, + "link": "https://leetcode.com/problems/trionic-array-ii/", + "title": "Trionic Array II" }, "3641": { - "id": 3641, "category": "Array & Hashing", - "title": "Longest Semi-Repeating Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-semi-repeating-subarray/" + "id": 3641, + "link": "https://leetcode.com/problems/longest-semi-repeating-subarray/", + "title": "Longest Semi-Repeating Subarray" }, "3642": { - "id": 3642, "category": "Array & Hashing", - "title": "Find Books with Polarized Opinions", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-books-with-polarized-opinions/" + "id": 3642, + "link": "https://leetcode.com/problems/find-books-with-polarized-opinions/", + "title": "Find Books with Polarized Opinions" }, "3643": { - "id": 3643, "category": "Two Pointers", - "title": "Flip Square Submatrix Vertically", "difficulty": "Easy", - "link": "https://leetcode.com/problems/flip-square-submatrix-vertically/" + "id": 3643, + "link": "https://leetcode.com/problems/flip-square-submatrix-vertically/", + "title": "Flip Square Submatrix Vertically" }, "3644": { - "id": 3644, "category": "Bit Manipulation", - "title": "Maximum K to Sort a Permutation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-k-to-sort-a-permutation/" + "id": 3644, + "link": "https://leetcode.com/problems/maximum-k-to-sort-a-permutation/", + "title": "Maximum K to Sort a Permutation" }, "3645": { - "id": 3645, "category": "Heap (Priority Queue)", - "title": "Maximum Total from Optimal Activation Order", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-total-from-optimal-activation-order/" + "id": 3645, + "link": "https://leetcode.com/problems/maximum-total-from-optimal-activation-order/", + "title": "Maximum Total from Optimal Activation Order" }, "3646": { - "id": 3646, "category": "Backtracking", - "title": "Next Special Palindrome Number", "difficulty": "Hard", - "link": "https://leetcode.com/problems/next-special-palindrome-number/" + "id": 3646, + "link": "https://leetcode.com/problems/next-special-palindrome-number/", + "title": "Next Special Palindrome Number" }, "3647": { - "id": 3647, "category": "Dynamic Programming", - "title": "Maximum Weight in Two Bags", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-weight-in-two-bags/" + "id": 3647, + "link": "https://leetcode.com/problems/maximum-weight-in-two-bags/", + "title": "Maximum Weight in Two Bags" }, "3648": { - "id": 3648, "category": "Math & Geometry", - "title": "Minimum Sensors to Cover Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-sensors-to-cover-grid/" + "id": 3648, + "link": "https://leetcode.com/problems/minimum-sensors-to-cover-grid/", + "title": "Minimum Sensors to Cover Grid" }, "3649": { - "id": 3649, "category": "Math & Geometry", - "title": "Number of Perfect Pairs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/number-of-perfect-pairs/" + "id": 3649, + "link": "https://leetcode.com/problems/number-of-perfect-pairs/", + "title": "Number of Perfect Pairs" }, "3650": { - "id": 3650, "category": "Graph Traversal", - "title": "Minimum Cost Path with Edge Reversals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-cost-path-with-edge-reversals/" + "id": 3650, + "link": "https://leetcode.com/problems/minimum-cost-path-with-edge-reversals/", + "title": "Minimum Cost Path with Edge Reversals" }, "3651": { - "id": 3651, "category": "Dynamic Programming", - "title": "Minimum Cost Path with Teleportations", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-cost-path-with-teleportations/" + "id": 3651, + "link": "https://leetcode.com/problems/minimum-cost-path-with-teleportations/", + "title": "Minimum Cost Path with Teleportations" }, "3652": { - "id": 3652, "category": "Sliding Window", - "title": "Best Time to Buy and Sell Stock using Strategy", "difficulty": "Medium", - "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-using-strategy/" + "id": 3652, + "link": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock-using-strategy/", + "title": "Best Time to Buy and Sell Stock using Strategy" }, "3653": { - "id": 3653, "category": "Array & Hashing", - "title": "XOR After Range Multiplication Queries I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/xor-after-range-multiplication-queries-i/" + "id": 3653, + "link": "https://leetcode.com/problems/xor-after-range-multiplication-queries-i/", + "title": "XOR After Range Multiplication Queries I" }, "3654": { - "id": 3654, "category": "Dynamic Programming", - "title": "Minimum Sum After Divisible Sum Deletions", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-sum-after-divisible-sum-deletions/" + "id": 3654, + "link": "https://leetcode.com/problems/minimum-sum-after-divisible-sum-deletions/", + "title": "Minimum Sum After Divisible Sum Deletions" }, "3655": { - "id": 3655, "category": "Array & Hashing", - "title": "XOR After Range Multiplication Queries II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/xor-after-range-multiplication-queries-ii/" + "id": 3655, + "link": "https://leetcode.com/problems/xor-after-range-multiplication-queries-ii/", + "title": "XOR After Range Multiplication Queries II" }, "3656": { - "id": 3656, "category": "Graph Traversal", - "title": "Determine if a Simple Graph Exists", "difficulty": "Medium", - "link": "https://leetcode.com/problems/determine-if-a-simple-graph-exists/" + "id": 3656, + "link": "https://leetcode.com/problems/determine-if-a-simple-graph-exists/", + "title": "Determine if a Simple Graph Exists" }, "3657": { - "id": 3657, "category": "Array & Hashing", - "title": "Find Loyal Customers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-loyal-customers/" + "id": 3657, + "link": "https://leetcode.com/problems/find-loyal-customers/", + "title": "Find Loyal Customers" }, "3658": { - "id": 3658, "category": "Math & Geometry", - "title": "GCD of Odd and Even Sums", "difficulty": "Easy", - "link": "https://leetcode.com/problems/gcd-of-odd-and-even-sums/" + "id": 3658, + "link": "https://leetcode.com/problems/gcd-of-odd-and-even-sums/", + "title": "GCD of Odd and Even Sums" }, "3659": { - "id": 3659, "category": "Array & Hashing", - "title": "Partition Array Into K-Distinct Groups", "difficulty": "Medium", - "link": "https://leetcode.com/problems/partition-array-into-k-distinct-groups/" + "id": 3659, + "link": "https://leetcode.com/problems/partition-array-into-k-distinct-groups/", + "title": "Partition Array Into K-Distinct Groups" }, "3660": { - "id": 3660, "category": "Dynamic Programming", - "title": "Jump Game IX", "difficulty": "Medium", - "link": "https://leetcode.com/problems/jump-game-ix/" + "id": 3660, + "link": "https://leetcode.com/problems/jump-game-ix/", + "title": "Jump Game IX" }, "3661": { - "id": 3661, "category": "Dynamic Programming", - "title": "Maximum Walls Destroyed by Robots", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-walls-destroyed-by-robots/" + "id": 3661, + "link": "https://leetcode.com/problems/maximum-walls-destroyed-by-robots/", + "title": "Maximum Walls Destroyed by Robots" }, "3662": { - "id": 3662, "category": "Array & Hashing", - "title": "Filter Characters by Frequency", "difficulty": "Easy", - "link": "https://leetcode.com/problems/filter-characters-by-frequency/" + "id": 3662, + "link": "https://leetcode.com/problems/filter-characters-by-frequency/", + "title": "Filter Characters by Frequency" }, "3663": { - "id": 3663, "category": "Math & Geometry", - "title": "Find The Least Frequent Digit", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-the-least-frequent-digit/" + "id": 3663, + "link": "https://leetcode.com/problems/find-the-least-frequent-digit/", + "title": "Find The Least Frequent Digit" }, "3664": { - "id": 3664, "category": "Array & Hashing", - "title": "Two-Letter Card Game", "difficulty": "Medium", - "link": "https://leetcode.com/problems/two-letter-card-game/" + "id": 3664, + "link": "https://leetcode.com/problems/two-letter-card-game/", + "title": "Two-Letter Card Game" }, "3665": { - "id": 3665, "category": "Dynamic Programming", - "title": "Twisted Mirror Path Count", "difficulty": "Medium", - "link": "https://leetcode.com/problems/twisted-mirror-path-count/" + "id": 3665, + "link": "https://leetcode.com/problems/twisted-mirror-path-count/", + "title": "Twisted Mirror Path Count" }, "3666": { - "id": 3666, "category": "Graph Traversal", - "title": "Minimum Operations to Equalize Binary String", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-operations-to-equalize-binary-string/" + "id": 3666, + "link": "https://leetcode.com/problems/minimum-operations-to-equalize-binary-string/", + "title": "Minimum Operations to Equalize Binary String" }, "3667": { - "id": 3667, "category": "Math & Geometry", - "title": "Sort Array By Absolute Value", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-array-by-absolute-value/" + "id": 3667, + "link": "https://leetcode.com/problems/sort-array-by-absolute-value/", + "title": "Sort Array By Absolute Value" }, "3668": { - "id": 3668, "category": "Array & Hashing", - "title": "Restore Finishing Order", "difficulty": "Easy", - "link": "https://leetcode.com/problems/restore-finishing-order/" + "id": 3668, + "link": "https://leetcode.com/problems/restore-finishing-order/", + "title": "Restore Finishing Order" }, "3669": { - "id": 3669, "category": "Backtracking", - "title": "Balanced K-Factor Decomposition", "difficulty": "Medium", - "link": "https://leetcode.com/problems/balanced-k-factor-decomposition/" + "id": 3669, + "link": "https://leetcode.com/problems/balanced-k-factor-decomposition/", + "title": "Balanced K-Factor Decomposition" }, "3670": { - "id": 3670, "category": "Dynamic Programming", - "title": "Maximum Product of Two Integers With No Common Bits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-two-integers-with-no-common-bits/" + "id": 3670, + "link": "https://leetcode.com/problems/maximum-product-of-two-integers-with-no-common-bits/", + "title": "Maximum Product of Two Integers With No Common Bits" }, "3671": { - "id": 3671, "category": "Tree", - "title": "Sum of Beautiful Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-beautiful-subsequences/" + "id": 3671, + "link": "https://leetcode.com/problems/sum-of-beautiful-subsequences/", + "title": "Sum of Beautiful Subsequences" }, "3672": { - "id": 3672, "category": "Sliding Window", - "title": "Sum of Weighted Modes in Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/sum-of-weighted-modes-in-subarrays/" + "id": 3672, + "link": "https://leetcode.com/problems/sum-of-weighted-modes-in-subarrays/", + "title": "Sum of Weighted Modes in Subarrays" }, "3673": { - "id": 3673, "category": "Array & Hashing", - "title": "Find Zombie Sessions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/find-zombie-sessions/" + "id": 3673, + "link": "https://leetcode.com/problems/find-zombie-sessions/", + "title": "Find Zombie Sessions" }, "3674": { - "id": 3674, "category": "Bit Manipulation", - "title": "Minimum Operations to Equalize Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-operations-to-equalize-array/" + "id": 3674, + "link": "https://leetcode.com/problems/minimum-operations-to-equalize-array/", + "title": "Minimum Operations to Equalize Array" }, "3675": { - "id": 3675, "category": "Greedy", - "title": "Minimum Operations to Transform String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-transform-string/" + "id": 3675, + "link": "https://leetcode.com/problems/minimum-operations-to-transform-string/", + "title": "Minimum Operations to Transform String" }, "3676": { - "id": 3676, "category": "Stack", - "title": "Count Bowl Subarrays", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-bowl-subarrays/" + "id": 3676, + "link": "https://leetcode.com/problems/count-bowl-subarrays/", + "title": "Count Bowl Subarrays" }, "3677": { - "id": 3677, "category": "Bit Manipulation", - "title": "Count Binary Palindromic Numbers", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-binary-palindromic-numbers/" + "id": 3677, + "link": "https://leetcode.com/problems/count-binary-palindromic-numbers/", + "title": "Count Binary Palindromic Numbers" }, "3678": { - "id": 3678, "category": "Array & Hashing", - "title": "Smallest Absent Positive Greater Than Average", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-absent-positive-greater-than-average/" + "id": 3678, + "link": "https://leetcode.com/problems/smallest-absent-positive-greater-than-average/", + "title": "Smallest Absent Positive Greater Than Average" }, "3679": { - "id": 3679, "category": "Sliding Window", - "title": " Minimum Discards to Balance Inventory", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-discards-to-balance-inventory/" + "id": 3679, + "link": "https://leetcode.com/problems/minimum-discards-to-balance-inventory/", + "title": " Minimum Discards to Balance Inventory" }, "3680": { - "id": 3680, "category": "Greedy", - "title": "Generate Schedule", "difficulty": "Medium", - "link": "https://leetcode.com/problems/generate-schedule/" + "id": 3680, + "link": "https://leetcode.com/problems/generate-schedule/", + "title": "Generate Schedule" }, "3681": { - "id": 3681, "category": "Bit Manipulation", - "title": "Maximum XOR of Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-xor-of-subsequences/" + "id": 3681, + "link": "https://leetcode.com/problems/maximum-xor-of-subsequences/", + "title": "Maximum XOR of Subsequences" }, "3682": { - "id": 3682, "category": "Array & Hashing", - "title": "Minimum Index Sum of Common Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-index-sum-of-common-elements/" + "id": 3682, + "link": "https://leetcode.com/problems/minimum-index-sum-of-common-elements/", + "title": "Minimum Index Sum of Common Elements" }, "3683": { - "id": 3683, "category": "Array & Hashing", - "title": "Earliest Time to Finish One Task", "difficulty": "Easy", - "link": "https://leetcode.com/problems/earliest-time-to-finish-one-task/" + "id": 3683, + "link": "https://leetcode.com/problems/earliest-time-to-finish-one-task/", + "title": "Earliest Time to Finish One Task" }, "3684": { - "id": 3684, "category": "Greedy", - "title": "Maximize Sum of At Most K Distinct Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximize-sum-of-at-most-k-distinct-elements/" + "id": 3684, + "link": "https://leetcode.com/problems/maximize-sum-of-at-most-k-distinct-elements/", + "title": "Maximize Sum of At Most K Distinct Elements" }, "3685": { - "id": 3685, "category": "Dynamic Programming", - "title": "Subsequence Sum After Capping Elements", "difficulty": "Medium", - "link": "https://leetcode.com/problems/subsequence-sum-after-capping-elements/" + "id": 3685, + "link": "https://leetcode.com/problems/subsequence-sum-after-capping-elements/", + "title": "Subsequence Sum After Capping Elements" }, "3686": { - "id": 3686, "category": "Dynamic Programming", - "title": "Number of Stable Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-stable-subsequences/" + "id": 3686, + "link": "https://leetcode.com/problems/number-of-stable-subsequences/", + "title": "Number of Stable Subsequences" }, "3687": { - "id": 3687, "category": "Array & Hashing", - "title": "Library Late Fee Calculator", "difficulty": "Easy", - "link": "https://leetcode.com/problems/library-late-fee-calculator/" + "id": 3687, + "link": "https://leetcode.com/problems/library-late-fee-calculator/", + "title": "Library Late Fee Calculator" }, "3688": { - "id": 3688, "category": "Bit Manipulation", - "title": "Bitwise OR of Even Numbers in an Array", "difficulty": "Easy", - "link": "https://leetcode.com/problems/bitwise-or-of-even-numbers-in-an-array/" + "id": 3688, + "link": "https://leetcode.com/problems/bitwise-or-of-even-numbers-in-an-array/", + "title": "Bitwise OR of Even Numbers in an Array" }, "3689": { - "id": 3689, "category": "Greedy", - "title": "Maximum Total Subarray Value I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-total-subarray-value-i/" + "id": 3689, + "link": "https://leetcode.com/problems/maximum-total-subarray-value-i/", + "title": "Maximum Total Subarray Value I" }, "3690": { - "id": 3690, "category": "Graph Traversal", - "title": "Split and Merge Array Transformation", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-and-merge-array-transformation/" + "id": 3690, + "link": "https://leetcode.com/problems/split-and-merge-array-transformation/", + "title": "Split and Merge Array Transformation" }, "3691": { - "id": 3691, "category": "Tree", - "title": "Maximum Total Subarray Value II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-total-subarray-value-ii/" + "id": 3691, + "link": "https://leetcode.com/problems/maximum-total-subarray-value-ii/", + "title": "Maximum Total Subarray Value II" }, "3692": { - "id": 3692, "category": "Array & Hashing", - "title": "Majority Frequency Characters", "difficulty": "Easy", - "link": "https://leetcode.com/problems/majority-frequency-characters/" + "id": 3692, + "link": "https://leetcode.com/problems/majority-frequency-characters/", + "title": "Majority Frequency Characters" }, "3693": { - "id": 3693, "category": "Dynamic Programming", - "title": "Climbing Stairs II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/climbing-stairs-ii/" + "id": 3693, + "link": "https://leetcode.com/problems/climbing-stairs-ii/", + "title": "Climbing Stairs II" }, "3694": { - "id": 3694, "category": "Sliding Window", - "title": "Distinct Points Reachable After Substring Removal", "difficulty": "Medium", - "link": "https://leetcode.com/problems/distinct-points-reachable-after-substring-removal/" + "id": 3694, + "link": "https://leetcode.com/problems/distinct-points-reachable-after-substring-removal/", + "title": "Distinct Points Reachable After Substring Removal" }, "3695": { - "id": 3695, "category": "Graph Traversal", - "title": "Maximize Alternating Sum Using Swaps", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximize-alternating-sum-using-swaps/" + "id": 3695, + "link": "https://leetcode.com/problems/maximize-alternating-sum-using-swaps/", + "title": "Maximize Alternating Sum Using Swaps" }, "3696": { - "id": 3696, "category": "Array & Hashing", - "title": "Maximum Distance Between Unequal Words in Array I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-i/" + "id": 3696, + "link": "https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-i/", + "title": "Maximum Distance Between Unequal Words in Array I" }, "3697": { - "id": 3697, "category": "Math & Geometry", - "title": "Compute Decimal Representation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/compute-decimal-representation/" + "id": 3697, + "link": "https://leetcode.com/problems/compute-decimal-representation/", + "title": "Compute Decimal Representation" }, "3698": { - "id": 3698, "category": "Array & Hashing", - "title": "Split Array With Minimum Difference", "difficulty": "Medium", - "link": "https://leetcode.com/problems/split-array-with-minimum-difference/" + "id": 3698, + "link": "https://leetcode.com/problems/split-array-with-minimum-difference/", + "title": "Split Array With Minimum Difference" }, "3699": { - "id": 3699, "category": "Dynamic Programming", - "title": "Number of ZigZag Arrays I", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-zigzag-arrays-i/" + "id": 3699, + "link": "https://leetcode.com/problems/number-of-zigzag-arrays-i/", + "title": "Number of ZigZag Arrays I" }, "3700": { - "id": 3700, "category": "Dynamic Programming", - "title": "Number of ZigZag Arrays II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-zigzag-arrays-ii/" + "id": 3700, + "link": "https://leetcode.com/problems/number-of-zigzag-arrays-ii/", + "title": "Number of ZigZag Arrays II" }, "3701": { - "id": 3701, "category": "Array & Hashing", - "title": "Compute Alternating Sum", "difficulty": "Easy", - "link": "https://leetcode.com/problems/compute-alternating-sum/" + "id": 3701, + "link": "https://leetcode.com/problems/compute-alternating-sum/", + "title": "Compute Alternating Sum" }, "3702": { - "id": 3702, "category": "Bit Manipulation", - "title": "Longest Subsequence With Non-Zero Bitwise XOR", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-subsequence-with-non-zero-bitwise-xor/" + "id": 3702, + "link": "https://leetcode.com/problems/longest-subsequence-with-non-zero-bitwise-xor/", + "title": "Longest Subsequence With Non-Zero Bitwise XOR" }, "3703": { - "id": 3703, "category": "Stack", - "title": "Remove K-Balanced Substrings", "difficulty": "Medium", - "link": "https://leetcode.com/problems/remove-k-balanced-substrings/" + "id": 3703, + "link": "https://leetcode.com/problems/remove-k-balanced-substrings/", + "title": "Remove K-Balanced Substrings" }, "3704": { - "id": 3704, "category": "Dynamic Programming", - "title": "Count No-Zero Pairs That Sum to N", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-no-zero-pairs-that-sum-to-n/" + "id": 3704, + "link": "https://leetcode.com/problems/count-no-zero-pairs-that-sum-to-n/", + "title": "Count No-Zero Pairs That Sum to N" }, "3705": { - "id": 3705, "category": "Array & Hashing", - "title": "Find Golden Hour Customers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-golden-hour-customers/" + "id": 3705, + "link": "https://leetcode.com/problems/find-golden-hour-customers/", + "title": "Find Golden Hour Customers" }, "3706": { - "id": 3706, "category": "Array & Hashing", - "title": "Maximum Distance Between Unequal Words in Array II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-ii/" + "id": 3706, + "link": "https://leetcode.com/problems/maximum-distance-between-unequal-words-in-array-ii/", + "title": "Maximum Distance Between Unequal Words in Array II" }, "3707": { - "id": 3707, "category": "Array & Hashing", - "title": "Equal Score Substrings", "difficulty": "Easy", - "link": "https://leetcode.com/problems/equal-score-substrings/" + "id": 3707, + "link": "https://leetcode.com/problems/equal-score-substrings/", + "title": "Equal Score Substrings" }, "3708": { - "id": 3708, "category": "Array & Hashing", - "title": "Longest Fibonacci Subarray", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-fibonacci-subarray/" + "id": 3708, + "link": "https://leetcode.com/problems/longest-fibonacci-subarray/", + "title": "Longest Fibonacci Subarray" }, "3709": { - "id": 3709, "category": "Binary Search", - "title": "Design Exam Scores Tracker", "difficulty": "Medium", - "link": "https://leetcode.com/problems/design-exam-scores-tracker/" + "id": 3709, + "link": "https://leetcode.com/problems/design-exam-scores-tracker/", + "title": "Design Exam Scores Tracker" }, "3710": { - "id": 3710, "category": "Graph Traversal", - "title": "Maximum Partition Factor", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-partition-factor/" + "id": 3710, + "link": "https://leetcode.com/problems/maximum-partition-factor/", + "title": "Maximum Partition Factor" }, "3711": { - "id": 3711, "category": "Heap (Priority Queue)", - "title": "Maximum Transactions Without Negative Balance", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-transactions-without-negative-balance/" + "id": 3711, + "link": "https://leetcode.com/problems/maximum-transactions-without-negative-balance/", + "title": "Maximum Transactions Without Negative Balance" }, "3712": { - "id": 3712, "category": "Array & Hashing", - "title": "Sum of Elements With Frequency Divisible by K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sum-of-elements-with-frequency-divisible-by-k/" + "id": 3712, + "link": "https://leetcode.com/problems/sum-of-elements-with-frequency-divisible-by-k/", + "title": "Sum of Elements With Frequency Divisible by K" }, "3713": { - "id": 3713, "category": "Array & Hashing", - "title": "Longest Balanced Substring I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-balanced-substring-i/" + "id": 3713, + "link": "https://leetcode.com/problems/longest-balanced-substring-i/", + "title": "Longest Balanced Substring I" }, "3714": { - "id": 3714, "category": "Array & Hashing", - "title": "Longest Balanced Substring II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-balanced-substring-ii/" + "id": 3714, + "link": "https://leetcode.com/problems/longest-balanced-substring-ii/", + "title": "Longest Balanced Substring II" }, "3715": { - "id": 3715, "category": "Tree", - "title": "Sum of Perfect Square Ancestors", "difficulty": "Hard", - "link": "https://leetcode.com/problems/sum-of-perfect-square-ancestors/" + "id": 3715, + "link": "https://leetcode.com/problems/sum-of-perfect-square-ancestors/", + "title": "Sum of Perfect Square Ancestors" }, "3716": { - "id": 3716, "category": "Array & Hashing", - "title": "Find Churn Risk Customers", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-churn-risk-customers/" + "id": 3716, + "link": "https://leetcode.com/problems/find-churn-risk-customers/", + "title": "Find Churn Risk Customers" }, "3717": { - "id": 3717, "category": "Dynamic Programming", - "title": "Minimum Operations to Make the Array Beautiful", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-beautiful/" + "id": 3717, + "link": "https://leetcode.com/problems/minimum-operations-to-make-the-array-beautiful/", + "title": "Minimum Operations to Make the Array Beautiful" }, "3718": { - "id": 3718, "category": "Array & Hashing", - "title": "Smallest Missing Multiple of K", "difficulty": "Easy", - "link": "https://leetcode.com/problems/smallest-missing-multiple-of-k/" + "id": 3718, + "link": "https://leetcode.com/problems/smallest-missing-multiple-of-k/", + "title": "Smallest Missing Multiple of K" }, "3719": { - "id": 3719, "category": "Tree", - "title": "Longest Balanced Subarray I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-balanced-subarray-i/" + "id": 3719, + "link": "https://leetcode.com/problems/longest-balanced-subarray-i/", + "title": "Longest Balanced Subarray I" }, "3720": { - "id": 3720, "category": "Greedy", - "title": "Lexicographically Smallest Permutation Greater Than Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-permutation-greater-than-target/" + "id": 3720, + "link": "https://leetcode.com/problems/lexicographically-smallest-permutation-greater-than-target/", + "title": "Lexicographically Smallest Permutation Greater Than Target" }, "3721": { - "id": 3721, "category": "Tree", - "title": "Longest Balanced Subarray II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/longest-balanced-subarray-ii/" + "id": 3721, + "link": "https://leetcode.com/problems/longest-balanced-subarray-ii/", + "title": "Longest Balanced Subarray II" }, "3722": { - "id": 3722, "category": "Binary Search", - "title": "Lexicographically Smallest String After Reverse", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-reverse/" + "id": 3722, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-reverse/", + "title": "Lexicographically Smallest String After Reverse" }, "3723": { - "id": 3723, "category": "Greedy", - "title": "Maximize Sum of Squares of Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-sum-of-squares-of-digits/" + "id": 3723, + "link": "https://leetcode.com/problems/maximize-sum-of-squares-of-digits/", + "title": "Maximize Sum of Squares of Digits" }, "3724": { - "id": 3724, "category": "Greedy", - "title": "Minimum Operations to Transform Array", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-transform-array/" + "id": 3724, + "link": "https://leetcode.com/problems/minimum-operations-to-transform-array/", + "title": "Minimum Operations to Transform Array" }, "3725": { - "id": 3725, "category": "Dynamic Programming", - "title": "Count Ways to Choose Coprime Integers from Rows", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-ways-to-choose-coprime-integers-from-rows/" + "id": 3725, + "link": "https://leetcode.com/problems/count-ways-to-choose-coprime-integers-from-rows/", + "title": "Count Ways to Choose Coprime Integers from Rows" }, "3726": { - "id": 3726, "category": "Math & Geometry", - "title": "Remove Zeros in Decimal Representation", "difficulty": "Easy", - "link": "https://leetcode.com/problems/remove-zeros-in-decimal-representation/" + "id": 3726, + "link": "https://leetcode.com/problems/remove-zeros-in-decimal-representation/", + "title": "Remove Zeros in Decimal Representation" }, "3727": { - "id": 3727, "category": "Greedy", - "title": "Maximum Alternating Sum of Squares", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-alternating-sum-of-squares/" + "id": 3727, + "link": "https://leetcode.com/problems/maximum-alternating-sum-of-squares/", + "title": "Maximum Alternating Sum of Squares" }, "3728": { - "id": 3728, "category": "Array & Hashing", - "title": "Stable Subarrays With Equal Boundary and Interior Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/stable-subarrays-with-equal-boundary-and-interior-sum/" + "id": 3728, + "link": "https://leetcode.com/problems/stable-subarrays-with-equal-boundary-and-interior-sum/", + "title": "Stable Subarrays With Equal Boundary and Interior Sum" }, "3729": { - "id": 3729, "category": "Array & Hashing", - "title": "Count Distinct Subarrays Divisible by K in Sorted Array", "difficulty": "Hard", - "link": "https://leetcode.com/problems/count-distinct-subarrays-divisible-by-k-in-sorted-array/" + "id": 3729, + "link": "https://leetcode.com/problems/count-distinct-subarrays-divisible-by-k-in-sorted-array/", + "title": "Count Distinct Subarrays Divisible by K in Sorted Array" }, "3730": { - "id": 3730, "category": "Greedy", - "title": "Maximum Calories Burnt from Jumps", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-calories-burnt-from-jumps/" + "id": 3730, + "link": "https://leetcode.com/problems/maximum-calories-burnt-from-jumps/", + "title": "Maximum Calories Burnt from Jumps" }, "3731": { - "id": 3731, "category": "Array & Hashing", - "title": "Find Missing Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/find-missing-elements/" + "id": 3731, + "link": "https://leetcode.com/problems/find-missing-elements/", + "title": "Find Missing Elements" }, "3732": { - "id": 3732, "category": "Greedy", - "title": "Maximum Product of Three Elements After One Replacement", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-product-of-three-elements-after-one-replacement/" + "id": 3732, + "link": "https://leetcode.com/problems/maximum-product-of-three-elements-after-one-replacement/", + "title": "Maximum Product of Three Elements After One Replacement" }, "3733": { - "id": 3733, "category": "Binary Search", - "title": "Minimum Time to Complete All Deliveries", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-time-to-complete-all-deliveries/" + "id": 3733, + "link": "https://leetcode.com/problems/minimum-time-to-complete-all-deliveries/", + "title": "Minimum Time to Complete All Deliveries" }, "3734": { - "id": 3734, "category": "Two Pointers", - "title": "Lexicographically Smallest Palindromic Permutation Greater Than Target", "difficulty": "Hard", - "link": "https://leetcode.com/problems/lexicographically-smallest-palindromic-permutation-greater-than-target/" + "id": 3734, + "link": "https://leetcode.com/problems/lexicographically-smallest-palindromic-permutation-greater-than-target/", + "title": "Lexicographically Smallest Palindromic Permutation Greater Than Target" }, "3735": { - "id": 3735, "category": "Binary Search", - "title": "Lexicographically Smallest String After Reverse II", "difficulty": "Hard", - "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-reverse-ii/" + "id": 3735, + "link": "https://leetcode.com/problems/lexicographically-smallest-string-after-reverse-ii/", + "title": "Lexicographically Smallest String After Reverse II" }, "3736": { - "id": 3736, "category": "Math & Geometry", - "title": "Minimum Moves to Equal Array Elements III", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements-iii/" + "id": 3736, + "link": "https://leetcode.com/problems/minimum-moves-to-equal-array-elements-iii/", + "title": "Minimum Moves to Equal Array Elements III" }, "3737": { - "id": 3737, "category": "Tree", - "title": "Count Subarrays With Majority Element I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/count-subarrays-with-majority-element-i/" + "id": 3737, + "link": "https://leetcode.com/problems/count-subarrays-with-majority-element-i/", + "title": "Count Subarrays With Majority Element I" }, "3738": { - "id": 3738, "category": "Dynamic Programming", - "title": "Longest Non-Decreasing Subarray After Replacing at Most One Element", "difficulty": "Medium", - "link": "https://leetcode.com/problems/longest-non-decreasing-subarray-after-replacing-at-most-one-element/" + "id": 3738, + "link": "https://leetcode.com/problems/longest-non-decreasing-subarray-after-replacing-at-most-one-element/", + "title": "Longest Non-Decreasing Subarray After Replacing at Most One Element" }, "3739": { - "id": 3739, "category": "Array & Hashing", - "title": "Find Minimum Operations to Make All Elements Divisible by Three", "difficulty": "Easy", + "id": 3739, "link": "https://leetcode.com/problems/find-minimum-operations-to-make-all-elements-divisible-by-three/", - "tags": ["array", "math"] + "tags": ["array", "math"], + "title": "Find Minimum Operations to Make All Elements Divisible by Three" }, "3740": { - "id": 3740, "category": "Array & Hashing", - "title": "Minimum Distance Between Three Equal Elements I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-distance-between-three-equal-elements-i/" + "id": 3740, + "link": "https://leetcode.com/problems/minimum-distance-between-three-equal-elements-i/", + "title": "Minimum Distance Between Three Equal Elements I" }, "3741": { - "id": 3741, "category": "Array & Hashing", - "title": "Minimum Distance Between Three Equal Elements II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-distance-between-three-equal-elements-ii/" + "id": 3741, + "link": "https://leetcode.com/problems/minimum-distance-between-three-equal-elements-ii/", + "title": "Minimum Distance Between Three Equal Elements II" }, "3742": { - "id": 3742, "category": "Dynamic Programming", - "title": "Maximum Path Score in a Grid", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-path-score-in-a-grid/" + "id": 3742, + "link": "https://leetcode.com/problems/maximum-path-score-in-a-grid/", + "title": "Maximum Path Score in a Grid" }, "3743": { - "id": 3743, "category": "Array & Hashing", - "title": "Count the Number of Beautiful Subarrays", "difficulty": "Medium", + "id": 3743, "link": "https://leetcode.com/problems/count-the-number-of-beautiful-subarrays/", - "tags": ["array", "hash-table", "bit-manipulation", "prefix-sum"] + "tags": ["array", "hash-table", "bit-manipulation", "prefix-sum"], + "title": "Count the Number of Beautiful Subarrays" }, "3744": { - "id": 3744, "category": "Array & Hashing", - "title": "Find Kth Character in Expanded String", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-kth-character-in-expanded-string/" + "id": 3744, + "link": "https://leetcode.com/problems/find-kth-character-in-expanded-string/", + "title": "Find Kth Character in Expanded String" }, "3745": { - "id": 3745, "category": "Greedy", - "title": "Maximize Expression of Three Elements", "difficulty": "Easy", - "link": "https://leetcode.com/problems/maximize-expression-of-three-elements/" + "id": 3745, + "link": "https://leetcode.com/problems/maximize-expression-of-three-elements/", + "title": "Maximize Expression of Three Elements" }, "3746": { - "id": 3746, "category": "Stack", - "title": "Minimum String Length After Balanced Removals", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-string-length-after-balanced-removals/" + "id": 3746, + "link": "https://leetcode.com/problems/minimum-string-length-after-balanced-removals/", + "title": "Minimum String Length After Balanced Removals" }, "3747": { - "id": 3747, "category": "String", - "title": "Count Beautiful Substrings I", "difficulty": "Medium", + "id": 3747, "link": "https://leetcode.com/problems/count-beautiful-substrings-i/", - "tags": ["hash-table", "math", "string", "enumeration", "number-theory", "prefix-sum"] + "tags": ["hash-table", "math", "string", "enumeration", "number-theory", "prefix-sum"], + "title": "Count Beautiful Substrings I" }, "3748": { - "id": 3748, "category": "String", - "title": "Count Beautiful Substrings II", "difficulty": "Hard", + "id": 3748, "link": "https://leetcode.com/problems/count-beautiful-substrings-ii/", - "tags": ["hash-table", "math", "string", "number-theory", "prefix-sum"] + "tags": ["hash-table", "math", "string", "number-theory", "prefix-sum"], + "title": "Count Beautiful Substrings II" }, "3749": { - "id": 3749, "category": "Stack", - "title": "Evaluate Valid Expressions", "difficulty": "Hard", - "link": "https://leetcode.com/problems/evaluate-valid-expressions/" + "id": 3749, + "link": "https://leetcode.com/problems/evaluate-valid-expressions/", + "title": "Evaluate Valid Expressions" }, "3750": { - "id": 3750, "category": "Array & Hashing", - "title": "Minimum Number of Flips to Reverse Binary String", "difficulty": "Easy", - "link": "https://leetcode.com/problems/minimum-number-of-flips-to-reverse-binary-string/" + "id": 3750, + "link": "https://leetcode.com/problems/minimum-number-of-flips-to-reverse-binary-string/", + "title": "Minimum Number of Flips to Reverse Binary String" }, "3751": { - "id": 3751, "category": "Array & Hashing", - "title": "Total Waviness of Numbers in Range I", "difficulty": "Medium", - "link": "https://leetcode.com/problems/total-waviness-of-numbers-in-range-i/" + "id": 3751, + "link": "https://leetcode.com/problems/total-waviness-of-numbers-in-range-i/", + "title": "Total Waviness of Numbers in Range I" }, "3752": { - "id": 3752, "category": "Array & Hashing", - "title": "Lexicographically Smallest Negated Permutation that Sums to Target", "difficulty": "Medium", - "link": "https://leetcode.com/problems/lexicographically-smallest-negated-permutation-that-sums-to-target/" + "id": 3752, + "link": "https://leetcode.com/problems/lexicographically-smallest-negated-permutation-that-sums-to-target/", + "title": "Lexicographically Smallest Negated Permutation that Sums to Target" }, "3753": { - "id": 3753, "category": "Dynamic Programming", - "title": "Paths in Matrix Whose Sum Is Divisible by K", "difficulty": "Hard", + "id": 3753, "link": "https://leetcode.com/problems/paths-in-matrix-whose-sum-is-divisible-by-k/", - "tags": ["array", "dynamic-programming", "matrix"] + "tags": ["array", "dynamic-programming", "matrix"], + "title": "Paths in Matrix Whose Sum Is Divisible by K" }, "3754": { - "id": 3754, "category": "Array & Hashing", - "title": "Concatenate Non-Zero Digits and Multiply by Sum I", "difficulty": "Easy", - "link": "https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-i/" + "id": 3754, + "link": "https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-i/", + "title": "Concatenate Non-Zero Digits and Multiply by Sum I" }, "3755": { - "id": 3755, "category": "Array & Hashing", - "title": "Find Maximum Balanced XOR Subarray Length", "difficulty": "Medium", - "link": "https://leetcode.com/problems/find-maximum-balanced-xor-subarray-length/" + "id": 3755, + "link": "https://leetcode.com/problems/find-maximum-balanced-xor-subarray-length/", + "title": "Find Maximum Balanced XOR Subarray Length" }, "3756": { - "id": 3756, "category": "Array & Hashing", - "title": "Concatenate Non-Zero Digits and Multiply by Sum II", "difficulty": "Medium", - "link": "https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-ii/" + "id": 3756, + "link": "https://leetcode.com/problems/concatenate-non-zero-digits-and-multiply-by-sum-ii/", + "title": "Concatenate Non-Zero Digits and Multiply by Sum II" }, "3757": { - "id": 3757, "category": "Array & Hashing", - "title": "Number of Effective Subsequences", "difficulty": "Hard", - "link": "https://leetcode.com/problems/number-of-effective-subsequences/" + "id": 3757, + "link": "https://leetcode.com/problems/number-of-effective-subsequences/", + "title": "Number of Effective Subsequences" }, "3758": { - "id": 3758, "category": "Array & Hashing", - "title": "Convert Number Words to Digits", "difficulty": "Medium", - "link": "https://leetcode.com/problems/convert-number-words-to-digits/" + "id": 3758, + "link": "https://leetcode.com/problems/convert-number-words-to-digits/", + "title": "Convert Number Words to Digits" }, "3759": { - "id": 3759, "category": "Graph", - "title": "Minimum Cost to Convert String I", "difficulty": "Medium", + "id": 3759, "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-i/", - "tags": ["array", "string", "graph", "shortest-path"] + "tags": ["array", "string", "graph", "shortest-path"], + "title": "Minimum Cost to Convert String I" }, "3760": { - "id": 3760, "category": "Graph", - "title": "Minimum Cost to Convert String II", "difficulty": "Hard", + "id": 3760, "link": "https://leetcode.com/problems/minimum-cost-to-convert-string-ii/", - "tags": ["array", "string", "dynamic-programming", "graph", "trie", "shortest-path"] + "tags": ["array", "string", "dynamic-programming", "graph", "trie", "shortest-path"], + "title": "Minimum Cost to Convert String II" }, "3761": { - "id": 3761, "category": "Tree", - "title": "Count Valid Paths in a Tree", "difficulty": "Hard", + "id": 3761, "link": "https://leetcode.com/problems/count-valid-paths-in-a-tree/", - "tags": ["math", "dynamic-programming", "tree", "depth-first-search", "number-theory"] + "tags": ["math", "dynamic-programming", "tree", "depth-first-search", "number-theory"], + "title": "Count Valid Paths in a Tree" }, "3762": { - "id": 3762, "category": "Array & Hashing", - "title": "Minimum Operations to Make Array Values Equal to K", "difficulty": "Easy", + "id": 3762, "link": "https://leetcode.com/problems/minimum-operations-to-make-array-values-equal-to-k/", - "tags": ["array", "hash-table"] + "tags": ["array", "hash-table"], + "title": "Minimum Operations to Make Array Values Equal to K" }, "3763": { - "id": 3763, "category": "Array & Hashing", - "title": "Maximum Substrings With Distinct Start", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximum-substrings-with-distinct-start/" + "id": 3763, + "link": "https://leetcode.com/problems/maximum-substrings-with-distinct-start/", + "title": "Maximum Substrings With Distinct Start" }, "3764": { - "id": 3764, "category": "Database", - "title": "Most Common Course Pairs", "difficulty": "Hard", - "link": "https://leetcode.com/problems/most-common-course-pairs/" + "id": 3764, + "link": "https://leetcode.com/problems/most-common-course-pairs/", + "title": "Most Common Course Pairs" }, "3765": { - "id": 3765, "category": "Math & Geometry", - "title": "Complete Prime Number", "difficulty": "Medium", - "link": "https://leetcode.com/problems/complete-prime-number/" + "id": 3765, + "link": "https://leetcode.com/problems/complete-prime-number/", + "title": "Complete Prime Number" }, "3766": { - "id": 3766, "category": "Array & Hashing", - "title": "Minimum Operations to Make Binary Palindrome", "difficulty": "Medium", - "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-palindrome/" + "id": 3766, + "link": "https://leetcode.com/problems/minimum-operations-to-make-binary-palindrome/", + "title": "Minimum Operations to Make Binary Palindrome" }, "3767": { - "id": 3767, "category": "Greedy", - "title": "Maximize Points After Choosing K Tasks", "difficulty": "Medium", - "link": "https://leetcode.com/problems/maximize-points-after-choosing-k-tasks/" + "id": 3767, + "link": "https://leetcode.com/problems/maximize-points-after-choosing-k-tasks/", + "title": "Maximize Points After Choosing K Tasks" }, "3768": { - "id": 3768, "category": "Array & Hashing", - "title": "Minimum Inversion Count in Subarrays of Fixed Length", "difficulty": "Hard", - "link": "https://leetcode.com/problems/minimum-inversion-count-in-subarrays-of-fixed-length/" + "id": 3768, + "link": "https://leetcode.com/problems/minimum-inversion-count-in-subarrays-of-fixed-length/", + "title": "Minimum Inversion Count in Subarrays of Fixed Length" }, "3769": { - "id": 3769, "category": "Array & Hashing", - "title": "Sort Integers by Binary Reflection", "difficulty": "Easy", - "link": "https://leetcode.com/problems/sort-integers-by-binary-reflection/" + "id": 3769, + "link": "https://leetcode.com/problems/sort-integers-by-binary-reflection/", + "title": "Sort Integers by Binary Reflection" }, "3770": { - "id": 3770, "category": "Math & Geometry", - "title": "Largest Prime from Consecutive Prime Sum", "difficulty": "Medium", - "link": "https://leetcode.com/problems/largest-prime-from-consecutive-prime-sum/" + "id": 3770, + "link": "https://leetcode.com/problems/largest-prime-from-consecutive-prime-sum/", + "title": "Largest Prime from Consecutive Prime Sum" }, "3771": { - "id": 3771, "category": "Dynamic Programming", - "title": "Total Score of Dungeon Runs", "difficulty": "Medium", - "link": "https://leetcode.com/problems/total-score-of-dungeon-runs/" + "id": 3771, + "link": "https://leetcode.com/problems/total-score-of-dungeon-runs/", + "title": "Total Score of Dungeon Runs" }, "3772": { - "id": 3772, "category": "Tree", - "title": "Maximum Subgraph Score in a Tree", "difficulty": "Hard", - "link": "https://leetcode.com/problems/maximum-subgraph-score-in-a-tree/" + "id": 3772, + "link": "https://leetcode.com/problems/maximum-subgraph-score-in-a-tree/", + "title": "Maximum Subgraph Score in a Tree" } } diff --git a/explanations/156/en.md b/explanations/156/en.md new file mode 100644 index 0000000..c5083b0 --- /dev/null +++ b/explanations/156/en.md @@ -0,0 +1,56 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to flip a binary tree upside down, where the original leftmost node becomes the new root, and the original root becomes the rightmost leaf. The transformation follows a specific pattern where left children become parents and right children become left children. + +**1.1 Constraints & Complexity:** +- Input size: The tree can have up to O(n) nodes where n is the number of nodes +- **Time Complexity:** O(n) where n is the number of nodes - we visit each node exactly once +- **Space Complexity:** O(h) where h is the height of the tree - the recursion stack depth equals the tree height +- **Edge Case:** If the tree is empty or has no left child, return the root as-is + +**1.2 High-level approach:** +We use recursion to traverse to the leftmost node, which becomes the new root. During the backtracking phase, we reassign pointers to transform the tree structure according to the upside-down pattern. + +![Binary tree upside down transformation](https://assets.leetcode.com/static_assets/others/binary-tree-upside-down.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Create a new tree by copying nodes and reassigning pointers iteratively. This requires O(n) extra space. +- **Optimized Strategy:** Use recursion to transform the tree in-place by reassigning pointers during backtracking. This uses O(h) space for recursion. +- **Why it's better:** We modify the tree in-place without creating new nodes, making it more memory efficient. + +**1.4 Decomposition:** +1. Recursively traverse to the leftmost node, which will become the new root +2. During backtracking, reassign the current node's left child's left pointer to the current node's right child +3. Reassign the current node's left child's right pointer to the current node itself +4. Set the current node's left and right pointers to None to break old connections +5. Return the new root (leftmost node) from the deepest recursion + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example tree with nodes [1,2,3,4,5]: +- Root: 1, left: 2, right: 3 +- Node 2: left: 4, right: 5 +- After transformation, node 4 becomes the new root + +**2.2 Start Processing:** +We begin recursive traversal starting from the root, always going left first. + +**2.3 Trace Walkthrough:** + +| Node | Has Left? | Action | New Root | Transformations | +|------|-----------|--------|----------|------------------| +| 1 | Yes | Go left to 2 | - | - | +| 2 | Yes | Go left to 4 | - | - | +| 4 | No | Return 4 | 4 | - | +| 2 | - | Backtrack | 4 | 4.left = 5, 4.right = 2, 2.left = None, 2.right = None | +| 1 | - | Backtrack | 4 | 2.left = 3, 2.right = 1, 1.left = None, 1.right = None | + +**2.4 Increment and Loop:** +The recursion naturally handles the traversal. We continue until we reach a node with no left child. + +**2.5 Return Result:** +Return the new root (node 4), which is the leftmost node from the original tree. The tree is now upside down with all pointers correctly reassigned. + diff --git a/explanations/157/en.md b/explanations/157/en.md new file mode 100644 index 0000000..45c7946 --- /dev/null +++ b/explanations/157/en.md @@ -0,0 +1,54 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to read n characters from a file using the read4 API, which reads exactly 4 characters at a time. We must handle cases where n might not be a multiple of 4, and we need to stop reading when we've read n characters or reached the end of the file. + +**1.1 Constraints & Complexity:** +- Input size: `1 <= n <= 1000` characters to read +- **Time Complexity:** O(n) - we read at most n characters, and each read4 call reads up to 4 characters +- **Space Complexity:** O(1) - we use a fixed-size buffer of 4 characters +- **Edge Case:** If n is 0, we return 0 without reading. If the file has fewer than n characters, we return the actual number read + +**1.2 High-level approach:** +We repeatedly call read4 to read 4 characters at a time, copying them to the destination buffer until we've read n characters or reached the end of the file. We handle partial reads when n is not a multiple of 4. + +![Reading characters in chunks of 4](https://assets.leetcode.com/static_assets/others/read4-api.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Call read4 once for every character needed, which would be inefficient and incorrect since read4 reads 4 characters at a time. +- **Optimized Strategy:** Call read4 in a loop, reading 4 characters at a time and copying only what we need. This minimizes API calls. +- **Why it's better:** We make the minimum number of read4 calls needed, reading in optimal chunks of 4. + +**1.4 Decomposition:** +1. Create a temporary buffer of size 4 to store characters from read4 +2. Initialize a counter to track total characters read +3. Loop while we haven't read n characters yet +4. Call read4 to get up to 4 characters +5. Copy the minimum of (characters read, remaining needed) to the destination buffer +6. Update the total count and continue until done + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `n = 5`, file contains "abcde" +- Initialize `buf4 = ['', '', '', '']` (temporary buffer) +- Initialize `total = 0` (characters read so far) + +**2.2 Start Reading:** +We begin the loop to read characters until we've read n characters or reached EOF. + +**2.3 Trace Walkthrough:** + +| Iteration | total | n - total | read4() returns | buf4 | Copy to buf | total after | +|-----------|-------|-----------|------------------|------|-------------|--------------| +| 1 | 0 | 5 | 4 | ['a','b','c','d'] | buf[0:4] = ['a','b','c','d'] | 4 | +| 2 | 4 | 1 | 1 | ['e','','',''] | buf[4:5] = ['e'] | 5 | +| End | 5 | 0 | - | - | - | 5 | + +**2.4 Increment and Loop:** +After each read4 call, we update total by the number of characters copied. We continue until total >= n or read4 returns 0 (EOF). + +**2.5 Return Result:** +Return `total = 5`, which is the number of characters successfully read into the buffer. The buffer now contains ['a','b','c','d','e']. + diff --git a/explanations/158/en.md b/explanations/158/en.md new file mode 100644 index 0000000..b72549d --- /dev/null +++ b/explanations/158/en.md @@ -0,0 +1,63 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to read n characters from a file using the read4 API, but the read function may be called multiple times. We must maintain state between calls to handle leftover characters from previous read4 calls that weren't fully consumed. + +**1.1 Constraints & Complexity:** +- Input size: `1 <= n <= 1000` characters per read call +- **Time Complexity:** O(n) per read call - we process at most n characters per call +- **Space Complexity:** O(1) amortized - we use a queue that stores at most 4 characters at a time +- **Edge Case:** If read is called with n=0, return 0. If previous calls left characters in the queue, use them first + +**1.2 High-level approach:** +We maintain a queue to store leftover characters from previous read4 calls. When read is called, we first consume characters from the queue, then call read4 if needed. Any extra characters from read4 are stored in the queue for future calls. + +![Maintaining buffer between multiple read calls](https://assets.leetcode.com/static_assets/others/read4-multiple-calls.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Ignore previous state and start fresh each time, which would lose leftover characters and produce incorrect results. +- **Optimized Strategy:** Use a queue to buffer leftover characters between calls, ensuring we don't lose any data and minimize read4 calls. +- **Why it's better:** We correctly handle multiple calls by preserving state, and we avoid redundant read4 calls by reusing buffered characters. + +**1.4 Decomposition:** +1. Initialize a queue in the constructor to store leftover characters +2. When read is called, first check if the queue has characters and use them +3. If more characters are needed, call read4 to get new characters +4. Store any extra characters from read4 (beyond what's needed) in the queue +5. Return the total number of characters read + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: First call `read(buf, 1)`, then `read(buf, 2)`, file contains "abc" +- Initialize `self.queue = []` in constructor +- First call needs 1 character, second call needs 2 characters + +**2.2 Start Reading:** +We begin by checking the queue for leftover characters, then call read4 if needed. + +**2.3 Trace Walkthrough:** + +| Call | n | Queue Before | Action | read4() | Queue After | Return | +|------|---|--------------|--------|---------|------------|--------| +| 1 | 1 | [] | Call read4 | 4 chars: ['a','b','c',''] | ['b','c'] | 1 | +| 2 | 2 | ['b','c'] | Use queue first | - | [] | 2 | + +**Detailed first call:** +- Queue is empty, call read4 → gets ['a','b','c',''] (3 valid chars) +- Need 1 char, take 'a' from read4 result +- Store remaining ['b','c'] in queue +- Return 1 + +**Detailed second call:** +- Queue has ['b','c'], take both +- Need 2 chars, have 2 in queue, perfect +- Return 2 + +**2.4 Increment and Loop:** +We continue processing characters from the queue and calling read4 until we've read n characters or reached EOF. + +**2.5 Return Result:** +Return the total number of characters read (idx). The queue now contains any leftover characters for future read calls. + diff --git a/explanations/159/en.md b/explanations/159/en.md new file mode 100644 index 0000000..ee64a13 --- /dev/null +++ b/explanations/159/en.md @@ -0,0 +1,58 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to find the length of the longest substring that contains at most two distinct characters. This means we can have 0, 1, or 2 different characters in our substring, but not 3 or more. + +**1.1 Constraints & Complexity:** +- Input size: `1 <= s.length <= 10^5` +- **Time Complexity:** O(n) where n is the length of the string - each character is visited at most twice (once by right pointer, once by left pointer) +- **Space Complexity:** O(1) - we store at most 2 distinct characters in the hash map +- **Edge Case:** If the string has fewer than 2 distinct characters, return the entire string length + +**1.2 High-level approach:** +We use a sliding window technique with two pointers. The right pointer expands the window to include new characters, and the left pointer shrinks it when we have more than two distinct characters. We track character frequencies using a hash map. + +![Sliding window with two distinct characters](https://assets.leetcode.com/static_assets/others/sliding-window-two-distinct.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Check all possible substrings O(n²) and count distinct characters for each, which is O(n³) total. +- **Optimized Strategy:** Use sliding window to maintain a valid substring, expanding and contracting as needed. This is O(n) time. +- **Why it's better:** We avoid checking redundant substrings and process each character at most twice, making it much more efficient. + +**1.4 Decomposition:** +1. Initialize two pointers (left and right) at the start of the string +2. Use a hash map to count character frequencies in the current window +3. Expand the window by moving the right pointer and updating counts +4. When we have more than 2 distinct characters, shrink the window by moving the left pointer +5. Track the maximum window size throughout the process + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `s = "eceba"` +- Initialize `left = 0`, `right = 0`, `res = 0` +- Initialize `char_count = {}` (empty hash map) + +**2.2 Start Checking:** +We begin expanding the window by moving the right pointer. + +**2.3 Trace Walkthrough:** + +| Step | right | s[right] | char_count | Distinct | Action | left | res | +|------|-------|-----------|------------|----------|--------|-----|-----| +| 0 | 0 | 'e' | {'e':1} | 1 | Expand | 0 | 1 | +| 1 | 1 | 'c' | {'e':1,'c':1} | 2 | Expand | 0 | 2 | +| 2 | 2 | 'e' | {'e':2,'c':1} | 2 | Expand | 0 | 3 | +| 3 | 3 | 'b' | {'e':2,'c':1,'b':1} | 3 | Shrink | 1 | 3 | +| 3a | 3 | 'b' | {'e':1,'c':1,'b':1} | 3 | Shrink | 2 | 3 | +| 3b | 3 | 'b' | {'e':1,'b':1} | 2 | Expand | 2 | 3 | +| 4 | 4 | 'a' | {'e':1,'b':1,'a':1} | 3 | Shrink | 3 | 3 | +| 4a | 4 | 'a' | {'b':1,'a':1} | 2 | Expand | 3 | 3 | + +**2.4 Increment and Loop:** +After processing each character, we increment the right pointer. If we need to shrink, we increment the left pointer until we have at most 2 distinct characters. + +**2.5 Return Result:** +Return `res = 3`, which is the length of the longest substring with at most two distinct characters. In this case, "ece" or "ceb" both have length 3. + diff --git a/explanations/161/en.md b/explanations/161/en.md new file mode 100644 index 0000000..341c427 --- /dev/null +++ b/explanations/161/en.md @@ -0,0 +1,62 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to determine if two strings are exactly one edit distance apart. An edit can be: inserting one character, deleting one character, or replacing one character. The strings must differ by exactly one operation, not zero or more than one. + +**1.1 Constraints & Complexity:** +- Input size: `0 <= s.length, t.length <= 10^4` +- **Time Complexity:** O(n) where n is the length of the shorter string - we compare characters until we find a difference +- **Space Complexity:** O(1) - we only use a few variables, no extra data structures +- **Edge Case:** If both strings are empty, they are zero edit distance apart, return False. If one string is empty and the other has one character, return True. + +**1.2 High-level approach:** +We first check if the length difference is more than 1 (impossible to be one edit). Then we compare characters from the start. When we find the first difference, we check if the remaining substrings match based on whether the strings have the same length (replacement) or different lengths (insertion/deletion). + +![Comparing strings character by character](https://assets.leetcode.com/static_assets/others/one-edit-distance.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Try all possible single edits (insert, delete, replace) and check if any results in the target string. This is O(n²) or worse. +- **Optimized Strategy:** Compare strings character by character, and when we find a difference, check if the remaining parts match. This is O(n) time. +- **Why it's better:** We only need one pass through the strings, stopping as soon as we can determine the answer. + +**1.4 Decomposition:** +1. Check if length difference is more than 1 - if so, return False +2. Ensure s is the shorter string (swap if needed for easier logic) +3. Compare characters from the start until we find a difference +4. If lengths are equal, check if remaining substrings match (replacement case) +5. If lengths differ by 1, check if remaining substring of longer matches remaining of shorter (insertion/deletion case) + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `s = "ab"`, `t = "acb"` +- `len_s = 2`, `len_t = 3` +- Length difference is 1, so it's possible +- Swap to make s shorter: `s = "ab"`, `t = "acb"` (already correct) + +**2.2 Start Checking:** +We begin comparing characters from index 0. + +**2.3 Trace Walkthrough:** + +| i | s[i] | t[i] | Match? | Action | +|---|------|------|--------|--------| +| 0 | 'a' | 'a' | Yes | Continue | +| 1 | 'b' | 'c' | No | Check remaining | + +At i=1, we found a difference. Since `len_s < len_t`: +- Check if `s[1:] == t[2:]` → `"b" == "b"` → True +- This means 'c' was inserted in t, so return True + +**Another example:** `s = "ab"`, `t = "ac"` +- At i=1: `s[1:] == "b"`, `t[1:] == "c"` +- Since lengths are equal, check `s[1:] == t[1:]` → `"b" == "c"` → False +- This means it's a replacement, but the remaining parts don't match, so return False + +**2.4 Increment and Loop:** +We increment i as we compare characters. When we find a mismatch, we stop and check the remaining parts. + +**2.5 Return Result:** +Return True if exactly one edit is found (remaining parts match after the difference), False otherwise. For `s = "ab"`, `t = "acb"`, we return True because one insertion makes them equal. + diff --git a/explanations/163/en.md b/explanations/163/en.md new file mode 100644 index 0000000..921ffc8 --- /dev/null +++ b/explanations/163/en.md @@ -0,0 +1,57 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to find all missing number ranges in a sorted array between a lower and upper bound. A range can be a single number or a range like "a->b". We must return the smallest sorted list of ranges that covers every missing number. + +**1.1 Constraints & Complexity:** +- Input size: `0 <= nums.length <= 100`, `-10^9 <= lower <= upper <= 10^9` +- **Time Complexity:** O(n) where n is the length of nums - we iterate through the array once +- **Space Complexity:** O(1) excluding output - we only use a few variables +- **Edge Case:** If nums is empty, return the range [lower, upper]. If there are no gaps, return an empty list. + +**1.2 High-level approach:** +We iterate through the array and check gaps between consecutive numbers. We also check the gap before the first number (from lower) and after the last number (to upper). For each gap, we format it as either a single number or a range. + +![Finding missing ranges in sorted array](https://assets.leetcode.com/static_assets/others/missing-ranges.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Check every number from lower to upper to see if it's in nums, which is O(upper - lower) and inefficient for large ranges. +- **Optimized Strategy:** Iterate through nums once, checking gaps between consecutive elements. This is O(n) regardless of the range size. +- **Why it's better:** We only process the actual numbers in the array, not every number in the range, making it much more efficient. + +**1.4 Decomposition:** +1. Initialize a previous value to lower - 1 to track the last number we've seen +2. Append upper + 1 to nums temporarily to handle the gap after the last element +3. Iterate through each number in the modified array +4. Calculate the gap between previous and current number +5. If gap is 2, add a single number. If gap > 2, add a range + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `nums = [0,1,3,50,75]`, `lower = 0`, `upper = 99` +- Initialize `res = []` +- Initialize `prev = lower - 1 = -1` +- Append `upper + 1 = 100` to nums: `[0,1,3,50,75,100]` + +**2.2 Start Checking:** +We begin iterating through the modified nums array. + +**2.3 Trace Walkthrough:** + +| num | prev | gap (num - prev) | Condition | Result | prev after | +|-----|------|-------------------|-----------|--------|------------| +| 0 | -1 | 1 | gap == 1 | Skip (no gap) | 0 | +| 1 | 0 | 1 | gap == 1 | Skip (no gap) | 1 | +| 3 | 1 | 2 | gap == 2 | Add "2" | 3 | +| 50 | 3 | 47 | gap > 2 | Add "4->49" | 50 | +| 75 | 50 | 25 | gap > 2 | Add "51->74" | 75 | +| 100 | 75 | 25 | gap > 2 | Add "76->99" | 100 | + +**2.4 Increment and Loop:** +After processing each number, we update prev to the current number and continue to the next iteration. + +**2.5 Return Result:** +Return `res = ["2", "4->49", "51->74", "76->99"]`, which represents all missing ranges between 0 and 99. + diff --git a/explanations/170/en.md b/explanations/170/en.md new file mode 100644 index 0000000..72a8c80 --- /dev/null +++ b/explanations/170/en.md @@ -0,0 +1,63 @@ +## Explanation + +### Strategy (The "Why") + +**Restate the problem:** We need to design a data structure that supports adding numbers and checking if any two numbers in the structure sum to a target value. This is similar to the classic Two Sum problem, but we need to handle dynamic additions and queries. + +**1.1 Constraints & Complexity:** +- Input size: Number of add operations and find operations can be large +- **Time Complexity:** O(1) for add, O(n) for find where n is the number of distinct numbers added +- **Space Complexity:** O(n) where n is the number of distinct numbers stored +- **Edge Case:** If we add the same number twice and look for 2*number, we need at least 2 occurrences. If we look for a sum that requires two different numbers, we need both to exist. + +**1.2 High-level approach:** +We use a hash map to store the frequency of each number added. For the find operation, we iterate through all numbers and check if their complement (target - number) exists in the map. We handle the special case where the complement equals the number itself. + +![Hash map storing number frequencies](https://assets.leetcode.com/static_assets/others/two-sum-hashmap.png) + +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Store numbers in a list, and for each find, check all pairs O(n²) time. +- **Optimized Strategy:** Use a hash map for O(1) lookups. For find, iterate through keys and check complements in O(1) time each. +- **Why it's better:** Hash map lookups are O(1) average case, making find operations much faster than checking all pairs. + +**1.4 Decomposition:** +1. Initialize a hash map to store number frequencies in the constructor +2. For add operation, increment the count of the number in the hash map +3. For find operation, iterate through all numbers in the hash map +4. For each number, calculate its complement (target - number) +5. Check if complement exists, handling the case where complement equals the number (need count >= 2) + +### Steps (The "How") + +**2.1 Initialization & Example Setup:** +Let's use the example: `add(1)`, `add(3)`, `add(5)`, `find(4)`, `find(7)` +- Initialize `num_counts = {}` (empty hash map) + +**2.2 Start Adding:** +We add numbers to the data structure. + +**2.3 Trace Walkthrough:** + +| Operation | number | num_counts after | - | +|-----------|--------|-------------------|---| +| add(1) | 1 | {1: 1} | - | +| add(3) | 3 | {1: 1, 3: 1} | - | +| add(5) | 5 | {1: 1, 3: 1, 5: 1} | - | +| find(4) | - | {1: 1, 3: 1, 5: 1} | Check: 1→complement=3 (exists), return True | +| find(7) | - | {1: 1, 3: 1, 5: 1} | Check: 1→complement=6 (not exists), 3→complement=4 (not exists), 5→complement=2 (not exists), return False | + +**Detailed find(4) check:** +- num=1: complement = 4-1 = 3, exists in map → return True + +**Detailed find(7) check:** +- num=1: complement = 7-1 = 6, not in map +- num=3: complement = 7-3 = 4, not in map +- num=5: complement = 7-5 = 2, not in map +- return False + +**2.4 Increment and Loop:** +For find operations, we iterate through all keys in the hash map. We stop early if we find a valid pair. + +**2.5 Return Result:** +Return True if any pair sums to the target value, False otherwise. For find(4), we return True because 1 + 3 = 4. For find(7), we return False because no pair sums to 7. + diff --git a/explanations/27/en.md b/explanations/27/en.md index d6dd195..d332d56 100644 --- a/explanations/27/en.md +++ b/explanations/27/en.md @@ -1,131 +1,54 @@ -# 27. Remove Element [Easy] - -[https://leetcode.com/problems/remove-element/](https://leetcode.com/problems/remove-element/) - -## Description - -Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` **[in-place](https://en.wikipedia.org/wiki/In-place_algorithm)**. The order of the elements may be changed. Then return *the number of elements in* `nums` *which are not equal to* `val`. - -Consider the number of elements in `nums` which are not equal to `val` be `k`, to get accepted, you need to do the following things: - -1. Change the array `nums` such that the first `k` elements of `nums` contain the elements which are not equal to `val`. The remaining elements of `nums` are not important as well as the size of `nums`. -2. Return `k`. - -**Custom Judge:** - -The judge will test your solution with the following code: - -```raw -int[] nums = [...]; // Input array -int val = ...; // Value to remove -int[] expectedNums = [...]; // The expected answer with correct length. - // It is sorted with no values equaling val. - -int k = removeElement(nums, val); // Calls your implementation - -assert k == expectedNums.length; -sort(nums, 0, k); // Sort the first k elements of nums -for (int i = 0; i < actualLength; i++) { - assert nums[i] == expectedNums[i]; -} -``` - -If all assertions pass, then your solution will be **accepted**. - -**Example 1:** - -```raw -Input: nums = [3,2,2,3], val = 3 -Output: 2, nums = [2,2,_,_] -Explanation: Your function should return k = 2, with the first two elements of nums being 2. -It does not matter what you leave beyond the returned k (hence they are underscores). -``` - -**Example 2:** - -```raw -Input: nums = [0,1,2,2,3,0,4,2], val = 2 -Output: 5, nums = [0,1,4,0,3,_,_,_] -Explanation: Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4. -Note that the five elements can be returned in any order. -It does not matter what you leave beyond the returned k (hence they are underscores). -``` - -**Constraints:** - -- `0 <= nums.length <= 100` -- `0 <= nums[i] <= 50` -- `0 <= val <= 100` - ## Explanation -### Strategy - -This is a **two-pointer array manipulation problem** that requires removing all occurrences of a specific value from an array in-place. The key insight is that we don't need to actually "remove" elements - we just need to move all non-target elements to the front of the array and return the count. - -**Key observations:** -- We need to modify the array in-place without using extra space -- The order of elements can be changed -- We only care about the first `k` elements after removal -- We can use a two-pointer approach to overwrite elements efficiently - -**High-level approach:** -1. **Use a slow pointer**: Points to the next position where we'll place a valid element -2. **Use a fast pointer**: Iterates through the array to find valid elements -3. **Copy valid elements**: When we find an element not equal to `val`, copy it to the slow pointer position -4. **Return the count**: The slow pointer position at the end gives us the count of valid elements - -### Steps - -Let's break down the solution step by step: - -**Step 1: Initialize pointers** - -- `slow`: Points to the next position where we'll place a valid element (starts at 0) -- `fast`: Iterates through the array to find elements (starts at 0) - -**Step 2: Iterate through the array** - -For each element at position `fast`: -- If `nums[fast] != val`, copy it to `nums[slow]` and increment `slow` -- If `nums[fast] == val`, skip it (just increment `fast`) +### Strategy (The "Why") -**Step 3: Return the result** +**Restate the problem:** We need to remove all occurrences of a specific value from an array in-place, meaning we modify the original array without using extra space. The order of elements can be changed, and we only need to ensure the first k elements contain all non-target values. -- The value of `slow` at the end gives us the count of elements not equal to `val` -- The first `slow` elements of the array contain all the valid elements +**1.1 Constraints & Complexity:** +- Input size: `0 <= nums.length <= 100`, `0 <= nums[i] <= 50`, `0 <= val <= 100` +- **Time Complexity:** O(n) where n is the length of the array - we visit each element exactly once +- **Space Complexity:** O(1) - we modify the array in-place without using extra space +- **Edge Case:** If the array is empty or contains no elements equal to val, we return the original length -**Example walkthrough:** +**1.2 High-level approach:** +We use a two-pointer technique where one pointer scans through the array to find valid elements, and another pointer tracks where to place them. This allows us to "remove" elements by overwriting them with valid elements. -Let's trace through the first example: +![Two pointers moving through array](https://assets.leetcode.com/static_assets/others/two-pointers.png) -```raw -nums = [3,2,2,3], val = 3 +**1.3 Brute force vs. optimized strategy:** +- **Brute Force:** Create a new array, copy all non-target elements to it, then copy back. This requires O(n) extra space. +- **Optimized Strategy:** Use two pointers to overwrite elements in-place. This requires O(1) extra space and is more efficient. +- **Why it's better:** We avoid creating a new array, saving memory and making the solution more efficient. -Initial state: -slow = 0, fast = 0 +**1.4 Decomposition:** +1. Initialize a slow pointer at position 0 to track where valid elements should be placed +2. Use a fast pointer to iterate through all elements in the array +3. For each element, check if it's not equal to the target value +4. If valid, copy it to the slow pointer position and advance the slow pointer +5. Return the slow pointer value as the count of valid elements -Step 1: nums[0] = 3 == val -Skip 3, increment fast only -slow = 0, fast = 1 +### Steps (The "How") -Step 2: nums[1] = 2 != val -Copy 2 to nums[0], increment both -nums = [2,2,2,3], slow = 1, fast = 2 +**2.1 Initialization & Example Setup:** +Let's use the example: `nums = [3,2,2,3]`, `val = 3` +- Initialize `slow = 0` (points to next position for valid elements) +- Initialize `fast = 0` (scans through the array) -Step 3: nums[2] = 2 != val -Copy 2 to nums[1], increment both -nums = [2,2,2,3], slow = 2, fast = 3 +**2.2 Start Checking:** +We begin iterating through the array with the fast pointer. -Step 4: nums[3] = 3 == val -Skip 3, increment fast only -slow = 2, fast = 4 +**2.3 Trace Walkthrough:** -Result: Return slow = 2 -Final array: [2,2,_,_] (first 2 elements are valid) -``` +| Step | fast | nums[fast] | nums[fast] == val? | Action | nums after | slow | +|------|------|------------|-------------------|--------|------------|------| +| Initial | 0 | 3 | Yes | Skip, increment fast | [3,2,2,3] | 0 | +| 1 | 1 | 2 | No | Copy to nums[0], increment both | [2,2,2,3] | 1 | +| 2 | 2 | 2 | No | Copy to nums[1], increment both | [2,2,2,3] | 2 | +| 3 | 3 | 3 | Yes | Skip, increment fast | [2,2,2,3] | 2 | +| End | 4 | - | - | Loop ends | [2,2,2,3] | 2 | -> **Note:** The two-pointer approach is efficient because we only need one pass through the array. We don't need to actually remove elements - we just overwrite the positions where we want to keep elements. +**2.4 Increment and Loop:** +After each iteration, we increment the fast pointer. If we found a valid element, we also increment the slow pointer. -**Time Complexity:** O(n) - we visit each element exactly once -**Space Complexity:** O(1) - we modify the array in-place without extra space \ No newline at end of file +**2.5 Return Result:** +Return `slow = 2`, which represents the number of elements not equal to val. The first 2 elements `[2,2]` are the valid elements. diff --git a/package.json b/package.json new file mode 100644 index 0000000..1b39f3a --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "scripts": { + "format:json": "npx prettier --write 'data/**/*.json'" + } +} diff --git a/scripts/normalize_book_sets.py b/scripts/normalize_book_sets.py index c883ccc..9897f58 100755 --- a/scripts/normalize_book_sets.py +++ b/scripts/normalize_book_sets.py @@ -118,15 +118,19 @@ def normalize_book_sets( print("Error: The root of the JSON file must be an array.") return - # Find the "All-TODO" and "All" objects + # Find the "All-TODO" and "All" objects, and get premium list all_todo_obj = None all_obj = None + premium_set = set() for obj in data: if obj.get("title") == "All-TODO": all_todo_obj = obj elif obj.get("title") == "All": all_obj = obj + elif "premium" in obj: + # Get premium problems list + premium_set = set(obj.get("premium", [])) changes_made = False @@ -170,7 +174,7 @@ def normalize_book_sets( if d.is_dir() and d.name.isdigit() and not d.name.startswith("todo-") } - # Find problems that have both + # Find problems that have both (excluding premium) problems_with_both = sorted( [ p @@ -179,18 +183,29 @@ def normalize_book_sets( and has_both_solution_and_explanation( p, solutions_path, explanations_path ) + and p not in premium_set # Exclude premium problems ] ) original_count = len(all_obj.get("problems", [])) original_problems = set(all_obj.get("problems", [])) + problems_with_both_set = set(problems_with_both) - if set(problems_with_both) != original_problems: + # Remove premium problems from original_problems for comparison + original_non_premium = original_problems - premium_set + removed_premium = sorted(original_problems & premium_set) + + # Always update if there are premium problems to remove, or if sets differ + if removed_premium or problems_with_both_set != original_non_premium: changes_made = True - added = sorted(set(problems_with_both) - original_problems) - removed = sorted(original_problems - set(problems_with_both)) + added = sorted(problems_with_both_set - original_non_premium) + removed = sorted(original_non_premium - problems_with_both_set) print(f"\n[All] Updating problem list:") + if removed_premium: + print( + f" Removed {len(removed_premium)} premium problems: {removed_premium[:10]}{'...' if len(removed_premium) > 10 else ''}" + ) if added: print( f" Added {len(added)} problems: {added[:10]}{'...' if len(added) > 10 else ''}" @@ -284,8 +299,10 @@ def normalize_book_sets( print("[DRY RUN] Would write changes to file (use --write to apply)") else: try: + # Write JSON file (prettier will format it via pre-commit hook) with open(book_sets_file, "w", encoding="utf-8") as f: - json.dump(data, f, indent=2, ensure_ascii=False) + json.dump(data, f, ensure_ascii=False) + print("\n" + "=" * 70) print(f"✓ Successfully updated '{book_sets_file}'") except Exception as e: diff --git a/scripts/normalize_json.py b/scripts/normalize_json.py index fc17188..86bc015 100755 --- a/scripts/normalize_json.py +++ b/scripts/normalize_json.py @@ -2,9 +2,8 @@ """ Reads a JSON file, sorts its top-level keys numerically, -and writes the sorted data to a new JSON file following Prettier style. - -Prettier config: printWidth=150, tabWidth=2, useTabs=false, trailingComma=es5, bracketSpacing=false +and writes the sorted data to a new JSON file. +Prettier will format the output according to .prettierrc config. python scripts/normalize_json.py data/leetcode-problems.json """ @@ -14,66 +13,6 @@ from collections import OrderedDict -def format_json_value(value, indent_level=0, print_width=150): - """Format a JSON value with custom formatting following Prettier style.""" - indent = " " * indent_level - next_indent = " " * (indent_level + 1) - - if isinstance(value, dict): - if not value: - return "{}" - items = [] - for k, v in sorted(value.items()): - formatted_key = json.dumps(k, ensure_ascii=False) - formatted_value = format_json_value(v, indent_level + 1, print_width) - items.append(f"{next_indent}{formatted_key}: {formatted_value}") - return "{\n" + ",\n".join(items) + "\n" + indent + "}" - elif isinstance(value, list): - if not value: - return "[]" - # Check if it's a list of numbers (for problems arrays) - format multiple per line - if value and isinstance(value[0], (int, float)): - # Calculate available width (print_width minus indentation and brackets) - available_width = print_width - len(next_indent) - 2 - lines = [] - current_line = [] - current_length = 0 - - for i, item in enumerate(value): - item_str = str(item) - # Add comma and space length (2) if not first item on line - item_length = len(item_str) + (2 if current_line else 0) - - if current_length + item_length > available_width and current_line: - # Start a new line - lines.append(", ".join(str(x) for x in current_line)) - current_line = [item] - current_length = len(item_str) - else: - current_line.append(item) - current_length += item_length - - if current_line: - lines.append(", ".join(str(x) for x in current_line)) - - # Format with proper indentation - formatted_lines = [f"{next_indent}{line}" for line in lines] - return "[\n" + ",\n".join(formatted_lines) + "\n" + indent + "]" - else: - # Format other arrays - check if they fit on one line - formatted_items = [format_json_value(item, indent_level + 1, print_width) for item in value] - total_length = sum(len(str(item)) for item in formatted_items) - if total_length < 100 and len(value) <= 5: - # Short arrays on one line - return "[" + ", ".join(str(item).replace("\n", " ") for item in formatted_items) + "]" - else: - # Long arrays with line breaks - items = [f"{next_indent}{item}" for item in formatted_items] - return "[\n" + ",\n".join(items) + "\n" + indent + "]" - else: - return json.dumps(value, ensure_ascii=False) - - def sort_json_by_numeric_keys(input_file, output_file): """ Sort JSON file by numeric keys and format according to Prettier style. @@ -93,18 +32,9 @@ def sort_json_by_numeric_keys(input_file, output_file): sorted_items = sorted(data.items(), key=lambda item: int(item[0])) sorted_data = OrderedDict(sorted_items) - # Format the JSON with custom formatting following Prettier style - lines = ["{"] - items = [] - for key, value in sorted_data.items(): - formatted_key = json.dumps(key, ensure_ascii=False) - formatted_value = format_json_value(value, 1, print_width=150) - items.append(f' {formatted_key}: {formatted_value}') - lines.append(",\n".join(items)) - lines.append("}") - + # Write JSON (Prettier will format it via pre-commit hook) with open(output_file, "w", encoding="utf-8") as f: - f.write("\n".join(lines) + "\n") + json.dump(sorted_data, f, ensure_ascii=False) print( f"Successfully sorted '{input_file}' and saved the result to '{output_file}'." diff --git a/scripts/sort_book_sets_by_difficulty.py b/scripts/sort_book_sets_by_difficulty.py index ac6a7c9..983157f 100755 --- a/scripts/sort_book_sets_by_difficulty.py +++ b/scripts/sort_book_sets_by_difficulty.py @@ -183,9 +183,9 @@ def main(): print(f"Dry run complete. Would update {updated_count} set(s).") else: if updated_count > 0: - # Save updated book-sets.json + # Save updated book-sets.json (Prettier will format it via pre-commit hook) with open(BOOK_SETS_PATH, "w", encoding="utf-8") as f: - json.dump(book_sets, f, indent=2) + json.dump(book_sets, f, ensure_ascii=False) print(f"✓ Updated {updated_count} book set(s) in {BOOK_SETS_PATH}") else: print("No changes needed. All sets are already sorted.") diff --git a/scripts/update_problems_from_csv.py b/scripts/update_problems_from_csv.py index 909c90c..ff5d6e9 100644 --- a/scripts/update_problems_from_csv.py +++ b/scripts/update_problems_from_csv.py @@ -156,8 +156,9 @@ def save_json(data): ) sorted_data = OrderedDict(sorted_items) + # Write JSON (Prettier will format it via pre-commit hook) with open(JSON_PATH, "w", encoding="utf-8") as f: - json.dump(sorted_data, f, indent=2) + json.dump(sorted_data, f, ensure_ascii=False) return True except Exception as e: print(f"Error saving JSON: {e}") diff --git a/solutions/156/01.py b/solutions/156/01.py new file mode 100644 index 0000000..215cf9b --- /dev/null +++ b/solutions/156/01.py @@ -0,0 +1,23 @@ +from typing import Optional + +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right + +class Solution: + def upsideDownBinaryTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: + if not root or not root.left: + return root + + new_root = self.upsideDownBinaryTree(root.left) + + root.left.left = root.right + root.left.right = root + root.left = None + root.right = None + + return new_root + diff --git a/solutions/157/01.py b/solutions/157/01.py new file mode 100644 index 0000000..2f38a8e --- /dev/null +++ b/solutions/157/01.py @@ -0,0 +1,21 @@ +from typing import List + +# The read4 API is already defined for you. +# def read4(buf4: List[str]) -> int: + +class Solution: + def read(self, buf: List[str], n: int) -> int: + buf4 = [''] * 4 + total = 0 + + while total < n: + count = read4(buf4) + if count == 0: + break + + copy_count = min(count, n - total) + buf[total:total + copy_count] = buf4[:copy_count] + total += copy_count + + return total + diff --git a/solutions/158/01.py b/solutions/158/01.py new file mode 100644 index 0000000..1349fd2 --- /dev/null +++ b/solutions/158/01.py @@ -0,0 +1,25 @@ +from typing import List + +# The read4 API is already defined for you. +# def read4(buf4: List[str]) -> int: + +class Solution: + def __init__(self): + self.queue = [] + + def read(self, buf: List[str], n: int) -> int: + idx = 0 + + while idx < n: + if self.queue: + buf[idx] = self.queue.pop(0) + idx += 1 + else: + buf4 = [''] * 4 + count = read4(buf4) + if count == 0: + break + self.queue.extend(buf4[:count]) + + return idx + diff --git a/solutions/159/01.py b/solutions/159/01.py new file mode 100644 index 0000000..dff52f6 --- /dev/null +++ b/solutions/159/01.py @@ -0,0 +1,23 @@ +from collections import defaultdict + +class Solution: + def lengthOfLongestSubstringTwoDistinct(self, s: str) -> int: + left = 0 + right = 0 + res = 0 + char_count = defaultdict(int) + + while right < len(s): + char_count[s[right]] += 1 + + while len(char_count) > 2: + char_count[s[left]] -= 1 + if char_count[s[left]] == 0: + del char_count[s[left]] + left += 1 + + res = max(res, right - left + 1) + right += 1 + + return res + diff --git a/solutions/161/01.py b/solutions/161/01.py new file mode 100644 index 0000000..7dc1cc9 --- /dev/null +++ b/solutions/161/01.py @@ -0,0 +1,20 @@ +class Solution: + def isOneEditDistance(self, s: str, t: str) -> bool: + len_s, len_t = len(s), len(t) + + if abs(len_s - len_t) > 1: + return False + + if len_s > len_t: + s, t = t, s + len_s, len_t = len_t, len_s + + for i in range(len_s): + if s[i] != t[i]: + if len_s == len_t: + return s[i+1:] == t[i+1:] + else: + return s[i:] == t[i+1:] + + return len_s + 1 == len_t + diff --git a/solutions/163/01.py b/solutions/163/01.py new file mode 100644 index 0000000..c151b30 --- /dev/null +++ b/solutions/163/01.py @@ -0,0 +1,16 @@ +from typing import List + +class Solution: + def findMissingRanges(self, nums: List[int], lower: int, upper: int) -> List[str]: + res = [] + prev = lower - 1 + + for num in nums + [upper + 1]: + if num - prev == 2: + res.append(str(prev + 1)) + elif num - prev > 2: + res.append(f"{prev + 1}->{num - 1}") + prev = num + + return res + diff --git a/solutions/170/01.py b/solutions/170/01.py new file mode 100644 index 0000000..30982d7 --- /dev/null +++ b/solutions/170/01.py @@ -0,0 +1,17 @@ +from collections import defaultdict + +class TwoSum: + def __init__(self): + self.num_counts = defaultdict(int) + + def add(self, number: int) -> None: + self.num_counts[number] += 1 + + def find(self, value: int) -> bool: + for num in self.num_counts: + complement = value - num + if complement in self.num_counts: + if complement != num or self.num_counts[num] > 1: + return True + return False + diff --git a/solutions/27/01.py b/solutions/27/01.py index 031f788..6883a47 100644 --- a/solutions/27/01.py +++ b/solutions/27/01.py @@ -1,14 +1,15 @@ from typing import List -def removeElement(nums: List[int], val: int) -> int: - slow = 0 - - # Iterate through the array with fast pointer - for fast in range(len(nums)): - # If current element is not equal to val, keep it - if nums[fast] != val: - nums[slow] = nums[fast] - slow += 1 - - return slow +class Solution: + def removeElement(self, nums: List[int], val: int) -> int: + slow = 0 + + # Iterate through the array with fast pointer + for fast in range(len(nums)): + # If current element is not equal to val, keep it + if nums[fast] != val: + nums[slow] = nums[fast] + slow += 1 + + return slow