A fast but obscure code:
SeedRandom[1];
pairs = RandomInteger[100, {1000000, 2}];
Unitize[pairs[[2 ;;, 1]] - pairs[[;; -2, 2]] - 1] //
SparseArray[#, Automatic, 1]["AdjacencyLists"] & //
Function[adj,
Switch[Length@adj,
0, {} -> ArrayReshape[pairs, Insert[Dimensions@pairs, 1, 2]],
1, {pairs[[First@adj ;; First@adj + 1]]},
_, (pairs[[Span @@ (# + {1, 2})]] & /@
MaximalBy[
Transpose@{adj[[Prepend[# + 1, 1]]], adj[[Append[#, -1]]]} &@
SparseArray[Differences@adj, Automatic, 1][
"AdjacencyLists"] - 1, -Subtract @@ # &])
]
] // AbsoluteTiming
(*
{0.026446,
{{{0, 69}, {70, 62}, {63, 21}, {22, 3}},
{{9, 9}, {10, 31}, {32, 49}, {50, 72}}}}
*)
MaximalBy[
Split[
pairs,
(#2[[1]] - #1[[2]] == 1) &],
Length] // AbsoluteTiming
(*
{1.05492,
{{{0, 69}, {70, 62}, {63, 21}, {22, 3}},
{{9, 9}, {10, 31}, {32, 49}, {50, 72}}}}
*)