 <p>You increment <code>it</code> up to three times in the loop, before comparing against the end.</p> <p>You erase without saving the new iterator.</p> <p>Lots of side-effects.</p> <p>The ordering of <code>if(*it == *(--it)) {</code> isn't defined, so you might end up comparing an element against itself. (<code>==</code> isn't a sequence point, so <code>*it</code> and <code>*(--it)</code> can be evaluated in either order).</p> <p>You don't check for <code>tableAndHand</code> being empty - you increment <code>it</code> before checking.</p>