Spiral traversal of 2-D array using flag