Concept Flow - Merge Two Sorted Arrays Without Extra Space
Start with two sorted arrays A and B
Compare last element of A with first element of B
If A's last > B's first
Swap elements
Sort B
Repeat comparison until no swaps
Done: Both arrays sorted and merged
We repeatedly compare the largest element of the first array with the smallest of the second. If out of order, we swap and then sort B. Repeat until no swaps are needed. Finally, sort A.
