func solution(_ cacheSize:Int, _ cities:[String]) -> Int {
var baguni = Array<String>()
var result = 0
var cities1 = cities.map{$0.lowercased()}
for city in cities1 {
if cacheSize == 0 {return 5 * cities.count}
if !baguni.contains(city){
result += 5
if baguni.count != cacheSize {
baguni.append(city)
}
else if baguni.count == cacheSize {
baguni.removeFirst()
baguni.append(city)
}
}
else{
let inWord = city
baguni.removeAll{$0 == inWord}
baguni.append(city)
result += 1
}
}
return result
}
- 대소문자 구분안한다 = 소문자 또는 대문자로 통일
- 캐시 사이즈가 0 일 거라는 생각 못함.