J.P. Morgan Interview Question

data structures and algorithms, leet code easy/ easy-medium