Coder Social home page Coder Social logo

dmdv / solutions-to-problems Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aurimas13/solutions-to-problems

0.0 1.0 0.0 1.96 MB

Solutions to coding problems that can occur through high-tier interviews & preparation advices for them.

Python 99.29% Java 0.71%

solutions-to-problems's Introduction

Most common solutions to problems from interviews of high-tier companies.

Solutions to LeetCode & HackerRank problems.


python sql twitter stars


The repository is constantly updated when Python, Java or SQL solution to the problem found at LeetCode (mostly) or HackerRank is solved. The solutions to LeetCode problems are posted at the discussion sections in each solved problem's folder.
If the solved LeetCode problem is one of the problems asked by high-tier companies like Adobe, Airbnb, Amazon, Apple, Bloomberg, DE Shaw, Goldman Sachs, Google, LinkedIn, Meta (previously facebook), Microsoft, Netflix, Reddit, Spotify, Tesla], TikTok, Twitter or Uber then that solution for all the companies that had given it as a problem are indentified here while the total number of solved problems per comapny is given here. If the solution wasn't asked to be solved by any of the companies and the solved problem is not glued to any of the high-tier companies; it is just a random problem that was solved.

The progress of my LeetCode account regarding these solutions with additional information like blog post for some solutions giving explanations on them can be found by looking at my LeetCode profile.

The LeetCode solutions of Python are found here, HackerRank solutions of Python are found here while LeetCode solutions implementing Java are found here. Each problem folder has the description of the problem found through pressing the link in README at the respective folder or if it is provided for the particular high-tier company as described above. Some README's in the problem's forder also have the solution and explanation for the problem that redirects to the solution and the explanation to LeetCode post. By pressing on the name of the problem at the Problems and Solutions, Must Do Problems or Google Top you will be redirected to the problem description (1st column) followed by the solution (2nd column) while the 3rd and 4th columns give time and space complexities of the solution.

Currently, doing Python & a bit of Java problems of LeetCode. HackerRank problems were finished on May and from 28th of May 2022 am working on solving at least one Python problem from LeetCode daily. The solution is put at the respective LeetCode folder and added to the list of a problems and solutions where companies that provide that problem are identified.

SQL solutions of problems at HackerRank & LeetCode will come this year while they will be updated here for HackerRank and here for LeetCode.

Table of Contents

Preparation for Interviews

(Back to top)

To prepare for a MAANG interview or a MAANG-level company interview as well as land a job there I highly recommend solving as many problems below as possible and doing one or all of these:


Problems and Solutions

No. Question Solution in IDE Time Complexity Space Complexity Google Amazon Apple Meta Microsoft Adobe Airbnb Bloomberg DE Shaw Goldman Sachs LinkedIn Netflix Reddit Spotify Tesla TikTok Twitter Uber Others
1 01 Matrix 01 Matrix O(n^2) O(n^2)
2 3Sum 3Sum O(n^2) O(n)
  • []
3 3Sum Closest 3Sum Closest O(n^2) O(1)
4 4Sum 4Sum O(n^2) O(n)
5 A Number After a Double Reversal A Number After a Double Reversal O(n) O(n)
6 Accounts Merge Accounts Merge O(n^2) O(n^2)
7 Add Binary Add Binary O(n) O(n)
8 Add Digits Add Digits O(1) O(1)
9 Add Strings Add Strings O(n) O(n)
10 Add Two Numbers Add Two Numbers O(n) O(n)
11 Alien Dictionary Alien Dictionary O(n log n) O(n)
12 Basic Calculator Basic Calculator O(n^2) O(n)
13 Basic Calculator II Basic Calculator II O(n) O(n)
14 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
15 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
16 Best Time to Buy and Sell Stock III Best Time to Buy and Sell Stock III O(n) O(1)
17 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
18 Binary Search Binary Search O(log n) O(1)
19 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
20 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
21 Binary Tree Maximum Path Sum Binary Tree Maximum Path Sum O(n) O(n)
22 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
23 Brace Expansion Brace Expansion O(2^n) O(2^n)
24 Bulls and Cows Bulls and Cows O(n) O(1)
25 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
26 Check If N and Its Double Exist Check If N and Its Double Exist O(n) O(n)
27 Climbing Stairs Climbing Stairs O(n) O(n)
  • []
  • []
  • []
28 Clone Graph Clone Graph O(n) O(n)
29 Coin Change Coin Change O(n^2) O(n)
30 Combination Sum Combination Sum O(2^n) O(n)
31 Combination Sum II Combination Sum II O(n^2) O(n)
32 Combination Sum III Combination Sum III O(2^n) o(n)
33 Combination Sum IV Combination Sum IV O(n) O(n)
34 Construct Binary Tree from Preorder and Inorder Traversal Construct Binary Tree from Preorder and Inorder Traversal O(n) O(n)
35 Container With Most Water Container With Most Water O(n) O(1)
36 Contains Duplicate Contains Duplicate O(n) O(n)
37 Contains Duplicate II Contains Duplicate II O(n) O(n)
38 Contains Duplicate III Contains Duplicate III O(n log n) O(n)
39 Continuous Subarray Sum Continuous Subarray Sum O(n) O(n)
40 Count and Say Count and say O(2^n) O(n)
41 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
42 Count Number of Distinct Integers After Reverse Operations Count Number of Distinct Integers After Reverse Operations O(n log n) O(n)
43 Count Odd Numbers in an Interval Range Count Odd Numbers in an Interval Range O(1) O(1)
44 Count of Smaller Numbers After Self Count of Smaller Numbers After Self O(n log n) O(n)
45 Count Primes Count Primes O(n log n) O(n log n)
46 Count Square Submatrices with All Ones Count Square Submatrices with All Ones O(n^2) O(n^2)
47 Counting Bits Counting bits O(n log n) O(n)
48 Course Schedule Course Schedule O(n) O(n)
49 Course Schedule II Course Schedule III O(n) O(n)
50 Course Schedule III Course Schedule III O(n) O(n)
51 Custom Sort String Custom Sort String O(n) O(n)
52 Daily Temperatures Daily Temperatures O(n) O(n)
53 Encode and Decode Strings Encode and Decode Strings O(n) O(n)
54 Decode Ways Decode Ways O(n) O(n)
55 Design Add and Search Words Data Structure Design Add and Search Words Data Structure O(n) O(n)
56 Destination City Destination City O(n) O(n)
57 Determine if Two Events Have Conflict Determine if Two Events Have Conflict O(n log n) O(1)
58 Different Ways to Add Parentheses Different Ways to Add Parentheses O(2^n) O(2^n)
59 Edit Distance Edit Distance O(mn) O(mn)
60 Encode and Decode Strings Encode and Decode Strings O(n) O(n)
61 Evaluate Division Evaluate Division O(n) O(n)
62 Excel Sheet Column Title Excel Sheet Column Title O(log n) O(log n)
63 Expression Add Operators Expression Add Operators O(2^n) O(2^n)
64 Expression Add Operators Expression Add Operators O(2^n) O2^n)
65 Find All Anagrams in a String Find All Anagrams in a String O(n) O(1)
66 Find All Duplicates in an Array Find All Duplicates in an Array O(n) O(n)
67 Find First and Last Position of Element in Sotrted Array Find First and Last Position of Element in Sotrted Array O(log n) O(log n)
68 Find if Path Exists in Graph Find if Path Exists in Graph O(n) (O(n)
69 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
70 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
71 Find Pivot Index Find Pivot Index O(n) O(1)
72 Find Pivot Index Find Pivot Index O(n) O(1)
73 Find the Difference Find the Difference O(n) O(n)
74 Find the Duplicate Number Find the Duplicate Number O(n) O(1)
75 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String O(n) O(1)
76 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K Find the Minimum Number of Fibonacci Numbers Whose Sum Is K O(log n) O(log n)
77 Find Valid Matrix Given Row and Column Sums Find Valid Matrix Given Row and Column Sums O(n^2) O(n^2)
78 First Bad Version First Bad Version O(log n) O(1)
79 First Missing Positive First Missing Positive O(n) O(1)
80 First Unique Character in a String First Unique Character in a String O(n) O(n)
81 Flood Fill Flood Fill O(n^2) O(n^2)
82 Fraction to Recurring Decimal Fraction to Recurring Decimal O(n) O(n)
83 Frog Jump Frog Jumo O(n^2) O(n^2
84 Game of Life Game of Life O(n^2) O(1)
85 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
86 Graph Valid Tree Graph Valid Tree O(n) O(n)
87 Gray Code Gray Code
88 Group Anagrams Group Anagrams O(n) O(n)
89 Guess Number Higher or Lower Guess Number Higher or Lower O(log n) O(1)
90 H-Index H-Index O(n) O(1)
91 Happy Number Happy Number o(log n) O(log n)
92 High Five High Five O(n log n) O(n) <
93 House Robber House Robber O(n) O(1)
94 House Robber II House Robber II O(n) O(n)
95 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
96 Insert Interval Insert Interval O(n) O(n)
97 Integer Break Integer Break O(n^2) O(n)
98 Integer to Roman Integer to Roman O(1) O(1)
99 Intersection of Two Ararys Intersection of Two Ararys O(n^2) O(n^2)
100 Intersection of Two Ararys II Intersection of Two Ararys O(n) O(n)
101 Interval List Intersections Interval List Intersections O(n^2) O(n^2)
102 Invert Binary Tree Invert Binary Tree O(n) O(1)
103 Is Graph Bipartite? Is Graph Bipartite? O(n) O(n)
104 Island Perimeter Island Perimeter O(n^2) O(1)
105 Isomorphic Strings Isomorphic Strings O(n) O(n)
106 Jump Game Jump Game O(n^2) O(1)
107 Jump Game II Jump Gmae II O(n) O(1)
108 Jump Game III Jump Game III O(n) O(n)
109 K Closest Points to Origin K Closest Points to Origin O(n log n) O(n)
110 Kill Process Kill Process O(n) O(n)
111 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
112 Kth Smallest Element in a BST Kth Smallest Element in a BST O(n) O(n)
113 Largest Number Largest Number O(log n) O(n)
114 Largest Rectangle in Histogram Largest Rectangle in Histogram. O(n) O(n)
115 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
116 Linked List Cycle Linked List Cycle O(n) O(n)
117 Longest Common Prefix Longest Common Prefix O(n) O(1)
118 Longest Common Subsequence Longest Common Subsequence O(n) O(n)
119 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
120 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix O(n^2) O(n^2)
121 Longest Increasing Subsequence Longest Increasing Subsequence O(n^2) O(n)
122 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
123 Longest Repeating Character Replacement Longest Repeating Character Replacement O(n) O(1)
124 Longest String Chain Longest String Chain O(n log n) O(n)
125 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
126 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
127 Longest Word in Dictionary Longest Word in Dictionary O(n log n) O(n)
128 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
129 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
130 Majority Element Majority Element O(n) O(1)
131 Max Consecutive Ones III Max Consecutive Ones III O(n) O(1)
132 Max Consecutive Ones III Max Consecutive Ones III O(n) O(1)
133 Max Sum of Rectangle No Larger Than K [Max Sum of Rectangle No Larger Than K n log(n) O(n)
134 Maximal Rectangle Maximal Rectangle O(n) O(n)
135 Maximal Square Maximal Square O(n^2) O(n^2)
136 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
137 Maximum Number of Balloons here O(n) O(1)
138 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
139 Maximum Subarray Maximum Subarray O(n) O(n)
140 Maximum Subarray Maximum Subarray O(n) O(n)
141 Median of Two Sorted Arrays Median of Two Sorted Arrays O(log n) O(1)
142 Meeting Rooms Meeting Rooms O(n log n) O(n)
143 Meeting Rooms II Meeting Rooms II O(n log n) O(n)
144 Merge Intervals Merge Intervals O(n log n) O(n)
145 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
146 Merge Sorted Array Merge Sorted Array O(n) O(n)
147 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
148 Min Stack Min Stack O(n) O(n)
149 Minesweeper Minesweeper O(n^2) O(1)
150 Minimum Area Rectangle Minimum Area Rectangle O(n^2) O(n)
151 Minimum Difference Between Largest and Smallest Value in Three Moves Minimum Difference Between Largest and Smallest Value in Three Moves O(n log n) O(n)
152 Minimum Domino Rotations For Equal Row Minimum Domino Rotations For Equal Row O(n) O(1)
153 Minimum Knight Moves Minimum Knight Moves O(n) O(n)
154 Minimum Number of Operations to Convert Time Minimum Number of Operations to Convert Time O(n) O(1)
155 Minimum Obstacle Removal to Reach Corner Minimum Obstacle Removal to Reach Corner O(n^2) O(n)
156 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
157 Minimum Remove to Make Valid Parentheses Minimum Remove to Make Valid Parentheses O(n) O(n)
158 Minimum Window Substring Minimum Window Substring O(n) O(n)
159 Mirror Reflection Mirror Reflection O(n^2) O(1)
160 Missing Number Missing Number O(n) O(1)
161 Move Zeroes Move Zeroes O(n) O(1)
162 Multiply Strings Multiply Strings O(n^2) O(n)
163 N-Queens N-Queens O(n!) O(n!)
164 Network Delay Time Network Delay Time O(n log n) O(n)
165 Next Greater Element II Next Greater Element II O(n) O(n)
166 Next Permutation Next Permutation O(n) O(1)
167 Non-overlapping Intervals Non-overlapping intervals O(n) O(n)
168 Number of Boomerangs Number of Boomerangs O(n^2) (O(n))
169 Number of Closed Islands Number of Closed Islands O(n^2) O(n^2)
170 Number of Connected Components in an Undirected Graph Number of Connected Components in an Undirected Graph O(log n) O(n)
171 Number of Enclaves Number of Enclaves O(n^2) O(n^2)
172 Number of Good Ways to Split a String Number of Good Ways to Split a String O(n) O(n)
173 Number of Islands Number of Islands O(n^2) O(n^2)
174 Number of Provinces Number of Provinces O(n^2) O(n)
175 Number of 1 Bits Number of 1 bits O(log n) O(1)
176 Output Contest Matches Output Contest Matches O(log n) O(n)
177 Palindrome Number Palindrome Number O(log n) O(1)
178 Palindrome Permutation Palindrome Permutation O(n) O(n)
179 Palindrome Permutation II Palindrome Permutation II O(n) O(n)
180 Palindromic Substrings Palindromic Substrings O(n^2) O(n^2)
181 Partition Equal Subset Sum Partition Equal Subset Sum O(n^2) O(n)
182 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
183 Pascal's Triangle II Pascal's Triangle II O(n^2) O(n^2)
184 Path with Maximum Gold Path with Maximum Gold O(2^n) O(n)
185 Perfect Rectangle Perfect Rectangle O(n log n) O(n)
186 Perfect Squares Perfect Squares O(n) O(n)
187 Permutations Permutations O(n!) O(n!)
188 Permutations II Permutations II O(n!) O(n!)
189 Plus One Plus One O(n) O(n)
190 Pow(x, n) Pow(x, n) O(log n) O(log n)
191 Product of Array Except Self Product of Array Except Self O(n) O(n)
192 Queue Reconstruction by Height Queue Reconstruction by Height O(n log n) O(n)
193 Random Pick with Weight Random Pick with Weight O(log n) O(n)
194 Rectangle Area Rectangle Area O(1) O(1)
195 Regular Expression Matching Regular Expression Matching O(n^2) O(n^2)
196 Remove All Adjacent Duplicates in String II) Remove All Adjacent Duplicates in String II O(n) O(n)
197 Remove Duplicate Letters Remove Duplicate Letters O(n) O(1)
198 Remove Duplicates from Sorted Array Remove Duplicates from Sorted Array O(n) O(1)
199 Remove Element Remove Element O(n) O(1)
200 Remove Invalid Parentheses Remove Invalid Parentheses O(2^n) O(n)
201 Remove Nth Node From End of List Remove Nth Node From End of List O(n) O(1)
202 Reorder List Reorder List O(n) O(n)
203 Reverse Bits Reverse bits O(1) O(1)
204 Reverse Integer Reverse Integer O(log(n) O(1)
205 Reverse Linked List Reverse Linked List O(n) O(n)
206 Reverse Nodes in k-Group Reverse Nodes in k-Group
207 Reverse Words in a String Reverse Words in a String O(n) O(1)
208 Reverse Words in a String III Reverse Words in a String III O(n) O(n)
209 Roman to Integer Roman to Integer O(n) O(1)
210 Rotate Array Rotate Array O(n) O(1)
211 Rotate Image Rotate Image O(n^2) O(1)
212 Same Tree Same Tree O(log n) O(1)
213 Search a 2D Matrix Search a 2D Matrix O(log n) O(1)
214 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
215 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
216 Search in Rotated Sorted Array II Search in Rotated Sorted Array II O(log n) O(1)
217 Search Insert Position Search Insert Position O(log n) O(1)
218 Serialize and Deserialize BST Serialize and Deserialize BST O(n) O(n)
219 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
220 Shortest Bridge Shortest Bridge O(n^2) O(n^2)
221 Shortest Palindrome Shortest Palindrome O(n^2) O(n)
222 Shortest Word Distance Shortest Word Distance O(n) O(1)
223 Simplify Path Simplify Path O(n) O(n)
224 Single Number Single Number O(n) O(1)
225 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
226 Solve the Equation Solve the Equation O(n) O(1)
227 Sort Colors Sort Colors O(n) O(1)
228 Sort Integers by The Power Value Sort Integers by The Power Value O(n log n) O(n)
229 Sorting the Sentence Sorting the Sentence O(n log n) O(n)
230 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
231 Spiral Matrix II Spiral Matrix II O(n^2) O(n^2)
232 Split Array into Consecutive Subsequences Split Array into Consecutive Subsequences O(n) O(n)
233 Split Array Largest Sum Split Array Largest Sum O(log n O(1)
234 Sqrt(x) Sqrt(x) O(log n) O(1)
235 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
236 Strobogrammatic Number Strobogrammatic Number O(n) O(1)
237 Subarray Sum Equals K Subarray Sum Equals K O(n) O(n)
238 Subsets Subsets O(2^n) O(2^n)
239 Subtree of Another Tree Subtree of Another Tree O(n^2) O(n)
240 Sudoku Solver Sudoku Solver O(2^n) O(n^2))
241 Sum of Two Integers Sum of Two Integers O(1) O(1)
242 Surrounded Regions Surrounded Regions O(n^2) O(1)
243 Symmetric Tree Symmetric Tree O(n) O(n)
244 Target Sum Target Sum O(2^n) O(n)
245 Task Scheduler Task Scheduler O(n log n) O(n)
246 The Skyline Problem The Skyline Problem O(n log n) O(n)
247 Third Maximum Number Third Maximum Number O(n) O(1)
248 Time Needed to Inform All Employees Time Needed to Inform All Employees O(n) O(n)
249 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
250 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
251 Tree Diameter Tree Diameter O(n) O(n)
252 Two Sum Two Sum O(n) O(n)
253 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
254 Two Sum Less Than K Two Sum Less Than K O(n log n O(1)
255 Unique Binary Search Trees Unique Binary Search Trees O(n^2) O(n)
256 Unique Paths Unique Paths O(n^2) O(n^2)
257 Unique Paths II Unique Paths II O(n^2) O(n)
258 Valid Anagram Valid Anagram O(n) O(n)
259 Valid Number Valid Number O(n) O(1)
260 Valid Palindrome Valid Palindrome O(n) O(n)
261 Valid Palindrome II Valid Palindrome II O(n) O(1)
262 Valid Parentheses Valid Parentheses O(n) O(n)
263 Valid Parenthesis String Valid Parenthesis String O(n) O(1)
264 Valid Perfect Square Valid Perfect Square O(log n) O(1)
265 Valid Sudoku Valid Sudoku O(n^2) O(n)
266 Validate Binary Search Tree Validate Binary Search Tree O(n) O(n)
267 Validate Stack Sequences Validate Stack Sequences O(n) O(n)
268 Verifying an Alien Dictionary Verifying an Alien Dictionary O(n log n) O(n)
269 Walls And Gates Walls And Gates O(n^2) O(n^2)
270 Wildcard Matching Wildvard Matching O(n^2) O(n^2)
271 Word Break Word Break O(n^2) O(n)
272 Word Break II Word Break II O(n^2) O(n)
273 Word Ladder Word Ladder O(n^2) O(n^2)
274 Word Ladder II Word Ladder II O(n) O(n)
275 Word Search Word Search O(n^2) O(n)
276 Word Search II Word Search II O(n^2) O(n^2)
277 X of a Kind in a Deck of Cards X of a Kind in a Deck of Cards O(n log n) O(n)
278 ZigZag Conversion ZigZag Conversion O(n) O(n)
279 Find Kth Largest XOR Coordinate Value Find Kth Largest XOR Coordinate Value O(n^2 + n log n) O(n^2)
280 Maximum Number of Accepted Invitations Maximum Number of Accepted Invitations O(n^2) O(n)
281 Arithmetic Subarrays Arithmetic Subarrays O(n log n) O(n)
282 Find And Replace in String Find And Replace in String O(n + n log n) O(n)
283 Special Array With X Elements Greater Than or Equal X Special Array With X Elements Greater Than or Equal X O(n^2) O(1)
284 Peak Index in a Mountain Array Peak Index in a Mountain Array O(log n) O(1)
285 Determine if Two Strings Are Close Determine if Two Strings Are Close O(n) O(1)
286 Split a String Into the Max Number of Unique Substrings Split a String Into the Max Number of Unique Substrings O(2^n) O(2^n)
287 Regions Cut By Slashes Regions Cut By Slashes O(n^2) O(n^2)
288 Increment Submatrices by One Increment Submatrices by One O(n^2) O(n^2)
289 Count Numbers with Unique Digits Count Numbers with Unique Digits O(n) O(1)
290 Merge In Between Linked Lists Merge In Between Linked Lists O(n) O(1)
291 Painting a Grid With Three Different Colors Painting a Grid With Three Different Colors O(R^2 * n) O(R^2 + R * n)
292 Maximum Gap Maximum Gap O(n) O(n)
293 Pizza with 3n Slices Pizza with 3n Slices O(n^2) O(n^2)
294 Top K Frequent Elements Top K Frequent Elements O(n + m log m) O(n)
295 Minimum Time Difference Minimum Time Difference O(n log n) O(n)
296 Process Tasks Using Serverse Process Tasks Using Servers O(n log m) O(m)
297 Arithmetic Slices Arithmetic Slices O(n) O(n)

Total Number

Total number of LeetCode solutions per comapny are shown below:*

Company Name Total Solutions
Google 194
Amazon 172
Apple 166
Meta 146
Adobe 133
Microsoft 130
Bloomberg 130
Uber 107
Goldman Sachs 105
TikTok 57
LinkedIn 45
Tesla 35
Airbnb 34
Twitter 32
Spotify 21
DE Shaw 17
Reddit 15
Netflix 7
Others ALL


* To be updaded as going through the list of Problems and Solutions section and updating weekly after the solution is added and visualising which companies have that problem. Currently details of the problems that belong to specific company are commented under the company name by inspecting README


Must Do Problems

(Back to top)

No. Question Solution Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
3 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
4 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
5 Reverse Bits Reverse bits O(1) O(1)
6 Number of 1 Bits Number of 1 bits O(log n) O(1)
7 Contains Duplicate Contains Duplicate O(n) O(n)
8 Meeting Rooms Meeting Rooms O(n log n) O(1)
9 Missing Number Missing Number O(n) O(1)
10 Counting Bits Counting bits O(n log n) O(n)
11 Merge Intervals Merge Intervals O(n log n) O(n)
12 Insert Interval Insert Interval O(n) O(n)
13 Valid Palindrome Valid Palindrome O(n) O(n)
14 Valid Parentheses Valid Parentheses O(n) O(n)
15 Climbing Stairs Climbing Stairs O(n) O(n)
16 Same Tree Same Tree O(log n) O(1)
17 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
18 Linked List Cycle Linked List Cycle O(n) O(n)
19 Reverse Linked List Reverse Linked List O(n) O(n)
20 Invert Binary Tree Invert Binary Tree O(n) O(1)
21 Valid Anagram Valid Anagram O(n) O(n)
22 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
23 Subtree of Another Tree Subtree of Another Tree O(n^2) O(n)
24 Combination Sum Combination Sum O(2^n) O(n)
25 Container With Most Water Container With Most Water O(n) O(1)
26 3Sum 3Sum O(n^2) O(n)
27 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
28 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
29 Rotate Image Rotate Image O(n^2) O(1)
30 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
31 Word Search Word Search O(n^2) O(n)
32 Word Break Word Break O(n^2) O(n)
33 Number of Islands Number of Islands O(n^2) O(n^2)
34 Coin Change Coin Change O(n^2) O(n)
35 Course Schedule Course Schedule O(n) O(n)
36 Decode Ways Decode Ways O(n) O(n)
37 House Robber House Robber O(n) O(1)
38 Group Anagrams Group Anagrams O(n) O(n)
39 Find the Duplicate Number Find the Duplicate Number O(n) O(n)
40 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
41 Sum of Two Integers Sum of Two Integers O(1) O(1)
42 Maximum Subarray Maximum Subarray O(n) O(n)
43 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
44 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
45 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
46 Palindromic Substrings Palindromic Substrings O(n^2) O(n^2)
47 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
48 Product of Array Except Self Product of Array Except Self O(n) O(n)
49 Graph Valid Tree Graph Valid Tree O(n) O(n)
50 Unique Paths Unique Paths O(n^2) O(n^2)
51 Minimum Window Substring Minimum Window Substring O(n) O(n)
52 Remove Nth Node From End of List Remove Nth Node From End of List O(n) O(1)
53 Jump Game Jump Game O(n^2) O(1)
54 Reorder List Reorder List O(n) O(n)
55 Validate Binary Search Tree Validate Binary Search Tree O(n) O(n)
56 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
57 Construct Binary Tree from Preorder and Inorder Traversal Construct Binary Tree from Preorder and Inorder Traversal O(n) O(n)
58 Clone Graph Clone Graph O(n) O(n)
59 Kth Smallest Element in a BST Kth Smallest Element in a BST O(n) O(n)
60 Encode and Decode Strings Encode and Decode Strings O(n) O(n)
61 Design Add and Search Words Data Structure Design Add and Search Words Data Structure O(n) O(n)
62 Serialize and Deserialize BST Serialize and Deserialize BST O(n) O(n)
63 Longest Common Subsequence Longest Common Subsequence O(n) O(n)
64 Longest Increasing Subsequence Longest Increasing Subsequence O(n^2) O(n)
65 Pacific Atlantic Water Flow Pacific Atlantic Water Flow O(n^2) O(n^2)
66 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
67 Longest Repeating Character Replacement Longest Repeating Character Replacement O(n) O(1)
68 Non-overlapping Intervals Non-overlapping intervals O(n) O(n)
69 Number of Connected Components in an Undirected Graph Number of Connected Components in an Undirected Graph O(log n) O(n)
70 Alien Dictionary Alien Dictionary O(n log n) O(n)
71 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
72 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
73 House Robber II House Robber II O(n) O(n)
74 Meeting Rooms II Meeting Rooms II O(n log n) O(n)
75 Word Search II Word Search II O(n^2) O(n^2)
76 Binary Tree Maximum Path Sum Binary Tree Maximum Path Sum O(n) O(n)
77 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)

Google Top

(Back to top)

No. Question Solutiion Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Maximal Rectangle Maximal Rectangle O(n) O(n)
3 Insert Interval Insert Interval O(n) O(n)
4 X of a Kind in a Deck of Cards X of a Kind in a Deck of Cards O(n log n) O(n)
5 Maximal Square Maximal Square O(n^2) O(n^2)
6 Bulls and Cows Bulls and Cows O(n) O(1)
7 Evaluate Division Evaluate Division O(n^2) O(n^2)
8 Decode String Decode String O(n) O(n)
9 Longest String Chain Longest String Chain O(n log n) O(n)
10 Validate Stack Sequences Validate Stack Sequences O(n) O(n)
11 Minimum Window Substring Minimum Window Substring O(n) O(n)
12 The Skyline Problem The Skyline Problem O(n log n) O(n)
13 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix O(n^2) O(n^2)
14 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
15 Count of Smaller Numbers After Self Count of Smaller Numbers After Self O(n log n) O(n)
16 Network Delay Time Network Delay Time O(n log n) O(n)
17 Subarray Sum Equals K Subarray Sum Equals K O(n) O(n)
18 Max Sum of Rectangle No Larger Than K Max Sum of Rectangle No Larger Than K n log(n) O(n)
19 Split Array into Consecutive Subsequences Split Array into Consecutive Subsequences O(n) O(n)
20 Split Array Largest Sum Split Array Largest Sum O(log n O(1)
21 Minimum Domino Rotations For Equal Row Minimum Domino Rotations For Equal Row O(n) O(1)
22 Random Pick with Weight Random Pick with Weight O(log n) O(n)

License

LICENSE

solutions-to-problems's People

Contributors

aurimas13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.