ION Group Interview Question

Approach of two puzzles (riddles from GeeksforGeeks).