Skip to content

dhananjay8/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

157 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Software Engineering Interview Preparation

A comprehensive repository for interview prep: DSA, System Design, SQL, and Machine Coding.

πŸ“‚ Repository Structure

  • solutions/ β€” LeetCode solutions (JS + Python) organized by difficulty
  • SQL/ β€” SQL interview questions with solutions
  • System Design/ β€” System design case studies for interviews
  • Machine Coding/ β€” Frontend/full-stack machine coding rounds
  • DSA/ β€” DSA cheat sheet, sorting algorithms, patterns
  • Design Patterns/ β€” 12 design patterns with JS/Python/Java code
  • DevOps Notes/ β€” Linux, Docker, CI/CD, Terraform, AWS, Monitoring, Security
  • Kubernetes Notes/ β€” Core concepts, Networking, Storage, Scaling, Helm, GitOps

🧠 Quick Pattern Recognition Guide

If the problem says... Think about...
Sorted array Binary Search, Two Pointers
All permutations/subsets Backtracking
Tree DFS, BFS
Graph DFS, BFS, Union-Find
Linked list Two Pointers, Fast/Slow
Recursion banned Stack
In-place Swap, Store multiple values per pointer
Max/min subarray/subset Dynamic Programming
Top/least K items Heap, QuickSelect
Common strings HashMap, Trie
Optimize space Bit Manipulation, Greedy
String patterns Rolling Hash, Sliding Window

Complexity Guide (by constraint n)

n Target Complexity
n ≀ 12 O(n!)
n ≀ 25 O(2^n)
n ≀ 500 O(nΒ³)
n ≀ 10⁴ O(nΒ²)
n ≀ 10⁢ O(n log n)
n ≀ 10⁸ O(n)
n > 10⁸ O(log n) or O(1)

LeetCode Top 150 Interview Problems

Array & String (25 problems)

# Problem Solution
1 Two Sum Two Sum
2 Merge Sorted Array Merge Sorted Array
3 Remove Element Remove Element
4 Remove Duplicates from Sorted Array Remove Duplicates
5 Remove Duplicates from Sorted Array II Remove Duplicates II
6 Majority Element Majority Element
7 Rotate Array Rotate Array
8 Best Time to Buy and Sell Stock Stock I
9 Best Time to Buy and Sell Stock II Stock II
10 Jump Game Jump Game
11 Jump Game II Jump Game II
12 H-Index H-Index
13 Insert Delete GetRandom O(1) RandomizedSet
14 Product of Array Except Self Product Except Self
15 Gas Station Gas Station
16 Candy Candy
17 Trapping Rain Water Trapping Rain Water
18 Roman to Integer Roman to Integer
19 Integer to Roman Integer to Roman
20 Length of Last Word Length of Last Word
21 Longest Common Prefix Longest Common Prefix
22 Reverse Words in a String Reverse Words
23 Zigzag Conversion Zigzag Conversion
24 Find the Index of the First Occurrence in a String Find First Occurrence
25 Text Justification Text Justification

Two Pointers (5 problems)

# Problem Solution
26 Valid Palindrome Valid Palindrome
27 Is Subsequence Is Subsequence
28 Two Sum II - Input Array Is Sorted Two Sum II
29 Container With Most Water Container With Most Water
30 3Sum 3sum

Sliding Window (4 problems)

# Problem Solution
31 Minimum Size Subarray Sum Min Subarray Sum
32 Longest Substring Without Repeating Characters Longest Substring
33 Substring with Concatenation of All Words Substring Concatenation
34 Minimum Window Substring Min Window Substring

Matrix (5 problems)

# Problem Solution
35 Valid Sudoku Valid Sudoku
36 Spiral Matrix Spiral Matrix
37 Rotate Image Rotate Image
38 Set Matrix Zeroes Set Matrix Zeroes
39 Game of Life Game of Life

HashMap (9 problems)

# Problem Solution
40 Ransom Note Ransom Note
41 Isomorphic Strings Isomorphic Strings
42 Word Pattern Word Pattern
43 Valid Anagram Valid Anagram
44 Group Anagrams Group Anagrams
45 Two Sum Two Sum
46 Happy Number Happy Number
47 Contains Duplicate II Contains Duplicate II
48 Longest Consecutive Sequence Longest Consecutive

Intervals (4 problems)

# Problem Solution
49 Summary Ranges Summary Ranges
50 Merge Intervals Merge Intervals
51 Insert Interval Insert Interval
52 Minimum Number of Arrows to Burst Balloons Min Arrows

Stack (5 problems)

# Problem Solution
53 Valid Parentheses Valid Parentheses
54 Simplify Path Simplify Path
55 Min Stack Min Stack
56 Evaluate Reverse Polish Notation Evaluate RPN
57 Basic Calculator Basic Calculator

Linked List (11 problems)

# Problem Solution
58 Linked List Cycle Linked List Cycle
59 Add Two Numbers Add Two Numbers
60 Merge Two Sorted Lists Merge Two Sorted Lists
61 Copy List with Random Pointer Copy List
62 Reverse Linked List II Reverse Linked List II
63 Reverse Nodes in k-Group Reverse Nodes in k-Group
64 Remove Nth Node From End of List Remove Nth
65 Remove Duplicates from Sorted List II Remove Duplicates Sorted List II
66 Rotate List Rotate List
67 Partition List Partition List
68 LRU Cache LRU Cache

Binary Tree General (14 problems)

# Problem Solution
69 Maximum Depth of Binary Tree Max Depth
70 Same Tree Same Tree
71 Invert Binary Tree Invert Binary Tree
72 Symmetric Tree Symmetric Tree
73 Construct Binary Tree from Preorder and Inorder Traversal Construct Pre+In
74 Construct Binary Tree from Inorder and Postorder Traversal Construct In+Post
75 Populating Next Right Pointers in Each Node II Next Right II
76 Flatten Binary Tree to Linked List Flatten BT
77 Path Sum Path Sum
78 Sum Root to Leaf Numbers Sum Root to Leaf
79 Binary Tree Maximum Path Sum Max Path Sum
80 Binary Search Tree Iterator BST Iterator
81 Count Complete Tree Nodes Count Nodes
82 Lowest Common Ancestor of a Binary Tree LCA of BT

Binary Tree BFS (4 problems)

# Problem Solution
83 Binary Tree Right Side View Right Side View
84 Average of Levels in Binary Tree Average of Levels
85 Binary Tree Level Order Traversal Level Order
86 Binary Tree Zigzag Level Order Traversal Zigzag Level Order

Binary Search Tree (3 problems)

# Problem Solution
87 Minimum Absolute Difference in BST Min Abs Diff BST
88 Kth Smallest Element in a BST Kth Smallest BST
89 Validate Binary Search Tree Validate BST

Graph General (6 problems)

# Problem Solution
90 Number of Islands Number of Islands
91 Surrounded Regions Surrounded Regions
92 Clone Graph Clone Graph
93 Evaluate Division Evaluate Division
94 Course Schedule Course Schedule
95 Course Schedule II Course Schedule II

Graph BFS (3 problems)

# Problem Solution
96 Snakes and Ladders Snakes and Ladders
97 Minimum Genetic Mutation Genetic Mutation
98 Word Ladder Word Ladder

Trie (3 problems)

# Problem Solution
99 Implement Trie (Prefix Tree) Implement Trie
100 Design Add and Search Words Data Structure Design Add Search
101 Word Search II Word Search II

Backtracking (7 problems)

# Problem Solution
102 Letter Combinations of a Phone Number Letter Combinations
103 Combinations Combinations
104 Permutations Permutations
105 Combination Sum Combination Sum
106 N-Queens II N-Queens II
107 Generate Parentheses Generate Parentheses
108 Word Search Word Search

Divide & Conquer (4 problems)

# Problem Solution
109 Convert Sorted Array to Binary Search Tree Convert Sorted Array to BST
110 Sort List Sort List
111 Construct Quad Tree Construct Quad Tree
112 Merge k Sorted Lists Merge k Sorted Lists

