KFintech interview question

2 puzzles based on ds