File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
solution/0700-0799/0744.Find Smallest Letter Greater Than Target Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,24 @@ class Solution {
103
103
}
104
104
```
105
105
106
+ ### ** TypeScript**
107
+
108
+ ``` ts
109
+ function nextGreatestLetter(letters : string [], target : string ): string {
110
+ let left = 0 , right = letters .length ;
111
+ let x = target .charCodeAt (0 );
112
+ while (left < right ) {
113
+ let mid = (left + right ) >> 1 ;
114
+ if (x < letters [mid ].charCodeAt (0 )) {
115
+ right = mid ;
116
+ } else {
117
+ left = mid + 1 ;
118
+ }
119
+ }
120
+ return letters [left % letters .length ];
121
+ };
122
+ ```
123
+
106
124
### ** C++**
107
125
108
126
``` cpp
Original file line number Diff line number Diff line change @@ -132,6 +132,24 @@ class Solution {
132
132
}
133
133
```
134
134
135
+ ### ** TypeScript**
136
+
137
+ ``` ts
138
+ function nextGreatestLetter(letters : string [], target : string ): string {
139
+ let left = 0 , right = letters .length ;
140
+ let x = target .charCodeAt (0 );
141
+ while (left < right ) {
142
+ let mid = (left + right ) >> 1 ;
143
+ if (x < letters [mid ].charCodeAt (0 )) {
144
+ right = mid ;
145
+ } else {
146
+ left = mid + 1 ;
147
+ }
148
+ }
149
+ return letters [left % letters .length ];
150
+ };
151
+ ```
152
+
135
153
### ** C++**
136
154
137
155
``` cpp
Original file line number Diff line number Diff line change
1
+ function nextGreatestLetter ( letters : string [ ] , target : string ) : string {
2
+ let left = 0 , right = letters . length ;
3
+ let x = target . charCodeAt ( 0 ) ;
4
+ while ( left < right ) {
5
+ let mid = ( left + right ) >> 1 ;
6
+ if ( x < letters [ mid ] . charCodeAt ( 0 ) ) {
7
+ right = mid ;
8
+ } else {
9
+ left = mid + 1 ;
10
+ }
11
+ }
12
+ return letters [ left % letters . length ] ;
13
+ } ;
You can’t perform that action at this time.
0 commit comments