RailYatri Interview Question

Traversing array in different ways