Skip to content
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

练习1_4_11 #4

Open
tomleung1996 opened this issue Mar 5, 2017 · 1 comment
Open

练习1_4_11 #4

tomleung1996 opened this issue Mar 5, 2017 · 1 comment

Comments

@tomleung1996
Copy link

您用的方法是先找出最小下标,然后再递增下标直到数组值不再等于key,但是极端情况下,比如整个数组都是同一个数,那这样的方法的时间复杂度就是N了吧(题目要求的是logN)

我想是不是可以利用您在上一题中使用的找最小下标的方法,稍微改一下符号,再写一个找最大下标的方法,这样配合的话极端情况下时间复杂度就可以与logN成正比了

(我是初学者,如果说的不对请见谅)

@xiaoyuzdy
Copy link
Owner

很长时间没碰这个了,你自己看看吧,我当初写这个的时候也是菜逼,所以答案仅供参考。如果你的目标是校招进BAT这样的一线公司,这本书是远远不够的,一定要多刷题

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