MCPcopy Index your code
hub / github.com/Tiwarishashwat/InterviewCodes / merge

Method merge

MergeWithoutExtraSpace.java:2–17  ·  view source on GitHub ↗
(int arr1[], int arr2[], int n, int m)

Source from the content-addressed store, hash-verified

1class Solution {
2public void merge(int arr1[], int arr2[], int n, int m) {
3int i = 0, j = 0, k = n - 1;
4 while (i <= k && j < m) {
5 if (arr1[i] < arr2[j])
6 i++;
7 else {
8 int temp = arr2[j];
9 arr2[j] = arr1[k];
10 arr1[k] = temp;
11 j++;
12 k--;
13 }
14 }
15 Arrays.sort(arr1);
16 Arrays.sort(arr2);
17 }
18 }

Callers

nothing calls this directly

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected