J.P. Morgan interview question

Leetcode easy for the hackerrank