rewrite leetcode merge intervals