Goldman Sachs Interview Question

A coding question of leetcode medium difficulty