Skip to content

第一题思路一的解有问题 #7

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
gaoyl87 opened this issue Dec 18, 2017 · 1 comment
Closed

第一题思路一的解有问题 #7

gaoyl87 opened this issue Dec 18, 2017 · 1 comment

Comments

@gaoyl87
Copy link

gaoyl87 commented Dec 18, 2017

刚刚开始看leetcode,大家共勉。
第一题思路一
for (int i = 0; i < nums.length; ++i) {
是否应该是 i < nums.length - 1会更好

@Blankj
Copy link
Owner

Blankj commented Dec 18, 2017

不要钻牛角尖啦,那我还能说你每次循环都去算 nums.length -1 还消耗性能呢,我多走一重无效的 for 循环也比你多次运算好吧从最终生成的汇编来说,主要是思路,我也没说我的是最优解,优化得不能再优化,最终 AC 了,那这种思路就是对的,你要是这么钻,那我也没办法。

@Blankj Blankj closed this as completed Dec 18, 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