Databricks interview question

traditional leet code style problem