Binary Tree Paths via DFS Recursion

#day333 of #1001daysofcode problem statement (0257): Binary Tree Paths 💡 Approach: Used DFS recursion to explore all root-to-leaf paths in the binary tree. While traversing, I kept building the path string. When a leaf node is reached, the complete path is added to the result list. Example path format: 1->2->5 ⏱ Time Complexity: O(n) 🧠 Space Complexity: O(h) — recursion stack (h = height of the tree) Consistency in solving one problem every day 📈 #1001DaysOfCode #DSA #Java #LeetCode #ProblemSolving Shivam Mahajan #leetcode

  • text

To view or add a comment, sign in

Explore content categories