Hi,
See, your code is running in follwoing manner:
1. Go to first for loop: size of list is 4 and value of i =0.
2. First Attampt: In for loop i < l.size() means 0<4, condition is true go to inside loop and remove "0" from the list and "1" moved to 0th location of the list, now value of list is 3 and i is 1.
Second Attampt: Again go to inside loop and remove "2" because "2" on the 1st position, and then "3" moved to 1th location and then i is 2 and size of list is 2 then condition is false.