SHOW:
|
|
- or go back to the newest paste.
| 1 | - | def findMax(root, mySet, max): |
| 1 | + | def find_max(root, my_set, max): |
| 2 | - | if root == None: |
| 2 | + | if root is None: # jeśli może być trzystanowy, lub "if not root" jeśli jest dwustanowy |
| 3 | - | if len(mySet) >= max: |
| 3 | + | if len(my_set) >= max: |
| 4 | - | max = len(mySet) |
| 4 | + | max = len(my_set) |
| 5 | - | mySet.add(root.val) |
| 5 | + | |
| 6 | - | if mySet.left != None: |
| 6 | + | my_set.add(root.val) |
| 7 | - | findMax(root.left, root, max) |
| 7 | + | if my_set.left: |
| 8 | - | if mySet.right != None: |
| 8 | + | find_max(root.left, root, max) |
| 9 | - | findMax(root.right, root, max) |
| 9 | + | if my_set.right: |
| 10 | find_max(root.right, root, max) |