JPMorganChase Interview Question

Coding question on hacker rank, probably Leetcode easy to medium