Last active
September 17, 2022 15:33
-
-
Save 1gravity/4d7ce5d558a8467f2353b9614a5142d3 to your computer and use it in GitHub Desktop.
Kotlin Trie Basic Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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