LeetCode 112: Path Sum in Binary Tree

Day 82/150 🚀 LeetCode 112: Path Sum 🧠 Problem Given a binary tree and a targetSum, return true if there exists a root-to-leaf path where the sum of node values equals targetSum. 💡 Approach • Use DFS (Recursion) • Keep adding node values while traversing • Check at leaf node if sum equals target • Return true if any path matches ⏱ Time Complexity O(n) 📦 Space Complexity O(h) (recursion stack) ✅ Result: Accepted ⚡ Runtime: 3 ms 💾 Memory Beats: 94.93% #Day82 #LeetCode #BinaryTree #DFS #Recursion #DSA #CodingJourney #ProblemSolving

  • text

To view or add a comment, sign in

Explore content categories