Skip to content

Commit aad9432

Browse files
author
Rich Vigorito
committed
add solution to leetcode 88
1 parent 4b4df32 commit aad9432

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

leetcode/src/88.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
3+
4+
5+
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n) {
6+
int i = m - 1;
7+
int j = n - 1;
8+
int k = m + n - 1;
9+
10+
while (i >= 0 && j >= 0) {
11+
if (nums1[i] > nums2[j]) {
12+
nums1[k--] = nums1[i--];
13+
} else {
14+
nums1[k--] = nums2[j--];
15+
}
16+
}
17+
18+
while (j >= 0) {
19+
nums1[k--] = nums2[j--];
20+
}
21+
}
22+
23+
24+

0 commit comments

Comments
 (0)