J.P. Morgan interview question

Leetcode easy and medium. Random tech questions