rewrite leetcode merge sorted array