J.P. Morgan interview question

Leetcode medium and one leetcode easy problem