Need an efficient algorithm solve this kind of complex structure

Posted by Rizvan on Stack Overflow See other posts from Stack Overflow or by Rizvan
Published on 2012-06-21T14:14:08Z Indexed on 2012/06/21 15:16 UTC
Read the original article Hit count: 108

Problem Statement is :

Given 2 Dimensional array, print output for example

If 4 rows and 6 columns, output would be:

        1    2    3    4    5    6 
        16   17   18   19   20   7
        15   24   23   22   21   8
        14   13   12   11   10   9

I tried it is looking like square within square but when I attempted this problem, I put so many while and if loops but didn't got exact answer. If row and columns increases how to handle it?

This is not homework. I was learning solving complex structure so I need to understand it by some guidance.

© Stack Overflow or respective owner

Related posts about java

Related posts about c