Problem Statement
Given two sorted arrays arr1[] of size N and arr2[] of size M. Each array is sorted in non-decreasing order. Merge the two arrays into one sorted array in non-decreasing order without using any extra space.
Pattern: Pattern 2 values in 1 variable
Gap Solution
Also the Shell Sort intuition
- Maximum Subarray Sum | Leetcode | Kadane’s Algorithm | Brute-Better-Optimal | CPP/Java - YouTube
- Efficiently merging two sorted arrays with O(1) extra space - GeeksforGeeks
O(mlogm + nlogn)