Skip to content

Commit ab9eb42

Browse files
committed
feat: add typescript solution to lc problem: No.2309
No.2309.Greatest English Letter in Upper and Lower Case
1 parent 6ec4f22 commit ab9eb42

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

solution/2300-2399/2309.Greatest English Letter in Upper and Lower Case/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,16 @@ func greatestLetter(s string) string {
150150
### **TypeScript**
151151

152152
```ts
153-
153+
function greatestLetter(s: string): string {
154+
let couter = new Array(128).fill(false);
155+
for (let char of s) {
156+
couter[char.charCodeAt(0)] = true;
157+
}
158+
for (let i = 90; i >= 65; i--) {
159+
if (couter[i] && couter[i + 32]) return String.fromCharCode(i);
160+
}
161+
return '';
162+
};
154163
```
155164

156165
### **...**

solution/2300-2399/2309.Greatest English Letter in Upper and Lower Case/README_EN.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ func greatestLetter(s string) string {
137137
### **TypeScript**
138138

139139
```ts
140-
140+
function greatestLetter(s: string): string {
141+
let couter = new Array(128).fill(false);
142+
for (let char of s) {
143+
couter[char.charCodeAt(0)] = true;
144+
}
145+
for (let i = 90; i >= 65; i--) {
146+
if (couter[i] && couter[i + 32]) return String.fromCharCode(i);
147+
}
148+
return '';
149+
};
141150
```
142151

143152
### **...**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function greatestLetter(s: string): string {
2+
let couter = new Array(128).fill(false);
3+
for (let char of s) {
4+
couter[char.charCodeAt(0)] = true;
5+
}
6+
for (let i = 90; i >= 65; i--) {
7+
if (couter[i] && couter[i + 32]) return String.fromCharCode(i);
8+
}
9+
return '';
10+
};

0 commit comments

Comments
 (0)