Fidessa interview question

2 fairly easy algorithm questions.