Pregunta de entrevista de Databricks

Leetcode type, with runtime follow up.