Like in the title, say I want to expand it by 4, then I should get 2 new A, 1 new B, 1 new C, and the expanded array will be:
[A,A,A, B,B, C,C]
My code kind of works 'till the delta newArray-oldArray is <= of the size of the old array. After that threshold, the insert() function would append out-of-bounds-Zeroes for the rest of the loop.
i[]@array = {1,2,3,4,5}; int count; for(int i=0; i<10; i++) { count = i % len(i[]@array); insert(i[]@array, count+=i , i[]@array[count]); } // return: [ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Any idea how to make it work?
Thanks a lot!