Below our existing code, we added a correct implementation using lists, which is much
slower than our current implementation. Our earlier version of the code using lists
failed because we were changing the length of the list as we were iterating over
it using a for-loop. We fixed this issue by creating a copy of the original list
and mutating only the copy.