Fidessa Interview Question

2 fairly easy algorithm questions.