読者です 読者をやめる 読者になる 読者になる

Merge two sorted arrays

Merge Sort Cracking The Coding Interview

Problem

You are given two sorted arrays, A and B, where A has large enough buffer at the end to hold B. Write a method to merge B into A in sorted order

How to Solve

By merging two arrays like merge sort, we can achieve the goal. Since A has enough buffer at the end, we traverse the arrays from end to start.