I just want to share my idea that we can translate the problem 13.11 (find the longest contained interval or longest consecutive sequence) into a graph problem as follows:
Each number in the array corresponds to a node on a graph (or a number line) so that adjacent number nodes are connected. The longest contained interval is the maximum number of connected nodes (or longest segment) on the graph.
How to solve:
Add all node to an unvisited hash table (for fast lookup)
For each node
If the node is not visited
Mark the node as visited
Explore all the connected nodes by DFS/BFS
Update the maximum number of the connected nodes
Return the maximum of connected nodes