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

658.Find-K-Closest-Elements - boundary move explanation needed #103

Open
KalvenDebig opened this issue Aug 1, 2024 · 1 comment
Open

Comments

@KalvenDebig
Copy link

这里为什么不用abs(x - nums[mid]) 和 abs(x - nums[mid + k]), 而是选择用 x - nums[mid] 和 nums[mid + k] - k。
虽然说对于x 在递增数组范围外的情况是可以给到正确答案的,但是有点counter intuitive。希望能有解释。

@yangizone
Copy link

yangizone commented Aug 1, 2024 via email

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