---
# System prepended metadata

title: 04-22

---

# 04-22

## 1

A: [1, 2, 3, 5], size = 4
B: [3, 6, 7, 8], size = 8

output: [1,2,3,3,5,6,7,8]

```java
int[] res = new int[B.size];
int a=0;
int b=0;

int k=0;
for (int i=0; i<A.size; i++) {
    for (int j=0; j<B.size; j++) {
        if (A[i] < B[j]) {
            res[k] = A[i];
            k++;
            break;
        } else {
            res[k] = B[j];
            k++;
            continue;
        }
        
    }
}

for (int i=0; i<B.size; i++) {
    if (i<A.size && A[a]<B[b]) {
        res[i] = A[a];
        a++;
    } else {
        res[i] = B[b];
        b++;
    }
}

return res;
```

## 2
