Subtracting one arrayList from another arrayList

后端 未结 9 880
无人及你
无人及你 2021-01-01 11:00

I have two arrayLists and I am trying to \"subtract\" one arrayList from another. For example, if I have one arrayList [1,2,3] and I am trying to subtract [0, 2, 4] the resu

9条回答
  •  离开以前
    2021-01-01 11:38

    Your problem is that in your minusArray.remove(...) call you may shrink the size of the minusArray. To fix this, start at array.size() - 1 and count backwards to 0

    Check that - even that won't fix it. You need to reverse the order of your loops

提交回复
热议问题