DSA CHEAT SHEET — Save This Post!
Most Asked Patterns in TCS Infosys Amazon Interviews!
====================================
90% of coding interviews use THESE 10 patterns.
Master these = crack any tech interview!
====================================
PATTERN 1: TWO POINTERS
Use when: Sorted array, find pairs, remove duplicates
Problems: Two Sum, Reverse String, 3Sum
Logic: left=0, right=n-1, move based on condition
Companies: Amazon, Microsoft, TCS
PATTERN 2: SLIDING WINDOW
Use when: Subarray/substring with condition
Problems: Max sum subarray, Longest substring
Logic: Expand right, shrink left when invalid
Companies: Infosys, Wipro, Google
PATTERN 3: BINARY SEARCH
Use when: Sorted array, find position/condition
Problems: Search in rotated array, Find peak
Logic: mid = (lo+hi)//2, eliminate half each time
Companies: Amazon, Flipkart, Accenture
PATTERN 4: LINKED LIST (Fast & Slow Pointer)
Use when: Cycle detection, find middle
Problems: Detect cycle, Find middle, Palindrome
Logic: slow moves 1 step, fast moves 2 steps
Companies: TCS, Infosys, HCL
PATTERN 5: TREE BFS (Level Order)
Use when: Level-by-level traversal, shortest path
Problems: Level order, Zigzag, Right side view
Logic: Use queue, process level by level
Companies: Amazon, Cognizant, Capgemini
====================================
PATTERN 6: TREE DFS
Use when: Path sum, depth, validate BST
Problems: Max depth, Path sum, Inorder traversal
Logic: Recursion — visit node, left, right
Companies: Microsoft, Wipro, IBM
PATTERN 7: DYNAMIC PROGRAMMING
Use when: Optimization, count ways, max/min
Problems: Fibonacci, Knapsack, LCS, Coin change
Logic: Break into subproblems, store results
Companies: Amazon, Goldman Sachs, Barclays
PATTERN 8: STACK
Use when: Matching brackets, next greater element
Problems: Valid Parentheses, Stock Span, Min Stack
Logic: Push/pop based on LIFO order
Companies: TCS, Accenture, Infosys
PATTERN 9: HASHING (HashMap)
Use when: Count frequency, find duplicates, grouping
Problems: Two Sum, Anagram, Group Anagrams
Logic: key=element, value=count/index
Companies: Google, Amazon, Flipkart
PATTERN 10: GREEDY
Use when: Local optimal = global optimal
Problems: Activity selection, Jump game, Intervals
Logic: Always pick the best option at each step
Companies: Wipro, HCL, Mindtree
====================================
MUST KNOW COMPLEXITY:
Array access -> O(1)
Binary Search -> O(log n)
Linear Search -> O(n)
Bubble Sort -> O(n2)
Merge/Quick Sort-> O(n log n)
HashMap get/put -> O(1) average
BFS/DFS -> O(V + E)
====================================
30-DAY DSA PLAN FOR PLACEMENTS:
Week 1: Arrays + Strings + Hashing
Week 2: Linked List + Stack + Queue
Week 3: Trees + Binary Search
Week 4: DP + Greedy + Mock Tests
Practice on: LeetCode / GeeksForGeeks
Target: 2 problems daily = 60 problems/month
====================================
SAVE this post now!
You will need it before every interview!
Want FREE projects for your resume too?
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSA #DataStructures #Algorithms #CodingInterview
#TCS #Infosys #Wipro #Amazon #Microsoft #Google
#LeetCode #PlacementPrep #CampusPlacement
#BTech2026 #MCA2026 #BCA2026 #OffCampus
#DynamicProgramming #BinarySearch #LinkedList
#ProjectWithSourceCodes #StudentsOfIndia #Coding
Most Asked Patterns in TCS Infosys Amazon Interviews!
====================================
90% of coding interviews use THESE 10 patterns.
Master these = crack any tech interview!
====================================
PATTERN 1: TWO POINTERS
Use when: Sorted array, find pairs, remove duplicates
Problems: Two Sum, Reverse String, 3Sum
Logic: left=0, right=n-1, move based on condition
Companies: Amazon, Microsoft, TCS
PATTERN 2: SLIDING WINDOW
Use when: Subarray/substring with condition
Problems: Max sum subarray, Longest substring
Logic: Expand right, shrink left when invalid
Companies: Infosys, Wipro, Google
PATTERN 3: BINARY SEARCH
Use when: Sorted array, find position/condition
Problems: Search in rotated array, Find peak
Logic: mid = (lo+hi)//2, eliminate half each time
Companies: Amazon, Flipkart, Accenture
PATTERN 4: LINKED LIST (Fast & Slow Pointer)
Use when: Cycle detection, find middle
Problems: Detect cycle, Find middle, Palindrome
Logic: slow moves 1 step, fast moves 2 steps
Companies: TCS, Infosys, HCL
PATTERN 5: TREE BFS (Level Order)
Use when: Level-by-level traversal, shortest path
Problems: Level order, Zigzag, Right side view
Logic: Use queue, process level by level
Companies: Amazon, Cognizant, Capgemini
====================================
PATTERN 6: TREE DFS
Use when: Path sum, depth, validate BST
Problems: Max depth, Path sum, Inorder traversal
Logic: Recursion — visit node, left, right
Companies: Microsoft, Wipro, IBM
PATTERN 7: DYNAMIC PROGRAMMING
Use when: Optimization, count ways, max/min
Problems: Fibonacci, Knapsack, LCS, Coin change
Logic: Break into subproblems, store results
Companies: Amazon, Goldman Sachs, Barclays
PATTERN 8: STACK
Use when: Matching brackets, next greater element
Problems: Valid Parentheses, Stock Span, Min Stack
Logic: Push/pop based on LIFO order
Companies: TCS, Accenture, Infosys
PATTERN 9: HASHING (HashMap)
Use when: Count frequency, find duplicates, grouping
Problems: Two Sum, Anagram, Group Anagrams
Logic: key=element, value=count/index
Companies: Google, Amazon, Flipkart
PATTERN 10: GREEDY
Use when: Local optimal = global optimal
Problems: Activity selection, Jump game, Intervals
Logic: Always pick the best option at each step
Companies: Wipro, HCL, Mindtree
====================================
MUST KNOW COMPLEXITY:
Array access -> O(1)
Binary Search -> O(log n)
Linear Search -> O(n)
Bubble Sort -> O(n2)
Merge/Quick Sort-> O(n log n)
HashMap get/put -> O(1) average
BFS/DFS -> O(V + E)
====================================
30-DAY DSA PLAN FOR PLACEMENTS:
Week 1: Arrays + Strings + Hashing
Week 2: Linked List + Stack + Queue
Week 3: Trees + Binary Search
Week 4: DP + Greedy + Mock Tests
Practice on: LeetCode / GeeksForGeeks
Target: 2 problems daily = 60 problems/month
====================================
SAVE this post now!
You will need it before every interview!
Want FREE projects for your resume too?
https://t.me/Projectwithsourcecodes
Share with your placement batch!
#DSA #DataStructures #Algorithms #CodingInterview
#TCS #Infosys #Wipro #Amazon #Microsoft #Google
#LeetCode #PlacementPrep #CampusPlacement
#BTech2026 #MCA2026 #BCA2026 #OffCampus
#DynamicProgramming #BinarySearch #LinkedList
#ProjectWithSourceCodes #StudentsOfIndia #Coding
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
❤1
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