Skip to content

Solutions to coding problems that can occur through interviews & preparation advices

Notifications You must be signed in to change notification settings

analuisa-n/Solutions-To-Problems

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

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 or SQL solution to the problem found at LeetCode (primarily) or HackerRank is solved. The solutions to LeetCode problems are posted at the discussion sections in each solved problem 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 with Google Top, LinkedIn, Meta, Microsoft, Netflix, Reddit, Spotify, Tesla, TikTok, Twitter or Uber then that solution of specific company is added to the company's section as my GitHub solution found through contents. Otherwise it is added here as the solved problem is not glued to any of the high-tier companies' section; it is just a random problem that was solved.

The progress of my LeetCode account regarding these solutions with additional information on them can be found by looking at my LeetCode profile.

The Leetcode solutions of Python are found here while HackerRank solutions of Python 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 found through contents. By pressing on that company you will be redirected to the problem description (1st column) followed by the solution implemented in PyCharm (2nd column).

Currently, doing Python 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 high-tier company where it is a common interview question to be asked to solve. The problems for a particular company is seen through contents list.

SQL solutions of problems at HackerRank & LeetCode will come in Fall 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:


Must Do Problems

(Back to top)

No. Questions Solution in PyCharm 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)

Adobe

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Mirror Reflection Mirror Reflection O(n^2) O(1)
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 Number of 1 Bits Number of 1 bits O(log n) O(1)
6 Contains Duplicate Contains Duplicate O(n) O(n)
7 Missing Number Missing Number O(n) O(1)
8 Counting Bits Counting bits O(n log n) O(n)
9 Merge Intervals Merge Intervals O(n log n) O(n)
10 Valid Palindrome Valid Palindrome O(n) O(n)
11 Valid Parentheses Valid Parentheses O(n) O(n)
12 Climbing Stairs Climbing Stairs O(n) O(n)
13 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
14 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
15 Container With Most Water Container With Most Water O(n) O(1)
16 3Sum 3Sum O(n^2) O(n)
17 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
18 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
19 Rotate Image Rotate Image O(n^2) O(1)
20 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
21 Word Break Word Break O(n^2) O(n)
22 Number of Islands Number of Islands O(n^2) O(n^2)
23 Coin Change Coin Change O(n^2) O(n)
24 Maximum Subarray Maximum Subarray O(n) O(n)
25 Product of Array Except Self Product of Array Except Self O(n) O(n)
26 Minimum Window Substring Minimum Window Substring O(n) O(n)
27 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
28 Valid Anagram Valid Anagram O(n) O(n)
29 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
30 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
31 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
32 Maximal Square Maximal Square O(n^2) O(n^2)
33 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
34 Word Search Word Search O(n^2) O(n)
35 Word Search II Word Search II O(n^2) O(n^2)
36 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
37 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
38 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
39 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
40 Min Stack Min Stack O(n) O(n)
41 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
42 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
43 Linked List Cycle Linked List Cycle O(n) O(n)
44 Clone Graph Clone Graph O(n) O(n)
45 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
46 Word Ladder Word Ladder O(n^2) O(n^2)
47 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
48 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
49 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
50 Reverse Linked List Reverse Linked List O(n) O(n)
51 Count Primes Count Primes O(n log n) O(n log n)
52 House Robber House Robber O(n) O(1)
53 Decode Ways Decode Ways O(n) O(n)
54 Merge Sorted Array Merge Sorted Array O(n) O(n)
55 Subsets Subsets O(2^n) O(2^n)
56 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
57 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
58 Unique Paths Unique Paths O(n^2) O(n^2)
59 Jump Game Jump Game O(n^2) O(1)
60 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
61 N-Queens N-Queens O(n!) O(n!)
62 Pow(x, n) Pow(x, n) O(log n) O(log n)
63 Group Anagrams Group Anagrams O(n) O(n)
64 Permutations Permutations O(n!) O(n!)
65 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
66 Combination Sum Combination Sum O(2^n) O(n)
67 Count and Say Count and say O(2^n) O(n)
68 Valid Sudoku Valid Sudoku O(n^2) O(n)
69 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
70 Next Permutation Next Permutation O(n) O(1)
71 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
72 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
73 3Sum Closest 3Sum Closest O(n^2) O(1)
74 Roman to Integer Roman to Integer O(n) O(1)
75 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
76 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
77 Add Two Numbers Add Two Numbers O(n) O(n)
78 Two Sum Two Sum O(n) O(n)
79 Daily Temperatures Daily Temperatures
80 Basic Calculator Basic Calculator
81 Basic Calculator II Basic Calculator II
82 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
83 Game of Life Game of Life
84 Regular Expression Matching Regular Expression Matching
85 Wildcard Matching Wildvard Matching
86 Single Number Single Number
87 Happy Number Happy Number
88 Contains Duplicate II Contains Duplicate II
89 Contains Duplicate III Contains Duplicate III
90 Add Strings Add Strings
99 Reverse Nodes in k-Group Reverse Nodes in k-Group
100 Sudoku Solver Sudoku Solver
101 Multiply Strings Multiply Strings
102 Sort Colors Sort Colors
103 Course Schedule Course Schedule O(n) O(n)
104 Move Zeroes Move Zeroes
105 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
106 Subarray Sum Equals K Subarray Sum Equals K
107 Maximum Number of Balloons here
108 Jump Game II Jump Gmae II.
109 Find All Duplicates in an Array Find All Duplicates in an Array
110 Reverse Words in a String Reverse Words in a String
111 Word Pattern Word Pattern
112 Search a 2D Matrix Search a 2D Matrix
113 Longest Word in Dictionary Longest Word in Dictionary
114 Largest Number Largest Number
115 Invert Binary Tree Invert Binary Tree O(n) O(1)
116 Guess Number Higher or Lower Guess Number Higher or Lower
117 Island Perimeter Island Perimeter
118 Flood fill Flood fill
119 Find if Path Exists in Graph Find if Path Exists in Graph
120 Symmetric Tree Symmetric Tree O(n) O(n)
121 Surrounded Regions Surrounded Regions O(n^2) O(1)
122 4Sum 4Sum O(n^2) O(n)
123 Binary Search Binary Search O(log n) O(1)

Airbnb

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Combination Sum Combination Sum O(2^n) O(n)
3 Combination Sum II Combination Sum II
4 Contains Duplicate Contains Duplicate O(n) O(n)
5 Contains Duplicate II Contains Duplicate II
6 Contains Duplicate III Contains Duplicate III
7 Minimum Window Substring Minimum Window Substring O(n) O(n)
8 Maximal Square Maximal Square O(n^2) O(n^2)
9 Word Search II Word Search II O(n^2) O(n^2)
10 Fraction to Recurring Decimal Fraction to Recurring Decimal
11 House Robber House Robber O(n) O(1)
12 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
13 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
14 Add Two Numbers Add Two Numbers O(n) O(n)
15 Median of Two Sorted Arrays Median of Two Sorted Arrays
16 Regular Expression Matching Regular Expression Matching
17 Valid Parentheses Valid Parentheses O(n) O(n)
18 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
19 Wildcard Matching Wildvard Matching
20 Single Number Single Number
21 Fraction to Recurring Decimal Fraction to Recurring Decimal
22 Reverse Bits Reverse bits O(1) O(1)
23 Happy Number Happy Number
24 Basic Calculator II Basic Calculator II
25 Alien Dictionary Alien Dictionary O(n log n) O(n)
26 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
27 Coin Change Coin Change O(n^2) O(n)
28 Add Strings Add Strings
29 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)

