Skip to content

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

Description

@KalvenDebig

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions