-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
func exist(_ board: [[Character]], _ word: String) -> Bool {
var hashMap: [Character: Int] = [:]
var hasMapMatrix: [Character: Int] = [:]
for value in Array(word) {
hashMap[value, default: 0] += 1
}
for col in 0..<board.count {
for row in 0..<board[col].count {
hasMapMatrix[board[col][row], default: 0] += 1
}
}
var isExist: Bool = false
for char in word {
if let countworld = hashMap[char], let countMatrix = hasMapMatrix[char], countworld <= countMatrix {
isExist = true
}
}
return isExist
}
Metadata
Metadata
Assignees
Labels
No labels