Skip to content

Fix: Go solution for Iterative DFS in Invert Binary Tree is using recursive code #6161

Description

@prithesh07

Problem Reference

  • Problem: 0226-invert-binary-tree.go
  • Language: Go
  • Section: 3. Iterative DFS

Issue Description

The code snippet under Iterative DFS for Go is currently displaying the recursive implementation instead of using an explicit stack.

Current Code (Incorrect):

func invertTree(root *TreeNode) *TreeNode {
    if root == nil {
        return nil
    }

    root.Left, root.Right = root.Right, root.Left

    invertTree(root.Left)
    invertTree(root.Right)

    return root
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions