Arrays, strings and hash maps interview questions

Hash sets and maps for seen-before checks, complements, counting keys and prefix sums; in-place array tricks; what lists and dicts really cost.

5 quick facts

– interview-ready · 14 questions in this topic

– of 14 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. Spot the first repeated badge at the doorPredict
  2. Two gift prices that hit the budget exactlyFill the blank
  3. Group tile racks that hold the same lettersPredict
  4. Count sales stretches that add up to a targetPredict
  5. Longest run of consecutive ticket numbersPick the fix
  6. Find the value that fills more than half the listPredict
  7. Each shelf's product of all the other shelvesSpot the bug
  8. Shift a playlist k places to the right, in placeOrder the steps
  1. First order code that appears only oncePredict
  2. Find the balance point of a seesawFill the blank
  3. How a hash map keeps lookups fast on averagePick the fix
  4. Why appending to a list is amortized O(1)Predict
  5. What makes a good dictionary keyPredict
  6. Count or sort: choosing a frequency toolPredict

Practise this topic

Flashcards · 24

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 14 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Fix this PR · 1 review

Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Topic outline informed by the Tech Interview Handbook by Yangshun Tay and the NeetCode 150 pattern grouping by neetcode-gh, both MIT licensed. Every problem, solution and explanation is written by Best Latest Apps. Credits and license