Skip to content

Commit cc2b8a3

Browse files
committed
chore: add time complexity description
1 parent 4aac257 commit cc2b8a3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

โ€Žvalid-anagram/JustHm.swiftโ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Solution {
2-
func isAnagram(_ s: String, _ t: String) -> Bool {
2+
func isAnagram(_ s: String, _ t: String) -> Bool { // O(n)
33
// s ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž๋ฅผ ํ‚ค๋กœ ๋นˆ๋„์ˆ˜๋ฅผ ๊ฐ’์œผ๋กœ ์ €์žฅ
44
var baseDict = Dictionary(s.map{($0,1)}, uniquingKeysWith: +)
55

@@ -16,14 +16,14 @@ class Solution {
1616
}
1717
}
1818

19-
// MARK: ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•
19+
// MARK: ๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ• time: O(nlogn)
2020
class Solution2 {
2121
func isAnagram(_ s: String, _ t: String) -> Bool {
2222
s.sorted() == t.sorted()
2323
}
2424
}
2525

26-
// MARK: ์‹คํ–‰์†๋„๊ฐ€ ๊ฐ€์žฅ ๋น ๋ฆ„
26+
// MARK: ์‹คํ–‰์†๋„๊ฐ€ ๊ฐ€์žฅ ๋น ๋ฆ„ time: O(n)
2727
class Solution3 {
2828
func isAnagram(_ s: String, _ t: String) -> Bool {
2929
guard s.count == t.count else { return false }

0 commit comments

Comments
ย (0)