DSA CHEAT SHEET ā Save This!
Data Structures Asked in Every Interview!
====================================
DSA is tested in ALL product company interviews!
Amazon, Google, Microsoft, Flipkart, Adobe ā
ALL start with DSA rounds. Master this!
====================================
ARRAYS ā Most Basic, Most Asked!
Find max/min in array -> O(n) linear scan
Reverse an array -> two pointer approach
Find duplicates -> use HashSet O(n)
Rotate array by k -> reverse technique
Two Sum problem -> HashMap O(n)
Sliding Window -> for subarray problems
====================================
STRINGS
Palindrome check -> two pointers
Anagram check -> sort both or HashMap
Longest common prefix -> vertical scan
Count vowels/consonants -> loop + set
String reversal -> s[::-1] in Python
====================================
LINKED LIST ā Very Frequently Asked!
Reverse a linked list -> 3 pointer trick
Detect cycle -> Floyd's algo (slow/fast)
Find middle node -> slow/fast pointers
Merge 2 sorted lists -> compare & merge
Remove Nth node from end -> two pass
====================================
STACK & QUEUE
Stack: LIFO ā use for:
-> Valid parentheses check
-> Next Greater Element
-> Undo/Redo operations
Queue: FIFO ā use for:
-> BFS (level order traversal)
-> Sliding window maximum
====================================
TREES ā 30% of Interview Questions!
Inorder: Left -> Root -> Right
Preorder: Root -> Left -> Right
Postorder: Left -> Right -> Root
Level Order -> use Queue (BFS)
Height of tree -> recursion
Check BST -> inorder should be sorted
LCA of two nodes -> recursive approach
====================================
SORTING ALGORITHMS
Bubble Sort -> O(n²) | Simple
Selection Sort -> O(n²) | Simple
Insertion Sort -> O(n²) | Best for small
Merge Sort -> O(nlogn) | Stable sort
Quick Sort -> O(nlogn) | In-place
For interviews: Know Merge Sort well!
====================================
SEARCHING
Linear Search -> O(n) | Unsorted array
Binary Search -> O(logn) | Sorted array only
Binary Search template:
low, high = 0, len(arr)-1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target: return mid
elif arr[mid] < target: low = mid+1
else: high = mid-1
====================================
TIME COMPLEXITY QUICK REFERENCE:
O(1) -> Constant | Array index access
O(logn) -> Log | Binary search
O(n) -> Linear | Single loop
O(nlogn) -> Linearithmic | Merge sort
O(n²) -> Quadratic | Nested loops
====================================
TOP DSA PLATFORMS TO PRACTICE:
LeetCode -> leetcode.com (must!)
HackerRank -> hackerrank.com
GeeksForGeeks -> geeksforgeeks.org
Codeforces -> codeforces.com
====================================
Save this post ā revise before every interview!
Get FREE projects with DSA implementation:
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSA #DataStructures #Algorithms #LeetCode
#CodingInterview #TechInterview #Placements
#BTech2026 #MCA2026 #BCA2026 #CompetitiveCoding
#Java #Python #DSACheatSheet #FAANG
#ProjectWithSourceCodes #StudentsOfIndia
Data Structures Asked in Every Interview!
====================================
DSA is tested in ALL product company interviews!
Amazon, Google, Microsoft, Flipkart, Adobe ā
ALL start with DSA rounds. Master this!
====================================
ARRAYS ā Most Basic, Most Asked!
Find max/min in array -> O(n) linear scan
Reverse an array -> two pointer approach
Find duplicates -> use HashSet O(n)
Rotate array by k -> reverse technique
Two Sum problem -> HashMap O(n)
Sliding Window -> for subarray problems
====================================
STRINGS
Palindrome check -> two pointers
Anagram check -> sort both or HashMap
Longest common prefix -> vertical scan
Count vowels/consonants -> loop + set
String reversal -> s[::-1] in Python
====================================
LINKED LIST ā Very Frequently Asked!
Reverse a linked list -> 3 pointer trick
Detect cycle -> Floyd's algo (slow/fast)
Find middle node -> slow/fast pointers
Merge 2 sorted lists -> compare & merge
Remove Nth node from end -> two pass
====================================
STACK & QUEUE
Stack: LIFO ā use for:
-> Valid parentheses check
-> Next Greater Element
-> Undo/Redo operations
Queue: FIFO ā use for:
-> BFS (level order traversal)
-> Sliding window maximum
====================================
TREES ā 30% of Interview Questions!
Inorder: Left -> Root -> Right
Preorder: Root -> Left -> Right
Postorder: Left -> Right -> Root
Level Order -> use Queue (BFS)
Height of tree -> recursion
Check BST -> inorder should be sorted
LCA of two nodes -> recursive approach
====================================
SORTING ALGORITHMS
Bubble Sort -> O(n²) | Simple
Selection Sort -> O(n²) | Simple
Insertion Sort -> O(n²) | Best for small
Merge Sort -> O(nlogn) | Stable sort
Quick Sort -> O(nlogn) | In-place
For interviews: Know Merge Sort well!
====================================
SEARCHING
Linear Search -> O(n) | Unsorted array
Binary Search -> O(logn) | Sorted array only
Binary Search template:
low, high = 0, len(arr)-1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target: return mid
elif arr[mid] < target: low = mid+1
else: high = mid-1
====================================
TIME COMPLEXITY QUICK REFERENCE:
O(1) -> Constant | Array index access
O(logn) -> Log | Binary search
O(n) -> Linear | Single loop
O(nlogn) -> Linearithmic | Merge sort
O(n²) -> Quadratic | Nested loops
====================================
TOP DSA PLATFORMS TO PRACTICE:
LeetCode -> leetcode.com (must!)
HackerRank -> hackerrank.com
GeeksForGeeks -> geeksforgeeks.org
Codeforces -> codeforces.com
====================================
Save this post ā revise before every interview!
Get FREE projects with DSA implementation:
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSA #DataStructures #Algorithms #LeetCode
#CodingInterview #TechInterview #Placements
#BTech2026 #MCA2026 #BCA2026 #CompetitiveCoding
#Java #Python #DSACheatSheet #FAANG
#ProjectWithSourceCodes #StudentsOfIndia
Telegram
ProjectWithSourceCodes
Free Source Code Projects for Students š | Python | Java | Android | Web Dev | AI/ML | Final Year Projects | BCA ⢠BTech ⢠MCA | Interview Prep | Job Alerts
Website: https://updategadh.com
Website: https://updategadh.com
DSA CHEAT SHEET - Save This!
Data Structures Asked in Every Tech Interview!
====================================
DSA is tested at Amazon, Google, Microsoft,
Flipkart, Adobe, Uber, Swiggy ā ALL of them!
Master these before your placement rounds!
====================================
ARRAYS - Most Basic, Most Asked!
Two Sum -> HashMap O(n)
Find max/min -> linear scan O(n)
Reverse array -> two pointers O(n)
Find duplicates -> HashSet O(n)
Rotate by k -> reverse technique O(n)
Subarray sum -> sliding window O(n)
Merge sorted arrays -> two pointer O(n+m)
====================================
STRINGS
Palindrome check -> two pointers O(n)
Anagram check -> sort or HashMap O(n)
Longest substring no repeat -> sliding window
String reversal -> s[::-1] in Python
Count char frequency -> HashMap O(n)
====================================
LINKED LIST - Very Frequently Asked!
Reverse linked list -> 3 pointer trick O(n)
Detect cycle -> Floyd's slow/fast O(n)
Find middle -> slow/fast pointers O(n)
Merge 2 sorted lists -> compare & link O(n)
Remove Nth from end -> two pass O(n)
====================================
STACK & QUEUE
Stack (LIFO) - use for:
-> Valid parentheses {[()]}
-> Next Greater Element
-> Undo/Redo operations
Queue (FIFO) - use for:
-> BFS (level order tree traversal)
-> Sliding window maximum
====================================
TREES - 30% of Interview Questions!
Inorder: Left Root Right
Preorder: Root Left Right
Postorder: Left Right Root
Level Order: BFS using Queue
Height of tree -> recursion O(n)
Check BST valid -> inorder sorted check
Lowest Common Ancestor -> recursive O(n)
Path sum root to leaf -> DFS O(n)
====================================
GRAPHS
BFS -> Queue, shortest path unweighted
DFS -> Stack/Recursion, path finding
Detect cycle undirected -> Union Find
Detect cycle directed -> DFS + visited
Topological Sort -> Kahn's algo (BFS)
====================================
DYNAMIC PROGRAMMING
Fibonacci -> memoization O(n)
0/1 Knapsack -> 2D DP O(n*W)
Longest Common Subsequence -> 2D DP
Coin Change -> bottom-up DP O(n*amount)
Climb Stairs -> DP same as Fibonacci
====================================
TIME COMPLEXITY QUICK REFERENCE:
O(1) Constant | Array index
O(logn) Log | Binary search
O(n) Linear | Single loop
O(nlogn) Linearithmic | Merge sort
O(n2) Quadratic | Nested loops
O(2n) Exponential | Recursion tree
====================================
TOP DSA PRACTICE PLATFORMS:
LeetCode -> leetcode.com (must!)
GeeksForGeeks -> geeksforgeeks.org
HackerRank -> hackerrank.com
Codeforces -> codeforces.com
====================================
Save this - revise before every interview!
Get FREE projects with DSA implementations:
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSACheatSheet #DSA #DataStructures #Algorithms
#LeetCode #CodingInterview #Placements #FAANG
#BTech2026 #MCA2026 #BCA2026 #CompetitiveCoding
#Java #Python #TechInterview #DynamicProgramming
#ProjectWithSourceCodes #StudentsOfIndia
Data Structures Asked in Every Tech Interview!
====================================
DSA is tested at Amazon, Google, Microsoft,
Flipkart, Adobe, Uber, Swiggy ā ALL of them!
Master these before your placement rounds!
====================================
ARRAYS - Most Basic, Most Asked!
Two Sum -> HashMap O(n)
Find max/min -> linear scan O(n)
Reverse array -> two pointers O(n)
Find duplicates -> HashSet O(n)
Rotate by k -> reverse technique O(n)
Subarray sum -> sliding window O(n)
Merge sorted arrays -> two pointer O(n+m)
====================================
STRINGS
Palindrome check -> two pointers O(n)
Anagram check -> sort or HashMap O(n)
Longest substring no repeat -> sliding window
String reversal -> s[::-1] in Python
Count char frequency -> HashMap O(n)
====================================
LINKED LIST - Very Frequently Asked!
Reverse linked list -> 3 pointer trick O(n)
Detect cycle -> Floyd's slow/fast O(n)
Find middle -> slow/fast pointers O(n)
Merge 2 sorted lists -> compare & link O(n)
Remove Nth from end -> two pass O(n)
====================================
STACK & QUEUE
Stack (LIFO) - use for:
-> Valid parentheses {[()]}
-> Next Greater Element
-> Undo/Redo operations
Queue (FIFO) - use for:
-> BFS (level order tree traversal)
-> Sliding window maximum
====================================
TREES - 30% of Interview Questions!
Inorder: Left Root Right
Preorder: Root Left Right
Postorder: Left Right Root
Level Order: BFS using Queue
Height of tree -> recursion O(n)
Check BST valid -> inorder sorted check
Lowest Common Ancestor -> recursive O(n)
Path sum root to leaf -> DFS O(n)
====================================
GRAPHS
BFS -> Queue, shortest path unweighted
DFS -> Stack/Recursion, path finding
Detect cycle undirected -> Union Find
Detect cycle directed -> DFS + visited
Topological Sort -> Kahn's algo (BFS)
====================================
DYNAMIC PROGRAMMING
Fibonacci -> memoization O(n)
0/1 Knapsack -> 2D DP O(n*W)
Longest Common Subsequence -> 2D DP
Coin Change -> bottom-up DP O(n*amount)
Climb Stairs -> DP same as Fibonacci
====================================
TIME COMPLEXITY QUICK REFERENCE:
O(1) Constant | Array index
O(logn) Log | Binary search
O(n) Linear | Single loop
O(nlogn) Linearithmic | Merge sort
O(n2) Quadratic | Nested loops
O(2n) Exponential | Recursion tree
====================================
TOP DSA PRACTICE PLATFORMS:
LeetCode -> leetcode.com (must!)
GeeksForGeeks -> geeksforgeeks.org
HackerRank -> hackerrank.com
Codeforces -> codeforces.com
====================================
Save this - revise before every interview!
Get FREE projects with DSA implementations:
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSACheatSheet #DSA #DataStructures #Algorithms
#LeetCode #CodingInterview #Placements #FAANG
#BTech2026 #MCA2026 #BCA2026 #CompetitiveCoding
#Java #Python #TechInterview #DynamicProgramming
#ProjectWithSourceCodes #StudentsOfIndia
Telegram
ProjectWithSourceCodes
Free Source Code Projects for Students š | Python | Java | Android | Web Dev | AI/ML | Final Year Projects | BCA ⢠BTech ⢠MCA | Interview Prep | Job Alerts
Website: https://updategadh.com
Website: https://updategadh.com