Skip to content

Commit

Permalink
solved problem 0094-binary-tree-inorder-traversal in swift
Browse files Browse the repository at this point in the history
  • Loading branch information
smishralm10 committed Dec 30, 2022
1 parent 2d0e0cc commit e48bd14
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions swift/0094-binary-tree-inorder-traversal.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
func inorderTraversal(_ root: TreeNode?) -> [Int] {
var result: [Int] = []
func rec(_ node: TreeNode?) {
guard let node = node else { return }
rec(node.left)
result.append(node.val)
rec(node.right)
}

rec(root)
return result
}
}

0 comments on commit e48bd14

Please sign in to comment.