The slight memory increase in the second version comes from extra temporary variables and iterator handling inside the loop. While no extra heap memory is allocated, the compiler uses more stack or register space, causing marginally higher usage. The difference is very small and likely due to normal runtime variation.