Skip to content

Commit

Permalink
0004_Solved
Browse files Browse the repository at this point in the history
0004_Solved
  • Loading branch information
WAcry authored May 9, 2020
1 parent bcacf82 commit 74f1537
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ nums2 = [3, 4]

首先我们可以只考虑数字总个数为奇数的情况让我们看下下图

![](../Animation/image1.png)
![](../Animation/image1.PNG)

蓝框是中位数左边的数包括中位数),而橘框则为中位数右边的数

3个显然的规则
1.两个数组的蓝框总个数=(数字总个数+1)/2;
2.所有蓝框内的数都小于橘框内的数
3.中位数为蓝框中最大的那一位即数组1蓝框最后一位或数组2蓝框最后一位
![](../Animation/image2.png)
![](../Animation/image2.PNG)
如图我们要找到一组AB满足上面3条规则
对于规则1我们在数组1中找任意A然后根据规则1就能推算出对应的B的位置
对于规则2由于数组1和2都是有序数组即X1<A<Y1;X2<B<Y2我们实际上只需要判断A是否小于Y2以及B是否小于Y2
Expand Down

0 comments on commit 74f1537

Please sign in to comment.