79424173

Date: 2025-02-09 01:06:49
Score: 1
Natty:
Report link

You can modify the array in-place while iterating by keeping an index pointer (i). When you encounter an element that should be moved to the end:

  1. Remove it using remove(at:)
  2. Append it to the end of the array.
  3. Do not increment the index (i) in this case, since a new element has replaced the removed one at the same index.
Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: K.pen