문제 풀이
class MyHashMap {
private var keyValues: [Int: Int] = [:]
init() {}
func put(_ key: Int, _ value: Int) {
keyValues[key] = value
}
func get(_ key: Int) -> Int {
keyValues[key] ?? -1
}
func remove(_ key: Int) {
keyValues.removeValue(forKey: key)
}
}반응형
'알고리즘' 카테고리의 다른 글
| leetcode 187. Repeated DNA Sequences (0) | 2025.04.15 |
|---|---|
| 백준 2358번 평행선 문제 풀이 (0) | 2025.04.14 |
| leetcode 2283. Check if Number Has Equal Digit Count and Digit Value 문제 풀이 (0) | 2025.04.09 |
| 백준 3986번 문제 풀이 (0) | 2025.04.08 |
| leetcode 70. Climbing Stairs 문제 풀이 (0) | 2025.04.07 |