InterviewSam
Tech TracksStudySystem DesignAptitudeDaily Quiz
Log inStart free
Tech TracksStudySystem DesignAptitudeDaily Quiz
All topics

Arrays & Hashing

Store, look up and count data in O(1): the base of most coding interviews.

6 pages, free to read

Start studying
  1. 1

    Arrays & dynamic arrays

    Beginner

    An array stores items side by side in memory so any index is reachable in O(1); a dynamic array adds automatic resizing so appends are O(1) on average.

    9 min read
  2. 2

    Hash maps & hash sets

    Beginner

    A hash map turns a key into an array index with a hash function, giving O(1) average insert, delete and lookup; a hash set is the same structure storing keys only.

    10 min read
  3. 3

    Prefix sums

    Intermediate

    Precompute running totals once in O(n) so the sum of any range is a single subtraction in O(1).

    10 min read
  4. 4

    Counting & frequency maps

    Beginner

    Count how often each value appears in one O(n) pass, then answer anagram, duplicate, majority and top-k questions from the counts.

    8 min read
  5. 5

    2D arrays & matrix traversal

    Intermediate

    A matrix is a grid of rows and columns; most grid questions come down to visiting cells in the right order and stepping to neighbours with a direction list and a bounds check.

    10 min read
  6. 6

    In-place array tricks

    Intermediate

    Solve array problems with O(1) extra space by swapping, reversing, and using the array's own indexes and signs as storage.

    10 min read