Time O(d). Space O(d).
Tag Archives: DFS
Word Squares – Python 3 (Week 12 – 19)
Time O(n^m). Space O(n^m). n is length of dict. m is length of longest word.
Find Leaves of Binary Tree – Python 3 (Week 12 – 18)
Time O(n). Space O(n).
Word Break II – Python 3 (Week 12 – 17)
Time O(mn). Space O(mn).
Binary Tree Upside Down – Python 3 (Week 12 – 16)
Time O(h). Space O(h).
Inorder Successor in BST – Python 3 (Week 12 – 15)
class Solution: “”” @param: root: The root of the BST. @param: p: You need find the successor node of p. @return: Successor of p. “”” def inorderSuccessor(self, root, p): # write your code here if root == None or p == None: return None if root.val <= p.val: return self.inorderSuccessor(root.right, p) else: leftAns = self.inorderSuccessor(root.left, …
Continue reading “Inorder Successor in BST – Python 3 (Week 12 – 15)”