Skip to content

Instantly share code, notes, and snippets.

@1gravity
Last active September 17, 2022 15:33
Show Gist options
  • Save 1gravity/4d7ce5d558a8467f2353b9614a5142d3 to your computer and use it in GitHub Desktop.
Save 1gravity/4d7ce5d558a8467f2353b9614a5142d3 to your computer and use it in GitHub Desktop.
Kotlin Trie Basic Search
override fun search(key: String): Value? {
var currentNode = root
for (char in key) {
if (currentNode.children[char] == null) {
return null
}
currentNode = currentNode.children[char]!!
}
return currentNode.value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment