Merge Sorted Array

Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.

Topic refresher: Arrays — Index Thinking

Treat every array problem as: What do I know at index i? What must I remember from the past?

// Running best pattern
int best = nums[0];
for (int i = 1; i < n; i++) {
    // update state using nums[i]
    best = max(best, candidate);
}
return best;
Arrays

Merge Sorted Array

Easy
LeetCode
11/14
EasyArraysLeetCode #88

Merge Sorted Array

Merge nums2 into nums1 (size m+n) in-place. Fill from the back so you don't overwrite.

Examples

Example 1

Input

3 3
1 2 3
2 5 6

Output

1 2 2 3 5 6
Example 2

Input

1 0
1

Output

1

Stuck? Take a nudge

C++17