Unfold a 2-D matrix to a 1-D array in Adaptive zig-zag order, e.g., for matrix
[ 1 2 5 6;
3 4 7 8;
9 10 13 14;
11 12 15 16]
the resulting 1-D array should be
[ 1 5 9 13 2 3 4 6 7 8 10 11 12 14 15 16]
Sorry, the logic of what the problem suggests is not very clear to me. Should the input 2D matrix be broken up in 2-by-2 matrices first, and why?
@Bainhome, I believe your code cannot perform an adaptive zigzag scan of a valid 2x2 matrix due to the conditional statement implemented.
S**t, a euqal sign is forgotten...THX buddy.
What this code done to the index by using union is well-considered. Nice!
Which values occur exactly three times?
The Tower of Hanoi
Given a window, how many subsets of a vector sum positive
Divide by 4
Hilbert Scan Algorithm
Find my secret function IV
Stop a ZigZag scanning N*N Matrix at any diag you want
Who have the chance?
Find the maxmum value of N*N Matrix
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office