ION Group interview question

Approach of two puzzles (riddles from GeeksforGeeks).