Pregunta de entrevista de TikTok

Algorithm coding related question specifically.