Databricks Interview Question

Question was a standard leetcode medium/hard