IBM Interview Question

Couple of algorithm questions were asked me