Data structures and algorithms form the foundation of every software engineering technical interview. This curated list of 50 questions covers the topics most frequently tested across campus placement drives, IT services companies, and product start-ups.

Arrays and strings (questions 1–10)

  1. Find the maximum subarray sum (Kadane's algorithm)
  2. Rotate an array by K positions
  3. Find all pairs in an array that sum to a target value
  4. Find the first non-repeating character in a string
  5. Check if a string is an anagram of another
  6. Merge two sorted arrays in O(1) extra space
  7. Move all zeroes to the end of an array without changing relative order
  8. Find the longest common prefix among a list of strings
  9. Implement strStr (find a substring in a string)
  10. Count the frequency of each character in a string

Linked lists (questions 11–18)

  1. Reverse a linked list iteratively and recursively
  2. Detect a cycle in a linked list (Floyd's algorithm)
  3. Find the middle node of a linked list in one pass
  4. Merge two sorted linked lists
  5. Remove the Nth node from the end of a list
  6. Add two numbers represented as linked lists
  7. Flatten a multilevel doubly linked list
  8. Clone a linked list with a next and random pointer

Stacks and queues (questions 19–24)

  1. Implement a stack using two queues
  2. Evaluate a postfix expression
  3. Find the largest rectangle in a histogram
  4. Implement a queue using two stacks
  5. Next greater element for every array element
  6. Minimum stack: design a stack that retrieves the minimum in O(1)

Trees and binary search trees (questions 25–33)

  1. Level-order traversal of a binary tree
  2. Check if a binary tree is height-balanced
  3. Find the lowest common ancestor of two nodes
  4. Serialize and deserialize a binary tree
  5. Validate a binary search tree
  6. Find the Kth smallest element in a BST
  7. Convert a sorted array to a balanced BST
  8. Diameter of a binary tree
  9. Right side view of a binary tree

Graphs (questions 34–40)

  1. BFS and DFS implementation with adjacency list
  2. Detect a cycle in a directed graph
  3. Topological sort of a DAG
  4. Find all connected components in an undirected graph
  5. Shortest path in an unweighted graph (BFS)
  6. Number of islands (2D grid BFS/DFS)
  7. Check if a graph is bipartite

Hashing (questions 41–44)

  1. Find the first duplicate element in an array
  2. Longest consecutive sequence in an unsorted array
  3. Group anagrams together from a list of strings
  4. Two-sum using a hashmap in O(n)

Dynamic programming (questions 45–50)

  1. Fibonacci number using memoization and bottom-up DP
  2. 0/1 knapsack problem
  3. Longest common subsequence
  4. Coin change problem (minimum coins)
  5. Longest increasing subsequence
  6. Edit distance between two strings

How to approach DSA questions in interviews

When given a coding problem in an interview:

  • Ask one or two clarifying questions about constraints and edge cases
  • State your brute-force approach first, then identify the optimisation
  • Write pseudocode before actual code if the problem is complex
  • Think out loud throughout — interviewers score the process, not just the answer
  • Always discuss time and space complexity at the end

Practise at least ten problems from each category above. Track your solve times and revisit problems you could not solve within 25 minutes. Consistent daily practice over four to six weeks is the most reliable path to interview-day confidence.

How to study these questions

For each structure, write down its invariant, common operations, and the trade-off that makes it useful. Implement a small example without looking at a reference, then test an empty input, a duplicate, and a large input. In an interview, choose the structure because it supports the operation the problem needs, not because it is fashionable. Explain complexity after checking it and mention an alternative when the constraints could change. This turns a question list into durable problem-solving knowledge.