Hard problem. Exercise for union-find. Almost done by myself, with help of union-find by Robert Sedgewick and Kevin Wayne.
Problem
128. Longest Consecutive Sequence
Java
union–find
© 1.5 Case Study: Union-Find Copyright © 2000–2019 Robert Sedgewick and Kevin Wayne. All rights reserved.
1 | class Solution { |
Submission Detail
- 68 / 68 test cases passed.
- Runtime: 8 ms, faster than 23.72% of Java online submissions for Longest Consecutive Sequence.
- Memory Usage: 40.8 MB, less than 8.62% of Java online submissions for Longest Consecutive Sequence.