Skip to content

Commit b7c824d

Browse files
authored
Create minimum-difference-between-highest-and-lowest-of-k-scores.py
1 parent 621f25e commit b7c824d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(nlogn)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def minimumDifference(self, nums, k):
6+
"""
7+
:type nums: List[int]
8+
:type k: int
9+
:rtype: int
10+
"""
11+
nums.sort()
12+
return min(nums[i]-nums[i-k+1] for i in xrange(k-1, len(nums)))

0 commit comments

Comments
 (0)