Skip to content

Glossary: Coding Interviews in C++

Sort first

A pattern where sorting puts related items next to each other, so comparing neighbors answers "closest", "duplicates" or "group together" questions. It costs O(n log n).

Where the book teaches it

Related terms

std::sort and std::stable_sortMerge intervals