solution for merge sorted array