Skip to content

Introduction to DSA — Interview Preparation

Table of Contents

  1. Introduction
  2. Junior Questions
  3. Middle Questions
  4. Senior Questions
  5. Professional Questions
  6. Behavioral and Meta Questions
  7. Walkthrough Framework — How to Answer Any DSA Question Aloud
  8. How to Estimate Big-O on the Fly
  9. Coding Challenge — Two Sum in 3 Languages
  10. Talking Through Two Sum Aloud — A Sample Monologue
  11. Common Mistakes in DSA Interviews
  12. The One-Page DSA Cheat Sheet for Interviews
  13. Red Flags Interviewers Watch For
  14. Green Signals Interviewers Watch For
  15. Summary

Introduction

"Introduction to DSA" questions show up in three predictable slots of an interview loop. First, as the warm-up at the top of a coding round — "name a few data structures, what is Big-O" — used to gauge whether the candidate has any vocabulary at all. Second, as the phone-screen filter — short conceptual questions like "array vs linked list" or "when is a hash table O(n)" — used to cut candidates who memorized one LeetCode pattern but cannot reason about trade-offs. Third, as the opener of a system-design round, where the interviewer says something innocent like "we need to look up users by ID, what would you reach for" and silently judges whether the candidate jumps to a hash map without asking about size, ordering, and persistence. This file teaches you to talk about DSA at the meta level: not which problem to solve, but how to choose a structure, how to estimate Big-O on the fly, and how to walk through a problem aloud so the interviewer hears the reasoning behind the code.


Junior Questions

Junior-level interviewers are testing vocabulary and the ability to point at a data structure and say its name. The bar is low but unforgiving: confusing "stack" and "queue" is unrecoverable. Memorize this table, but more importantly, be able to answer each question in one sentence without filler. Long rambling answers at junior level signal uncertainty.

# Question Expected Answer Focus
1 What is DSA in one sentence? Organize data, operate efficiently
2 What is the difference between a data structure and an algorithm? Container vs procedure
3 Why do we care about Big-O notation? Predicts scaling, ignores constants
4 Name 5 common data structures. Array, linked list, hash, stack, queue
5 When would you use an array vs a linked list? Random access vs frequent insert
6 What is FIFO vs LIFO? Queue vs stack ordering
7 What is a hash table and why is lookup O(1) on average? Hash function, bucket, uniform spread
8 What is recursion in plain terms? Function calls itself, base case
9 Why is binary search O(log n)? Halves search space each step
10 What does "stable sort" mean? Preserves equal-key order
11 What does O(1) space mean? Memory does not grow with n
12 What is the difference between O(n) and O(n^2)? Linear vs quadratic growth
13 What is the worst case of linear search? O(n), element absent or last
14 What is a balanced binary tree? Heights differ by at most one
15 What is the difference between iteration and recursion? Loop vs self-call, stack frames

Middle Questions

Middle-level questions move from "what" to "why" and "when". The interviewer no longer wants the definition — they want to know whether you understand the trade-off, the failure mode, and the cost. A correct one-word answer is no longer enough; you need to name the condition under which the behavior holds. "Hash map is O(1)" earns no credit at this level. "Hash map is O(1) average assuming a good hash function and load factor below 0.75, degrading to O(n) under collisions" earns full credit.

# Question Expected Answer Focus
1 When does a hash table degrade to O(n)? Bad hash, adversarial keys, all collisions
2 What is amortized complexity? Give the dynamic-array example. Doubling, average O(1) push
3 Why is comparison sort bounded by Omega(n log n)? Decision tree, n! leaves
4 What is the difference between BFS and DFS? Queue level-order vs stack depth-first
5 When do you use DP vs greedy? Overlapping subproblems vs local optimum
6 What is the sliding window technique? Moving range, reuse work, O(n)
7 What is the two-pointer technique? Sorted array, opposite ends, linear
8 When do you reach for a heap? Top-K, streaming median, scheduling
9 How do you detect a cycle in a linked list? Floyd's tortoise and hare
10 What is the space-time trade-off? Precompute or cache, trade memory
11 What is a stable sort and when does it matter? Multi-key sort, preserve prior order
12 What is the difference between Big-O, Big-Theta, and Big-Omega? Upper, tight, lower bound
13 When do you use a trie over a hash map? Prefix queries, autocomplete
14 What is a topological sort and when do you need it? DAG ordering, dependency resolution
15 What is the difference between recursion and dynamic programming? DP memoizes overlapping subproblems

