JPMorganChase Interview Question

2 hackerrank questions in total.