Skip to content

Commit ac3f8e3

Browse files
authored
Merge pull request #3191 from nsk126/main
Added 1984-minimum-difference-between-highest-and-lowest-of-k-scores.c
2 parents f5546f1 + 6bb3acc commit ac3f8e3

2 files changed

+27
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
int cmp(const void* a, const void* b) {
2+
return *(int*)a - *(int*)b;
3+
}
4+
5+
int min(int a, int b){
6+
if(a > b) return b;
7+
return a;
8+
}
9+
10+
int minimumDifference(int* nums, int numsSize, int k) {
11+
if (k == 1) return 0;
12+
13+
qsort(nums, numsSize, sizeof(int), cmp);
14+
int res = 1e5;
15+
int l = 0;
16+
int r = k - 1;
17+
18+
while (r < numsSize)
19+
{
20+
res = min(res, nums[r] - nums[l]);
21+
l += 1;
22+
r += 1;
23+
}
24+
25+
return res;
26+
}

ruby/1929-concatenation-of-array.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# @return {Integer[]}
33
def get_concatenation(nums)
44
nums + nums
5-
end
5+
end

0 commit comments

Comments
 (0)