Day 16 | LeetCode Learning Journal 🚀 Today I solved Binary Tree Right Side View . This problem helped me understand how to identify the nodes visible when looking at a binary tree from the right side. 🔑 Key Points: • Uses Breadth-First Search (BFS) with a queue. • Traverse the binary tree level by level. • At each level, capture the last node visited. • The last node of every level represents the right side view. • Continue until all levels of the tree are processed. 🌱 What I Learned: • How to apply level order traversal in binary trees • Identifying the rightmost node at each level • Better understanding of queue-based traversal • Strengthened my binary tree traversal concepts • Improved problem-solving skills in tree-based problems #LeetCode #100DaysOfCode #DSA #BinaryTree #BFS #RightSideView #Day16 🚀
Binary Tree Right Side View with BFS
More Relevant Posts
-
Day 17 | LeetCode Learning Journal 🚀 Today I solved Binary Tree Maximum Path Sum. This problem helped me understand how to find the maximum path sum in a binary tree, where a path can start and end at any node. 🔑 Key Points: • Uses Depth-First Search (DFS) with recursion. • Calculate the maximum contribution from left and right subtrees. • Ignore negative path sums to maximize the result. • Update the global maximum path sum at each node. • Continue traversal until all nodes are processed. 🌱 What I Learned: • How to handle complex recursion in binary trees • Calculating path sums while traversing the tree • Managing global variables to track the maximum result • Improved understanding of DFS in tree problems • Strengthened my problem-solving skills for advanced binary tree questions #LeetCode #100DaysOfCode #DSA #BinaryTree #DFS #MaximumPathSum #Day17 🚀
To view or add a comment, sign in
-
-
🚀 Day 22/100 — LeetCode Challenge Today's problem: First Bad Version 🧠 Concept: Binary Search on Answer 💡 Key Idea: Instead of searching for a value, use binary search to find the point where a condition changes (from good to bad). ⚡ Time Complexity: O(log n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Learning how binary search can be applied beyond just searching in arrays. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 20 | LeetCode Learning Journal. Today I solved Minimum Depth of Binary Tree. This problem looked simple at first, but it taught me an important edge case in binary trees! 🔑 Key Points: • Used recursion (DFS) to calculate depth. • Handled cases where one subtree is missing. • Learned that we must not take min of NULL paths directly. • Carefully checked leaf nodes (both left & right NULL). • Returned correct depth by considering valid paths only. 🌱 What I Learned: • Difference between minimum depth and general depth calculation • Importance of handling edge cases in trees • How NULL nodes can affect recursion results • Improved understanding of binary tree traversal logic #LeetCode #100DaysOfCode #DSA #BinaryTree #Recursion #DFS #Day20 🚀
To view or add a comment, sign in
-
-
🚀 Day 21/100 — LeetCode Challenge Starting a new phase with Binary Search. Today's problems: • Binary Search • Search Insert Position 🧠 Concept: Binary Search 💡 Key Idea: Divide the search space in half at every step to efficiently locate the target in a sorted array. ⚡ Time Complexity: O(log n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Excited to dive deeper into binary search and its variations. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
Day 24 Today I solved “Number of 1 Bits” on LeetCode. The task is to count the number of set bits (1s) in the binary representation of a number — also known as Hamming Weight. At first, the straightforward approach is: 👉 Check each bit one by one (using shifts) But I learned a much more efficient trick: 💡 Brian Kernighan’s Algorithm Key Idea: n & (n - 1) removes the rightmost set bit Repeat this until n = 0 Count how many times we do this 👉 Example: n = 11 (1011) 1011 → 1010 1010 → 1000 1000 → 0000 → Count = 3 This gives: Time Complexity: O(k) {k=number of set bits} Space Complexity: O(1) 💡 Key takeaway: Bit manipulation can drastically improve efficiency by operating directly on binary representations. #LeetCode #DSA #LearnInPublic
To view or add a comment, sign in
-
-
🚀 Day 19/100 — LeetCode Challenge (Revision Day) Today I revised Monotonic Stack problems: • Daily Temperatures • Next Greater Element I 🧠 Key Learning: Monotonic stack is extremely useful for solving “next greater/smaller element” problems efficiently in O(n) time. Revisiting these problems helped strengthen pattern recognition and understanding. 📂 Solutions Repository https://lnkd.in/gkFh2mPZ #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #Revision
To view or add a comment, sign in
-
Day 23 | LeetCode Learning Journal 🚀 Today I solved Binary Tree Tilt.This problem helped me understand how to combine tree traversal with calculations at each node! 🔑 Key Points: • Used postorder traversal to calculate subtree sums. • Calculated tilt as the absolute difference of left and right subtree sums. • Accumulated tilt for every node in the tree. • Focused on returning subtree sums while updating the result. • Efficient single traversal solution. 🌱 What I Learned: • How to compute values while traversing a tree. • Importance of postorder traversal in such problems. • Better understanding of recursion with return values. • Improved handling of tree-based calculations. #LeetCode #100DaysOfCode #DSA #CodingJourney #BinaryTree #Day23 🚀
To view or add a comment, sign in
-
-
Day 40 | LeetCode Learning Journal 🚀 Today I solved Validate Binary Search Tree (BST) using a range-based recursive approach. This problem helped me deeply understand how BST properties apply to the entire tree, not just immediate children! 🔑 Key Points: • Checked whether a binary tree is a valid BST. • Maintained a valid range (min, max) for each node. • Ensured every node follows BST rules globally. • Used recursion to traverse and validate nodes. 🌱 What I Learned: • Importance of passing constraints (min/max) in recursion. • Difference between local vs global validation in trees. • Strengthened understanding of Binary Search Tree properties. • Improved recursive thinking for tree problems. #LeetCode #100DaysOfCode #DSA #CodingJourney #Day40 🚀
To view or add a comment, sign in
-
-
🚀 Day 25/100 — LeetCode Challenge Today's problem: Find Minimum in Rotated Sorted Array 🧠 Concept: Binary Search on Rotated Array 💡 Key Idea: The minimum element represents the pivot point of rotation. By comparing mid with the rightmost element, we can efficiently narrow down the search space. ⚡ Time Complexity: O(log n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Continuing to explore how binary search can be adapted for different problem variations. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
Day 7 🚀 Solved: Balanced Binary Tree (LeetCode 110) This problem builds on recursion and tree depth. A tree is balanced if the height difference between left and right subtrees is at most 1 for every node. 💡 My approaches: 🔹 Approach 1 (Brute Force): For every node, calculate left and right subtree heights Check the difference and recurse further 🔹 Approach 2 (Optimal – Postorder DFS): Compute height and balance together in one traversal Avoid recomputing subtree heights 💡 Key learning: Instead of solving subproblems separately, combine them in a single DFS to optimize performance. ⏱️ Time Complexity: Brute Force → O(n²) Optimal → O(n) 🔗 GitHub: https://lnkd.in/gVdJeg2a #DSA #LeetCode #Coding
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