cpp implementation of Longest Consecutive Sequence