Data structures and algorithms questions commonly asked in frontend engineering interviews. Master the fundamentals with interactive explanations.
Showing 32 of 32 questions
Always state time AND space complexity of your solution
Learn more →Know complexities of common operations (array access, hash lookup, sort)
Learn more →Use n & (n - 1) to clear the lowest set bit
Learn more →XOR cancels pairs: a ^ a = 0, a ^ 0 = a
Learn more →Arrays are great when you need index-based access
Learn more →For frequent front operations, consider a deque or linked list
Learn more →Hash maps often turn O(n²) brute force into O(n)
Learn more →When you need "have I seen this before?", think hash set
Learn more →When you see nested structures or matching pairs, think stack
Learn more →DFS (depth-first search) can use explicit stack or recursion
Learn more →BFS = Queue, DFS = Stack (or recursion)
Learn more →BFS finds shortest path in UNWEIGHTED graphs
Learn more →State graph representation first in your first 30 seconds
Learn more →Start with BFS or DFS on brute structure before optimizing
Learn more →Always start word problems by clarifying alphabet and case rules
Learn more →If many strings exist and queries are prefixes, start with a trie
Learn more →Draw the pointers! Visualize before coding
Learn more →Use dummy head node to simplify edge cases
Learn more →Start by clarifying whether you need smallest-first or largest-first
Learn more →Explain why repeated global selection is exactly what heaps optimize
Learn more →Start with a DFS template before adding logic
Learn more →Use level-by-level reasoning for BFS questions
Learn more →State the state of one recursive call before moving to the next
Learn more →Write base case first, then recursion, then combine
Learn more →You rarely implement sort from scratch — but you MUST understand partition logic
Learn more →When you see intervals, pairs, or "closest/largest" — think sort first
Learn more →When you see "contiguous subarray" or "substring" with an optimization goal, think sliding window
Learn more →Ask yourself: is the window size fixed or variable? This determines your template
Learn more →Draw decision tree first; label "choose / skip" branches
Learn more →Track exactly what is part of current path state
Learn more →Start by identifying the subproblem: what decision is being made at each step?
Learn more →Write the brute-force recursive solution first, then add memoization, then convert to tabulation if needed
Learn more →