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

旋转数组三个值一样的情况,应该直接return吧? #19

Open
gospel303 opened this issue Jul 25, 2019 · 0 comments
Open

旋转数组三个值一样的情况,应该直接return吧? #19

gospel303 opened this issue Jul 25, 2019 · 0 comments

Comments

@gospel303
Copy link

            elif rotateArray[mid] == rotateArray[front] and rotateArray[front] == rotateArray[rear]:
                for i in range(1, len(rotateArray)):
                    if rotateArray[i] < minVal:
                        minVal = rotateArray[i]
                        rear = i

这一段代码,mid,front,rear的值都一样之后,遍历整个数组找出最小值了,应该就直接return吧,怎么又进循环了。这里又多循环几次,切到只剩两个数了才出循环,不是做白工了吗。第一次就已经在整个list里遍历了一遍,找出最小值了,再循环没意义啊。

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