Skip to content

Commit 6741dfb

Browse files
authored
feat: add typescript solution to lc problem: No.1876.Substrings of Size Three with Distinct Characters (doocs#430)
1 parent 9d34990 commit 6741dfb

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README.md

+17
Original file line numberDiff line numberDiff 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
```

solution/1800-1899/1876.Substrings of Size Three with Distinct Characters/README_EN.md

+16
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
};

0 commit comments

Comments
 (0)