Update LongestConsecutive.cpp

fix a problem of not stopping.