Thoughtworks Interview Question

Some hard Puzzles were asked