DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
hard
Binary Search

Median of Two Sorted Arrays

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Median of Two Sorted Arrays** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Binary search on shorter array partition **Edge Cases to Consider:** - (1) One array empty - (2) Arrays of different sizes - (3) All elements of one array smaller

Examples

Example 1
Input: [1,3], [2]
Output: 2.0
Explanation: Odd total
Example 2
Input: [1,2], [3,4]
Output: 2.5
Explanation: Even total
Example 3
Input: [0,0], [0,0]
Output: 0.0

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪One array empty
  • ▪Arrays of different sizes
  • ▪All elements of one array smaller
Frequently Asked At
GoogleAmazonMicrosoftMetaFlipkart