今際の国の呵呵君
Monday, September 24, 2018
[LeetCode]Smallest Range I
这道题没什么好说的,算出当前数组的最大最小值之差diff。如果2 * K >= diff,我们可以完全把这个差值抹为0,否则就为diff - 2 * K。时间复杂度O(N),代码如下;
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment