File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
solution/2300-2399/2309.Greatest English Letter in Upper and Lower Case Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,16 @@ func greatestLetter(s string) string {
150
150
### ** TypeScript**
151
151
152
152
``` 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
+ };
154
163
```
155
164
156
165
### ** ...**
Original file line number Diff line number Diff line change @@ -137,7 +137,16 @@ func greatestLetter(s string) string {
137
137
### ** TypeScript**
138
138
139
139
``` 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
+ };
141
150
```
142
151
143
152
### ** ...**
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments