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 79db69e

Browse files
feat: add cs solution to lc problem: No.1930 (doocs#1964)
* feat: add cs solution to lc problem: No.1930 * Update README_EN.md to lc problem: No.1930 * Update README.md to lc problem: No.1930
1 parent a105ff0 commit 79db69e

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

‎solution/1900-1999/1930.Unique Length-3 Palindromic Subsequences/README.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,25 @@ func countPalindromicSubsequence(s string) (ans int) {
144144
}
145145
```
146146

147+
### **C#**
148+
149+
```cs
150+
public class Solution {
151+
public int CountPalindromicSubsequence(string s) {
152+
int ans = 0;
153+
for (char c = 'a'; c <= 'z'; ++c) {
154+
int l = s.IndexOf(c), r = s.LastIndexOf(c);
155+
HashSet<char> cs = new HashSet<char>();
156+
for (int i = l + 1; i < r; ++i) {
157+
cs.Add(s[i]);
158+
}
159+
ans += cs.Count;
160+
}
161+
return ans;
162+
}
163+
}
164+
```
165+
147166
### **...**
148167

149168
```

‎solution/1900-1999/1930.Unique Length-3 Palindromic Subsequences/README_EN.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ func countPalindromicSubsequence(s string) (ans int) {
126126
}
127127
```
128128

129+
### **C#**
130+
131+
```cs
132+
public class Solution {
133+
public int CountPalindromicSubsequence(string s) {
134+
int ans = 0;
135+
for (char c = 'a'; c <= 'z'; ++c) {
136+
int l = s.IndexOf(c), r = s.LastIndexOf(c);
137+
HashSet<char> cs = new HashSet<char>();
138+
for (int i = l + 1; i < r; ++i) {
139+
cs.Add(s[i]);
140+
}
141+
ans += cs.Count;
142+
}
143+
return ans;
144+
}
145+
}
146+
```
147+
129148
### **...**
130149

131150
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Solution {
2+
public int CountPalindromicSubsequence(string s) {
3+
int ans = 0;
4+
for (char c = 'a'; c <= 'z'; ++c) {
5+
int l = s.IndexOf(c), r = s.LastIndexOf(c);
6+
HashSet<char> cs = new HashSet<char>();
7+
for (int i = l + 1; i < r; ++i) {
8+
cs.Add(s[i]);
9+
}
10+
ans += cs.Count;
11+
}
12+
return ans;
13+
}
14+
}

0 commit comments

Comments
(0)

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