Amazon

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Add Two Numbers Add Two Numbers O(n) O(n)
3 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
4 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
5 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
6 Permutations Permutations O(n!) O(n!)
7 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
8 Merge Intervals Merge Intervals O(n log n) O(n)
9 Pascal's Triangle II Pascal's Triangle II O(n^2) O(n^2)
10 Valid Parentheses Valid Parentheses O(n) O(n)
11 Same Tree Same Tree O(log n) O(1)
12 Linked List Cycle Linked List Cycle O(n) O(n)
13 Reverse Linked List Reverse Linked List O(n) O(n)
14 Valid Anagram Valid Anagram O(n) O(n)
15 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
16 Subtree of Another Tree Subtree of Another Tree O(n^2) O(n)
17 3Sum 3Sum O(n^2) O(n)
18 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
19 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
20 Rotate Image Rotate Image O(n^2) O(1)
21 Word Break Word Break O(n^2) O(n)
22 Number of Islands Number of Islands O(n^2) O(n^2)
23 Group Anagrams Group Anagrams O(n) O(n)
24 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
25 Product of Array Except Self Product of Array Except Self O(n) O(n)
26 Minimum Window Substring Minimum Window Substring O(n) O(n)
27 Validate Binary Search Tree Validate Binary Search Tree O(n) O(n)
28 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
29 Serialize and Deserialize BST Serialize and Deserialize BST O(n) O(n)
30 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
31 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
32 Word Search II Word Search II O(n^2) O(n^2)
33 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
34 Subarray Sum Equals K Subarray Sum Equals K
35 ZigZag Conversion ZigZag Conversion
36 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
37 Find All Anagrams in a String Find All Anagrams in a String
38 Basic Calculator Basic Calculator
39 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
40 Sort Colors Sort Colors
41 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
42 Word Ladder Word Ladder O(n^2) O(n^2)
43 Edit Distance Edit Distance
44 Rotate Array Rotate Array
45 Count Primes Count Primes O(n log n) O(n log n)
46 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
47 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
48 K Closest Points to Origin K Closest Points to Origin
49 Subsets Subsets O(2^n) O(2^n)
50 Happy Number Happy Number
51 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
52 Min Stack Min Stack O(n) O(n)
53 Spiral Matrix II Spiral Matrix II
54 Unique Paths II Unique Paths II
55 Accounts Merge Accounts Merge
56 Gray Code Gray Code
57 Word Ladder II Word Ladder II
58 Third Maximum Number Third Maximum Number
59 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
60 Median of Two Sorted Arrays Median of Two Sorted Arrays
61 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
62 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
63 Minesweeper Minesweeper
64 First Unique Character in a String First Unique Character in a String
65 Find Pivot Index Find Pivot Index
66 Solve the Equation Solve the Equation
67 Combination Sum Combination Sum O(2^n) O(n)
68 Combination Sum II Combination Sum II
69 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
70 Container With Most Water Container With Most Water O(n) O(1)
71 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
72 Word Search Word Search O(n^2) O(n)
73 Coin Change Coin Change O(n^2) O(n)
74 Maximum Subarray Maximum Subarray O(n) O(n)
75 Remove All Adjacent Duplicates in String II) Remove All Adjacent Duplicates in String II
76 High Five High Five
77 Shortest Word Distance Shortest Word Distance
78 Maximal Square Maximal Square O(n^2) O(n^2)
79 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
80 The Skyline Problem The Skyline Problem O(n log n) O(n)
81 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
82 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
83 Fraction to Recurring Decimal Fraction to Recurring Decimal
84 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
85 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
86 Clone Graph Clone Graph O(n) O(n)
87 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
88 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
89 Valid Palindrome Valid Palindrome O(n) O(n)
90 House Robber House Robber O(n) O(1)
91 Decode Ways Decode Ways O(n) O(n)
92 Merge Sorted Array Merge Sorted Array O(n) O(n)
93 Climbing Stairs Climbing Stairs O(n) O(n)
94 Unique Paths Unique Paths O(n^2) O(n^2)
95 Insert Interval Insert Interval O(n) O(n)
96 Jump Game Jump Game O(n^2) O(1)
97 N-Queens N-Queens O(n!) O(n!)
98 Pow(x, n) Pow(x, n) O(log n) O(log n)
99 Count and Say Count and say O(2^n) O(n)
100 Valid Sudoku Valid Sudoku O(n^2) O(n)
101 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
102 Next Permutation Next Permutation O(n) O(1)
103 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
104 3Sum Closest 3Sum Closest O(n^2) O(1)
105 Roman to Integer Roman to Integer O(n) O(1)
106 Daily Temperatures Daily Temperatures
107 Game of Life Game of Life
108 Regular Expression Matching Regular Expression Matching
109 Wildcard Matching Wildvard Matching
110 Single Number Single Number
111 Reverse Bits Reverse bits O(1) O(1)
112 Contains Duplicate II Contains Duplicate II
113 Contains Duplicate III Contains Duplicate III
114 Basic Calculator II Basic Calculator II
115 Alien Dictionary Alien Dictionary O(n log n) O(n)
116 Add Strings Add Strings
117 Reverse Nodes in k-Group Reverse Nodes in k-Group
118 Sudoku Solver Sudoku Solver
119 Multiply Strings Multiply Strings
120 Course Schedule Course Schedule O(n) O(n)
121 Move Zeroes Move Zeroes
122 Jump Game II Jump Gmae II.
123 Course Schedule III Course Schedule III
124 Find All Duplicates in an Array Find All Duplicates in an Array
125 Excel Sheet Column Title Excel Sheet Column Title
126 Reverse Words in a String Reverse Words in a String
127 Word Pattern Word Pattern
128 Search a 2D Matrix Search a 2D Matrix
129 Longest Word in Dictionary Longest Word in Dictionary
130 Largest Number Largest Number
131 Invert Binary Tree Invert Binary Tree O(n) O(1)
132 Guess Number Higher or Lower Guess Number Higher or Lower
133 Number of Enclaves Number of Enclaves
134 Walls And Gates Walls And Gates
135 Island Perimeter Island Perimeter
136 Flood fill Flood fill
137 Find if Path Exists in Graph Find if Path Exists in Graph
138 Symmetric Tree Symmetric Tree O(n) O(n)
139 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
140 Number of Islands Number of Islands O(n^2) O(n^2)
141 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
142 Jump Game III Jump Game III O(n) O(n)
143 Kill process Kill process O(n) O(n)
144 Surrounded Regions Surrounded Regions O(n^2) O(1)
145 Brace Expansion Brace Expansion O(2^n) O(2^n)
146 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
147 4Sum 4Sum O(n^2) O(n)
148 Binary Search Binary Search O(log n) O(1)
149 Destination City Destination City O(n) O(n)

Apple

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
3 3Sum 3Sum O(n^2) O(n)
4 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
5 Maximum Subarray Maximum Subarray O(n) O(n)
6 Add Two Numbers Add Two Numbers O(n) O(n)
7 Number of Islands Number of Islands O(n^2) O(n^2)
8 Move Zeroes Move Zeroes
9 Valid Parentheses Valid Parentheses O(n) O(n)
10 Merge Intervals Merge Intervals O(n log n) O(n)
11 Product of Array Except Self Product of Array Except Self O(n) O(n)
12 Decode String Decode String
13 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
14 Container With Most Water Container With Most Water O(n) O(1)
15 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
16 Combination Sum Combination Sum O(2^n) O(n)
17 Rotate Image Rotate Image O(n^2) O(1)
18 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
19 Unique Paths Unique Paths O(n^2) O(n^2)
20 Word Break Word Break O(n^2) O(n)
21 Random Pick with Weight Random Pick with Weight
22 Roman to Integer Roman to Integer O(n) O(1)
23 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
24 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
25 Pow(x, n) Pow(x, n) O(log n) O(log n)
26 Valid Palindrome Valid Palindrome O(n) O(n)
27 House Robber House Robber O(n) O(1)
28 First Bad Version First Bad Version
29 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
30 Regular Expression Matching Regular Expression Matching
31 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
32 Remove Duplicates from Sorted Array Remove Duplicates from Sorted Array
33 Group Anagrams Group Anagrams O(n) O(n)
34 Word Search Word Search O(n^2) O(n)
35 Word Search II Word Search II O(n^2) O(n^2)
36 Merge Sorted Array Merge Sorted Array O(n) O(n)
37 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
38 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
39 Count of Smaller Numbers After Self Count of Smaller Numbers After Self
40 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
41 Permutations Permutations O(n!) O(n!)
42 Climbing Stairs Climbing Stairs O(n) O(n)
43 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
44 Maximal Rectangle Maximal Rectangle O(n) O(n)
45 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
46 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
47 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
48 Course Schedule Course Schedule O(n) O(n)
49 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
50 Contains Duplicate Contains Duplicate O(n) O(n)
51 Maximal Square Maximal Square O(n^2) O(n^2)
52 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
53 H-Index H-Index
54 Sort Colors Sort Colors
55 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
56 Word Ladder Word Ladder O(n^2) O(n^2)
57 Rotate Array Rotate Array
58 Remove Duplicate Letters Remove Duplicate Letters
59 3Sum Closest 3Sum Closest O(n^2) O(1)
60 Valid Parenthesis String Valid Parenthesis String
61 Count Primes Count Primes O(n log n) O(n log n)
62 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
63 Valid Sudoku Valid Sudoku O(n^2) O(n)
64 Reverse Integer Reverse Integer
65 Multiply Strings Multiply Strings
66 Integer to Roman Integer to Roman
67 First Missing Positive First Missing Positive
68 Palindrome Number Palindrome Number
69 N-Queens N-Queens O(n!) O(n!)
70 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
71 Largest Rectangle in Histogram Largest Rectangle in Histogram
72 Word Break II Word Break II
73 Max Consecutive Ones III Max Consecutive Ones III
74 Next Greater Element II Next Greater Element II
75 Find First and Last Position of Element in Sorted Array Find First and Last Position of Element in Sorted Array
76 Sqrt(x) Sqrt(x)
77 Integer to English Words Integer to English Words
78 Majority Element Majority Element
79 Basic Calculator II Basic Calculator II
80 Reverse Words in a String III Reverse Words in a String III
122 4Sum 4Sum O(n^2) O(n)
82 Frog Jump Frog Jumo
83 Happy Number Happy Number
84 Sudoku Solver Sudoku Solver
85 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
86 Min Stack Min Stack O(n) O(n)
87 Median of Two Sorted Arrays Median of Two Sorted Arrays
88 Valid Anagram Valid Anagram O(n) O(n)
89 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
90 Coin Change Coin Change O(n^2) O(n)
91 Remove All Adjacent Duplicates in String II) Remove All Adjacent Duplicates in String II
92 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
93 The Skyline Problem The Skyline Problem O(n log n) O(n)
94 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
95 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
96 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
97 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
98 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
99 Fraction to Recurring Decimal Fraction to Recurring Decimal
100 Linked List Cycle Linked List Cycle O(n) O(n)
101 Clone Graph Clone Graph O(n) O(n)
102 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
103 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
104 Reverse Linked List Reverse Linked List O(n) O(n)
105 Decode Ways Decode Ways O(n) O(n)
106 Subsets Subsets O(2^n) O(2^n)
107 Unique Paths II Unique Paths II
108 Insert Interval Insert Interval O(n) O(n)
109 Jump Game Jump Game O(n^2) O(1)
110 Pow(x, n) Pow(x, n) O(log n) O(log n)
111 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
112 Count and Say Count and say O(2^n) O(n)
113 Next Permutation Next Permutation O(n) O(1)
114 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
115 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
116 Daily Temperatures Daily Temperatures
117 Basic Calculator Basic Calculator
118 Basic Calculator II Basic Calculator II
119 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
120 Game of Life Game of Life
121 Wildcard Matching Wildvard Matching
122 Single Number Single Number
123 Reverse Bits Reverse bits O(1) O(1)
124 Contains Duplicate III Contains Duplicate III
125 Alien Dictionary Alien Dictionary O(n log n) O(n)
126 Add Strings Add Strings
127 Reverse Nodes in k-Group Reverse Nodes in k-Group
128 Subarray Sum Equals K Subarray Sum Equals K
129 Jump Game II Jump Gmae II.
130 Find All Duplicates in an Array Find All Duplicates in an Array
131 Reverse Words in a String Reverse Words in a String
132 Word Pattern Word Pattern
133 Search a 2D Matrix Search a 2D Matrix
134 Check If N and Its Double Exist Check If N and Its Double Exist O(n) O(n)
135 Largest Number Largest Number
136 Invert Binary Tree Invert Binary Tree O(n) O(1)
137 Guess Number Higher or Lower Guess Number Higher or Lower
138 Walls And Gates Walls And Gates
139 Island Perimeter Island Perimeter
140 Flood fill Flood fill
141 Find if Path Exists in Graph Find if Path Exists in Graph
142 Symmetric Tree Symmetric Tree O(n) O(n)
143 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
144 Number of Islands Number of Islands O(n^2) O(n^2)
145 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
146 Jump Game III Jump Game III O(n) O(n)
147 Surrounded Regions Surrounded Regions O(n^2) O(1)
148 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
149 Binary Search Binary Search O(log n) O(1)

Bloomberg

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Mirror Reflection Mirror Reflection O(n^2) O(1)
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 Number of 1 Bits Number of 1 bits O(log n) O(1)
6 Contains Duplicate Contains Duplicate O(n) O(n)
7 Meeting Rooms Meeting Rooms O(n log n) O(1)
8 Missing Number Missing Number O(n) O(1)
9 Merge Intervals Merge Intervals O(n log n) O(n)
10 Valid Palindrome Valid Palindrome O(n) O(n)
11 Valid Parentheses Valid Parentheses
12 Climbing Stairs Climbing Stairs O(n) O(n)
13 Valid Anagram Valid Anagram O(n) O(n)
14 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
15 Container With Most Water Container With Most Water O(n) O(1)
16 3Sum 3Sum O(n^2) O(n)
17 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
18 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
19 Rotate Image Rotate Image O(n^2) O(1)
20 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
21 Word Search Word Search O(n^2) O(n)
22 Word Search II Word Search II O(n^2) O(n^2)
23 Word Break Word Break O(n^2) O(n)
24 Number of Islands Number of Islands O(n^2) O(n^2)
25 Coin Change Coin Change O(n^2) O(n)
26 Maximum Subarray Maximum Subarray O(n) O(n)
27 Product of Array Except Self Product of Array Except Self O(n) O(n)
28 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
29 Remove All Adjacent Duplicates in String II) Remove All Adjacent Duplicates in String II
30 Palindrome Permutation Palindrome Permutation
31 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
32 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
33 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
34 The Skyline Problem The Skyline Problem O(n log n) O(n)
35 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
36 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
37 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
38 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
39 Two Sum Two Sum O(n) O(n)
40 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
41 Min Stack Min Stack O(n) O(n)
42 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
43 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
44 Linked List Cycle Linked List Cycle O(n) O(n)
45 Clone Graph Clone Graph O(n) O(n)
46 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
47 Word Ladder Word Ladder O(n^2) O(n^2)
48 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
49 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
50 Reverse Linked List Reverse Linked List O(n) O(n)
51 House Robber House Robber O(n) O(1)
52 Decode Ways Decode Ways O(n) O(n)
53 Merge Sorted Array Merge Sorted Array O(n) O(n)
54 Subsets Subsets O(2^n) O(2^n)
55 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
56 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
57 Unique Paths Unique Paths O(n^2) O(n^2)
58 Unique Paths II Unique Paths II
59 Insert Interval Insert Interval
60 Jump Game Jump Game O(n^2) O(1)
61 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
62 N-Queens N-Queens O(n!) O(n!)
63 Pow(x, n) Pow(x, n) O(log n) O(log n)
64 Group Anagrams Group Anagrams O(n) O(n)
65 Permutations Permutations O(n!) O(n!)
66 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
67 Combination Sum Combination Sum O(2^n) O(n)
68 Count and Say Count and say O(2^n) O(n)
69 Valid Sudoku Valid Sudoku O(n^2) O(n)
70 Next Permutation Next Permutation O(n) O(1)
71 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
72 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
73 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
74 3Sum Closest 3Sum Closest O(n^2) O(1)
75 Roman to Integer Roman to Integer O(n) O(1)
76 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
77 Add Two Numbers Add Two Numbers O(n) O(n)
78 Daily Temperatures Daily Temperatures
79 Game of Life Game of Life
80 Regular Expression Matching Regular Expression Matching
81 Wildcard Matching Wildvard Matching
82 Single Number Single Number
83 Reverse Bits Reverse bits O(1) O(1)
84 Happy Number Happy Number
85 Contains Duplicate II Contains Duplicate II
86 Alien Dictionary Alien Dictionary O(n log n) O(n)
87 Add Strings Add Strings
88 Reverse Nodes in k-Group Reverse Nodes in k-Group
89 Sudoku Solver Sudoku Solver
90 Multiply Strings Multiply Strings
91 Sort Colors Sort Colors
92 Course Schedule Course Schedule O(n) O(n)
93 Move Zeroes Move Zeroes
94 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
95 Subarray Sum Equals K Subarray Sum Equals K
96 Jump Game II Jump Gmae II.
97 Course Schedule III Course Schedule III
98 Find All Duplicates in an Array Find All Duplicates in an Array
99 Reverse Words in a String Reverse Words in a String
100 Search a 2D Matrix Search a 2D Matrix
101 Largest Number Largest Number
102 Invert Binary Tree Invert Binary Tree O(n) O(1)
103 Guess Number Higher or Lower Guess Number Higher or Lower
104 Walls And Gates Walls And Gates
105 Island Perimeter Island Perimeter
106 Flood fill Flood fill
107 Symmetric Tree Symmetric Tree O(n) O(n)
108 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
109 Number of Islands Number of Islands O(n^2) O(n^2)
110 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
111 Kill process Kill process O(n) O(n)
112 Surrounded Regions Surrounded Regions O(n^2) O(1)
113 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
114 4Sum 4Sum O(n^2) O(n)
115 Binary Search Binary Search O(log n) O(1)

DE Shaw

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Maximum Subarray Maximum Subarray O(n) O(n)
2 Product of Array Except Self Product of Array Except Self O(n) O(n)
3 Daily Temperatures Daily Temperatures
4 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
5 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
6 Max Consecutive Ones III Max Consecutive Ones III
7 Verifying an Alien Dictionary Verifying an Alien Dictionary O(n log n) O(n)
8 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix
9 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
10 Number of Islands Number of Islands O(n^2) O(n^2)
11 Group Anagrams Group Anagrams O(n) O(n)
12 Rotate Image Rotate Image O(n^2) O(1)
13 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
14 First Missing Positive First Missing Positive
15 Next Permutation Next Permutation O(n) O(1)
16 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
17 Container With Most Water Container With Most Water O(n) O(1)

