JPMorganChase interview question

2 Programming Tasks, somewhat difficult