Goldman Sachs Interview Question

leedcode question, data structure, and algorithms