From e8f6162edbec75bee5dc41913d28867ad7301e5f Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Sun, 19 Nov 2023 12:05:04 +0530 Subject: [PATCH 1/3] feat: add cs solution to lc problem: No.1887 --- .../Solution.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/Solution.cs diff --git a/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/Solution.cs b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/Solution.cs new file mode 100644 index 0000000000000..f425272f08370 --- /dev/null +++ b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/Solution.cs @@ -0,0 +1,13 @@ +public class Solution { + public int ReductionOperations(int[] nums) { + Array.Sort(nums); + int ans = 0, up = 0; + for (int i = 1; i < nums.Length; i++) { + if (nums[i] != nums[i - 1]) { + up++; + } + ans += up; + } + return ans; + } +} From 6d43c58f83127d963024544426eb45ad4ad9b507 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Sun, 19 Nov 2023 12:07:33 +0530 Subject: [PATCH 2/3] Update README_EN.md to lc problem: No.1887 --- .../README_EN.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README_EN.md b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README_EN.md index 93780a3955faf..f050c24969e09 100644 --- a/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README_EN.md +++ b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README_EN.md @@ -183,6 +183,24 @@ func reductionOperations(nums []int) int { } ``` +### **C#** + +```cs +public class Solution { + public int ReductionOperations(int[] nums) { + Array.Sort(nums); + int ans = 0, up = 0; + for (int i = 1; i < nums.Length; i++) { + if (nums[i] != nums[i - 1]) { + up++; + } + ans += up; + } + return ans; + } +} +``` + ### **...** ``` From 26a0b18640cc1770c1a6cd465e40cd161b854d46 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Sun, 19 Nov 2023 12:08:12 +0530 Subject: [PATCH 3/3] Update README.md to lc problem: No.1887 --- .../README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README.md b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README.md index e4b95b4e4d250..d951f83323901 100644 --- a/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README.md +++ b/solution/1800-1899/1887.Reduction Operations to Make the Array Elements Equal/README.md @@ -201,6 +201,24 @@ func reductionOperations(nums []int) int { } ``` +### **C#** + +```cs +public class Solution { + public int ReductionOperations(int[] nums) { + Array.Sort(nums); + int ans = 0, up = 0; + for (int i = 1; i < nums.Length; i++) { + if (nums[i] != nums[i - 1]) { + up++; + } + ans += up; + } + return ans; + } +} +``` + ### **...** ```