The answer will depend on the size of the matrix.. right?
On Saturday, April 27, 2013 8:22:00 PM UTC+5:30, ASK wrote:
Hi all,
I was asked this question in Amazon interview.
There is a matrix suppose(3x4). And I traverse through each position only
once in spiral movement like (0,0),(0,1),
I donno the optimized answer...but yea the for loop answer depends on size
of matrix. Here is the answer of normal spiral movement
public void PrintInSpiral(int [][] numbers, int size)
{
for(int i = size ā 1 , j = 0 ; i = 0 ; iā, j++)
{
for(int k = j ; k i; k++)*
Console.Write(numbers[j][k]+ );