Skip to content

Commit e042fa3

Browse files
committed
feat: Add LeetCode242 solution for Valid Anagram
1 parent 5aa5ba0 commit e042fa3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-anagram/WhiteHyun.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// 242. Valid Anagram.swift
3+
// https://leetcode.com/problems/valid-anagram/description/
4+
// Algorithm
5+
//
6+
// Created by 홍승현 on 2024/04/26.
7+
//
8+
9+
import Foundation
10+
11+
final class LeetCode242 {
12+
func isAnagram(_ s: String, _ t: String) -> Bool {
13+
Dictionary(s.map { ($0, 1) }, uniquingKeysWith: +) == Dictionary(t.map { ($0, 1) }, uniquingKeysWith: +)
14+
}
15+
}

0 commit comments

Comments
 (0)