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

27[快慢指针](盲人摸硬币) #9

Open
happysmile12321 opened this issue Feb 22, 2024 · 0 comments
Open

27[快慢指针](盲人摸硬币) #9

happysmile12321 opened this issue Feb 22, 2024 · 0 comments

Comments

@happysmile12321
Copy link
Owner

happysmile12321 commented Feb 22, 2024

很久很久以前,有一个国王,他命令手下的人铸金币。
但是他不知道手底下的人偷奸耍滑了没,
这个时候他将所有硬币放在一个桌子上,想让人把劣币给丢掉。
这个时候来了个盲人,他左手在最左边,右手放在左边第一个硬币上,就这样,右手一个一个地检验硬币的重量。
右手摸到一个良币,他先讲左手往右移一个单位,再把右手的硬币交给左手,然后右手再往右移动,直到右手摸完所有硬币。
如果是劣币,就左手就暂时不移动,这时,摸到的下一个良币就会把劣币给挤下桌子。结束后,左手包括它左边的都是良币,其余都是劣币。右手直接放到左手上,往右将硬币都推下桌。

@happysmile12321 happysmile12321 changed the title 27 27[快慢指针](盲人摸硬币) Feb 23, 2024
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