From dc2b0cc40cb24ffd644c125ac1304b1d535655e3 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Fri, 17 Nov 2023 22:24:58 +0530 Subject: [PATCH 1/3] feat: add cs solution to lc problem: No.1877 --- .../Solution.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/Solution.cs diff --git a/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/Solution.cs b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/Solution.cs new file mode 100644 index 0000000000000..8cf09c4e28549 --- /dev/null +++ b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/Solution.cs @@ -0,0 +1,10 @@ +public class Solution { + public int MinPairSum(int[] nums) { + Array.Sort(nums); + int ans = 0, n = nums.Length; + for (int i = 0; i < n >> 1; ++i) { + ans = Math.Max(ans, nums[i] + nums[n - i - 1]); + } + return ans; + } +} From 2141ea4850fdd67d1598f4047397d4f9d51ced58 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Fri, 17 Nov 2023 22:26:48 +0530 Subject: [PATCH 2/3] Update README_EN.md to lc problem: No.1877 --- .../README_EN.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README_EN.md b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README_EN.md index 5e5fc9ecf766c..9b78d50ee6865 100644 --- a/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README_EN.md +++ b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README_EN.md @@ -122,6 +122,21 @@ function minPairSum(nums: number[]): number { } ``` +### **C#** + +```cs +public class Solution { + public int MinPairSum(int[] nums) { + Array.Sort(nums); + int ans = 0, n = nums.Length; + for (int i = 0; i < n >> 1; ++i) { + ans = Math.Max(ans, nums[i] + nums[n - i - 1]); + } + return ans; + } +} +``` + ### **...** ``` From 22675dad5de3db1068ea55b7c3849beb7c7ea46c Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Fri, 17 Nov 2023 22:27:24 +0530 Subject: [PATCH 3/3] Update README.md to lc problem: No.1877 --- .../README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README.md b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README.md index 97d3fc1ae73b0..731e7a74364ca 100644 --- a/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README.md +++ b/solution/1800-1899/1877.Minimize Maximum Pair Sum in Array/README.md @@ -136,6 +136,21 @@ function minPairSum(nums: number[]): number { } ``` +### **C#** + +```cs +public class Solution { + public int MinPairSum(int[] nums) { + Array.Sort(nums); + int ans = 0, n = nums.Length; + for (int i = 0; i < n >> 1; ++i) { + ans = Math.Max(ans, nums[i] + nums[n - i - 1]); + } + return ans; + } +} +``` + ### **...** ```