Interview Questions/Coding/Median Of Two Sorted Arrays

Median Of Two Sorted Arrays

Preview mode. Log in to edit, run, submit, and save progress.

Hard

Median Of Two Sorted Arrays

Two sorted sensor logs are stored in separate arrays. Without merging them fully, return the median value of all readings together. If the total number of readings is even, return the average of the two middle values.

Examples

Example 1
Input:
1 3
2
Output:
2

Approach hint

The left half of the merged order must contain exactly half the elements.

Common mistake

Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.

solution.cpp