Senior Questions

Senior-level interviewers are watching for one thing: can you scale a structure beyond a single machine without panicking. They will ask about LRU caches, distributed hashing, hot partitions, and rate limiting because every back-end system runs into those exact problems. The expected answer is no longer the algorithm — it is the architecture around the algorithm. Mention specific real systems by name when you can (Redis, RocksDB, Cassandra, DynamoDB). Concrete references signal that you have read source code or production postmortems.

# Question Expected Answer Focus
1 Design an LRU cache with O(1) get and put. Hash map plus doubly linked list
2 When do you pick a B-tree over an LSM tree? Read-heavy vs write-heavy workload
3 What is a Bloom filter and when do you use one? Probabilistic membership, no false negatives
4 How do you deal with a hot partition in a sharded store? Virtual nodes, request hedging, key salting
5 How do you evict entries from an unbounded cache? LRU, LFU, TTL, size cap
6 What is consistent hashing and why does it matter? Minimal remap on resize, ring topology
7 When do you choose lock-free over locking? High contention, latency tail, CAS loops
8 Why does the hash flooding attack matter in production? Adversary forces O(n), seed randomization
9 How do you build a sliding-window rate limiter? Bucketed counters, ring buffer, Redis ZSET
10 How do you compute a running median over a stream? Two heaps, balanced sizes

Professional Questions

Professional-level questions are rare in industry interviews and common in research, infrastructure, and database-vendor interviews. The interviewer expects formal vocabulary: invariant, potential function, decision tree, reduction, approximation ratio. You do not need to write a flawless proof on a whiteboard — you need to sketch the structure of the proof and use the words correctly. "By the potential method, define Phi as twice the size minus the capacity; then each push has constant amortized cost" is a complete answer at this level.

# Question Expected Answer Focus
1 Prove dynamic-array amortized O(1) push via the potential method. Phi = 2*size - capacity, telescoping
2 Prove the comparison-sort lower bound via a decision tree. n! leaves, height >= log(n!) = Omega(n log n)
3 What is the cell-probe model and what does it bound? Counts memory reads, ignores compute
4 Define Las Vegas vs Monte Carlo randomized algorithms. Always correct vs bounded error
5 What does NP-complete mean precisely? In NP, every NP problem reduces in poly time
6 Define an alpha-approximation algorithm. Within factor alpha of optimum
7 What does cache-oblivious mean? Optimal I/O without knowing M or B
8 Name a classical lower bound for hash tables. Static dictionary, Omega(log n / log log n)

Behavioral and Meta Questions

The behavioral round is where most candidates underprepare. The interviewer is checking whether you can talk about your own past work with the same structured clarity you bring to a coding problem. Use the STAR framework (Situation, Task, Action, Result) but compress it: one sentence each. Have two concrete stories ready that involve a data-structure choice and a measurable outcome. Vague stories ("I improved performance") are worse than no story.

# Question Expected Answer Focus
1 How do you choose a data structure under interview pressure? Access pattern first, then Big-O
2 Walk through a past system where a structure choice changed the outcome. Concrete metric, before/after
3 Describe a time you traded correctness for speed. Approximation, business justification
4 Describe a bug you fixed that turned out to be the wrong data structure. Linear scan in hot path, swap structure
5 How do you keep DSA skills sharp when day-to-day work is glue code? Spaced practice, source reading, postmortems
6 When the interviewer asks "is there a better approach", what is your default response? Restate constraint, check unused property

Walkthrough Framework — How to Answer Any DSA Question Aloud

