Sunday, August 30, 2015

MJ [32] Iterate a nested array (Deep Iterator)

Question:
Write an iterator to iterate a nested array. For example, for given array:
                                          [1,2,[3,[4,5],[6,7],8],9,10] 
call iterator.next() 10 times should return 1,2,3,4,5,6,7,8,9,10.



Dark nodes are of TYPE_NESTED. Numbered nodes are of TYPE_ITEM.
Ref

No comments:

Post a Comment