Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 40999a2

Browse files
feat: add cs solution to lc problem: No.1980 (doocs#1973)
* feat: add cs solution to lc problem: No.1980 * Update README_EN.md to lc problem: No.1980 * Update README.md to lc problem: No.1980
1 parent dc9fc4f commit 40999a2

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

‎solution/1900-1999/1980.Find Unique Binary String/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ func findDifferentBinaryString(nums []string) string {
139139
}
140140
```
141141

142+
### **C#**
143+
144+
```cs
145+
public class Solution {
146+
public string FindDifferentBinaryString(string[] nums) {
147+
int mask = 0;
148+
foreach (var x in nums) {
149+
int cnt = x.Count(c => c == '1');
150+
mask |= 1 << cnt;
151+
}
152+
int i = 0;
153+
while ((mask >> i & 1) == 1) {
154+
i++;
155+
}
156+
return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i));
157+
}
158+
}
159+
```
160+
142161
### **...**
143162

144163
```

‎solution/1900-1999/1980.Find Unique Binary String/README_EN.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ func findDifferentBinaryString(nums []string) string {
120120
}
121121
```
122122

123+
### **C#**
124+
125+
```cs
126+
public class Solution {
127+
public string FindDifferentBinaryString(string[] nums) {
128+
int mask = 0;
129+
foreach (var x in nums) {
130+
int cnt = x.Count(c => c == '1');
131+
mask |= 1 << cnt;
132+
}
133+
int i = 0;
134+
while ((mask >> i & 1) == 1) {
135+
i++;
136+
}
137+
return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i));
138+
}
139+
}
140+
```
141+
123142
### **...**
124143

125144
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Solution {
2+
public string FindDifferentBinaryString(string[] nums) {
3+
int mask = 0;
4+
foreach (var x in nums) {
5+
int cnt = x.Count(c => c == '1');
6+
mask |= 1 << cnt;
7+
}
8+
int i = 0;
9+
while ((mask >> i & 1) == 1) {
10+
i++;
11+
}
12+
return string.Format("{0}{1}", new string('1', i), new string('0', nums.Length - i));
13+
}
14+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /