J.P. Morgan interview question

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