Skip to content

Commit

Permalink
dfs solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiragKr04 authored Apr 16, 2024
1 parent 7bb2d59 commit b541756
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 0623-add-one-row-to-tree/0623-add-one-row-to-tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,21 @@ def addOneRow(self, root: Optional[TreeNode], val: int, depth: int) -> Optional[

return root

# class Solution:
# def addOneRow(self, root: Optional[TreeNode], val: int, depth: int) -> Optional[TreeNode]:

# if depth == 1:
# return TreeNode(val, root, None)

# elif depth == 2:
# root.left = TreeNode(val, root.left, None)
# root.right = TreeNode(val, None, root.right)

# else:
# if root.left:
# self.addOneRow(root.left, val, depth - 1)
# if root.right:
# self.addOneRow(root.right, val, depth - 1)

# return root

0 comments on commit b541756

Please sign in to comment.