IBM interview question

Puzzle solving