Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update 3. 数组中重复的数字.md #1418

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

Open
gyl1041 wants to merge 1 commit into CyC2018:master
base: master
Choose a base branch
Loading
from gyl1041:master

Conversation

@gyl1041
Copy link

@gyl1041 gyl1041 commented Jun 10, 2025

这里第二次调用是多余的!
duplicate 中每一次for循环的目的都是为了让 nums[i] == i ,也就是第 i 个位置等于 i 。 所以 while 循环要么找到重复数字return,要么结束循环后使得 nums[i] == i ,这时候再调用 swap(nums, i, nums[i]) 没有任何意义

这里第二次调用是多余的!
duplicate 中每一次for循环的目的都是为了让 nums[i] == i ,也就是第 i 个位置等于 i 。
所以 while 循环要么找到重复数字return,要么结束循环后使得 nums[i] == i ,这时候再调用 swap(nums, i, nums[i]) 没有任何意义
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /