File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed
solution/1700-1799/1704.Determine if String Halves Are Alike Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,25 @@ impl Solution {
174
174
}
175
175
```
176
176
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
+
177
196
### ** ...**
178
197
179
198
```
Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ impl Solution {
158
158
}
159
159
```
160
160
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
+
161
180
### ** ...**
162
181
163
182
```
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments