Pregunta de entrevista de Confluent

A leetcode medium question during the first round.