Day 34 | LeetCode Learning Journal 🚀 Today’s focus was Problem 104: Maximum Depth of Binary Tree. The core idea here is the elegance of Recursion. Instead of thinking about the entire tree at once, the concept is to break it down: the height of any node is simply 1 + the maximum height of its children. It’s fascinating how the code "drills down" to the leaf nodes (the base case) and then builds the answer back up as the recursion unwinds. This problem is a perfect example of how a Bottom-Up approach works—solving the smallest sub-problems first to find the solution for the root. 34 days done — and my intuition for recursive thinking is getting much sharper. Understanding how memory stacks and base cases interact is key to mastering more complex tree and graph algorithms. #LeetCode #100DaysOfCode #Recursion #BinaryTree #LogicBuilding #DSA #CPlusPlus #CodingJourney #ProblemSolving #DepthFirstSearch
Maximizing Binary Tree Depth with Recursion
More Relevant Posts
-
Day 36 | LeetCode Learning Journal 🚀 Leveling up today with a Hard challenge: Problem 124: Binary Tree Maximum Path Sum. This problem was a masterclass in recursive depth. Unlike many tree problems where you just pass data upward, this one required tracking a "global maximum" while simultaneously deciding which branch offers the best path to contribute to the parent node. Key insights from today: Post-order Traversal: Understanding that we need information from both subtrees before we can make a decision at the current node. The "Max" Logic: Learning to ignore negative path sums by using max(0, ...) was the "aha!" moment that made everything click. Global vs. Local: Differentiating between the path that can be extended to a parent and the path that ends at the current node. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #BinaryTree #Recursion #Algorithm #HardProblem
To view or add a comment, sign in
-
-
LeetCode #51 — N-Queens | Backtracking at Its Best Just solved the classic N-Queens problem — one of the most interesting backtracking challenges that tests logic, recursion, and optimization. Problem Insight:Place n queens on an n × n chessboard so that no two queens attack each other. That means: No same row No same column No same diagonal Approach: Backtracking + Safe Position Checks Place one queen row by row Check if the current position is safe If valid, move to the next row If stuck, backtrack and try another position What I Learned: 1) Backtracking is about trying possibilities efficiently 2) Constraints help prune unnecessary paths 3) Visualizing the board makes recursion easier to understand This problem is a great reminder that patience + recursion can solve even the toughest puzzles. #LeetCode #NQueens #Backtracking #Algorithms #CodingJourney #ProblemSolving #DSA #TechLearning
To view or add a comment, sign in
-
-
🚀 Day 22/60 — Learning Step by Step Today I worked on: 📌 Majority Element (LeetCode #169) At first, I approached the problem using a brute force method by counting the frequency of each element. While it worked, I realized it was inefficient with a time complexity of O(n²). 💡 The real learning came when I explored the optimal approach: • Understanding why brute force is not scalable • Learning Moore’s Voting Algorithm • Observing how majority elements “cancel out” others • Achieving O(n) time and O(1) space This problem helped me understand how powerful pattern-based thinking can be, especially when problems seem simple on the surface but have deeper optimizations. ✨ Key Takeaways: • Brute force is a starting point, not the destination • Look for patterns in the problem (not just logic) • Optimal solutions often come from smart observations • Time and space complexity matter a lot in interviews Still learning, still improving, one step at a time 🚀 Grateful for the guidance and inspiration from Shiv ram Sharma sir. #DSA #LeetCode #Arrays #Algorithms #ProblemSolving #LearningInPublic #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
A student recently shared this with me 👀 She solved the problem correctly. Clean logic. Correct output. But what caught my attention wasn’t the answer. It was how she approached it. Instead of jumping straight into coding, she broke the problem down, identified patterns, and thought through the logic step by step. That’s rare. Because most students today are focused on: 👉 “Kitne questions solve kiye?” Not on 👉 “Kaise solve kiya?” And that’s the real difference. At CodingNovas, we don’t just train students to write code. We train them to think in systems, patterns, and structure. Because in the long run, that’s what turns a learner into an engineer. Good to see this shift happening early 👏 This is where real growth begins 🚀 — Shiv Ram Sharma Founder & CEO, CodingNovas #CodingNovas #LearningJourney #DSA #ProblemSolving #Storytelling #BuildInPublic
🚀 Day 22/60 — Learning Step by Step Today I worked on: 📌 Majority Element (LeetCode #169) At first, I approached the problem using a brute force method by counting the frequency of each element. While it worked, I realized it was inefficient with a time complexity of O(n²). 💡 The real learning came when I explored the optimal approach: • Understanding why brute force is not scalable • Learning Moore’s Voting Algorithm • Observing how majority elements “cancel out” others • Achieving O(n) time and O(1) space This problem helped me understand how powerful pattern-based thinking can be, especially when problems seem simple on the surface but have deeper optimizations. ✨ Key Takeaways: • Brute force is a starting point, not the destination • Look for patterns in the problem (not just logic) • Optimal solutions often come from smart observations • Time and space complexity matter a lot in interviews Still learning, still improving, one step at a time 🚀 Grateful for the guidance and inspiration from Shiv ram Sharma sir. #DSA #LeetCode #Arrays #Algorithms #ProblemSolving #LearningInPublic #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
Day 39 | LeetCode Learning Journal 🚀 Today I solved Sqrt(x) using Binary Search. This problem helped me understand how searching techniques can be applied beyond arrays to mathematical problems! 🔑 Key Points: • Find the integer square root of a number. • Avoid using built-in sqrt functions. • Applied Binary Search to reduce time complexity. • Stored the last valid answer (floor value). 🌱 What I Learned: • How Binary Search can be used on answer space. • Importance of avoiding overflow using long long. • Efficient way to handle large inputs. • Strengthened problem-solving with math + logic. #LeetCode #100DaysOfCode #DSA #CodingJourney #Day39 🚀
To view or add a comment, sign in
-
-
🚀 Day 23/100 – LeetCode Challenge ✅ Problem Solved: Sort an Array Today’s problem was all about implementing sorting from scratch without using any built-in functions. I used the Merge Sort algorithm to achieve the required O(n log n) time complexity. This was a great revision of divide-and-conquer concepts, where the array is recursively divided and then merged in sorted order. 💡 Key Learning: Understanding sorting algorithms is fundamental for interviews Merge Sort guarantees O(n log n) performance Writing algorithms from scratch improves problem-solving depth ⚡ Complexity: Time: O(n log n) Space: O(n) Building strong fundamentals, one day at a time 🚀 #Day23 #100DaysOfCode #LeetCode #DSA #Cpp #CodingJourney #Sorting #MergeSort
To view or add a comment, sign in
-
-
Day 16 of #30DaysOfLeetCode Solved LeetCode Problem #69 – Sqrt(x) using C. Problem: Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The solution must not use built-in functions like sqrt() or pow(). Approach I used: • Applied Binary Search to find the integer square root • Searched within the range 0 to x • Compared mid * mid with x • If it was smaller → moved right • If it was larger → moved left • Stored the last valid value as the final answer Performance: • Runtime: 0 ms • Memory: 9.06 MB What I learned today: • How binary search can be used for mathematical problems • Importance of choosing the correct data type (long) to avoid overflow • Better understanding of efficient problem-solving techniques • Staying consistent every day is making the problems easier to solve #LeetCode #DSA #Algorithms #BinarySearch #CProgramming #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Coding Challenge: Day 12 Solved Peak Index in a Mountain Array. ⚡ Approach: Used Binary Search instead of linear scan. Compared arr[mid] with arr[mid + 1]: If increasing → move right If decreasing → peak is on left (or mid) This helps directly reach the peak efficiently. ⚡ Time Complexity: ✔ O(log n) ⚡ Space Complexity: ✔ O(1) ⚡ Key Learning: ✔ Binary Search works on patterns, not just sorted arrays ✔ Identify increasing/decreasing trends #DSA #LeetCode #BinarySearch #CPlusPlus #ProblemSolving
To view or add a comment, sign in
-
-
Tired of complex infrastructure setup? The expanded #EOSCEUNode Tools Hub is your one-stop shop for research software, ready for instant deployment. From data processing to advanced analytics, access powerful tools like Galaxy for biomedical research and DaskHub for parallel computing in Python. ✅ One-Stop Access: A curated catalogue of reliable applications. ✅ For All Skill Levels: Deploy easily as a beginner or use TOSCA templates for advanced, reproducible workflows. ✅ Cost-Covered: Computational resources are provided by the European Commission. Ready to get started? We have everything you need: Watch the Demo Video: See how to allocate a Virtual Machine and set up tools in your User Space. Follow the Tutorial: "Tools Hub: Introduction for Researchers" Take the Course: "How to use the EOSC EU Node Tools Hub: A Complete Guide" 🔗 Explore the Tools Hub: https://lnkd.in/epvSbBEj
To view or add a comment, sign in
-
-
🚀 Just built K-Means Clustering from scratch in C++! I implemented the K-Means algorithm step-by-step to understand how clustering works internally. 🔹 Generated random data points 🔹 Calculated Euclidean distance 🔹 Assigned clusters 🔹 Updated centroids iteratively This project helped me understand how data can be grouped efficiently and how clustering is used in real-world applications. 🔗 GitHub: https://lnkd.in/gVYbNAKj Open to feedback and suggestions! #cpp #algorithms #machinelearning #coding #developers
To view or add a comment, sign in
-
Explore related topics
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