InterviewStack.io LogoInterviewStack.io
Interview Prep13 min read

50 Software Engineer Interview Questions You Should Prepare For

A comprehensive collection of 50 software engineer interview questions organized by topic, with difficulty progression, tips for each category, and strategies for effective practice.

IT
InterviewStack TeamEngineering
|

How Coding Interviews Work in 2026

The coding interview remains the most heavily weighted signal in software engineering hiring. Despite ongoing debates about whether LeetCode-style problems reflect real engineering work, the format persists because it provides a standardized, repeatable way to evaluate problem-solving ability under constraints.

A typical coding interview session lasts 45 to 60 minutes. You will receive one to two problems, and you are expected to write working code while explaining your thought process. Most companies use a shared coding environment (CoderPad, HackerRank, or a Google Doc), though some still use physical whiteboards for on-site interviews.

What has evolved is the evaluation criteria. Modern interviewers care less about whether you produce a perfectly optimal solution and more about:

  • How you approach the problem — Do you clarify requirements? Do you consider edge cases? Do you start with a brute-force solution before optimizing?
  • How you communicate — Can you explain your thought process clearly? Do you respond well to hints?
  • Code quality — Is your code clean, readable, and well-structured? Do you use meaningful variable names?
  • Testing awareness — Do you consider how to test your solution? Do you trace through examples?

The following 50 questions are organized by topic and progress from foundational to advanced within each category. You do not need to solve all 50, but you should be comfortable with the patterns they represent.

Arrays and Strings (Questions 1-10)

Arrays and strings are the most commonly tested topic because they appear in nearly every real-world application and can be combined with many algorithmic patterns.

1. Two Sum — Given an array of integers and a target, find two numbers that add up to the target. This is the classic warm-up problem. Use a hash map for O(n) time complexity.

2. Best Time to Buy and Sell Stock — Find the maximum profit from a single buy/sell transaction. This teaches the pattern of tracking a running minimum while iterating.

3. Product of Array Except Self — Return an array where each element is the product of all other elements, without using division. Teaches prefix and suffix product patterns.

4. Maximum Subarray (Kadane's Algorithm) — Find the contiguous subarray with the largest sum. A fundamental dynamic programming problem that every candidate should know.

5. Merge Intervals — Given a collection of intervals, merge overlapping ones. Tests sorting and interval manipulation, commonly used in scheduling problems.

6. Three Sum — Find all unique triplets that sum to zero. Builds on Two Sum with sorting and two-pointer technique to handle duplicates.

7. Container With Most Water — Find two lines that, together with the x-axis, form a container holding the most water. A classic two-pointer problem.

8. Longest Substring Without Repeating Characters — Find the length of the longest substring without duplicate characters. This is the canonical sliding window problem.

9. Minimum Window Substring — Find the smallest window in a string that contains all characters of another string. A harder sliding window problem that combines character frequency tracking.

10. Trapping Rain Water — Calculate how much water can be trapped between elevation bars. Can be solved with two pointers, stack, or precomputation. Tests your ability to choose among multiple approaches.

Tips for arrays and strings:

  • Master the two-pointer technique. It appears in at least 30% of array problems.
  • Understand sliding window patterns for substring and subarray problems.
  • Always consider whether sorting the input first simplifies the problem.
  • Hash maps are your best friend for O(1) lookups and frequency counting.

Linked Lists (Questions 11-15)

Linked list problems test pointer manipulation and your ability to reason about data structures without random access.

11. Reverse a Linked List — Reverse a singly linked list iteratively and recursively. This is a building block for many other problems.

12. Detect a Cycle in a Linked List — Determine if a linked list has a cycle using Floyd's tortoise and hare algorithm. The fast/slow pointer pattern extends far beyond linked lists.

13. Merge Two Sorted Linked Lists — Merge two sorted lists into one sorted list. Tests your ability to handle pointer manipulation cleanly.

14. Remove Nth Node From End of List — Remove the nth node from the end in one pass using the two-pointer gap technique.

15. LRU Cache — Design and implement a Least Recently Used cache with O(1) get and put operations. Combines a hash map with a doubly linked list. This is one of the most commonly asked medium-hard questions.

Tips for linked lists:

  • Always handle edge cases: empty list, single node, operations on the head or tail.
  • Draw the pointer changes before writing code. A diagram saves time and prevents bugs.
  • The dummy head node technique simplifies many linked list operations by eliminating special cases for the head.

Trees and Graphs (Questions 16-25)

Trees and graphs are where interviews get substantially harder. These problems test recursion, BFS, DFS, and the ability to reason about hierarchical and networked data structures.

16. Maximum Depth of a Binary Tree — Find the maximum depth using recursion. The simplest tree problem and a good starting point.

17. Validate Binary Search Tree — Determine if a binary tree is a valid BST. Tests your understanding of BST invariants and in-order traversal.

18. Lowest Common Ancestor of a Binary Tree — Find the LCA of two nodes. Teaches bottom-up recursive thinking in trees.

19. Binary Tree Level Order Traversal — Return the values level by level using BFS. A fundamental BFS pattern applicable to many graph problems.

20. Serialize and Deserialize a Binary Tree — Convert a tree to a string and back. Tests your ability to design encoding schemes and handle edge cases.

21. Number of Islands — Count the number of islands in a 2D grid. The classic BFS/DFS grid problem that every candidate must know.

22. Clone Graph — Create a deep copy of a graph. Tests BFS/DFS with visited tracking and hash map usage.

23. Course Schedule (Topological Sort) — Determine if you can finish all courses given prerequisite relationships. Tests cycle detection and topological ordering in directed graphs.

24. Word Ladder — Find the shortest transformation sequence from one word to another. A BFS problem where the graph is implicit rather than explicit.

25. Alien Dictionary — Determine the character order in an alien language from a sorted dictionary. Combines graph construction with topological sort.

Tips for trees and graphs:

  • For trees, always ask: is it a binary tree, BST, or n-ary tree? The constraints change the approach.
  • BFS for shortest path in unweighted graphs, DFS for exhaustive search and path-finding.
  • For graph problems, always consider: is the graph directed or undirected? Can it have cycles? Is it connected?
  • Practice both iterative (using a stack or queue) and recursive approaches for DFS.

Dynamic Programming (Questions 26-33)

Dynamic programming is the topic that intimidates candidates most, but it follows predictable patterns once you learn to recognize them.

26. Climbing Stairs — How many distinct ways can you climb n stairs, taking 1 or 2 steps at a time? The simplest DP problem, equivalent to the Fibonacci sequence.

27. Coin Change — Find the minimum number of coins needed to make a target amount. A classic unbounded knapsack problem.

28. Longest Increasing Subsequence — Find the length of the longest strictly increasing subsequence. Can be solved in O(n^2) with DP or O(n log n) with binary search.

29. Unique Paths — Count the number of paths from the top-left to bottom-right corner of a grid. A 2D DP problem that teaches grid-based state transitions.

30. Word Break — Determine if a string can be segmented into dictionary words. Combines DP with string processing.

31. House Robber — Find the maximum amount you can rob without robbing adjacent houses. Teaches the pattern of DP with constraints on adjacent elements.

32. Edit Distance — Find the minimum number of operations to convert one string to another. A classic 2D DP problem tested at many companies.

33. Longest Common Subsequence — Find the length of the longest common subsequence between two strings. Another fundamental 2D DP problem with many practical applications.

Tips for dynamic programming:

  • Start with the brute-force recursive solution. Identify overlapping subproblems. Add memoization. Then convert to bottom-up tabulation if needed.
  • State definition is the hardest part. Ask: "What information do I need to make a decision at each step?"
  • Draw the state transition diagram for small inputs before coding.
  • Practice recognizing DP pattern categories: linear, grid, interval, knapsack, string matching.

Sorting and Searching (Questions 34-38)

These questions test fundamental algorithmic knowledge and are often combined with other topics.

34. Search in Rotated Sorted Array — Find a target in a rotated sorted array in O(log n). A modified binary search problem that appears frequently.

35. Find Minimum in Rotated Sorted Array — Find the minimum element in a rotated sorted array. Simpler than searching for a specific target but tests the same binary search modification pattern.

36. Kth Largest Element in an Array — Find the kth largest element. Can be solved with a heap (O(n log k)) or quickselect (O(n) average).

37. Merge K Sorted Lists — Merge k sorted linked lists into one sorted list. Tests your knowledge of heaps and divide-and-conquer approaches.

38. Median of Two Sorted Arrays — Find the median of two sorted arrays in O(log(m+n)). One of the hardest binary search problems, often asked at top companies.

Tips for sorting and searching:

  • Binary search has many variations. Practice the template: what is the search space, what is the condition, and how do you narrow the range?
  • For "kth" problems, consider heaps first. A min-heap of size k gives you the kth largest element.
  • Know the time complexities of common sorting algorithms and when each is appropriate.

System Design Concepts in Coding Interviews (Questions 39-43)

Some coding interviews include lightweight design questions or ask you to implement system components.

39. Design a Hash Map — Implement a hash map with put, get, and remove operations. Tests understanding of hashing, collision resolution, and dynamic resizing.

40. Design a Min Stack — Implement a stack that supports push, pop, top, and getMin in O(1). Tests creative use of auxiliary data structures.

41. Implement a Trie (Prefix Tree) — Build a trie that supports insert, search, and startsWith operations. Fundamental for autocomplete and dictionary problems.

42. Design a Hit Counter — Count the number of hits in the past 5 minutes. Tests your understanding of time-based data structures and circular buffers.

43. Implement a Rate Limiter — Design a simple rate limiter using the token bucket or sliding window algorithm. Bridges coding and system design.

Object-Oriented Design (Questions 44-47)

OOP questions test your ability to model real-world problems with clean abstractions.

44. Design a Parking Lot System — Model a parking lot with different vehicle sizes and spot types. Tests class hierarchy design and encapsulation.

45. Design a Library Management System — Model books, members, borrowing, and reservations. Tests relationship modeling and state management.

46. Design an Elevator System — Model elevators, floors, and scheduling. Tests state machines and algorithm design within an OOP framework.

47. Design a File System — Model files, directories, and operations like create, delete, and search. Tests the composite pattern and tree-based structures.

Tips for OOP questions:

  • Start by identifying the core entities (nouns) and actions (verbs).
  • Apply SOLID principles, but do not over-engineer. Interviewers want clean, practical designs.
  • Consider extensibility: how would your design accommodate new requirements?

Concurrency (Questions 48-50)

Concurrency questions are common for backend and infrastructure roles.

48. Print in Order — Ensure three methods execute in order across three threads. Tests your understanding of locks, semaphores, or barriers.

49. Producer-Consumer Problem — Implement a thread-safe bounded buffer. The classic concurrency problem that tests mutex and condition variable usage.

50. Read-Write Lock — Implement a lock that allows concurrent reads but exclusive writes. Tests your understanding of reader-writer synchronization.

Tips for concurrency:

  • Know the difference between mutexes, semaphores, and condition variables.
  • Understand common concurrency pitfalls: deadlock, livelock, starvation, and race conditions.
  • Practice thinking about what shared state needs protection and what can be lock-free.

Time and Space Complexity Expectations

Interviewers expect you to analyze and state the time and space complexity of your solution. Here is a quick reference for expected complexities by problem type:

  • Array/string problems: Most should be solvable in O(n) or O(n log n). An O(n^2) solution is usually acceptable only as a brute-force starting point.
  • Tree problems: Most should be O(n) where n is the number of nodes. An O(n^2) tree solution usually indicates a suboptimal approach.
  • Graph problems: Typically O(V + E) for BFS/DFS-based solutions.
  • Dynamic programming: Ranges from O(n) for linear DP to O(n^2) or O(n * m) for 2D problems. State the complexity in terms of the dimensions of your DP table.
  • Sorting-based solutions: O(n log n) is generally optimal. If the interviewer asks for better, consider counting sort or bucket sort for constrained inputs.

Always state both time and space complexity. Interviewers appreciate when you proactively discuss the trade-off between time and space.

How to Practice Effectively

Follow the 3-Step Problem Solving Process

For every problem you practice:

  1. Attempt it cold for 20 minutes. Do not look at hints. Struggle with it. This builds the pattern-recognition skills you need in real interviews.
  2. Study the solution thoroughly. Do not just read it; understand why each step is necessary. Identify the pattern it uses.
  3. Re-solve it from memory the next day. If you cannot, you did not actually learn it.

Focus on Patterns, Not Problems

There are thousands of coding problems but only about 15 fundamental patterns. Once you recognize which pattern a problem uses, the solution becomes much more approachable. InterviewStack organizes practice problems by pattern, making it easy to build systematic mastery rather than solving random problems.

Simulate Real Conditions

Practice with a timer (45 minutes per problem), talk through your solution out loud, and write code in a plain editor without auto-complete. The gap between solving a problem in comfortable conditions and solving it under interview pressure is larger than most people expect.

Track Your Progress

Keep a log of problems you have solved, noting the pattern, difficulty, and whether you solved it independently. Review problems you struggled with weekly. Spaced repetition is far more effective than cramming.

Do Mock Interviews

Practicing alone only takes you so far. Mock interviews with another person, whether a friend, colleague, or through InterviewStack's AI mock interview feature, provide the pressure and communication practice that solo study cannot replicate. Aim for at least two mock interviews per week during your active preparation period.

Final Thoughts

Nobody expects you to solve every problem perfectly. Interviewers are looking for clear thinking, good communication, and the ability to make progress on unfamiliar problems. If you master the fundamental patterns, practice under realistic conditions, and learn to communicate your reasoning clearly, you will be well-prepared for any coding interview you encounter.

Topics

software engineercoding interviewdata structuresalgorithmsinterview questionsprogramming

Ready to practice?

Put what you've learned into practice with AI mock interviews and structured preparation guides.