Pergunta de entrevista da empresa TikTok

Algorithm coding related question specifically.