Intuit interview question

leetcode medium hard question was asked.