Pergunta de entrevista da empresa Databricks

Question was a standard leetcode medium/hard