File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
solution/1900-1999/1930.Unique Length-3 Palindromic Subsequences Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,25 @@ func countPalindromicSubsequence(s string) (ans int) {
144
144
}
145
145
```
146
146
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
+
147
166
### ** ...**
148
167
149
168
```
Original file line number Diff line number Diff line change @@ -126,6 +126,25 @@ func countPalindromicSubsequence(s string) (ans int) {
126
126
}
127
127
```
128
128
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
+
129
148
### ** ...**
130
149
131
150
```
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments