We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 37b336c commit b8af01dCopy full SHA for b8af01d
valid-anagram/delight010.swift
@@ -0,0 +1,14 @@
1
+class Solution {
2
+ func isAnagram(_ s: String, _ t: String) -> Bool {
3
+ var sDictionary: [Character: Int] = [:]
4
+ var tDictionary: [Character: Int] = [:]
5
+ for char in s {
6
+ sDictionary[char] = (sDictionary[char] ?? 0) + 1
7
+ }
8
+ for char in t {
9
+ tDictionary[char] = (tDictionary[char] ?? 0) + 1
10
11
+ return sDictionary == tDictionary
12
13
+}
14
+
0 commit comments