Goldman Sachs

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
3 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
4 Counting Bits Counting bits O(n log n) O(n)
5 Valid Parentheses Valid Parentheses O(n) O(n)
6 Valid Anagram Valid Anagram O(n) O(n)
7 3Sum 3Sum O(n^2) O(n)
8 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
9 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
10 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
11 Remove All Adjacent Duplicates in String II) Remove All Adjacent Duplicates in String II
12 Maximum Subarray Maximum Subarray O(n) O(n)
13 Product of Array Except Self Product of Array Except Self O(n) O(n)
14 Daily Temperatures Daily Temperatures
15 Number of Islands Number of Islands O(n^2) O(n^2)
16 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
17 Group Anagrams Group Anagrams O(n) O(n)
18 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
19 Next Permutation Next Permutation O(n) O(1)
20 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
21 Container With Most Water Container With Most Water O(n) O(1)
22 High Five High Five
23 Palindrome Permutation Palindrome Permutation
24 Find Pivot Index Find Pivot Index
25 Palindromic Substrings Palindromic Substrings O(n^2) O(n^2)
26 Find All Anagrams in a String Find All Anagrams in a String
27 Pacific Atlantic Water Flow Pacific Atlantic Water Flow O(n^2) O(n^2)
28 Evaluate Division Evaluate Division
29 Decode String Decode String
30 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
31 Counting Bits Counting bits O(n log n) O(n)
32 Coin Change Coin Change O(n^2) O(n)
33 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
34 Find the Duplicate Number Find the Duplicate Number O(n) O(n)
35 Move Zeroes Move Zeroes
36 First Bad Version First Bad Version
37 H-Index H-Index
38 Meeting Rooms II Meeting Rooms II O(n log n) O(n)
39 Shortest Word Distance Shortest Word Distance
40 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
41 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
42 Maximal Square Maximal Square O(n^2) O(n^2)
43 The Skyline Problem The Skyline Problem O(n log n) O(n)
44 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
45 Word Search Word Search O(n^2) O(n)
46 Word Search II Word Search II O(n^2) O(n^2)
47 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
48 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
49 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
50 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
51 Fraction to Recurring Decimal Fraction to Recurring Decimal
52 Min Stack Min Stack O(n) O(n)
53 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
54 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
55 Linked List Cycle Linked List Cycle O(n) O(n)
56 Word Break Word Break O(n^2) O(n)
57 Clone Graph Clone Graph O(n) O(n)
58 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
59 Word Ladder Word Ladder O(n^2) O(n^2)
60 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
61 Pascal's Triangle II Pascal's Triangle II O(n^2) O(n^2)
62 Valid Palindrome Valid Palindrome O(n) O(n)
63 Reverse Linked List Reverse Linked List O(n) O(n)
64 Count Primes Count Primes O(n log n) O(n log n)
65 House Robber House Robber O(n) O(1)
66 Decode Ways Decode Ways O(n) O(n)
67 Merge Sorted Array Merge Sorted Array O(n) O(n)
68 Subsets Subsets O(2^n) O(2^n)
69 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
70 Climbing Stairs Climbing Stairs O(n) O(n)
71 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
72 Unique Paths Unique Paths O(n^2) O(n^2)
73 Unique Paths II Unique Paths II
74 Insert Interval Insert Interval O(n) O(n)
75 Merge Intervals Merge Intervals O(n log n) O(n)
76 Jump Game Jump Game O(n^2) O(1)
77 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
78 N-Queens N-Queens O(n!) O(n!)
79 Group Anagrams Group Anagrams O(n) O(n)
80 Permutations Permutations O(n!) O(n!)
81 Combination Sum Combination Sum O(2^n) O(n)
82 Count and Say Count and say O(2^n) O(n)
83 Valid Sudoku Valid Sudoku O(n^2) O(n)
84 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
85 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
86 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
87 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
88 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
89 3Sum Closest 3Sum Closest O(n^2) O(1)
90 Roman to Integer Roman to Integer O(n) O(1)
91 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
92 Add Two Numbers Add Two Numbers O(n) O(n)
93 Jump Game II Jump Gmae II.
94 Search a 2D Matrix Search a 2D Matrix
95 Longest Word in Dictionary Longest Word in Dictionary
96 Determine if Two Events Have Conflict Determine if Two Events Have Conflict
97 Largest Number Largest Number
98 Invert Binary Tree Invert Binary Tree O(n) O(1)
99 Symmetric Tree Symmetric Tree O(n) O(n)
100 Number of Islands Number of Islands O(n^2) O(n^2)
101 Jump Game III Jump Game III O(n) O(n)
102 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
103 Binary Search Binary Search O(log n) O(1)

Google Top

(Back to top)

No. Questions Solution in PyCharm 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
8 Decode String Decode String
9 Longest String Chain Longest String Chain
10 Validate Stack Sequences Validate Stack Sequences
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
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
16 Network Delay Time Network Delay Time
17 Subarray Sum Equals K Subarray Sum Equals K
18 Max Sum of Rectangle No Larger Than K [Max Sum of Rectangle No Larger Than K
19 Split Array into Consecutive Subsequences Split Array into Consecutive Subsequences
20 Split Array Largest Sum Split Array Largest Sum
21 Minimum Domino Rotations For Equal Row Minimum Domino Rotations For Equal Row
22 Random Pick with Weight Random Pick with Weight

Google

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
3 Remove Duplicates from Sorted Array Remove Duplicates from Sorted Array
4 Next Permutation Next Permutation O(n) O(1)
5 Maximal Rectangle Maximal Rectangle O(n) O(n)
6 Move Zeroes Move Zeroes
7 Merge Intervals Merge Intervals O(n log n) O(n)
8 Insert Interval Insert Interval O(n) O(n)
9 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
10 Valid Parentheses Valid Parentheses O(n) O(n)
11 Same Tree Same Tree O(log n) O(1)
12 Plus One Plus One
13 Bulls and Cows Bulls and Cows O(n) O(1)
14 Evaluate Division Evaluate Division
15 Decode String Decode String
16 Word Break Word Break O(n^2) O(n)
17 Number of Islands Number of Islands O(n^2) O(n^2)
18 House Robber House Robber O(n) O(1)
19 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
20 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
21 Product of Array Except Self Product of Array Except Self O(n) O(n)
22 Clone Graph Clone Graph O(n) O(n)
23 Kth Smallest Element in a BST Kth Smallest Element in a BST O(n) O(n)
24 Longest Increasing Subsequence Longest Increasing Subsequence O(n^2) O(n)
25 Pacific Atlantic Water Flow Pacific Atlantic Water Flow O(n^2) O(n^2)
26 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
27 Word Search II Word Search II O(n^2) O(n^2)
28 The Skyline Problem The Skyline Problem O(n log n) O(n)
29 Pow(x, n) Pow(x, n) O(log n) O(log n)
30 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix
31 Find Median from Data Stream Find Median from Data Stream O(log n) O(n)
32 Count of Smaller Numbers After Self Count of Smaller Numbers After Self
33 Subarray Sum Equals K Subarray Sum Equals K
34 Max Sum of Rectangle No Larger Than K [Max Sum of Rectangle No Larger Than K
35 Split Array into Consecutive Subsequences Split Array into Consecutive Subsequences
36 Split Array Largest Sum Split Array Largest Sum
37 Target Sum Target Sum
38 H-Index H-Index
39 Regular Expression Matching Regular Expression Matching
40 Basic Calculator Basic Calculator
41 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
42 Wildcard Matching Wildvard Matching
43 Add Strings Add Strings
44 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
45 Word Ladder Word Ladder O(n^2) O(n^2)
46 Shortest Palindrome Shortest Palindrome
47 Remove Duplicate Letters Remove Duplicate Letters
48 Valid Parenthesis String Valid Parenthesis String
49 Game of Life Game of Life
50 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
51 Word Break II Word Break II
52 Next Greater Element II Next Greater Element II
53 K Closest Points to Origin K Closest Points to Origin
54 Expression Add Operators Expression Add Operators
55 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
56 Combination Sum IV Combination Sum IV
57 Min Stack Min Stack O(n) O(n)
58 Fraction to Recurring Decimal Fraction to Recurring Decimal
59 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
60 Perfect Squares Perfect Squares
61 Find the Difference Find the Difference
62 Daily Temperatures Daily Temperatures
63 Isomorphic Strings Isomorphic Strings
64 Max Consecutive Ones Max Concsecutive Ones
65 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
66 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
67 First Unique Character in a String First Unique Character in a String
68 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
69 Valid Anagram Valid Anagram O(n) O(n)
70 Container With Most Water Container With Most Water O(n) O(1)
71 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
72 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
73 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
74 Word Search Word Search O(n^2) O(n)
75 Coin Change Coin Change O(n^2) O(n)
76 Maximum Subarray Maximum Subarray O(n) O(n)
77 Palindrome Permutation Palindrome Permutation
78 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
79 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
80 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
81 Best Time to Buy and Sell Stock II Best Time to Buy and Sell Stock II O(n) O(1)
82 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
83 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
84 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
85 Linked List Cycle Linked List Cycle O(n) O(n)
86 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
87 Valid Palindrome Valid Palindrome O(n) O(n)
88 Reverse Linked List Reverse Linked List O(n) O(n)
89 Decode Ways Decode Ways O(n) O(n)
90 Merge Sorted Array Merge Sorted Array O(n) O(n)
91 Subsets Subsets O(2^n) O(2^n)
92 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
93 Climbing Stairs Climbing Stairs
94 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
95 Unique Paths Unique Paths O(n^2) O(n^2)
96 Unique Paths II Unique Paths II
97 Jump Game Jump Game O(n^2) O(1)
98 N-Queens N-Queens O(n!) O(n!)
99 Group Anagrams Group Anagrams O(n) O(n)
100 Permutations Permutations O(n!) O(n!)
101 Count and Say Count and say O(2^n) O(n)
102 Combination Sum Combination Sum O(2^n) O(n)
103 Valid Sudoku Valid Sudoku O(n^2) O(n)
104 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
105 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
106 3Sum 3Sum O(n^2) O(n)
107 3Sum Closest 3Sum Closest O(n^2) O(1)
108 Roman to Integer Roman to Integer O(n) O(1)
109 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
110 Add Two Numbers Add Two Numbers O(n) O(n)
111 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
112 Single Number Single Number
113 Reverse Bits Reverse bits O(1) O(1)
114 Happy Number Happy Number
115 Contains Duplicate II Contains Duplicate II
116 Contains Duplicate III Contains Duplicate III
117 Basic Calculator II Basic Calculator II
118 Alien Dictionary Alien Dictionary O(n log n) O(n)
119 Reverse Nodes in k-Group Reverse Nodes in k-Group
120 Sudoku Solver Sudoku Solver
121 Multiply Strings Multiply Strings
122 Sort Colors Sort Colors
123 Course Schedule Course Schedule O(n) O(n)
124 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
125 Perfect Rectangle Perfect Rectangle
126 Jump Game II Jump Gmae II
127 Course Schedule III Course Schedule III
128 Permutations II Permutations II
129 Find All Duplicates in an Array Find All Duplicates in an Array
130 Excel Sheet Column Title Excel Sheet Column Title
131 Reverse Words in a String Reverse Words in a String
132 Strobogrammatic Number Strobogrammatic Number
133 Search a 2D Matrix Search a 2D Matrix
134 Check If N and Its Double Exist Check If N and Its Double Exist O(n) O(n)
135 Longest Word in Dictionary Longest Word in Dictionary
136 Determine if Two Events Have Conflict Determine if Two Events Have Conflict
137 Largest Number Largest Number
138 Invert Binary Tree Invert Binary Tree O(n) O(1)
139 Guess Number Higher or Lower Guess Number Higher or Lower
140 Number of Enclaves Number of Enclaves
141 Walls And Gates Walls And Gates
142 Island Perimeter Island Perimeter
143 Flood fill Flood fill
144 Find if Path Exists in Graph Find if Path Exists in Graph
145 Tree Diameter Tree Diameter O(n) O(n)
146 Symmetric Tree Symmetric Tree O(n) O(n)
147 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
148 Minimum Obstacle Removal to Reach Corner Minimum Obstacle Removal to Reach Corner O(n^2) O(n)
149 Number of Islands Number of Islands O(n^2) O(n^2)
150 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
151 Jump Game III Jump Game III O(n) O(n)
152 Kill process Kill process O(n) O(n)
153 Surrounded Regions Surrounded Regions O(n^2) O(1)
154 Brace Expansion Brace Expansion O(2^n) O(2^n)
155 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
156 4Sum 4Sum O(n^2) O(n)
157 Binary Search Binary Search O(log n) O(1)
158 Minimum Number of Operations to Convert Time Minimum Number of Operations to Convert Time O(n) O(1)
159 Destination City Destination City O(n) O(n)

LinkedIn

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Number of Islands Number of Islands O(n^2) O(n^2)
2 Valid Number Valid Number
3 Paint House Paint House
4 Valid Palindrome Valid Palindrome O(n) O(n)
5 Valid Parentheses Valid Parentheses O(n) O(n)
6 Same Tree Same Tree O(log n) O(1)
7 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
8 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
9 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
10 Maximum Subarray Maximum Subarray O(n) O(n)
11 Minimum Window Substring Minimum Window Substring O(n) O(n)
12 Shortest Word Distance Shortest Word Distance
13 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
14 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
15 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
16 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
17 Word Break Word Break O(n^2) O(n)
18 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
19 Word Ladder Word Ladder O(n^2) O(n^2)
20 House Robber House Robber O(n) O(1)
21 Merge Sorted Array Merge Sorted Array O(n) O(n)
22 Climbing Stairs Climbing Stairs O(n) O(n)
23 Insert Interval Insert Interval O(n) O(n)
24 Merge Intervals Merge Intervals O(n log n) O(n)
25 Pow(x, n) Pow(x, n) O(log n) O(log n)
26 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
27 Permutations Permutations O(n!) O(n!)
28 Combination Sum Combination Sum O(2^n) O(n)
29 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
30 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
31 3Sum 3Sum O(n^2) O(n)
32 Roman to Integer Roman to Integer O(n) O(1)
33 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
34 Two Sum Two Sum O(n) O(n)
35 Basic Calculator Basic Calculator
36 Basic Calculator II Basic Calculator II
37 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
38 Subarray Sum Equals K Subarray Sum Equals K
39 Reverse Words in a String Reverse Words in a String
40 Invert Binary Tree Invert Binary Tree O(n) O(1)
41 Symmetric Tree Symmetric Tree O(n) O(n)
42 4Sum 4Sum O(n^2) O(n)

Meta

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
2 Remove Duplicates from Sorted Array Remove Duplicates from Sorted Array
3 Interval List Intersections Interval List Intersections
4 Merge Sorted Array Merge Sorted Array O(n) O(n)
5 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
6 Best Time to Buy and Sell Stock III Best Time to Buy and Sell Stock III O(n) O(1)
7 Best Time to Buy and Sell Stock IV Best Time to Buy and Sell Stock IV O(n^2) O(n^2)
8 Move Zeroes Move Zeroes
9 Roman to Integer Roman to Integer O(n) O(1)
10 Merge Intervals Merge Intervals O(n log n) O(n)
11 Insert Interval Insert Interval O(n) O(n)
12 Valid Palindrome II Valid Palindrome II
13 Valid Parentheses Valid Parentheses O(n) O(n)
14 Plus One Plus One
15 Maximal Square Maximal Square O(n^2) O(n^2)
16 3Sum 3Sum O(n^2) O(n)
17 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
18 Word Break Word Break O(n^2) O(n)
19 Number of Islands Number of Islands O(n^2) O(n^2)
20 Course Schedule Course Schedule O(n) O(n)
21 Maximum Subarray Maximum Subarray O(n) O(n)
22 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
23 Product of Array Except Self Product of Array Except Self O(n) O(n)
24 Minimum Window Substring Minimum Window Substring O(n) O(n)
25 Binary Tree Level Order Traversal Binary Tree Level Order Traversal O(n) O(n)
26 Clone Graph Clone Graph O(n) O(n)
27 Kth Smallest Element in a BST Kth Smallest Element in a BST O(n) O(n)
28 Encode and Decode Strings Encode and Decode Strings O(n) O(n)
29 Design Add and Search Words Data Structure Design Add and Search Words Data Structure O(n) O(n)
30 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
31 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
32 Binary Tree Maximum Path Sum Binary Tree Maximum Path Sum O(n) O(n)
33 The Skyline Problem The Skyline Problem O(n log n) O(n)
34 Pow(x, n) Pow(x, n) O(log n) O(log n)
35 Longest Increasing Path in a Matrix Longest Increasing Path in a Matrix
36 Subarray Sum Equals K Subarray Sum Equals K
37 Valid Palindrome Valid Palindrome O(n) O(n)
38 Target Sum Target Sum
39 H-Index H-Index
40 Count and Say Count and say O(2^n) O(n)
41 Task Scheduler Task Scheduler
42 Regular Expression Matching Regular Expression Matching
43 Simplify Path Simplify Path
44 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
45 Find All Anagrams in a String Find All Anagrams in a String
46 Custom Sort String Custom Sort String
47 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
48 Wildcard Matching Wildvard Matching
49 Add Strings Add Strings
50 First Bad Version First Bad Version
51 Is Graph Bipartite? Is Graph Bipartite?
52 Max Consecutive Ones III Max Consecutive Ones III
53 K Closest Points to Origin K Closest Points to Origin
54 Expression Add Operators Expression Add Operators
55 Sudoku Solver Sudoku Solver
56 Combination Sum Combination Sum O(2^n) O(n)
57 Combination Sum IV Combination Sum IV O(2^n) O(n)
58 Valid Number Valid Number
59 Remove Invalid Parentheses Remove Invalid Parentheses
60 Fraction to Recurring Decimal Fraction to Recurring Decimal
61 Add Binary Add Binary
62 Partition Equal Subset Sum Partition Equal Subset Sum
63 Reverse Nodes in k-Group Reverse Nodes in k-Group
64 Find the Index of the First Occurrence in a String Find the Index of the First Occurrence in a String
65 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
66 Verifying an Alien Dictionary Verifying an Alien Dictionary O(n log n) O(n)
67 Shortest Bridge Shortest Bridge
68 Continuous Subarray Sum Continuous Subarray Sum
69 Minimum Remove to Make Valid Parentheses Minimum Remove to Make Valid Parentheses
70 Maximum Depth of Binary Tree Maximum Depth of Binary Tree O(n) O(n)
71 Rotate Image Rotate Image O(n^2) O(1)
72 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
73 Palindrome Permutation Palindrome Permutation
74 Shortest Word Distance Shortest Word Distance
75 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
76 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
77 Word Search Word Search O(n^2) O(n)
78 Word Search II Word Search II O(n^2) O(n^2)
79 Two Sum Two Sum O(n) O(n)
80 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
81 Min Stack Min Stack O(n) O(n)
82 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
83 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
84 Linked List Cycle Linked List Cycle O(n) O(n)
85 Word Ladder Word Ladder O(n^2) O(n^2)
86 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
87 Reverse Linked List Reverse Linked List O(n) O(n)
88 House Robber House Robber O(n) O(1)
89 Decode Ways Decode Ways O(n) O(n)
90 Subsets Subsets O(2^n) O(2^n)
91 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
92 Climbing Stairs Climbing Stairs O(n) O(n)
93 Unique Paths Unique Paths O(n^2) O(n^2)
94 Unique Paths II Unique Paths II
95 Jump Game Jump Game O(n^2) O(1)
96 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
97 N-Queens N-Queens O(n!) O(n!)
98 Group Anagrams Group Anagrams O(n) O(n)
99 Permutations Permutations O(n!) O(n!)
100 Trapping Rain Water Trapping Rain Water O(n^2) O(n)
101 Valid Sudoku Valid Sudoku O(n^2) O(n)
102 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
103 Next Permutation Next Permutation O(n) O(1)
104 Generate Parentheses Generate Parentheses O(2^n) O(2^n)
105 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
106 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
107 Add Two Numbers Add Two Numbers O(n) O(n)
108 Daily Temperatures Daily Temperatures
109 Basic Calculator Basic Calculator
110 Single Number Single Number
111 Reverse Bits Reverse bits O(1) O(1)
112 Happy Number Happy Number
113 Contains Duplicate II Contains Duplicate II
114 Basic Calculator II Basic Calculator II
115 Alien Dictionary Alien Dictionary O(n log n) O(n)
116 Reverse Nodes in k-Group Reverse Nodes in k-Group
117 Multiply Strings Multiply Strings
118 Sort Colors Sort Colors
119 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
120 Find All Duplicates in an Array Find All Duplicates in an Array
121 Excel Sheet Column Title Excel Sheet Column Title
122 Reverse Words in a String Reverse Words in a String
123 Strobogrammatic Number Strobogrammatic Number
124 Word Pattern Word Pattern
125 Search a 2D Matrix Search a 2D Matrix
126 Largest Number Largest Number
127 Invert Binary Tree Invert Binary Tree O(n) O(1)
128 Walls And Gates Walls And Gates
129 Island Perimeter Island Perimeter
130 Flood fill Flood fill
131 Tree Diameter Tree Diameter O(n) O(n)
132 Symmetric Tree Symmetric Tree O(n) O(n)
133 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
134 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
135 Jump Game III Jump Game III O(n) O(n)
136 4Sum 4Sum O(n^2) O(n)
137 Binary Search Binary Search O(log n) O(1)

Microsoft

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum O(n) O(n)
2 Add Two Numbers Add Two Numbers O(n) O(n)
3 String to Integer (atoi) String to Integer (atoi) O(n) O(1)
4 Roman to Integer Roman to Integer O(n) O(1)
5 Merge Two Sorted Lists Merge Two Sorted Lists O(n) O(n)
6 Merge k Sorted Lists Merge k Sorted Lists O(n log n) O(1)
7 Number of 1 Bits Number of 1 bits O(log n) O(1)
8 Missing Number Missing Number O(n) O(1)
9 Remove Duplicates from Sorted Array Remove Duplicates from Sorted Array
10 Merge Intervals Merge Intervals O(n log n) O(n)
11 Valid Palindrome Valid Palindrome O(n) O(n)
12 Valid Parentheses Valid Parentheses O(n) O(n)
13 Linked List Cycle Linked List Cycle O(n) O(n)
14 Reverse Linked List Reverse Linked List O(n) O(n)
15 3Sum 3Sum O(n^2) O(n)
16 Longest Palindromic Substring Longest Palindromic Substring O(n^2) O(1)
17 Search in Rotated Sorted Array Search in Rotated Sorted Array O(log n) O(1)
18 Number of Islands Number of Islands O(n^2) O(n^2)
19 Maximum Subarray Maximum Subarray O(n) O(n)
20 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
21 Spiral Matrix Spiral Matrix O(n^2) O(n^2)
22 Product of Array Except Self Product of Array Except Self O(n) O(n)
23 Jump Game Jump Game O(n^2) O(1)
24 Implement Trie (Prefix Tree) Implement Trie (Prefix Tree) O(n) O(n)
25 Word Search II Word Search II O(n^2) O(n^2)
26 Binary Tree Maximum Path Sum Binary Tree Maximum Path Sum O(n) O(n)
27 The Skyline Problem The Skyline Problem O(n log n) O(n)
28 Rotate Array Rotate Array
29 Reverse Nodes in k-Group Reverse Nodes in k-Group
30 Binary Search Tree Iterator Binary Search Tree Iterator O(n) O(n)
31 Add Digits Add Digits
32 Median of Two Sorted Arrays Median of Two Sorted Arrays O(n) O(n)
33 Kth Largest Element in an Array Kth Largest Element in an Array O(n log n) O(n)
34 Valid Anagram Valid Anagram O(n) O(n)
35 Container With Most Water Container With Most Water O(n) O(1)
36 Longest Substring Without Repeating Characters Longest Substring Without Repeating Characters O(n) O(n)
37 Rotate Image Rotate Image O(n^2) O(1)
38 Word Search Word Search O(n^2) O(n)
39 Word Break Word Break O(n^2) O(n)
40 Coin Change Coin Change O(n^2) O(n)
41 Palindrome Permutation Palindrome Permutation
42 Search a 2D Matrix II Search a 2D Matrix II O(n) O(1)
43 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
44 Sliding Window Maximum Sliding Window Maximum O(n) O(n)
45 Maximal Square Maximal Square O(n^2) O(n^2)
46 Two Sum II - Input array is sorted Two Sum II - Input Array Is Sorted O(n) O(n)
47 Fraction to Recurring Decimal Fraction to Recurring Decimal
48 Min Stack Min Stack O(n) O(n)
49 Find Minimum in Rotated Sorted Array Find Minimum in Rotated Sorted Array O(log n) O(1)
50 Maximum Product Subarray Maximum Product Subarray O(n) O(n)
51 Clone Graph Clone Graph O(n) O(n)
52 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
53 Longest Consecutive Sequence Longest Consecutive Sequence O(n log n) O(1)
54 Pascal's Triangle Pascal's Triangle O(n^2) O(n^2)
55 Pascal's Triangle II Pascal's Triangle II O(n^2) O(n^2)
56 Count Primes Count Primes O(n log n) O(n log n)
57 House Robber House Robber O(n) O(1)
58 Merge Sorted Array Merge Sorted Array O(n) O(n)
59 Decode Ways Decode Ways O(n) O(n)
60 Subsets Subsets O(2^n) O(2^n)
61 Set Matrix Zeroes Set Matrix Zeroes O(n^2) O(n)
62 Climbing Stairs Climbing Stairs O(n) O(n)
63 Minimum Path Sum Minmum Path Sum O(n^2) O(1)
64 Unique Paths Unique Paths O(n^2) O(n^2)
65 Unique Paths II Unique Paths II
66 Insert Interval Insert Interval O(n) O(n)
67 N-Queens N-Queens O(n!) O(n!)
68 Pow(x, n) Pow(x, n) O(log n) O(log n)
69 Group Anagrams Group Anagrams O(n) O(n)
70 Combination Sum Combination Sum O(2^n) O(n)
71 Count and Say Count and say O(2^n) O(n)
72 Valid Sudoku Valid Sudoku O(n^2) O(n)
73 Longest Valid Parentheses Longest Valid Parentheses O(n) O(n)
74 Next Permutation Next Permutation 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
76 Letter Combinations of a Phone Number Letter Combinations of a Phone Number O(2^n) O(2^n)
77 3Sum Closest 3Sum Closest O(n^2) O(1)
78 Daily Temperatures Daily Temperatures
79 Game of Life Game of Life
80 Regular Expression Matching Regular Expression Matching
81 Wildcard Matching Wildvard Matching
82 Single Number Single Number
83 Reverse Bits Reverse bits O(1) O(1)
84 Happy Number Happy Number
85 Contains Duplicate II Contains Duplicate II
86 Basic Calculator II Basic Calculator II
87 Alien Dictionary Alien Dictionary O(n log n) O(n)
88 Add Strings Add Strings
89 Sudoku Solver Sudoku Solver
90 Multiply Strings Multiply Strings
91 Sort Colors Sort Colors
92 Course Schedule Course Schedule O(n) O(n)
93 Move Zeroes Move Zeroes
94 Top K Frequent Elements Top K Frequent Elements O(n) O(n)
95 Subarray Sum Equals K Subarray Sum Equals K
96 Maximum Number of Balloons here
97 Jump Game II Jump Gmae II.
98 Course Schedule III Course Schedule III
99 Find All Duplicates in an Array Find All Duplicates in an Array
100 Excel Sheet Column Title Excel Sheet Column Title
101 Reverse Words in a String Reverse Words in a String
102 Strobogrammatic Number Strobogrammatic Number
103 Word Pattern Word Pattern
104 Search a 2D Matrix Search a 2D Matrix
105 Largest Number Largest Number
106 Invert Binary Tree Invert Binary Tree O(n) O(1)
107 Walls And Gates Walls And Gates
108 Find if Path Exists in Graph Find if Path Exists in Graph
109 Tree Diameter Tree Diameter O(n) O(n)
110 Symmetric Tree Symmetric Tree O(n) O(n)
111 Binary Tree Vertical Order Traversal Binary Tree Vertical Order Traversal O(n) O(n)
112 Cheapest Flights Within K Stops Cheapest Flights Within K Stops O(n^2) O(n)
113 Jump Game III Jump Game III O(n) O(n)
114 Kill process Kill process O(n) O(n)
115 Surrounded Regions Surrounded Regions O(n^2) O(1)
116 Count Complete Tree Nodes Count Complete Tree Nodes O(log n) O(log n)
117 4Sum 4Sum O(n^2) O(n)
118 Binary Search Binary Search O(log n) O(1)

Netflix

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Department Top Three Salaries Department Top Three Salaries
2 Valid Parentheses Valid Parentheses O(n) O(n)
3 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
4 Merge Intervals Merge Intervals O(n log n) O(n)
5 Group Anagrams Group Anagrams O(n) O(n)
6 Top K Frequent Elements Top K Frequent Elements O(n) O(n)

Reddit

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Combination Sum Combination Sum O(2^n) O(n)
2 Combination Sum II Combination Sum II
3 Number of Islands Number of Islands O(n^2) O(n^2)
4 Merge Sorted Array Merge Sorted Array O(n) O(n)
5 Subsets Subsets O(2^n) O(2^n)
6 Insert Interval Insert Interval O(n) O(n)
7 Daily Temperatures Daily Temperatures
8 Merge Intervals Merge Intervals O(n log n) O(n)
9 Best Time to Buy and Sell Stock Best Time to Buy and Sell Stock O(n) O(1)
10 Basic Calculator Basic Calculator
11 Lowest Common Ancestor of a Binary Tree Lowest Common Ancestor of a Binary Tree O(n) O(1)
12 Lowest Common Ancestor of a Binary Search Tree Lowest Common Ancestor of a Binary Search Tree O(n) O(1)
13 Game of Life Game of Life

Spotify

(Back to top)

No. Questions Solution in PyCharm Time Complexity Space Complexity
1 Two Sum Two Sum

About

Solutions to coding problems that can occur through interviews & preparation advices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.6%
  • Java 0.4%