Skip to main content

Posts

Showing posts with the label Print Spiral

Print Spiral

  Print Spiral Send Feedback For a given two-dimensional integer array/list of size (N x M), print it in a spiral form. That is, you need to print in the order followed for every iteration: a. First row(left to right) b. Last column(top to bottom) c. Last row(right to left) d. First column(bottom to top)  Mind that every element will be printed only once. Refer to the Image: Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. First line of each test case or query contains two integer values, 'N' and 'M', separated by a single space. They represent the 'rows' and 'columns' respectively, for the two-dimensional array/list. Second line onwards, the next 'N' lines or rows represent the ith row values. Each of the ith row constitutes 'M' column values separated by a single space. Output format : For each test case, print the elements of the tw...