Skip to content

Commit ec44267

Browse files
Qiu-ITyanglbme
andauthored
feat: add php solution to lc problem: No.0744 (doocs#953)
Co-authored-by: Yang Libin <contact@yanglibin.info>
1 parent 9b8fe07 commit ec44267

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

solution/0700-0799/0744.Find Smallest Letter Greater Than Target/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,29 @@ impl Solution {
201201
}
202202
```
203203

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+
204227
### **...**
205228

206229
```

solution/0700-0799/0744.Find Smallest Letter Greater Than Target/README_EN.md

+23
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,29 @@ impl Solution {
167167
}
168168
```
169169

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+
170193
### **...**
171194

172195
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

0 commit comments

Comments
 (0)