From 8ee1c939f7193a95bbbdfc46bd3378bd83d8c66e Mon Sep 17 00:00:00 2001 From: Suresh <nsk126@gmail.com> Date: Sat, 30 Dec 2023 22:00:10 +0530 Subject: [PATCH 1/3] Added 1984-minimum-difference-between-highest-and-lowest-of-k-scores.c --- ...e-between-highest-and-lowest-of-k-scores.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 c/1984-minimum-difference-between-highest-and-lowest-of-k-scores.c diff --git a/c/1984-minimum-difference-between-highest-and-lowest-of-k-scores.c b/c/1984-minimum-difference-between-highest-and-lowest-of-k-scores.c new file mode 100644 index 000000000..8b3cd183e --- /dev/null +++ b/c/1984-minimum-difference-between-highest-and-lowest-of-k-scores.c @@ -0,0 +1,26 @@ +int cmp(const void* a, const void* b) { + return *(int*)a - *(int*)b; +} + +int min(int a, int b){ + if(a > b) return b; + return a; +} + +int minimumDifference(int* nums, int numsSize, int k) { + if (k == 1) return 0; + + qsort(nums, numsSize, sizeof(int), cmp); + int res = 1e5; + int l = 0; + int r = k - 1; + + while (r < numsSize) + { + res = min(res, nums[r] - nums[l]); + l += 1; + r += 1; + } + + return res; +} \ No newline at end of file From e557b3b8c2fb6df849575d36a10b4d6c98ca1926 Mon Sep 17 00:00:00 2001 From: Suresh <nsk126@gmail.com> Date: Sun, 31 Dec 2023 12:04:29 +0530 Subject: [PATCH 2/3] Added 1929-concatenation-of-array.rb --- ruby/1929-concatenation-of-array.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 ruby/1929-concatenation-of-array.rb diff --git a/ruby/1929-concatenation-of-array.rb b/ruby/1929-concatenation-of-array.rb new file mode 100644 index 000000000..4b5139c59 --- /dev/null +++ b/ruby/1929-concatenation-of-array.rb @@ -0,0 +1,6 @@ +# @param {Integer[]} nums +# @return {Integer[]} +def get_concatenation(nums) + nums = nums + nums + return nums +end \ No newline at end of file From 440180cc09c231dd65f428dc0e72b03abda688f2 Mon Sep 17 00:00:00 2001 From: Yaseen Khan <kyaseen49@yahoo.com> Date: Sun, 10 Nov 2024 07:37:16 -0700 Subject: [PATCH 3/3] Remove code to prevent merge conflict --- ruby/1929-concatenation-of-array.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ruby/1929-concatenation-of-array.rb b/ruby/1929-concatenation-of-array.rb index 4b5139c59..8b1378917 100644 --- a/ruby/1929-concatenation-of-array.rb +++ b/ruby/1929-concatenation-of-array.rb @@ -1,6 +1 @@ -# @param {Integer[]} nums -# @return {Integer[]} -def get_concatenation(nums) - nums = nums + nums - return nums -end \ No newline at end of file +