It's not "iterating and removing".
It's "iterating, removing and adding".
That's why the cached index remains valid.
why not? I like this solution?
Can you explain why iterating and removing items from the array is bad practice?
My solution is pretty similar to this.
Iterating from the end... Yep, that's clever)
Debatable, this solution does win in space complexity.
You shouldn't iterate through an array and remove from it at the same time, even if doing it from the end works.
well i guess you can't be blamed. the tests don't enforce immutability.
A couple of things that would make this kata more fun:
Test.assertSimilar(actual, expected, msg)
This comment is hidden because it contains spoiler information about the solution