GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Lowest Common Ancestor

Suhas S Englisch 1 Karte

Karten in diesem Stapel (1)

  1. 1LCAclass Solution:
    def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
    # Recursive
    # if root.val >= min(p.val, q.val) and root.val <= max(p.val, q.val):
    # return root
    # node = root
    # if q.val>node.val and p.val>node.val:
    # return self.lowestCommonAncestor(root.right,p,q)
    # elif q.val= min(p.val, q.val) and root.val <= max(p.val, q.val):
    return root
    elif root.val < min(p.val, q.val):
    root = root.right
    else:
    root = root.left

Informationen

Beschreibung
Karteikarten am Lowest Common Ancestor, erstellt von Suhas S am 09/09/2019.
Erstellt von
Suhas S
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck