Interview in a few hours?

Brush up before you log in.

Fast recall cards, focused search, and just enough detail to refresh the right answers before the interview starts.

Clear

Results update as you type. Press / to jump straight into search.

All revision cards

49 cards

Coding Exercises Easy O(n * m)

Longest Common Prefix

Shrink the candidate prefix until every string starts with it. If it becomes empty, there is no shared prefix.

Return the longest common prefix shared by all strings in a list.

Coding Exercises Medium O(n)

Longest Consecutive Sequence

Put all numbers in a set, then expand sequences only from values whose previous number is absent. That avoids re-counting the same streak multiple times.

Return the length of the longest consecutive sequence in an unsorted array.

Coding Exercises Medium O(1)

LRU Cache

Store items in an OrderedDict, move keys to the end whenever they are read or updated, and evict the oldest item when capacity is exceeded.

Implement an LRU cache with O(1) get and put operations.

Coding Exercises Easy O(n)

Majority Element

Track a running candidate and increment or decrement a counter as you scan. When the counter drops to zero, start fresh with the current value as the new candidate.

Return the element that appears more than n // 2 times in an array.

Coding Exercises Medium O(n log n)

Merge Intervals

Sort intervals by start, then compare each interval with the current merged tail. Extend the tail end when ranges overlap; otherwise append a new interval.

Merge all overlapping intervals and return the condensed list.