JPMorganChase Interview Question

Typicall SD question and as standard coding problem.