Databricks interview question

Medium Leetcode Question with open answer