79698639

Date: 2025-07-11 16:54:36
Score: 1
Natty:
Report link

Because you're deleting the element and then immediately adding the same element back during the forEach loop, the Set gets modified in a way that causes the added element to be treated as a new item to iterate. Since foreach continues iterating over newly added elements during the same loop, this creates an infinite cycle: the element gets re-added, queued for iteration again, and the loop never ends, leading to a dead loop or infinite loop.

Reasons:
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Md. Okiluzzaman Talukder