Skip to content

Commit 22814eb

Browse files
authored
Merge pull request #2266 from gourgopal/patch-4
Create 1984-minimum-difference-between-highest-and-lowest-of-k-scores.cs
2 parents aa8ce9d + 0579616 commit 22814eb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class Solution {
2+
public int MinimumDifference(int[] nums, int k) {
3+
int min = Int32.MaxValue;
4+
int l = 0, r = k - 1;
5+
Array.Sort(nums);
6+
while (r < nums.Length) {
7+
min = Math.Min(min, nums[r] - nums[l]);
8+
l++;
9+
r++;
10+
}
11+
return min;
12+
}
13+
}

0 commit comments

Comments
 (0)