Dsa Interview asked in chennai product based companies for anthony
Array Hash Table Binary Search Depth-First Search Breadth-First Search Graph Theory Sliding Window Binary Tree DSA
These are the problems faced by my junior anthony during interviews in chennai india
1. Array & Two Pointers / Sliding Window
Description: Problems involving array traversals, element pair searching, sequence tracking, and subarray constraints using linear scanning, hash sets, or multi-pointer approaches.
- #141 Rotate array based on k: 189. Rotate Array — Three-step array reversal algorithm
- #142 Pair sum in array for target: 1. Two Sum / 167. Two Sum II — Hash Map lookup or Two Pointers
- #143 Search target in rotated sorted array: 33. Search in Rotated Sorted Array — Modified Binary Search
- #150 Find palindrome substrings: 647. Palindromic Substrings — Expand Around Center technique
- #152 Common elements in two arrays: 350. Intersection of Two Arrays II — Hash Map or Stream filtering
- #153 Merge and sort two arrays/lists using streams: 88. Merge Sorted Array — Two Pointers or Java 8 Stream
concat().sorted() - #154 Check if two strings are anagrams: 242. Valid Anagram — Frequency Array / Hash Map
- #155 Find second largest distinct element: Single-pass tracking with
max1andmax2variables - #156 Find missing number in 1..n range: 268. Missing Number — Gauss Sum Formula or Bitwise XOR
- #157 Longest consecutive subsequence: 128. Longest Consecutive Sequence — Hash Set lookup
- #159 n/2 odd-sum pairs from array: Array Partitioning — Pair odd elements with even elements
- #162 Find duplicate number: 287. Find the Duplicate Number — Floyd’s Tortoise and Hare ( time, space)
- #174 Longest subarray with max-min ≤ 1: 1438. Longest Continuous Subarray With Absolute Diff ≤ Limit — Sliding Window with Monotonic Deques
- #176 Best time to buy/sell stock: 121. Best Time to Buy and Sell Stock — Single-pass running minimum tracking
- #177 Group anagrams: 49. Group Anagrams — Hash Map with sorted string or frequency key
2. Stack, Queue, & Linked List
Description: Data structure operations requiring LIFO stack ordering, pointer manipulation, cycle detection, or in-place node re-linking.
- #145 Balanced parentheses: 20. Valid Parentheses — Stack matching
- #158 Next greater element: 496. Next Greater Element I — Monotonic Stack
- #160 Reverse singly linked list: 206. Reverse Linked List — Iterative 3-pointer or Recursive reversal
- #164 Cycle detection problems: 141. Linked List Cycle — Fast & Slow Pointers (Floyd’s Cycle Algorithm)
- #166 Delete target node in linked list via next-node copy trick: 237. Delete Node in a Linked List — Value overwrite (
node.val = node.next.val)
3. Binary Trees & Graph Algorithms
Description: Tree traversals, matrix searches, level order processing, and graph dependency resolution using BFS, DFS, and topological sorting.
- #144 Sum of all levels in BST: 637. Average Levels in Binary Tree — Breadth-First Search (BFS Level Order)
- #163 Rotten fruit problem: 994. Rotting Oranges — Multi-source BFS
- #165 Matrix text/word search: 79. Word Search — Depth-First Search with Backtracking
- #167 Binary tree side view: 199. Binary Tree Right Side View — BFS or Modified DFS
- #168 Binary tree top view: Top View of Binary Tree — BFS with Horizontal Distance tracking
- #171 Number of islands: 200. Number of Islands — Grid DFS / BFS / Union-Find
- #178 Course schedule: 207. Course Schedule — Topological Sort / Kahn’s Algorithm
4. Dynamic Programming & Greedy Strategies
Description: Optimization problems requiring dynamic subproblem breakdown, unbounded knapsack formulations, or greedy choices.
- #146 Denomination/currency notes problem: 322. Coin Change — Bottom-Up Dynamic Programming
- #147 Generate valid IP addresses: 93. Restore IP Addresses — Backtracking DFS
- #148 Maximum bags with full capacity of rocks: 2279. Maximum Bags With Full Capacity of Rocks — Greedy strategy with sorting
- #149 House robber (max profit) and variant for min: 198. House Robber — Dynamic Programming ()
- #151 Merge k sorted arrays using heap: 23. Merge k Sorted Lists — Min-Heap / PriorityQueue ()
- #170 Coin Change 2: 518. Coin Change II — Unbounded Knapsack DP
- #175 Minimum platforms problem: Minimum Platforms — Two Pointers on sorted arrival/departure times
5. Math, Brain Teasers, & Analytical Puzzles
Description: Logic-based interview riddles and geometry/math problems often asked to test step-by-step problem-solving skills.
- #161 Angle between clock hands: 1344. Angle Between Hands of a Clock — Math formula for hour and minute degree differences
- #169 Man-goat-grass-tiger river crossing puzzle: State-space river crossing logic puzzle (7 sequential trips)
- #172 25 horses, 5 tracks, find top 3 with minimum races: Elimination puzzle — Solved in 7 races
- #173 10 bottles with one heavier pill bottle, single weighing: Single weighing logic — Take 1 pill from bottle #1, 2 from #2, ..., up to 10 from #10

