Unverified Commit 74f15372 authored by Ziyuan Zhang's avatar Ziyuan Zhang Committed by GitHub
Browse files

0004_Solved

0004_Solved
parent bcacf826
......@@ -31,7 +31,7 @@ nums2 = [3, 4]
首先,我们可以只考虑数字总个数为奇数的情况。让我们看下下图:
![](../Animation/image1.png)
![](../Animation/image1.PNG)
蓝框是中位数左边的数(包括中位数),而橘框则为中位数右边的数。
......@@ -39,7 +39,7 @@ nums2 = [3, 4]
1.两个数组的蓝框总个数=(数字总个数+1)/2;
2.所有蓝框内的数都小于橘框内的数
3.中位数为蓝框中最大的那一位(即数组1蓝框最后一位,或数组2蓝框最后一位)
![](../Animation/image2.png)
![](../Animation/image2.PNG)
如图,我们要找到一组A,B,满足上面3条规则。
对于规则1,我们在数组1中找任意A,然后根据规则1就能推算出对应的B的位置。
对于规则2,由于数组1和2都是有序数组,即X1<A<Y1;X2<B<Y2。我们实际上只需要判断A是否小于Y2,以及B是否小于Y2。
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment