File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,41 @@ func isAnagram(_ s: String, _ t: String) -> Bool {
221
221
}
222
222
```
223
223
224
+ PHP:
225
+ ``` php
226
+ class Solution {
227
+ /**
228
+ * @param String $s
229
+ * @param String $t
230
+ * @return Boolean
231
+ */
232
+ function isAnagram($s, $t) {
233
+ if (strlen($s) != strlen($t)) {
234
+ return false;
235
+ }
236
+ $table = [];
237
+ for ($i = 0; $i < strlen($s); $i++) {
238
+ if (!isset($table[$s[$i]])) {
239
+ $table[$s[$i]] = 1;
240
+ } else {
241
+ $table[$s[$i]]++;
242
+ }
243
+ if (!isset($table[$t[$i]])) {
244
+ $table[$t[$i]] = -1;
245
+ } else {
246
+ $table[$t[$i]]--;
247
+ }
248
+ }
249
+ foreach ($table as $record) {
250
+ if ($record != 0) {
251
+ return false;
252
+ }
253
+ }
254
+ return true;
255
+ }
256
+ }
257
+ ```
258
+
224
259
## 相关题目
225
260
226
261
* 383.赎金信
You can’t perform that action at this time.
0 commit comments