This problem is based on an Apple interview problem described here.
Two sorted integer arrays are given. Print twice their combined median.
For an odd total length, print 2 * median.
0≤n,m≤200000
1≤n+m
Arrays are sorted in nondecreasing order
−109≤value≤109
nma1⋯anb1⋯bm
one integer: twice the combined median
1. Determine Combined Array Composition:∙ Input Array A=[1,3],B=[2]∙ Combined Sorted State =[1,2,3]⟹Total Elements (N+M)=3(Odd)2. Median Extraction & Scale Calculation:∙ Exact Middle Position Index =⌊3/2⌋=1∙ Median Element Value =2∙ Twice the Median =2×2=4Output: 4
1. Determine Combined Array Composition:∙ Input Array A=[1,2],B=[3,4]∙ Combined Sorted State =[1,2,3,4]⟹Total Elements (N+M)=4(Even)2. Median Extraction & Scale Calculation:∙ Left-Center Element Value (Index 1) =2∙ Right-Center Element Value (Index 2) =3∙ Standard Combined Median Value =(2+3)/2=2.5∙ Twice the Median =2×2.5=2+3=5Output: 5