Skip to content

004题目的疑问 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LomoLin opened this issue Dec 10, 2017 · 1 comment
Closed

004题目的疑问 #5

LomoLin opened this issue Dec 10, 2017 · 1 comment

Comments

@LomoLin
Copy link

LomoLin commented Dec 10, 2017

你好,在算法004的题目中,既然是两个已经排序好的数组中,要取这两个数组的中位数,为什么不直接去第一个数组的中位数,再去第二个数组的中位数,最后取这两个中位数的平均值,不就是结果了吗?感觉看004的算法有点复杂。我这样的算法是否有什么问题,还望告知,谢谢!

@Blankj
Copy link
Owner

Blankj commented Dec 10, 2017

那你是想太少了,比如 {1}{1, 2} 你的结果对吗,而且题目要求时间复杂度是 O(log (m+n))

@LomoLin LomoLin closed this as completed Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants