Last active
May 16, 2019 22:22
-
-
Save Mintri1199/242f2592f50d101c948c0a62863076cd to your computer and use it in GitHub Desktop.
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
class DecimalSearchTree { | |
... | |
func contains(numbers: String) -> Bool{ | |
// Return true if this Decimal search tree contains a path at contains | |
// all the numbers iteratively. | |
var currentNode: DecimalTreeNode? = self.root | |
for character in numbers { | |
let index = Int(String(character)) | |
if let newNode = currentNode?.next[index!] { | |
currentNode = newNode | |
} else { | |
currentNode = nil | |
break | |
} | |
} | |
return currentNode != nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment