File tree Expand file tree Collapse file tree
solution/1800-1899/1876.Substrings of Size Three with Distinct Characters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ class Solution {
8181}
8282```
8383
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+
84101### ** ...**
85102
86103```
Original file line number Diff line number Diff line change @@ -71,6 +71,22 @@ class Solution {
7171}
7272```
7373
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+
7490### ** ...**
7591
7692```
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