Most "top coding interview questions" lists are just LeetCode problems repackaged. This is not that. These are the conceptual questions that interviewers ask to test whether you actually understand computer science — not whether you memorized a sliding window template.
These questions show up in phone screens, on-sites, and system design rounds. They are asked at FAANG companies, startups, and everywhere in between. For each question, I have included what the interviewer is actually evaluating — because knowing the intent behind the question changes how you answer it.
If you want to practice answering these with AI-graded feedback, the coding interview questions section covers many of these topics with structured scoring.
1. What is the difference between an array and a linked list? When would you choose one over the other?
What they are testing: Whether you understand memory layout (contiguous vs. pointer-based), cache performance, and can articulate real tradeoffs — not just recite Big-O. Strong answers mention cache locality, allocation patterns, and practical use cases like implementing an LRU cache.
2. How does a hash map work internally? What happens during a collision?
What they are testing: Understanding of hashing, buckets, chaining vs. open addressing, load factor, and rehashing. Bonus: discussing amortized O(1) and when it degrades to O(n). Interviewers want to know if you can reason about performance, not just use the data structure.
3. Explain how a binary search tree maintains order. What is the difference between a BST and a balanced BST?
What they are testing: Whether you understand why unbalanced BSTs degrade to O(n) and what rotations accomplish. Mentioning AVL vs. Red-Black tradeoffs (strict balance vs. fewer rotations) signals depth.
4. What is a heap? How does a priority queue use one?
What they are testing: Array-based tree representation, heapify operations, and practical applications (scheduling, top-k problems, merge-k-sorted). Interviewers want to hear you connect the data structure to real use cases.
5. Explain the difference between a stack and a queue. Give a real-world system that uses each.
What they are testing: Basic understanding plus the ability to connect abstractions to systems. Call stacks, undo operations (stack). Message queues, BFS traversal, request buffering (queue). Weak answers just define LIFO and FIFO.
6. What is a trie? When is it better than a hash map for string lookups?
What they are testing: Understanding of prefix-based lookups, autocomplete systems, and memory tradeoffs. The key insight: tries enable prefix queries that hash maps cannot do efficiently.
7. How does a graph differ from a tree? What representations exist for graphs in memory?
What they are testing: Adjacency matrix vs. adjacency list tradeoffs (dense vs. sparse graphs), directed vs. undirected, cycles. Interviewers want to see you choose representations based on the problem's characteristics.
8. What is a bloom filter? What are the tradeoffs of using one?
What they are testing: Probabilistic data structures understanding. False positives but no false negatives. Space efficiency vs. accuracy. Real applications: spell checkers, cache lookups, network routers. This question separates textbook knowledge from systems knowledge.
9. Explain the difference between a set and a map. How are they typically implemented?
What they are testing: Whether you understand that a set is essentially a map with only keys. Implementation via hash tables or balanced BSTs. Ordered vs. unordered variants and when order matters.
10. What is a skip list? How does it compare to a balanced BST?
What they are testing: Understanding of probabilistic balancing vs. deterministic balancing. Skip lists are simpler to implement, support concurrent access more easily, and are used in systems like Redis. This is a depth question — not everyone will know it.
11. How would you implement an LRU cache? What data structures would you combine?
What they are testing: The hash map + doubly linked list combination and why both are needed. O(1) get and put operations. This is one of the most common data structure design questions because it tests composition, not just knowledge of individual structures.
12. What is the difference between a B-tree and a binary tree? Why do databases use B-trees?
What they are testing: Disk-based data structure understanding. B-trees minimize disk seeks by having high fan-out (many keys per node). This connects data structures to real systems — databases and file systems.
13. Explain what a circular buffer is and where it is used.
What they are testing: Fixed-size buffer with wrap-around, used in logging, streaming, and producer-consumer systems. The key: O(1) operations with bounded memory. Interviewers are checking if you think about memory constraints.
14. What is a disjoint set (union-find)? What is path compression?
What they are testing: Understanding of near-O(1) amortized operations for connectivity queries. Path compression and union by rank optimizations. Applications: network connectivity, Kruskal's MST, equivalence classes.
15. How does an immutable data structure work? What are the performance implications?
What they are testing: Structural sharing, persistent data structures, and why immutability matters for concurrency. The tradeoff: more memory allocation vs. thread safety without locks. Functional programming awareness.
16. Explain the difference between BFS and DFS. When would you use each?
What they are testing: Not just the traversal order — the practical implications. BFS for shortest path in unweighted graphs, level-order processing. DFS for cycle detection, topological sort, maze solving. Memory tradeoffs (BFS queue can be large for wide graphs).
17. What is dynamic programming? How do you identify when a problem can be solved with DP?
What they are testing: Overlapping subproblems + optimal substructure. Top-down (memoization) vs. bottom-up (tabulation). The real test: can you articulate the two properties, or do you just pattern-match problem types?
18. Explain how quicksort works. What is its worst case and how do you avoid it?
What they are testing: Partitioning, pivot selection, O(n^2) worst case with sorted input and first-element pivot. Randomized pivot selection or median-of-three. Why quicksort is often faster than mergesort in practice (cache locality, in-place).
19. What is the difference between a greedy algorithm and dynamic programming?
What they are testing: Greedy makes locally optimal choices and never reconsiders. DP considers all subproblems. Greedy works when the problem has the greedy-choice property. The interviewer wants you to give an example where greedy fails and DP succeeds.
20. How does binary search work? What are the common pitfalls in implementing it?
What they are testing: Integer overflow in midpoint calculation, off-by-one errors in boundary conditions, and when to use inclusive vs. exclusive bounds. The fact that binary search is "simple" but notoriously bug-prone is the point of the question.
21. What is a topological sort? Give an example of when you would use it.
What they are testing: DAG ordering, dependency resolution. Build systems, course prerequisites, task scheduling. Cycle detection as a byproduct. Kahn's algorithm (BFS) vs. DFS-based approaches.
22. Explain Dijkstra's algorithm. When does it fail?
What they are testing: Greedy shortest-path with non-negative weights. Fails with negative edges (use Bellman-Ford). Priority queue implementation detail. Practical applications in routing, maps, network protocols.
23. What is the time complexity of common operations on a balanced BST? Why?
What they are testing: O(log n) for search, insert, delete — because the tree height is log n. The "why" matters more than the answer. Interviewers want to see you derive complexity from structure, not recite it.
24. Explain the concept of amortized analysis. Give an example.
What they are testing: Average cost over a sequence of operations vs. worst-case per operation. Dynamic array resizing is the classic example: O(n) occasional resize, but O(1) amortized insert. This tests mathematical reasoning about performance.
25. What is the difference between stable and unstable sorting algorithms? When does stability matter?
What they are testing: Preservation of relative order for equal elements. Matters when sorting by multiple keys (sort by name, then by age — stability preserves name order within same age). Merge sort is stable; quicksort is not.
26. How does a consistent hashing algorithm work? Why is it used in distributed systems?
What they are testing: Hash ring, virtual nodes, minimal key redistribution when nodes join or leave. Used in CDNs, distributed caches, database sharding. This bridges algorithms and systems thinking.
27. What is backtracking? How does it differ from brute force?
What they are testing: Pruning invalid branches early vs. exhaustive enumeration. Constraint satisfaction problems, N-queens, Sudoku solvers. The key insight is that backtracking is brute force with intelligence about when to stop exploring.
28. Explain the two-pointer technique. What types of problems does it solve?
What they are testing: Reducing O(n^2) to O(n) for sorted array problems. Pair sum, container with most water, removing duplicates. Interviewers want to see you recognize the pattern and explain why it works (invariant maintenance).
29. What is the difference between a process and a thread?
What they are testing: Memory isolation (processes have separate address spaces, threads share), context switching cost, and when to choose each. Strong answers mention IPC overhead vs. shared memory risks.
30. Explain how garbage collection works. What are the tradeoffs of different GC strategies?
What they are testing: Mark-and-sweep, generational GC, reference counting. Stop-the-world pauses vs. concurrent collection. Why generational GC works (weak generational hypothesis). Practical impact on latency-sensitive systems.
31. What is a deadlock? What are the four conditions required for one to occur?
What they are testing: Mutual exclusion, hold and wait, no preemption, circular wait. More importantly: how to prevent deadlocks (lock ordering, timeouts, lock-free data structures). Interviewers want prevention strategies, not just definitions.
32. How does virtual memory work? What is a page fault?
What they are testing: Address translation, page tables, TLB, demand paging. Why virtual memory enables processes to use more memory than physically available. Performance implications of page faults (disk I/O is orders of magnitude slower).
33. What is the difference between TCP and UDP? When would you choose UDP?
What they are testing: Reliability vs. speed tradeoff. TCP guarantees ordering and delivery; UDP does not. UDP for real-time applications (gaming, video streaming, DNS) where retransmission adds unacceptable latency. The interviewer wants practical judgment, not protocol details.
34. Explain what happens when you type a URL into a browser.
What they are testing: DNS resolution, TCP handshake, TLS negotiation, HTTP request, server processing, response rendering. This is a systems literacy test — depth in any layer is a bonus, but covering the full stack is expected.
35. What is the CAP theorem? Give a real-world example of each tradeoff.
What they are testing: Consistency, Availability, Partition tolerance — pick two during a network partition. CP: HBase, MongoDB (with majority write concern). AP: Cassandra, DynamoDB. The nuance: CAP applies during partitions; in normal operation you can have all three. Practicing technical interview questions on distributed systems concepts like this is where most candidates have gaps.
36. What is the difference between horizontal and vertical scaling?
What they are testing: Adding machines (horizontal) vs. adding resources to one machine (vertical). Horizontal requires distributed system design (load balancing, data partitioning, consistency). Vertical is simpler but has hardware limits. Interviewers want to hear you discuss when each is appropriate.
37. How does an index work in a database? What are the costs of adding indexes?
What they are testing: B-tree/B+ tree index structure, read speedup vs. write slowdown, storage overhead, index selectivity. The tradeoff: every index speeds up specific queries but slows down writes and consumes disk. Strong answers mention covering indexes and composite index ordering.
38. What is eventual consistency? How does it differ from strong consistency?
What they are testing: Convergence guarantees vs. linearizability. Eventual consistency allows stale reads but offers higher availability. Real examples: DNS propagation (eventually consistent), bank transactions (strongly consistent). The interviewer wants you to connect the concept to system design decisions.
39. What is the difference between passing by value and passing by reference?
What they are testing: Whether you understand memory semantics, not just syntax. Java passes object references by value. Python passes object references but reassignment does not affect the caller. C++ has true pass-by-reference with &. The nuance matters.
40. What is a closure? How does it capture variables?
What they are testing: A function that captures variables from its enclosing scope. Capture by reference vs. by value (varies by language). Common gotcha: closures in loops capturing the loop variable. Practical use: callbacks, decorators, partial application.
41. Explain the difference between compiled and interpreted languages. Where do JIT compilers fit?
What they are testing: Ahead-of-time compilation vs. runtime interpretation. JIT as a hybrid: interpret first, compile hot paths. V8 (JavaScript), HotSpot (Java). Performance implications and startup time tradeoffs.
42. What is type erasure? How does it affect generics in Java?
What they are testing: Generic type information removed at compile time. Cannot do instanceof on generic types, cannot create generic arrays. Contrast with C++ templates (code generation) or C# reified generics (type info preserved at runtime). This is a depth question for Java candidates.
43. How does memory management differ between languages with GC and languages without it?
What they are testing: Manual allocation/deallocation (C/C++) vs. automatic GC (Java, Go, Python). Rust's ownership model as a third approach. Tradeoffs: developer productivity vs. predictable latency vs. memory efficiency. Interviewers want you to discuss real engineering tradeoffs, not advocate for one approach.
44. What is the Global Interpreter Lock (GIL)? How does it affect Python concurrency?
What they are testing: GIL prevents true parallel execution of Python bytecode in CPython. Threads are still useful for I/O-bound work but not CPU-bound. Workarounds: multiprocessing, C extensions, asyncio. This tests whether you understand the difference between concurrency and parallelism.
45. What is the difference between concurrency and parallelism?
What they are testing: Concurrency is about structure (dealing with multiple things). Parallelism is about execution (doing multiple things simultaneously). A single-core machine can be concurrent but not parallel. This distinction is fundamental and frequently confused.
46. What is a race condition? How do you prevent one?
What they are testing: Unsynchronized access to shared mutable state. Prevention: mutexes, atomic operations, immutable data, message passing. The interviewer wants to hear multiple approaches and when each is appropriate — not just "use a lock."
47. Explain the producer-consumer problem. What synchronization primitives does it require?
What they are testing: Bounded buffer, mutex + condition variables (or semaphores). Why a mutex alone is insufficient (busy waiting). Real applications: thread pools, message queues, pipeline architectures. This is a FAANG interview prep staple because it combines theory with practical systems.
48. What is an atomic operation? How does compare-and-swap (CAS) work?
What they are testing: Hardware-level indivisible operations. CAS: read current value, compare with expected, swap if equal — all atomically. Foundation for lock-free data structures. ABA problem as a known pitfall. This separates candidates who have worked on performance-critical code from those who have not.
49. What is the difference between optimistic and pessimistic locking?
What they are testing: Pessimistic: lock before accessing (assume conflict). Optimistic: proceed without locking, detect conflicts at commit time (assume no conflict). Optimistic is better for low-contention scenarios. Database versioning as an optimistic locking implementation. Interviewers want you to discuss when each is the right choice.
50. What are the tradeoffs between threads, async/await, and actor models for concurrency?
What they are testing: Threads: simple model, expensive context switches, shared memory risks. Async/await: cooperative scheduling, efficient for I/O-bound work, colored function problem. Actors: message passing, no shared state, location transparency (Erlang/Akka). The interviewer wants to see you evaluate concurrency models by workload characteristics, not by personal preference.
Do not try to memorize answers. For each question, make sure you can explain the concept to a colleague in your own words, give a concrete example, and articulate the tradeoffs. If you cannot explain why something works — not just what it is — that is a gap worth closing.
These 50 questions cover the conceptual foundation that interviewers test at every level. The depth of your answer is what changes between junior and senior — a senior engineer discussing hash maps should mention real-world performance characteristics, not just chaining vs. open addressing.
Try a free assessment — no signup needed.
Start Free Assessment