Printing the snake pattern in matrix is one of the basic problems . In various companies this question is asked how can you print the Snake pattern . Look the image below , this is how a snake pattern look.
First of all we traverse the row from left to right , but second time we traverse the row from right to left. Then left to right and we keep doing this until we traverse each row .
So we have implemented a java code to do this task.
Output : 1,2,3,4,5,4,3,7,5,2,0,3,1,5,6,4,9