Data structures and algorithms (DSA) is the core of technical interviews at every Indian tech company, from TCS campus drives to FAANG India's SDE-1 loops. The topics and difficulty differ by company type: IT services companies test basic data structures and simple programs; product companies test medium LeetCode patterns; FAANG India tests hard problems with optimal complexity. This guide covers the complete DSA topic list, the most asked question patterns, and a structured preparation path for Indian candidates.
DSA Topics by Company Type in India
IT services companies (TCS, Infosys, Wipro, Cognizant, Capgemini): expect LeetCode easy difficulty. Must-know: arrays (search, sort, find max/min/second-largest), strings (reverse, palindrome, anagram, character count), linked list (reverse, detect cycle), stack (balanced parentheses), queue, basic recursion (factorial, Fibonacci), sorting algorithms (bubble, insertion, selection with their O(n^2) complexity). Algorithmic thinking matters more than advanced data structures. A fully correct, working solution to both problems is the target.
Indian product companies (Flipkart, Swiggy, Zepto, Razorpay, CRED, Zomato, Meesho, Paytm): expect LeetCode medium difficulty. Common patterns: two-pointer (pair sum, 3Sum, remove duplicates), sliding window (longest substring without repeating chars, max sum subarray of size k), binary search on answer space (minimum capacity, minimum days), trees (BFS level-order, DFS traversals, LCA, BST validation), graphs (BFS for shortest path, DFS for connected components, topological sort), dynamic programming (fibonacci, climbing stairs, house robber, 0/1 knapsack, LCS), heap (K largest elements, merge K sorted lists).
FAANG India (Amazon, Google, Microsoft, Meta): expect LeetCode medium to hard. In addition to product company topics: advanced graph (Dijkstra, Bellman-Ford, Floyd-Warshall, minimum spanning tree: Prim's/Kruskal's), advanced DP (edit distance, matrix chain multiplication, DP on trees/graphs), trie (prefix matching, word search), segment tree and BIT/Fenwick tree (range sum query, range update), advanced string algorithms (KMP, Z-function for pattern matching).
Array and String Patterns: The Essential Problems
Must-know array and string problems with their optimal approaches: (1) Two Sum: target pattern. Given array and target, find two indices whose values sum to target. Optimal: hash map stores value-to-index as you iterate. O(n) time, O(n) space. Common follow-up: what if the array is sorted? Then two-pointer, O(n) time, O(1) space. (2) Maximum Subarray (Kadane's Algorithm): find contiguous subarray with maximum sum. Track currentMax (max subarray ending at current index) and globalMax. currentMax = max(nums[i], currentMax + nums[i]). O(n) time, O(1) space. (3) Product of Array Except Self: no division allowed. Build prefix products going left-to-right, then multiply by suffix products going right-to-left in a second pass. O(n) time, O(1) extra space (not counting output). (4) Longest Substring Without Repeating Characters: sliding window with a set. Expand right pointer; when a character already in the set is found, shrink from the left until the duplicate is removed. Track maximum window size. O(n) time, O(min(n,m)) space where m is the character set size. (5) Valid Parentheses: stack. Push all opening brackets; for each closing bracket, check if it matches the top of the stack; if stack is empty at the end, valid. O(n) time, O(n) space. (6) Merge Intervals: sort by start time. Initialize result with the first interval. For each subsequent interval, if its start <= result.last.end, merge (update result.last.end = max(result.last.end, current.end)); otherwise add as a new interval. O(n log n) time for sort.
Tree and Graph Patterns: What Indian Product Companies Test
Tree patterns: BFS (level-order traversal using queue): push root, then while queue is not empty, pop the front node, process it, and push its left and right children. Returns levels in order. O(n) time, O(w) space where w is max width. DFS (in-order for BST gives sorted order): in-order = left, root, right. Pre-order = root, left, right (used for cloning a tree). Post-order = left, right, root (used for deleting a tree). Binary Search Tree: for a valid BST, every node's value must be greater than all values in its left subtree and less than all values in its right subtree; validate with a range [min, max] propagated down the tree. Lowest Common Ancestor (LCA): in a BST, if both nodes are less than current: go left; if both greater: go right; otherwise current is LCA. In a general binary tree: use post-order DFS returning the found node.
Graph patterns: BFS for shortest path (unweighted): queue + visited set. Each level of BFS corresponds to one step further from the source. DFS for connected components: for each unvisited node, DFS from it and mark all reachable nodes as the same component. Topological sort (Kahn's algorithm): compute in-degree for all nodes; start with nodes having in-degree 0; for each processed node, reduce in-degree of its neighbours; if any neighbour reaches 0, add to queue. Union-Find for cycle detection in undirected graph: for each edge (u, v), find the root of u and v; if same root, edge creates a cycle; otherwise union them. Dijkstra's (shortest path in weighted graph): min-heap priority queue; process smallest-distance node first; update distances of neighbours.
Practise coding interview walk-throughs and technical explanations with HireStepX's AI voice interviewer. Get scored feedback on your reasoning clarity and problem-solving communication. First 2 sessions free.
Practice freeDynamic Programming: Recognising and Solving DP Problems
When to use DP: the problem asks for maximum, minimum, or count of ways, AND the problem has overlapping subproblems (computing the answer for a larger input requires computing the same smaller inputs repeatedly). DP = recursion + memoisation (top-down) or table-filling (bottom-up).
The canonical problems and their approaches: Fibonacci: top-down: def fib(n, memo={}): if n <= 1: return n; if n in memo: return memo[n]; memo[n] = fib(n-1, memo) + fib(n-2, memo); return memo[n]. Bottom-up: dp[0]=0; dp[1]=1; for i in range(2,n+1): dp[i]=dp[i-1]+dp[i-2]. 0/1 Knapsack: dp[i][w] = max value using first i items with weight limit w. Recurrence: dp[i][w] = max(dp[i-1][w], dp[i-1][w-weight[i]] + value[i]) if weight[i] <= w, else dp[i-1][w]. Coin Change (minimum coins): dp[i] = minimum coins to make amount i. dp[0]=0; for each amount from 1 to target: for each coin: if coin <= amount: dp[amount] = min(dp[amount], dp[amount-coin]+1). Longest Common Subsequence (LCS): dp[i][j] = LCS of s1[:i] and s2[:j]. If s1[i-1]==s2[j-1]: dp[i][j] = dp[i-1][j-1]+1. Else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]). LCS of two strings of length m and n: O(mn) time and space. Interview signal for DP mastery: solving the problem AND explaining the recurrence relation clearly. A correct solution that cannot be explained is a yellow flag.
Frequently asked questions
Explore more