File tree 3 files changed +44
-0
lines changed
solution/1800-1899/1876.Substrings of Size Three with Distinct Characters
3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ class Solution {
81
81
}
82
82
```
83
83
84
+ ### ** TypeScript**
85
+
86
+ ``` ts
87
+ function countGoodSubstrings(s : string ): number {
88
+ const n: number = s .length ;
89
+ let count: number = 0 ;
90
+ for (let i: number = 0 ; i < n - 2 ; ++ i ) {
91
+ let a: string = s .charAt (i ), b: string = s .charAt (i + 1 ), c: string = s .charAt (i + 2 );
92
+ if (a != b && a != c && b != c ) {
93
+ ++ count ;
94
+ }
95
+ }
96
+ return count ;
97
+ };
98
+
99
+ ```
100
+
84
101
### ** ...**
85
102
86
103
```
Original file line number Diff line number Diff line change @@ -71,6 +71,22 @@ class Solution {
71
71
}
72
72
```
73
73
74
+ ### ** TypeScript**
75
+
76
+ ``` ts
77
+ function countGoodSubstrings(s : string ): number {
78
+ const n: number = s .length ;
79
+ let count: number = 0 ;
80
+ for (let i: number = 0 ; i < n - 2 ; ++ i ) {
81
+ let a: string = s .charAt (i ), b: string = s .charAt (i + 1 ), c: string = s .charAt (i + 2 );
82
+ if (a != b && a != c && b != c ) {
83
+ ++ count ;
84
+ }
85
+ }
86
+ return count ;
87
+ };
88
+ ```
89
+
74
90
### ** ...**
75
91
76
92
```
Original file line number Diff line number Diff line change
1
+ function countGoodSubstrings ( s : string ) : number {
2
+ const n : number = s . length ;
3
+ let count : number = 0 ;
4
+ for ( let i : number = 0 ; i < n - 2 ; ++ i ) {
5
+ let a : string = s . charAt ( i ) , b : string = s . charAt ( i + 1 ) , c : string = s . charAt ( i + 2 ) ;
6
+ if ( a != b && a != c && b != c ) {
7
+ ++ count ;
8
+ }
9
+ }
10
+ return count ;
11
+ } ;
You can’t perform that action at this time.
0 commit comments