trivial problem. similar to merge sorted array.