Skip to content

Commit e09ecde

Browse files
authored
Merge pull request neetcode-gh#980 from samirangode/samirangode-patch-1
Update 4_Median_of_Two_Sorted_Arrays.cpp
2 parents e8b64bf + 81fbee4 commit e09ecde

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cpp/neetcode_150/05_binary_search/median_of_two_sorted_arrays.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ class Solution {
2121
if (m > n) {
2222
return findMedianSortedArrays(nums2, nums1);
2323
}
24+
if(m==0){
25+
if(n%2==0){
26+
return (nums2[n/2 - 1] + nums2[n/2])/2.0;
27+
}else{
28+
cout<<n/2;
29+
30+
return nums2[n/2];
31+
}
32+
}
2433

2534
int total = m + n;
2635

0 commit comments

Comments
 (0)