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

Algorithms/AlgorithmsTest/src/Num1_1_04/Num_1_04_11.java #8

Open
lutaoact opened this issue Jun 1, 2017 · 0 comments
Open

Algorithms/AlgorithmsTest/src/Num1_1_04/Num_1_04_11.java #8

lutaoact opened this issue Jun 1, 2017 · 0 comments

Comments

@lutaoact
Copy link
Contributor

lutaoact commented Jun 1, 2017

howMany()方法,在最坏情况下,复杂度为O(n),如果一个数组的所有元素都是指定的可以,那循环就会执行n次。
我觉得正确的做法应该是,参考前一题,先找出最小索引,再找出最大索引,这两个操作都是对数级的复杂度,然后直接就能求出结果。

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

1 participant