From 8862610112c165a51c03fc9dff9bdcc88f6bb68c Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Thu, 16 Nov 2023 20:06:23 +0530 Subject: [PATCH 1/3] feat: add cs solution to lc problem: No.1980 --- .../1980.Find Unique Binary String/Solution.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 solution/1900-1999/1980.Find Unique Binary String/Solution.cs diff --git a/solution/1900-1999/1980.Find Unique Binary String/Solution.cs b/solution/1900-1999/1980.Find Unique Binary String/Solution.cs new file mode 100644 index 0000000000000..3855b7d848da8 --- /dev/null +++ b/solution/1900-1999/1980.Find Unique Binary String/Solution.cs @@ -0,0 +1,14 @@ +public class Solution { + public string FindDifferentBinaryString(string[] nums) { + int mask = 0; + foreach (var x in nums) { + int cnt = x.Count(c => c == '1'); + mask |= 1 << cnt; + } + int i = 0; + while ((mask >> i & 1) == 1) { + i++; + } + return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i)); + } +} From a719fbc80d234a4bced84d5744b37a1d8bc3b454 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Thu, 16 Nov 2023 20:08:54 +0530 Subject: [PATCH 2/3] Update README_EN.md to lc problem: No.1980 --- .../README_EN.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/solution/1900-1999/1980.Find Unique Binary String/README_EN.md b/solution/1900-1999/1980.Find Unique Binary String/README_EN.md index ca15d8262e780..c181d5fc5ef8e 100644 --- a/solution/1900-1999/1980.Find Unique Binary String/README_EN.md +++ b/solution/1900-1999/1980.Find Unique Binary String/README_EN.md @@ -120,6 +120,25 @@ func findDifferentBinaryString(nums []string) string { } ``` +### **C#** + +```cs +public class Solution { + public string FindDifferentBinaryString(string[] nums) { + int mask = 0; + foreach (var x in nums) { + int cnt = x.Count(c => c == '1'); + mask |= 1 << cnt; + } + int i = 0; + while ((mask >> i & 1) == 1) { + i++; + } + return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i)); + } +} +``` + ### **...** ``` From 6591037cc6fd715fdffbdb36a3e621ff93b5c835 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Thu, 16 Nov 2023 20:10:36 +0530 Subject: [PATCH 3/3] Update README.md to lc problem: No.1980 --- .../1980.Find Unique Binary String/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/solution/1900-1999/1980.Find Unique Binary String/README.md b/solution/1900-1999/1980.Find Unique Binary String/README.md index f91a151741c9a..6f66f4eb85e81 100644 --- a/solution/1900-1999/1980.Find Unique Binary String/README.md +++ b/solution/1900-1999/1980.Find Unique Binary String/README.md @@ -139,6 +139,25 @@ func findDifferentBinaryString(nums []string) string { } ``` +### **C#** + +```cs +public class Solution { + public string FindDifferentBinaryString(string[] nums) { + int mask = 0; + foreach (var x in nums) { + int cnt = x.Count(c => c == '1'); + mask |= 1 << cnt; + } + int i = 0; + while ((mask >> i & 1) == 1) { + i++; + } + return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i)); + } +} +``` + ### **...** ```