J.P. Morgan Interview Question

2 coding assignments from HackerRank. First one was very easy, second was a little more complicated.