The interviewer is not testing whether you can pattern-match to a memorized template. They are testing whether your reasoning is loud, ordered, and falsifiable. Follow these seven steps in order, narrate each one, and never skip step 1.

  1. Clarify the input. Ask out loud: what is the type, what is the range of n, can it be empty, are duplicates allowed, is it sorted, is it streamed or in memory, what fits in RAM. Write the constraints on the whiteboard.
  2. Identify the access pattern. Say what you need from the data: membership? min? top-K? range? FIFO? prefix? The access pattern selects the structure — not the other way around.
  3. Propose the brute force and its Big-O. Even if it is obviously slow, state it. This proves you can solve the problem at all, and it gives the interviewer a baseline to push back against.
  4. Propose a better approach and its Big-O. Name the trick out loud: "two pointers because the array is sorted", "hash map because we need O(1) membership", "heap because we need streaming top-K". State the time and space cost.
  5. Walk through a small example by hand. Pick an input of size 3 to 5 and trace the state. Bugs surface here before they surface in code. If the example fails, restart from step 4 with a different approach.
  6. Code it. Now, and not before. Write the function signature, then the body. Talk while you type. Do not minimize variable names to look smart.
  7. Test edge cases. Empty input. Single element. All duplicates. Already-sorted. All negative. Overflow. The interviewer is watching to see if you self-trigger these tests or wait to be asked.

Candidates who run this loop sound senior even on junior questions. Candidates who skip step 1 and dive into code sound junior even on senior questions.

A useful drill: practice the seven steps on a problem you have already solved. The goal is not to discover the answer — you know the answer — but to rehearse narrating the answer in the right order. By the time you sit down with a real interviewer, the narration should be automatic, and your conscious attention can stay on the problem itself.


How to Estimate Big-O on the Fly

Interviewers often interrupt your code with "what is the complexity?" and watch how fast you answer. You do not need to do a formal derivation. You need a small toolbox of rules of thumb that get you the right answer in under five seconds.

Rule of Thumb Reasoning Example
One loop over n items, constant work inside -> O(n) Sum n constants Linear scan, reverse array
Two nested loops, each over n -> O(n^2) n times n Brute-force pair check, bubble sort
One loop, but halve the range each step -> O(log n) log2(n) iterations Binary search, BST descent
One loop over n, log work inside -> O(n log n) n times log n Comparison sort, n binary searches
Recursion T(n) = T(n/2) + O(1) -> O(log n) Master theorem case 1 Binary search recursive form
Recursion T(n) = 2 T(n/2) + O(n) -> O(n log n) Master theorem case 2 Merge sort, quicksort average
Recursion T(n) = T(n-1) + O(1) -> O(n) n levels, constant per level Naive factorial, tail recursion
Recursion T(n) = T(n-1) + O(n) -> O(n^2) Sum 1..n Naive sum of triangle
Recursion T(n) = 2 T(n-1) + O(1) -> O(2^n) Branching factor 2, depth n Naive Fibonacci, subset enumeration
Loop where index doubles each step -> O(log n) i = 1, 2, 4, 8, ... stops at n Exponential search outer loop
Loop where index square-roots each step -> O(log log n) Van Emde Boas style Rare, mention if asked
Sliding window over array of length n -> O(n) Each element enters and exits once Longest substring without repeats
Two pointers from both ends -> O(n) Pointers move toward each other, total steps n Three-sum after sort
Hash map insert and lookup -> O(1) average, O(n) worst Constant on uniform spread, linear under collisions Two-sum hash map solution
Heap push and pop -> O(log n) Sift up or sift down a balanced tree of size n Top-K with min-heap
Sort n items, then scan once -> O(n log n) Dominant term is the sort Most "sort first, then..." patterns

For space complexity, ask three questions: how much extra memory does the algorithm allocate, how deep is the recursion stack, and does the output count toward the budget. Recursive solutions in Python often surprise candidates because the call stack adds O(depth) space even when the algorithm "looks O(1)".

When you are unsure, state the answer with a hedge: "I think this is O(n log n) because we sort once and then scan, but if the input is already sorted the dominant cost would be the scan and it becomes O(n)." Hedging with reasoning is a strong signal. Hedging without reasoning is weak.

Translating n into Wall-Clock Time

Big-O is abstract, but interviewers also like to ask "is this fast enough?" The following back-of-envelope numbers, assuming roughly 10^8 simple operations per second in a typical interview language, let you answer that question instantly.

n O(log n) O(n) O(n log n) O(n^2) O(2^n)
10 ~3 ns ~100 ns ~330 ns ~1 us ~10 us
100 ~7 ns ~1 us ~7 us ~100 us infeasible
1,000 ~10 ns ~10 us ~100 us ~10 ms infeasible
10,000 ~13 ns ~100 us ~1.3 ms ~1 s infeasible
100,000 ~17 ns ~1 ms ~17 ms ~100 s infeasible
10^6 ~20 ns ~10 ms ~200 ms ~10000 s infeasible
10^7 ~23 ns ~100 ms ~2.3 s infeasible infeasible
10^9 ~30 ns ~10 s ~300 s infeasible infeasible

Reading the table: if the interviewer says n is up to 10^5, then O(n^2) is the boundary of "barely acceptable" and O(n log n) or better is "definitely safe". If n is 10^7, you need O(n) or O(n log n). If n is 10^9, you are in distributed-systems territory and must talk about streaming, sampling, or sharding. Knowing where the n^2 wall sits is the difference between writing code that finishes and code that times out.


Coding Challenge — Two Sum in 3 Languages

Problem: Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to target. You may assume each input has exactly one solution, and you may not use the same element twice.

Two Sum is the canonical introductory DSA problem because it touches arrays, hashing, time-space trade-off, and "can you spot the O(n) trick". Interviewers expect you to start with the brute force, then improve.

Naive O(n^2) — Brute Force

The most direct reading of the problem: try every pair.

Go

package main

import "fmt"

func twoSumBrute(nums []int, target int) []int {
    for i := 0; i < len(nums); i++ {
        for j := i + 1; j < len(nums); j++ {
            if nums[i]+nums[j] == target {
                return []int{i, j}
            }
        }
    }
    return nil
}

func main() {
    fmt.Println(twoSumBrute([]int{2, 7, 11, 15}, 9)) // [0 1]
}

Java

public class TwoSumBrute {
    public static int[] twoSum(int[] nums, int target) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[]{i, j};
                }
            }
        }
        return null;
    }

    public static void main(String[] args) {
        int[] r = twoSum(new int[]{2, 7, 11, 15}, 9);
        System.out.println(r[0] + "," + r[1]); // 0,1
    }
}

Python

def two_sum_brute(nums, target):
    n = len(nums)
    for i in range(n):
        for j in range(i + 1, n):
            if nums[i] + nums[j] == target:
                return [i, j]
    return None


if __name__ == "__main__":
    print(two_sum_brute([2, 7, 11, 15], 9))  # [0, 1]

Cost: Time O(n^2), space O(1). At n=10,000 this is 100 million comparisons — still under a second, but at n=1,000,000 it is a trillion. Unusable.

Optimal O(n) — Hash Map Lookup

The trick: as we iterate, ask "have I already seen target - current?" — that is a membership query, and a hash map answers it in O(1). We trade O(n) memory for O(n) time.

Go

package main

import "fmt"

func twoSum(nums []int, target int) []int {
    seen := make(map[int]int, len(nums))
    for i, v := range nums {
        if j, ok := seen[target-v]; ok {
            return []int{j, i}
        }
        seen[v] = i
    }
    return nil
}

func main() {
    fmt.Println(twoSum([]int{2, 7, 11, 15}, 9)) // [0 1]
}

Java

import java.util.HashMap;

public class TwoSum {
    public static int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> seen = new HashMap<>(nums.length);
        for (int i = 0; i < nums.length; i++) {
            Integer j = seen.get(target - nums[i]);
            if (j != null) {
                return new int[]{j, i};
            }
            seen.put(nums[i], i);
        }
        return null;
    }

    public static void main(String[] args) {
        int[] r = twoSum(new int[]{2, 7, 11, 15}, 9);
        System.out.println(r[0] + "," + r[1]); // 0,1
    }
}

Python

def two_sum(nums, target):
    seen = {}
    for i, v in enumerate(nums):
        complement = target - v
        if complement in seen:
            return [seen[complement], i]
        seen[v] = i
    return None


if __name__ == "__main__":
    print(two_sum([2, 7, 11, 15], 9))  # [0, 1]

Cost: Time O(n), space O(n). At n=1,000,000 this finishes in milliseconds.

Why the Hash-Map Solution Is the Canonical Answer

The interviewer is testing four things at once:

  1. Can you turn a search problem into a membership query? The cognitive jump from "check every pair" to "store as you go and ask if the complement exists" is the most important pattern in DSA. It reappears in three-sum, anagram grouping, longest substring without repeats, and dozens of others.
  2. Do you reach for the right structure? Membership in O(1) means hash set or hash map. A candidate who reaches for a sorted array and binary search (O(n log n)) is not wrong, but is one level behind.
  3. Do you state the trade-off explicitly? "We are spending O(n) memory to save O(n) time per element" is the sentence the interviewer wants to hear. It proves you understand that O(1) lookup is not free.
  4. Do you handle the index-vs-value confusion? Many candidates store the value as the key and the value again as the value. The map must be value -> index because the problem asks for indices, not values. Getting this right on the first try is a small but real signal.

If the interviewer asks for a follow-up, the typical extensions are: what if the array is sorted (use two pointers, O(1) space), what if you need all pairs (group by complement), what if duplicates exist (decide whether [3, 3] with target 6 returns [0, 1] or is invalid).

Per-Language Pitfalls on Two Sum

Language Common Mistake Fix
Go Returning nil and the caller dereferencing it without a check Add a (result, ok) pattern or sentinel slice
Go Pre-sizing the map without the capacity hint, causing rehashes make(map[int]int, len(nums))
Java Using int for the map value and forgetting autoboxing cost Acceptable; mention it if asked about perf
Java Comparing boxed Integer with == instead of .equals outside the cache range Use .intValue() or primitive comparison
Python Re-checking seen on every iteration with if v in seen then seen[v] One lookup: seen.get(complement) or try-except
Python Recursion-depth concerns on the brute-force version (when written recursively) Iterate; or bump sys.setrecursionlimit

Follow-Up Variations the Interviewer May Ask

Variation Expected Approach Complexity
Sorted input Two pointers from both ends O(n) time, O(1) space
Return values instead of indices Same hash map, store value pairs O(n) time, O(n) space
Return all unique pairs Hash map with set semantics O(n) time, O(n) space
Three Sum: find a + b + c = target Sort, fix one, two-pointer the rest O(n^2) time, O(1) space
Four Sum Sort, fix two, two-pointer the rest O(n^3) time, O(1) space
Two Sum with closest sum, not exact Sort, two pointers, track best diff O(n log n) time
Two Sum where the array is a data stream Maintain a hash set as values arrive O(1) per insert
Two Sum across two different arrays Hash one array, scan the other O(n + m) time
Two Sum but cannot use extra memory Sort in place, two pointers (loses indices) O(n log n) time
Two Sum with very large n (out of core) External sort then two-pointer, or hash on disk O(n log n) I/O

Knowing these variations cold turns a single problem into the structure of an entire problem family. Interviewers love candidates who, when asked "what if the array is sorted", answer in one breath without needing to reread the problem.


Talking Through Two Sum Aloud — A Sample Monologue

To show what the walkthrough framework sounds like when applied to Two Sum, here is the narration a strong candidate produces, end to end, in about 90 seconds before writing any code.

"Before I start — a few questions. The input is an array of integers and a target. Can the array be empty? Can there be duplicates? Is there always exactly one solution, or do I return all of them? And what is the rough size of n — hundreds, millions?

OK, assume one unique solution, possible duplicates, n up to about 10^4. The output is the two indices, not the two values.

The access pattern here is: for each element, I want to know if its complement — that is, target minus the current value — has been seen. That is a membership query. A hash set or hash map answers membership in O(1).

The brute-force solution is two nested loops checking every pair. That is O(n^2) time, O(1) space. At n = 10^4 it does 10^8 comparisons, which is borderline — about a second. Acceptable, but I can do better.

The improvement: as I scan the array, I store each value I have seen in a hash map keyed by value, with the index as the value. When I get to position i, I check if target - nums[i] is already in the map. If yes, I return the stored index and i. If no, I add nums[i] to the map and continue.

That is O(n) time, O(n) space. I am trading memory for speed.

Let me trace it on [2, 7, 11, 15] with target 9. i=0, v=2, complement=7, not in map, store {2: 0}. i=1, v=7, complement=2, in map at index 0, return [0, 1]. Correct.

Edge cases I want to handle: empty array — return null or empty. Single element — cannot form a pair, return null. Duplicates like [3, 3] with target 6 — works because by the time I look up the complement on the second 3, the first 3 is in the map. Negative numbers — works, addition does not care about sign. Integer overflow — target - nums[i] could overflow if both are near MAX_INT, but the problem usually constrains the range, so I will note it and move on.

Coding it now."

This is what the interviewer wants to hear. The candidate stated constraints, the access pattern, the brute force with its Big-O, the improvement with its Big-O, traced a small example, and listed edge cases — all before writing a single line of code. The code that follows is almost guaranteed to be correct because all the thinking is done. Candidates who jump straight to code spend the next ten minutes fixing the bugs that this narration would have prevented.


Common Mistakes in DSA Interviews

  • Coding before clarifying. Writing the function signature before asking about input range, duplicates, or constraints. The interviewer is silently downgrading you.
  • No Big-O. Finishing the solution and not stating the time and space cost unprompted. Always say "this is O(n) time and O(n) space" out loud.
  • Ignoring edge cases. Empty input, single element, all duplicates, negative numbers, integer overflow. Self-trigger these checks before the interviewer asks.
  • Memorized patterns without understanding. Reaching for "sliding window" because the problem mentions a substring, without checking whether the window invariant holds.
  • Premature optimization. Skipping the brute force to look smart. The interviewer wants the brute force as a baseline. It also proves you can solve the problem at all.
  • Silent thinking. Long pauses where nothing comes out of your mouth. The interviewer cannot grade silence. Narrate, even if you say "I am stuck because X — let me try Y".
  • Bad variable names. Using a, b, c, tmp, tmp2 to look fast. Use seen, complement, left, right. Naming is part of the signal.
  • Mutating the input without permission. Sorting the array, popping the stack, modifying the linked list — without telling the interviewer or restoring it.
  • Skipping the trace. Writing 25 lines of code, hitting Run, and seeing it crash. Trace by hand on a 4-element example first.
  • Arguing with the interviewer. When the interviewer pushes back, do not defend the wrong answer. Restate their constraint and ask "is there a property of the input I am not using" — this is almost always the right question.

The One-Page DSA Cheat Sheet for Interviews

If you have ten seconds to pick a structure, read the access pattern and use the default in this table. Justify only if the interviewer asks.

Access Pattern Default Structure Time per Op When to Override
Random access by index Array / slice O(1) Frequent inserts in middle -> linked list
Membership (is X in the set?) Hash set O(1) avg Need sorted order -> balanced BST
Key -> value lookup Hash map O(1) avg Range queries on keys -> balanced BST
FIFO order Queue (deque) O(1) Bounded with priorities -> heap
LIFO order Stack O(1) Need min/max too -> MinStack pattern
Top-K, min, or max in stream Heap (priority queue) O(log n) Static array -> quickselect O(n)
Ordered range queries Balanced BST / skip list O(log n + k) Read-mostly + huge -> B-tree, sorted array
Prefix lookup (autocomplete) Trie O(L) by length Memory tight -> compressed trie or ternary tree
Approximate membership at scale Bloom filter O(k) hashes Need exact -> hash set
Count of distinct elements in a stream HyperLogLog O(1) per insert Small set -> hash set
Disjoint groups, "are X and Y joined?" Union-find (DSU) O(alpha(n)) Need to enumerate group -> adjacency list
Graph traversal (shortest in edges) BFS with queue O(V + E) Weighted edges -> Dijkstra with heap
Graph traversal (any path, cycle check) DFS with stack or recursion O(V + E) Need shortest weighted -> Dijkstra
Sliding range over a sequence Two pointers + counter O(n) Need min/max in window -> monotonic deque
Substring / pattern search Hash, KMP, or rolling hash O(n + m) Many patterns -> Aho-Corasick
Range sum or range update on an array Prefix sum / Fenwick tree O(log n) Range assign -> segment tree with lazy prop
Nearest neighbor in 2D k-d tree O(log n) avg High dimension -> LSH or hash grid
LRU cache Hash map + doubly linked O(1) get/put LFU semantics -> hash + min-heap of counts
Rate limiting Token bucket or sliding log O(1) per request Distributed -> Redis with ZSET
Distributed key routing Consistent hash ring O(log n) lookup Static cluster -> modulo hashing

The interview-day skill is matching the left column to the right column in under five seconds. Everything else — the code, the Big-O, the edge cases — is mechanics that follow from the choice.


Red Flags Interviewers Watch For

These are the moments where the interviewer mentally moves you down a level. They rarely tell you in the room. They tell the hiring committee afterward.

  • You wrote code before asking about input size. Every problem has a different right answer for n=100 vs n=10^9. Not asking signals you treat all problems as the same.
  • You used the word "obviously" for something the interviewer questioned. It is never obvious. If they ask, explain.
  • You confused average and worst case. "Hash map is O(1)" is fine. "Hash map is always O(1)" is wrong. The follow-up "always?" is a trap with one correct answer.
  • You memorized "LRU = hash + linked list" but cannot explain why a single hash map will not work. Memorization without reasoning is a red flag.
  • You wrote a recursive solution and could not state the recursion depth. Recursion depth is the easy first question after "what is the time complexity". Not having the answer suggests you did not think about it.
  • You called the interviewer's pushback wrong. When they say "are you sure", the answer is never "yes, I am sure". The answer is "let me retrace".
  • You tested only the happy path. No empty input, no single element, no duplicates. The interviewer will run those tests themselves and silently grade.
  • You used a library and could not implement it. Reaching for heapq or TreeMap is fine if you can also explain how the structure works internally.

Green Signals Interviewers Watch For

These are the moments where the interviewer mentally moves you up a level.

  • You asked a clarifying question that revealed a trick. "Are the values distinct?" is a small question that often eliminates whole approaches.
  • You stated the Big-O of the brute force before writing it. Proves you can reason without code.
  • You named the trade-off out loud. "I am trading O(n) space for O(n) time" is the sentence senior candidates say without prompting.
  • You traced a 4-element example before submitting. This catches off-by-one and shows discipline.
  • You self-corrected. "Wait, this fails on duplicates — let me adjust." Self-correction is stronger than getting it right the first time.
  • You knew when to stop optimizing. "This is O(n) time and O(n) space. We could do it in O(n) time and O(1) space with two pointers, but only if the array is sorted, which it is not. So O(n) extra space is the right answer." That sentence ends the interview question well.
  • You connected the problem to a real system. "This pattern shows up in deduplication for log ingestion." Concrete application signals seniority.
  • You handled the follow-up. Most "intro to DSA" rounds end with a twist: what if n is one billion, what if the data is streamed, what if memory is bounded. Having a clean answer ready signals you have thought about scale.

Summary

Introduction-to-DSA questions are not testing whether you can sort an array. They are testing whether you can pick a structure for an access pattern, estimate a Big-O without writing code, and narrate the trade-off out loud. The Junior and Middle tables in this file cover the vocabulary. The Senior and Professional tables cover the system-design and formal-reasoning depth. The seven-step walkthrough framework and the rules-of-thumb table are the two things to internalize before the interview. The cheat sheet is the safety net for the moment when you blank out.

If you take one thing from this file, take this: do not write code before you have stated the access pattern out loud. Every other mistake in this document follows from breaking that rule.

Preparation Checklist Before the Interview

  • Re-read this file the morning of the interview, focusing on the cheat sheet and the seven-step framework.
  • Have two behavioral stories rehearsed: one about a data-structure choice that worked, one about a wrong choice you corrected.
  • Solve five problems out loud the day before, narrating in the seven-step format even on problems you already know.
  • Review the "n vs wall-clock" table so you instantly know what n size each Big-O class handles.
  • Practice writing Two Sum (both versions) in your strongest language until you can produce it in under three minutes without thinking.
  • Practice writing it in your weakest language until you can produce it in under six minutes.
  • If applying to a database, infrastructure, or systems role, also rehearse the LRU cache and the sliding-window rate limiter.

What Good Looks Like

The best DSA interviews end with the candidate and the interviewer agreeing on the solution before any code is written. The code is a formality at that point. The reasoning was the interview. If you can make the interviewer nod and say "yes, that is the right approach" before you touch the keyboard, you have already passed.