Pergunta de entrevista da empresa Nextdoor

Sorting question, basic leetcode problem