Pregunta de entrevista de Meta

LC M Questions but cant use window function to solve.