1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
output should be in zig zag like
1 6 2 3 7 11 16 12 8 4 5 9 13 17 21 22 18 14 10 15 19 23 24 20 25
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
output should be in zig zag like
1 6 2 3 7 11 16 12 8 4 5 9 13 17 21 22 18 14 10 15 19 23 24 20 25
Just to give you something to think about:
The sequence you've described is each of the minor diagonals in reverse order in the subarrays:
[0, 0] [0, 0]
[0, 0] [1, 1]
[0, 0] [2, 2]
. . .
[0, 0] [5, 5]
[1, 1] [5, 5]
. . .
[5, 5] [5, 5]
So you might write a method to find the subarrays and then a method to find the elements in the minor diagonal of the resulting subarrays in reverse order.