Example:Input: A[] = {1, 4, 5}, B[] = {2, 3} Output: 3 Explanation: Merging both the arrays and arranging them in ascending: [1, 2, 3, 4, 5] Hence, the median is 3
Merge both sorted arrays A and B into a new auxiliary array & find the median, either by selecting middle element in an odd-length array or taking the mean of the two middle elements in an even-length array.
Since both arrays are sorted, a binary search approach can be employed. The binary search allows us to eliminate parts of the arrays that do not contribute to the answer.