JPMorganChase interview question

2 hackerrank questions in total.