Skip to content

Commit 0e58922

Browse files
committed
Added neetcode 150 and 250 problems
1 parent 2abfa78 commit 0e58922

14 files changed

Lines changed: 347 additions & 0 deletions

Binary Search/Binary Search.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1. Minimize the Maximum or Maximize the minimum.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/description/
2+
3+
'''
4+
You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.
5+
6+
You need to distribute all products to the retail stores following these rules:
7+
8+
A store can only be given at most one product type but can be given any amount of it.
9+
After distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.
10+
Return the minimum possible x.
11+
12+
13+
14+
Example 1:
15+
16+
Input: n = 6, quantities = [11,6]
17+
Output: 3
18+
Explanation: One optimal way is:
19+
- The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3
20+
- The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3
21+
The maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.
22+
Example 2:
23+
24+
Input: n = 7, quantities = [15,10,10]
25+
Output: 5
26+
Explanation: One optimal way is:
27+
- The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5
28+
- The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5
29+
- The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5
30+
The maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.
31+
Example 3:
32+
33+
Input: n = 1, quantities = [100000]
34+
Output: 100000
35+
Explanation: The only optimal way is:
36+
- The 100000 products of type 0 are distributed to the only store.
37+
The maximum number of products given to any store is max(100000) = 100000.
38+
39+
40+
Constraints:
41+
42+
m == quantities.length
43+
1 <= m <= n <= 105
44+
1 <= quantities[i] <= 105
45+
'''
46+
47+
48+
49+

