Skip to content

Commit dc79ba6

Browse files
authored
feat: add php solution to lc problem: No.1941 (doocs#1029)
1 parent d0b941d commit dc79ba6

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

solution/1900-1999/1941.Check if All Characters Have Equal Number of Occurrences/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,24 @@ function areOccurrencesEqual(s: string): boolean {
156156
}
157157
```
158158

159+
### **PHP**
160+
161+
```php
162+
class Solution {
163+
/**
164+
* @param String $s
165+
* @return Boolean
166+
*/
167+
function areOccurrencesEqual($s) {
168+
for ($i = 0; $i < strlen($s); $i++) {
169+
$hashtable[$s[$i]] += 1;
170+
}
171+
$rs = array_unique($hashtable);
172+
return count($rs) === 1;
173+
}
174+
}
175+
```
176+
159177
### **...**
160178

161179
```

solution/1900-1999/1941.Check if All Characters Have Equal Number of Occurrences/README_EN.md

+18
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ function areOccurrencesEqual(s: string): boolean {
140140
}
141141
```
142142

143+
### **PHP**
144+
145+
```php
146+
class Solution {
147+
/**
148+
* @param String $s
149+
* @return Boolean
150+
*/
151+
function areOccurrencesEqual($s) {
152+
for ($i = 0; $i < strlen($s); $i++) {
153+
$hashtable[$s[$i]] += 1;
154+
}
155+
$rs = array_unique($hashtable);
156+
return count($rs) === 1;
157+
}
158+
}
159+
```
160+
143161
### **...**
144162

145163
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
/**
3+
* @param String $s
4+
* @return Boolean
5+
*/
6+
function areOccurrencesEqual($s) {
7+
for ($i = 0; $i < strlen($s); $i++) {
8+
$hashtable[$s[$i]] += 1;
9+
}
10+
$rs = array_unique($hashtable);
11+
return count($rs) === 1;
12+
}
13+
}

0 commit comments

Comments
 (0)