Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public void merge(int A[], int m, int B[], int n) {
- int index = m + n -1;
- int a = m - 1;
- int b = n - 1;
- while(a >= 0 && b >=0){
- if(A[a] > B[b]){
- A[index] = A[a];
- a--;
- index--;
- }else{
- A[index] = B[b];
- b--;
- index--;
- }
- }
- if(a < 0){
- while(index >= 0){
- A[index] = B[b];
- b--;
- index--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement