🚀 Day 58 / 100 – LeetCode Challenge ✅ Problem Solved: Binary Tree Postorder Traversal 📊 Difficulty: Easy 💻 Language: Java Today’s problem focused on understanding tree traversal, specifically Postorder Traversal (Left → Right → Root). 🔍 Key Learnings: Mastered recursive approach for tree traversal Understood how DFS (Depth First Search) works in binary trees Strengthened problem-solving with clean and efficient logic ⚡ Performance: Runtime: 0 ms (Beats 100%) 🔥 Memory: 42.96 MB 💡 Approach: Used a simple recursive helper function: Traverse left subtree Traverse right subtree Add root node value This problem may be easy, but it builds a strong foundation for advanced tree problems 💪 📈 Consistency is key — 58 days down, 42 more to go! #LeetCode #100DaysOfCode #Java #DataStructures #CodingJourney #BinaryTree #DSA #Learning #Consistency
Binary Tree Postorder Traversal in Java
More Relevant Posts
-
Day 77 of #100DaysOfLeetCode 💻✅ Solved #153. Find Minimum in Rotated Sorted Array problem in Java. Approach: • Used Binary Search to find minimum element • Compared mid with right to decide direction • Reduced search space until pointers converged Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 43.62 MB (Beats 78.18% submissions) Key Learning: ✓ Strengthened Binary Search on rotated arrays ✓ Learned how to identify unsorted portion efficiently ✓ Improved optimization over linear search Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 76 of #100DaysOfLeetCode 💻✅ Solved #33. Search in Rotated Sorted Array problem in Java. Approach: • Applied Binary Search on rotated array • Checked which half is sorted at each step • Reduced search space based on target position Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 43.80 MB (Beats 70.96% submissions) Key Learning: ✓ Mastered searching in rotated sorted arrays ✓ Improved Binary Search decision-making ✓ Learned efficient handling of edge cases Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 DSA Journey — LeetCode Practice 📌 Problem: Binary Tree Postorder Traversal (LeetCode 145) 💻 Language: Java 🔹 Approach: To solve this problem, I used Depth-First Search (DFS) with Recursion to perform postorder traversal of the binary tree. • Recursively traverse the left subtree • Recursively traverse the right subtree • Visit the root node and store its value • Follow Postorder pattern: Left → Right → Root This approach works efficiently because recursion naturally follows the postorder traversal structure. ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(n) (including recursion stack) 📖 Key Learning: This problem strengthened my understanding of DFS, recursion, and tree traversal patterns. It also reinforced the postorder pattern (Left → Right → Root), which is a fundamental concept used in many tree-based problems 💡 #DSA #Java #LeetCode #ProblemSolving #CodingJourney #LearningInPublic #BinaryTree #DFS #Recursion #TreeTraversal
To view or add a comment, sign in
-
-
🚀 DSA Journey — LeetCode Practice 📌 Problem: Binary Tree Inorder Traversal (LeetCode 94) 💻 Language: Java 🔹 Approach: To solve this problem, I used Depth-First Search (DFS) with Recursion to perform inorder traversal of the binary tree. • Recursively traverse the left subtree • Visit the root node and store its value • Recursively traverse the right subtree • Follow Inorder pattern: Left → Root → Right This approach works efficiently because recursion naturally follows the inorder traversal structure. ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(n) (including recursion stack) 📖 Key Learning: This problem strengthened my understanding of DFS, recursion, and tree traversal patterns. It also reinforced the inorder pattern (Left → Root → Right), which is a fundamental concept used in many tree-based problems 💡 #DSA #Java #LeetCode #ProblemSolving #CodingJourney #LearningInPublic #BinaryTree #DFS #Recursion #TreeTraversal
To view or add a comment, sign in
-
-
Day 60 of #100DaysOfLeetCode 💻✅ Solved #389. Find the Difference problem in Java. Approach: • Initialized a variable to store the sum • Subtracted ASCII values of all characters in string s • Added ASCII values of all characters in string t • The remaining value represents the extra character • Converted the result back to character and returned it Performance: ✓ Runtime: 3 ms (Beats 38.82% submissions) ✓ Memory: 43.34 MB (Beats 30.69% submissions) Key Learning: ✓ Learned a clever use of ASCII values for problem solving ✓ Practiced using math-based approach instead of extra data structures ✓ Improved understanding of string manipulation techniques Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Math #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 74 of #100DaysOfLeetCode 💻✅ Solved #162. Find Peak Element problem in Java. Approach: • Used Binary Search technique to efficiently find the peak element • Set two pointers, left at start and right at end of the array • Calculated mid index using safe mid formula • Compared nums[mid] with nums[mid + 1] to determine direction • If mid element is smaller, moved search space to right half • Otherwise, moved search space to left half including mid • Continued until left and right pointers converged • Final position (left == right) represents the peak index Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 44.32 MB (Beats 25.49% submissions) Key Learning: ✓ Strengthened understanding of Binary Search on unsorted arrays ✓ Learned how to apply divide-and-conquer beyond traditional searching ✓ Improved intuition for peak finding using neighbor comparison ✓ Practiced optimizing search space instead of linear scanning Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🔥 𝗗𝗮𝘆 𝟵𝟰/𝟭𝟬𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 𝟭𝟱𝟯𝟵. 𝗞𝘁𝗵 𝗠𝗶𝘀𝘀𝗶𝗻𝗴 𝗣𝗼𝘀𝗶𝘁𝗶𝘃𝗲 𝗡𝘂𝗺𝗯𝗲𝗿 | 🟢 Easy | Java Marked as Easy — but the optimal solution is pure binary search brilliance. 🎯 🔍 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 Given a sorted array, find the kth missing positive integer. Linear scan works — but can we do O(log n)? 💡 𝗧𝗵𝗲 𝗞𝗲𝘆 𝗜𝗻𝘀𝗶𝗴𝗵𝘁 At index i, the value arr[i] should be i+1 in a complete sequence. So missing numbers before arr[i] = arr[i] - 1 - i This lets us binary search on the count of missing numbers! ⚡ 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵 — 𝗕𝗶𝗻𝗮𝗿𝘆 𝗦𝗲𝗮𝗿𝗰𝗵 ✅ If arr[mid] - 1 - mid < k → not enough missing numbers yet, go right ✅ Else → too many missing, go left ✅ After the loop, left + k gives the exact answer 𝗪𝗵𝘆 𝗹𝗲𝗳𝘁 + 𝗸? After binary search, left is the index where the kth missing number falls beyond. left numbers exist in the array before that point, so the answer is left + k. No extra passes needed. ✨ 📊 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 ⏱ Time: O(log n) — vs O(n) linear scan 📦 Space: O(1) This is a perfect example of binary searching on a derived condition, not just a value. A real upgrade from the naive approach. 🧠 📂 𝗙𝘂𝗹𝗹 𝘀𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗼𝗻 𝗚𝗶𝘁𝗛𝘂𝗯: https://lnkd.in/gVYcjNS6 𝟲 𝗺𝗼𝗿𝗲 𝗱𝗮𝘆𝘀. 𝗧𝗵𝗲 𝗳𝗶𝗻𝗶𝘀𝗵 𝗹𝗶𝗻𝗲 𝗶𝘀 𝗿𝗶𝗴𝗵𝘁 𝘁𝗵𝗲𝗿𝗲! 🏁 #LeetCode #Day94of100 #100DaysOfCode #Java #DSA #BinarySearch #Arrays #CodingChallenge #Programming
To view or add a comment, sign in
-
🚀 DSA Journey — LeetCode Practice 📌 Problem: Maximum Depth of Binary Tree 💻 Language: Java 🔹 Approach: To solve this problem, I used Breadth-First Search (BFS) with a Queue to perform level-order traversal of the binary tree. • Start by adding the root node to the queue • Traverse the tree level by level • For each level, process all nodes currently in the queue • Add left and right children of each node to the queue • Increment the level count after completing each level 📌 Logic Insight: Each iteration of the outer loop represents one level of the tree, which directly helps in calculating the maximum depth. ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(n) (queue storage in worst case) 💡 Key Learning: This problem helped me understand how level-order traversal (BFS) can be used not just for traversal, but also for solving structural problems like finding tree depth efficiently. It also reinforced the importance of queue-based processing in trees. #DSA #Java #LeetCode #BinaryTree #BFS #Queue #CodingJourney #ProblemSolving #LearningInPublic #TreeTraversal
To view or add a comment, sign in
-
-
Day 66 of #100DaysOfLeetCode 💻✅ Solved #3427. Sum of Variable Length Subarrays problem in Java. Approach: • Iterated through each index of the array • Determined the starting index using i - nums[i] • Ensured the start index does not go below 0 • Calculated sum of elements from start to current index i • Added each subarray sum to the total Performance: ✓ Runtime: 1 ms (Beats 99.90% submissions) ✓ Memory: 45.22 MB (Beats 56.30% submissions) Key Learning: ✓ Practiced handling variable-length subarrays ✓ Improved understanding of index-based range calculations ✓ Strengthened nested loop logic for array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 73 of #100DaysOfLeetCode 💻✅ Solved #389. Find the Difference problem in Java. Approach: • Initialized a variable to store the sum • Added ASCII values of all characters in string t • Subtracted ASCII values of all characters in string s • The remaining value represents the extra character • Converted the result back to character and returned it Performance: ✓ Runtime: 1 ms (Beats 99.89% submissions) 🚀 ✓ Memory: 42.77 MB (Beats 97.03% submissions) Key Learning: ✓ Practiced optimized string traversal using enhanced for-loop ✓ Reinforced understanding of ASCII-based solutions ✓ Learned how mathematical approaches can simplify problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Math #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development