Pregunta de entrevista de ByteDance

It is a two-pointer rank problem.