Skip to content

Commit 59ddbbd

Browse files
authored
feat: add php solution to lc problem: No.2351 (doocs#994)
1 parent 1f56b64 commit 59ddbbd

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

solution/2300-2399/2351.First Letter to Appear Twice/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ char repeatedCharacter(char *s) {
270270
}
271271
```
272272

273+
### **PHP**
274+
275+
```php
276+
class Solution {
277+
/**
278+
* @param String $s
279+
* @return String
280+
*/
281+
function repeatedCharacter($s) {
282+
for ($i = 0;; $i++) {
283+
$hashtable[$s[$i]] += 1;
284+
if ($hashtable[$s[$i]] == 2) return $s[$i];
285+
}
286+
}
287+
}
288+
```
289+
273290
### **...**
274291

275292
```

solution/2300-2399/2351.First Letter to Appear Twice/README_EN.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,23 @@ char repeatedCharacter(char *s) {
250250
}
251251
```
252252

253+
### **PHP**
254+
255+
```php
256+
class Solution {
257+
/**
258+
* @param String $s
259+
* @return String
260+
*/
261+
function repeatedCharacter($s) {
262+
for ($i = 0;; $i++) {
263+
$hashtable[$s[$i]] += 1;
264+
if ($hashtable[$s[$i]] == 2) return $s[$i];
265+
}
266+
}
267+
}
268+
```
269+
253270
### **...**
254271

255272
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
/**
3+
* @param String $s
4+
* @return String
5+
*/
6+
function repeatedCharacter($s) {
7+
for ($i = 0;; $i++) {
8+
$hashtable[$s[$i]] += 1;
9+
if ($hashtable[$s[$i]] == 2) return $s[$i];
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)