Kadane's Algorithm (2 problems)

# Problem Solution
113 Maximum Subarray Maximum Subarray
114 Maximum Sum Circular Subarray Max Sum Circular

Binary Search (7 problems)

# Problem Solution
115 Search Insert Position Search Insert Position
116 Search a 2D Matrix Search 2D Matrix
117 Find Peak Element Find Peak
118 Search in Rotated Sorted Array Search Rotated
119 Find First and Last Position of Element in Sorted Array Find First Last
120 Find Minimum in Rotated Sorted Array Find Min Rotated
121 Median of Two Sorted Arrays Median of Two Sorted Arrays

Heap (4 problems)

# Problem Solution
122 Kth Largest Element in an Array Kth Largest Element
123 IPO IPO
124 Find K Pairs with Smallest Sums Find K Pairs
125 Find Median from Data Stream Find Median

Bit Manipulation (6 problems)

# Problem Solution
126 Add Binary Add Binary
127 Reverse Bits Reverse Bits
128 Number of 1 Bits Number of 1 Bits
129 Single Number Single Number
130 Single Number II Single Number II
131 Bitwise AND of Numbers Range Bitwise AND Range

Math (6 problems)

# Problem Solution
132 Palindrome Number Palindrome Number
133 Plus One Plus One
134 Factorial Trailing Zeroes Factorial Trailing Zeroes
135 Sqrt(x) Sqrt(x)
136 Pow(x, n) Pow(x, n)
137 Max Points on a Line Max Points on a Line

1D Dynamic Programming (5 problems)

# Problem Solution
138 Climbing Stairs Climbing Stairs
139 House Robber House Robber
140 Word Break Word Break
141 Coin Change Coin Change
142 Longest Increasing Subsequence LIS

Multidimensional DP (8 problems)

# Problem Solution
143 Triangle Triangle
144 Minimum Path Sum Minimum Path Sum
145 Unique Paths II Unique Paths II
146 Longest Palindromic Substring Longest Palindromic Substring
147 Interleaving String Interleaving String
148 Edit Distance Edit Distance
149 Best Time to Buy and Sell Stock III Stock III
150 Best Time to Buy and Sell Stock IV Stock IV

πŸ”₯ Frequently Asked Questions (DE/FAANG Rounds)

➀ Data Engineering Round Problems

# Problem Pattern Solution
1 Top-K Active Users (Last 1 Hour) β€” Stream Heap + Sliding Window JS / Py
2 Order Reconciliation β€” Two Systems HashMap + Set Operations JS / Py
3 Session Grouping + Revenue β€” 30-min Inactivity Sorting + Interval Merging JS / Py

➀ Classic Must-Know Problems

# Problem LC Pattern Solution
1 LRU Cache + LFU Cache 146 / 460 HashMap + DLL / Freq Map JS / Py
2 Find Median from Data Stream 295 Two Heaps JS / Py
3 Word Ladder 127 BFS + Wildcard Preprocessing JS / Py
4 Merge K Sorted Lists 23 Min-Heap JS / Py
5 Detect Cycle in Directed Graph β€” DFS 3-color / Kahn's BFS JS / Py
6 Maximum Subarray Sum (Kadane's) 53 Kadane's / Greedy DP JS / Py
7 Kth Largest Element in a Stream 703 Min-Heap of Size K JS / Py
8 Task Scheduler 621 Greedy + Max-Heap JS / Py

➀ Pattern Batches (JS + Python)

Pattern LeetCode Numbers Solution File
Sliding Window 76, 209, 424, 567, 904 JS / Py
Two Pointers 11, 15, 26, 42, 75, 88 JS / Py
Binary Search 33, 153, 162, 704 JS / Py
BFS 102, 200, 994, 542, 286, 815 JS / Py
Backtracking 39, 46, 51, 78, 79 JS / Py
Dynamic Programming 70, 198, 300, 322, 1143, 416 JS / Py

πŸ“– Quick Reference Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors