Pergunta de entrevista da empresa Apple

All the questions were easy. Simple pointer chasing or DFS