Binary Search/Sweep Coverage/Painter's Partition.py

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Neetcode 150.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# NeetCode 150 Repo Mapping
2+
3+
This file maps the standard NeetCode 150 problems to the closest implementation currently present in this repo.
4+
5+
## Arrays & Hashing
6+
- `217. Contains Duplicate` — Not found yet
7+
- `242. Valid Anagram` — Not found yet
8+
- [1. Two Sum](<2 Pointers/arrays/1. Two Sum.py>)
9+
- [49. Group Anagrams](<Strings/49. Group Anagrams.py>)
10+
- [347. Top K Frequent Elements](<Heap/347. Top K Frequent Elements.py>)
11+
- [238. Product of Array Except Self](<Array/238. Product of Array Except Self.py>)
12+
- [271. Encode and Decode Strings](<Strings/271. Encode and Decode Strings.py>)
13+
- [36. Valid Sudoku](<Matrix/36. Valid Sudoku.py>)
14+
- [128. Longest Consecutive Sequence](<Array/128. Longest Consecutive Sequence.py>)
15+
16+
## Two Pointers
17+
- [125. Valid Palindrome](<Strings/125. Valid Palindrome.py>)
18+
- [167. Two Sum II - Input Array Is Sorted](<2 Pointers/arrays/167. Two Sum II - Input Array Is Sorted.py>)
19+
- [15. 3Sum](<2 Pointers/arrays/15. 3Sum.py>)
20+
- [11. Container With Most Water](<2 Pointers/arrays/11. Container With Most Water.py>)
21+
- [42. Trapping Rain Water](<2 Pointers/arrays/42. Trapping Rain Water.py>)
22+
23+
## Sliding Window
24+
- [121. Best Time to Buy and Sell Stock](<Greedy/121. Best Time to Buy and Sell Stock.py>)
25+
- [3. Longest Substring Without Repeating Characters](<Sliding Window/dynamic/3. Longest Substring Without Repeating Characters.py>)
26+
- [424. Longest Repeating Character Replacement](<Sliding Window/dynamic/424. Longest Repeating Character Replacement.py>)
27+
- [567. Permutation in String](<Sliding Window/fixed/567. Permutation in String.py>)
28+
- [76. Minimum Window Substring](<Sliding Window/dynamic/76. Minimum Window Substring.py>)
29+
- [239. Sliding Window Maximum](<Queue/239. Sliding Window Maximum.py>)
30+
31+
## Stack
32+
- [20. Valid Parentheses](<Stack/20. Valid Parentheses.py>)
33+
- [155. Min Stack](<Stack/Advance Stack/Min Stack.py>)
34+
- [150. Evaluate Reverse Polish Notation](<Stack/150. Evaluate Reverse Polish Notation.py>)
35+
- [22. Generate Parentheses](<Recursion & Backtracking/recursion/22. Generate Parentheses.py>)
36+
- [739. Daily Temperatures](<Stack/Monotonic_stack/739. Daily Temperatures.py>)
37+
- [853. Car Fleet](<Stack/853. Car Fleet.py>)
38+
- [84. Largest Rectangle in Histogram](<Stack/Advance Stack/84. Largest Rectangle in Histogram.py>)
39+
40+
## Binary Search
41+
- `704. Binary Search` — Not found yet
42+
- [74. Search a 2D Matrix](<Binary Search/74. Search a 2D Matrix.py>)
43+
- [875. Koko Eating Bananas](<Binary Search/875. Koko Eating Bananas.py>)
44+
- [33. Search in Rotated Sorted Array](<Binary Search/33. Search in Rotated Sorted Array.py>)
45+
- [153. Find Minimum in Rotated Sorted Array](<Binary Search/153. Find Minimum in Rotated Sorted Array.py>)
46+
- [981. Time Based Key-Value Store](<System Design/981. Time Based Key-Value Store.py>)
47+
- [4. Median of Two Sorted Arrays](<Binary Search/4. Median of Two Sorted Arrays.py>)
48+
49+
## Linked List
50+
- [206. Reverse Linked List](<LinkedList/206. Reverse Linked List.py>)
51+
- [21. Merge Two Sorted Lists](<LinkedList/21. Merge Two Sorted Lists.py>)
52+
- [143. Reorder List](<LinkedList/143. Reorder List.py>)
53+
- [19. Remove Nth Node From End of List](<LinkedList/19. Remove Nth Node From End of List.py>)
54+
- [138. Copy List with Random Pointer](<LinkedList/138. Copy List with Random Pointer.py>)
55+
- [2. Add Two Numbers](<LinkedList/2. Add Two Numbers.py>)
56+
- [141. Linked List Cycle](<LinkedList/141. Linked List Cycle.py>)
57+
- [287. Find the Duplicate Number](<LinkedList/287. Find the Duplicate Number.py>)
58+
- [146. LRU Cache](<System Design/146. LRU Cache.py>)
59+
- [23. Merge k Sorted Lists](<LinkedList/23. Merge k Sorted Lists.py>)
60+
- [25. Reverse Nodes in k-Group](<LinkedList/25. Reverse Nodes in k-Group.py>)
61+
62+
## Trees
63+
- [226. Invert Binary Tree](<Binary Tree/226. Invert Binary Tree.py>)
64+
- [104. Maximum Depth of Binary Tree](<Binary Tree/104. Maximum Depth of Binary Tree.py>)
65+
- [543. Diameter of Binary Tree](<Binary Tree/543. Diameter of Binary Tree.py>)
66+
- [110. Balanced Binary Tree](<Binary Tree/110. Balanced Binary Tree.py>)
67+
- [100. Same Tree](<Binary Tree/100. Same Tree.py>)
68+
- [572. Subtree of Another Tree](<Binary Tree/572. Subtree of Another Tree.py>)
69+
- [235. Lowest Common Ancestor of a Binary Search Tree](<Binary Search Tree/235. Lowest Common Ancestor of a Binary Search Tree.py>)
70+
- [236. Lowest Common Ancestor of a Binary Tree](<Binary Tree/236. Lowest Common Ancestor of a Binary Tree.py>)
71+
- [102. Binary Tree Level Order Traversal](<Binary Tree/102. Binary Tree Level Order Traversal.py>)
72+
- [199. Binary Tree Right Side View](<Binary Tree/199. Binary Tree Right Side View.py>)
73+
- [1448. Count Good Nodes in Binary Tree](<Binary Tree/1448. Count Good Nodes in Binary Tree.py>)
74+
- [98. Validate Binary Search Tree](<Binary Search Tree/98. Validate Binary Search Tree.py>)
75+
- [230. Kth Smallest Element in a BST](<Binary Search Tree/230. Kth Smallest Element in a BST.py>)
76+
- [105. Construct Binary Tree from Preorder and Inorder Traversal](<Binary Tree/105. Construct Binary Tree from Preorder and Inorder Traversal.py>)
77+
- [124. Binary Tree Maximum Path Sum](<Binary Tree/124. Binary Tree Maximum Path Sum.py>)
78+
- [297. Serialize and Deserialize Binary Tree](<Binary Tree/297. Serialize and Deserialize Binary Tree.py>)
79+
80+
## Heap / Priority Queue
81+
- [703. Kth Largest Element in a Stream](<Heap/703. Kth Largest Element in a Stream.py>)
82+
- [1046. Last Stone Weight](<Heap/1046. Last Stone Weight.py>)
83+
- [973. K Closest Points to Origin](<Heap/973. K Closest Points to Origin.py>)
84+
- [215. Kth Largest Element in an Array](<Heap/215. Kth Largest Element in an Array.py>)
85+
- [621. Task Scheduler](<Heap/621. Task Scheduler.py>)
86+
- [355. Design Twitter](<System Design/355. Design Twitter.py>)
87+
- [295. Find Median from Data Stream](<Heap/295. Find Median from Data Stream.py>)
88+
- [767. Reorganize String](<Heap/767. Reorganize String.py>)
89+
90+
## Backtracking
91+
- [78. Subsets](<Recursion & Backtracking/subset/subsets.py>)
92+
- [39. Combination Sum](<Recursion & Backtracking/combinations/39. Combination Sum.py>)
93+
- [46. Permutations](<Recursion & Backtracking/permutations/46. Permutations.py>)
94+
- `90. Subsets II` — Not found yet
95+
- [40. Combination Sum II](<Recursion & Backtracking/combinations/40. Combination Sum II.py>)
96+
- [79. Word Search](<Recursion & Backtracking/path on grid/79. Word Search.py>)
97+
- [131. Palindrome Partitioning](<Recursion & Backtracking/palindrome/131. Palindrome Partitioning.py>)
98+
- [17. Letter Combinations of a Phone Number](<Recursion & Backtracking/combinations/17. Letter Combinations of a Phone Number.py>)
99+
- [51. N-Queens](<Recursion & Backtracking/recursion/51. N-Queens.py>)
100+
101+
## Tries
102+
- [208. Implement Trie (Prefix Tree)](<Tries/Strings/208. Implement Trie (Prefix Tree).py>)
103+
- [211. Design Add and Search Words Data Structure](<Tries/Strings/211. Design Add and Search Words Data Structure.py>)
104+
- [212. Word Search II](<Tries/Strings/212. Word Search II.py>)
105+
106+
## Intervals
107+
- [57. Insert Interval](<Intervals/57. Insert Interval.py>)
108+
- [56. Merge Intervals](<Intervals/56. Merge Intervals.py>)
109+
- [435. Non-overlapping Intervals](<Intervals/435. Non-overlapping Intervals.py>)
110+
- [252. Meeting Rooms](<Intervals/252. Meeting Rooms.py>)
111+
- [253. Meeting Rooms II](<Intervals/253. Meeting Rooms II.py>)
112+
- [1851. Minimum Interval to Include Each Query](<Heap/1851. Minimum Interval to Include Each Query.py>)
113+
114+
## Greedy
115+
- [53. Maximum Subarray](<Greedy/53. Maximum Subarray.py>)
116+
- [55. Jump Game](<Greedy/Jump Game.py>)
117+
- `45. Jump Game II` — Not found yet
118+
- [134. Gas Station](<Greedy/134. Gas Station.py>)
119+
- [846. Hand of Straights](<Greedy/846. Hand of Straights.py>)
120+
- [1899. Merge Triplets to Form Target Triplet](<Greedy/1899. Merge Triplets to Form Target Triplet.py>)
121+
- [763. Partition Labels](<Greedy/763. Partition Labels.py>)
122+
- [678. Valid Parenthesis String](<Greedy/678. Valid Parenthesis String.py>)
123+
124+
## Advanced Graphs
125+
- [332. Reconstruct Itinerary](<Graph/DFS & BFS/332. Reconstruct Itinerary.py>)
126+
- [1584. Min Cost to Connect All Points](<Graph/Minimum Spanning Tree/1584. Min Cost to Connect All Points.py>)
127+
- [778. Swim in Rising Water](<Graph/Dijkastra Algo/778. Swim in Rising Water.py>)
128+
- [269. Alien Dictionary](<Graph/Topological Sort/269. Alien Dictionary.py>)
129+
- [787. Cheapest Flights Within K Stops](<Graph/Bellman Ford/787. Cheapest Flights Within K Stops.py>)
130+
- [743. Network Delay Time](<Graph/Dijkastra Algo/743. Network Delay Time.py>)
131+
132+
## Graphs
133+
- [200. Number of Islands](<Graph/DFS & BFS/200. Number of Islands.py>)
134+
- `695. Max Area of Island` — Not found yet
135+
- [133. Clone Graph](<Graph/DFS & BFS/133. Clone Graph.py>)
136+
- [286. Walls and Gates](<Graph/DFS & BFS/286. Walls and Gates.py>)
137+
- [994. Rotting Oranges](<Graph/DFS & BFS/994. Rotting Oranges.py>)
138+
- [417. Pacific Atlantic Water Flow](<Graph/DFS & BFS/417. Pacific Atlantic Water Flow.py>)
139+
- [130. Surrounded Regions](<Graph/DFS & BFS/130. Surrounded Regions.py>)
140+
- [207. Course Schedule](<Graph/Topological Sort/207. Course Schedule.py>)
141+
- [210. Course Schedule II](<Graph/Topological Sort/210. Course Schedule II.py>)
142+
- [261. Graph Valid Tree](<Graph/DFS & BFS/178 · Graph Valid Tree.py>) (equivalent problem)
143+
- [684. Redundant Connection](<Graph/Disjoint Set Union/684. Redundant Connection.py>)
144+
145+
## 1-D Dynamic Programming
146+
- [70. Climbing Stairs](<Dynamic Programming/Count Distinct Ways/70. Climbing Stairs.py>)
147+
- [746. Min Cost Climbing Stairs](<Dynamic Programming/Count Distinct Ways/746. Min Cost Climbing Stairs.py>)
148+
- [198. House Robber](<Dynamic Programming/Linear DP/198. House Robber.py>)
149+
- [213. House Robber II](<Dynamic Programming/Linear DP/213. House Robber II.py>)
150+
- [5. Longest Palindromic Substring](<2 Pointers/strings/5. Longest Palindromic Substring.py>)
151+
- [647. Palindromic Substrings](<Dynamic Programming/Palindromic Subsequence/647. Palindromic Substrings.py>)
152+
- [91. Decode Ways](<Dynamic Programming/Count Distinct Ways/91. Decode Ways.py>)
153+
- [322. Coin Change](<Dynamic Programming/Knapsack/322. Coin Change.py>)
154+
- [152. Maximum Product Subarray](<Dynamic Programming/Kadane/152. Maximum Product Subarray.py>)
155+
- [139. Word Break](<Dynamic Programming/String Partition/139. Word Break.py>)
156+
- [300. Longest Increasing Subsequence](<Dynamic Programming/Linear DP/300. Longest Increasing Subsequence.py>)
157+
- [416. Partition Equal Subset Sum](<Dynamic Programming/Subset Sum/416. Partition Equal Subset Sum.py>)
158+
159+
## 2-D Dynamic Programming
160+
- [62. Unique Paths](<Dynamic Programming/Grid/62. Unique Paths.py>)
161+
- [1143. Longest Common Subsequence](<Dynamic Programming/String Partition/1143. Longest Common Subsequence.py>)
162+
- [309. Best Time to Buy and Sell Stock with Cooldown](<Dynamic Programming/State Machine/309. Best Time to Buy and Sell Stock with Cooldown.py>)
163+
- [518. Coin Change II](<Dynamic Programming/Knapsack/518. Coin Change II.py>)
164+
- [494. Target Sum](<Dynamic Programming/Subset Sum/494. Target Sum.py>)
165+
- [97. Interleaving String](<Dynamic Programming/String Partition/97. Interleaving String.py>)
166+
- [329. Longest Increasing Path in a Matrix](<Dynamic Programming/Grid/329. Longest Increasing Path in a Matrix.py>)
167+
- [115. Distinct Subsequences](<Dynamic Programming/String Partition/115. Distinct Subsequences.py>)
168+
- [72. Edit Distance](<Dynamic Programming/String Partition/72. Edit Distance.py>)
169+
- [312. Burst Balloons](<Dynamic Programming/State Machine/312. Burst Balloons.py>)
170+
- [10. Regular Expression Matching](<Dynamic Programming/String Partition/10. Regular Expression Matching.py>)
171+
172+
## Bit Manipulation
173+
- [136. Single Number](<Bit Manipulation/Single Number.py>)
174+
- [191. Number of 1 Bits](<Bit Manipulation/191. Number of 1 Bits.py>)
175+
- [338. Counting Bits](<Bit Manipulation/338. Counting Bits.py>)
176+
- [190. Reverse Bits](<Bit Manipulation/190. Reverse Bits.py>)
177+
- [268. Missing Number](<Bit Manipulation/268. Missing Number.py>)
178+
- [371. Sum of Two Integers](<Bit Manipulation/371. Sum of Two Integers.py>)
179+
- [7. Reverse Integer](<Bit Manipulation/7. Reverse Integer.py>)
180+
181+
## Math & Geometry
182+
- [48. Rotate Image](<Matrix/48. Rotate Image.py>)
183+
- [54. Spiral Matrix](<Matrix/54. Spiral Matrix.py>)
184+
- [73. Set Matrix Zeroes](<Matrix/73. Set Matrix Zeroes.py>)
185+
- [202. Happy Number](<Mathematics/202. Happy Number.py>)
186+
- [66. Plus One](<Mathematics/66. Plus One.py>)
187+
- [50. Pow(x, n)](<Mathematics/Modular Arithmetic/50. Pow(x, n).py>)
188+
- [43. Multiply Strings](<Mathematics/43. Multiply Strings.py>)
189+
- [2013. Detect Squares](<Mathematics/2013. Detect Squares.py>)

0 commit comments

Comments
 (0)