Goldman Sachs Interview Question

problem using array list of arrray list