If I have the following multidimensional array (of an arbitrary size):
a,b,c
d,e,f
g,h,i
And I'd like to find all possible vertical traversals (adg, adh, aeh, aeg, aei, bdg, etc), how would I go about doing that in Java?
What's making this difficult for me is the fact that the array is of an arbitrary square size (you don't know if its a 2x2
or a 3x3
or 4x4
), so you can't just make N
nested for loops
, where N = length of multidimensional array
. Any help would be great!
Edit: I am defining vertical traversals as either moving down and to the left, directly down, and down and to the right