solve clone-graph and merge-intervals