KFintech Interview Question

2 puzzles based on ds