Coding

Merge two sorted arrays into one sorted array.

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge them into a single array sorted in non-decreasing order.

Input: nums1 = [0], m = 0, nums2 = [1], n = 1

Output: [1]

Explanation: Since nums1 is initially considered empty (m=0), it is completely overwritten by the single element from nums2.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions