As reported: Oracle Fusion HCM Senior Application Engineer (Hyderabad), round 1 (in person), Apr 2025 — the first of three questions: arrange two arrays without extra space so that
A = [10,2,20,-1],B = [1,5,25]becomeA = [-1,1,2,5],B = [10,20,25].
Given two integer arrays a (length n) and b (length m), rearrange their elements in place so that, reading a from start to end and then b from start to end, all n + m values are in non-decreasing order. Each array keeps its length. Use only O(1) extra space — no merged copy.
Example 1
a = [10,2,20,-1], b = [1,5,25]
Output: a = [-1,1,2,5], b = [10,20,25]
Example 2
a = [1,5,9,10,15,20], b = [2,3,8,13]
Output: a = [1,2,3,5,8,9], b = [10,13,15,20]
Constraints: 1 ≤ n, m ≤ 10^4; -10^9 ≤ a[i], b[i] ≤ 10^9.
Code runner format: one JSON value per line — a, then b. Implement arrange(a, b); it modifies both arrays, and the harness prints [a, b].