我希望数组列表在迭代过程中发生变化和变化。 本质上,当我从数组中删除元素时,要遍历整个数组而不是遍历其索引。
========================================
例:
- Loop condition - Remove current element
if(current element + next element)%2 == 0
- And stop iteration once the array length is < 3
- Array to work on -
4, 2, 13, 15, 8, 6, 7
第一次迭代后,我得到了。
2, 15, 6, 7
现在我们在此副本上运行迭代
经过第二次迭代,我得到了。
2, 21, 7
现在我们在此副本上运行迭代
经过第三次迭代,我得到了。
2, 7
返回此数组。
========================================