Comments

This is what I did and the tests passed. I guess you didn't apply the idea for each connected component.