File tree 3 files changed +64
-0
lines changed
solution/0700-0799/0744.Find Smallest Letter Greater Than Target
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,29 @@ impl Solution {
201
201
}
202
202
```
203
203
204
+ ### ** PHP**
205
+
206
+ ``` php
207
+ class Solution {
208
+ /**
209
+ * @param String[] $letters
210
+ * @param String $target
211
+ * @return String
212
+ */
213
+ function nextGreatestLetter($letters, $target) {
214
+ $left = 0;
215
+ $right = count($letters);
216
+ while ($left <= $right) {
217
+ $mid = floor($left + ($right - $left) / 2);
218
+ if ($letters[$mid] > $target) $right = $mid - 1;
219
+ else $left = $mid + 1;
220
+ }
221
+ if ($left >= count($letters)) return $letters[0];
222
+ else return $letters[$left];
223
+ }
224
+ }
225
+ ```
226
+
204
227
### ** ...**
205
228
206
229
```
Original file line number Diff line number Diff line change @@ -167,6 +167,29 @@ impl Solution {
167
167
}
168
168
```
169
169
170
+ ### ** PHP**
171
+
172
+ ``` php
173
+ class Solution {
174
+ /**
175
+ * @param String[] $letters
176
+ * @param String $target
177
+ * @return String
178
+ */
179
+ function nextGreatestLetter($letters, $target) {
180
+ $left = 0;
181
+ $right = count($letters);
182
+ while ($left <= $right) {
183
+ $mid = floor($left + ($right - $left) / 2);
184
+ if ($letters[$mid] > $target) $right = $mid - 1;
185
+ else $left = $mid + 1;
186
+ }
187
+ if ($left >= count($letters)) return $letters[0];
188
+ else return $letters[$left];
189
+ }
190
+ }
191
+ ```
192
+
170
193
### ** ...**
171
194
172
195
```
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ /**
3
+ * @param String[] $letters
4
+ * @param String $target
5
+ * @return String
6
+ */
7
+ function nextGreatestLetter ($letters , $target ) {
8
+ $left = 0 ;
9
+ $right = count ($letters );
10
+ while ($left <= $right ) {
11
+ $mid = floor ($left + ($right - $left ) / 2 );
12
+ if ($letters [$mid ] > $target ) $right = $mid - 1 ;
13
+ else $left = $mid + 1 ;
14
+ }
15
+ if ($left >= count ($letters )) return $letters [0 ];
16
+ else return $letters [$left ];
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments