Typical coding interview corner cases
reference
This is by no means an exhaustive list, and there are much better resources out there. It is just what I used when studying as a quick-ref when solving a problem.
Sequences
- Empty sequence
- Sequence with 1 or 2 elements
- Sequence with repeated elements
String
- Empty string
- Single character string
- String with only one distinct character
Tree
- Empty tree
- One or two nodes
- Skewed tree (like a linked list)
Graphs
- Empty graph
- Graph with one or two nodes
- Disjoint graph
- Graph with cycles
Intervals
- Single interval
- Non-overlapping interval
- Interval within an interval
- Duplicate interval
Linked Lists
- One or two nodes
- List has a cycle. Clarify with interviewer
Matrices
- Empty matrix
- 1x1 matrix
- Matrix with only 1 row/column
Links to this note
Having a framework by which you approach every single technical interview greatly improves your chances of success. It can’t help you have a perfect session, but almost guarantees you will...
Size of the input? Range of values? Recursion stack issues. Is the input valid? How should the algorithm behave for corner cases? Can I mutate the input? Generally a bad...
tl;dr; This applies to Big Tech and other companies who are applying similar interviewing strategies. Spend 2 weeks reading “Cracking the Coding Interview” and familiarizing yourself with the process. Sign...