Skip to content

Commit 47cb74d

Browse files
authored
feat: add php solution to lc problem: No.1704 (doocs#979)
1 parent c97c66d commit 47cb74d

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

solution/1700-1799/1704.Determine if String Halves Are Alike/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ impl Solution {
174174
}
175175
```
176176

177+
### **PHP**
178+
179+
```php
180+
class Solution {
181+
/**
182+
* @param String $s
183+
* @return Boolean
184+
*/
185+
function halvesAreAlike($s) {
186+
$cnt = 0;
187+
for ($i = 0; $i < strlen($s) / 2; $i++) {
188+
if (strpos("aeiouAEIOU", $s[$i]) !== false) $cnt++;
189+
if (strpos("aeiouAEIOU", $s[strlen($s) / 2 + $i]) !== false) $cnt--;
190+
}
191+
return $cnt == 0;
192+
}
193+
}
194+
```
195+
177196
### **...**
178197

179198
```

solution/1700-1799/1704.Determine if String Halves Are Alike/README_EN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,25 @@ impl Solution {
158158
}
159159
```
160160

161+
### **PHP**
162+
163+
```php
164+
class Solution {
165+
/**
166+
* @param String $s
167+
* @return Boolean
168+
*/
169+
function halvesAreAlike($s) {
170+
$cnt = 0;
171+
for ($i = 0; $i < strlen($s) / 2; $i++) {
172+
if (strpos("aeiouAEIOU", $s[$i]) !== false) $cnt++;
173+
if (strpos("aeiouAEIOU", $s[strlen($s) / 2 + $i]) !== false) $cnt--;
174+
}
175+
return $cnt == 0;
176+
}
177+
}
178+
```
179+
161180
### **...**
162181

163182
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
/**
3+
* @param String $s
4+
* @return Boolean
5+
*/
6+
function halvesAreAlike($s) {
7+
$cnt = 0;
8+
for ($i = 0; $i < strlen($s) / 2; $i++) {
9+
if (strpos("aeiouAEIOU", $s[$i]) !== false) $cnt++;
10+
if (strpos("aeiouAEIOU", $s[strlen($s) / 2 + $i]) !== false) $cnt--;
11+
}
12+
return $cnt == 0;
13+
}
14+
}

0 commit comments

Comments
 (0)