Skip to content

Interview Prep

Coding & DSA Interview Questions

The concepts behind data-structure and algorithm interview questions — paired with the practice problems that let you actually write the code.

12 of 12 Coding & DSA questions shown. Answers are hidden by default — try each one before revealing it.

  1. 1.On average, what is the time complexity of looking up a value by key in a well-implemented hash table?

    Easy

    hash-tablecomplexity

  2. 2.You need to implement an LRU (least-recently-used) cache whose get and put operations both run in O(1) time. Which combination of data structures achieves this?

    Hard

    data-structuresdesignlinked-list

  3. 3.What is the time complexity of binary search on a sorted array of n elements?

    Easy

    searchingcomplexityarrays

  4. 4.What is the worst-case time complexity of quicksort when the pivot is chosen naively, such as always taking the first element?

    Hard

    sortingcomplexity

  5. 5.Which data structure would you use to perform a level-order (breadth-first) traversal of a binary tree?

    Easy

    treesbfsqueue

  6. 6.You compute the nth Fibonacci number iteratively, keeping only the previous two values in two variables as you loop up to n. What is the auxiliary space complexity?

    Medium

    recursioncomplexitydynamic-programming

  7. 7.Given an array of integers and a target value, how would you find the two numbers in the array that add up to the target? Walk through your approach and give its time and space complexity.

    Easy

    arrayshash-tablecomplexity

  8. 8.Explain how binary search works, and why the input array must be sorted for it to be correct. What happens if you run it on an unsorted array?

    Easy

    searchingarrayscomplexity

  9. 9.How would you check whether a given string is a palindrome, ignoring case and any non-alphanumeric characters? Describe your approach and its time and space complexity.

    Medium

    stringstwo-pointerscomplexity

  10. 10.How would you determine whether a string of brackets — for example '{[()]}' — is balanced? Explain your approach and why a stack is the natural structure for it.

    Medium

    stacksstrings

  11. 11.Given a sentence, how would you reverse the order of the words (not the letters within each word) — for example turning 'the sky is blue' into 'blue is sky the'? Discuss at least two approaches and the trade-offs between them.

    Medium

    stringsarrays

  12. 12.Explain what memoization means and why it changes the time complexity of computing the nth Fibonacci number from exponential to linear.

    Medium

    recursiondynamic-programmingcomplexity

← All interview prep categories