File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1
1
class Solution {
2
- func isAnagram( _ s: String , _ t: String ) -> Bool {
2
+ func isAnagram( _ s: String , _ t: String ) -> Bool { // O(n)
3
3
// s ๋ฌธ์์ด์ ๋ฌธ์๋ฅผ ํค๋ก ๋น๋์๋ฅผ ๊ฐ์ผ๋ก ์ ์ฅ
4
4
var baseDict = Dictionary ( s. map { ( $0, 1 ) } , uniquingKeysWith: + )
5
5
@@ -16,14 +16,14 @@ class Solution {
16
16
}
17
17
}
18
18
19
- // MARK: ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ
19
+ // MARK: ๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ time: O(nlogn)
20
20
class Solution2 {
21
21
func isAnagram( _ s: String , _ t: String ) -> Bool {
22
22
s. sorted ( ) == t. sorted ( )
23
23
}
24
24
}
25
25
26
- // MARK: ์คํ์๋๊ฐ ๊ฐ์ฅ ๋น ๋ฆ
26
+ // MARK: ์คํ์๋๊ฐ ๊ฐ์ฅ ๋น ๋ฆ time: O(n)
27
27
class Solution3 {
28
28
func isAnagram( _ s: String , _ t: String ) -> Bool {
29
29
guard s. count == t. count else { return false }
You canโt perform that action at this time.
0 commit comments