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
Binary Tree Maximum Path Sum LeetCode Challenge
More Relevant Posts
-
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
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
-
-
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 12/150 — Neetcode Journey 🚀 Solved: Subsets, Subsets II, N-Queens 💡 Key Insight: Backtracking is about systematically exploring all possibilities and undoing choices at the right time ⚠️ Challenge: N-Queens was challenging — managing constraints (rows, columns, diagonals) requires careful thinking 🧠 What I learned: 1. Subsets problems build the foundation for backtracking 2. Handling duplicates (Subsets II) adds an extra layer of complexity 3. Constraint-based problems (like N-Queens) test deeper understanding of recursion Definitely one of the more mentally demanding days so far. #DataStructures #Algorithms #CodingJourney #DSA #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 9 of #100DaysOfCode Today’s problem was all about finding the missing number in a sequence — simple on the surface, but a great exercise in logic and optimization. 🔍 Problem Insight: Given an array of n distinct numbers from the range [0, n], one number is missing. The task is to identify it efficiently. 💡 What I learned: Brute force works, but it's not scalable Using the sum formula n(n+1)/2 makes it O(n) time and O(1) space Even better: XOR approach eliminates overflow risks and is super elegant ⚡ Key takeaway: Sometimes the smartest solutions come from mathematical thinking rather than coding complexity. 📌 Example: nums = [3,0,1] → Missing = 2 Consistency > Perfection. Showing up daily and improving step by step. #DSA #ProblemSolving #CodingJourney #100DaysOfCode #LeetCode #Algorithms #LearningEveryday #DSAwithedSlash
To view or add a comment, sign in
-
-
Day 2/150 — Neetcode Journey 🚀 Solved: Valid Palindrome, Two Sum II (Sorted), 3Sum, Container With Most Water 💡 Key Insight: Two pointers can drastically reduce time complexity when working with sorted arrays or paired conditions ⚠️ Struggle: Got stuck handling duplicate answers (especially in 3Sum) — logic worked, but output wasn’t clean 🧠 What I learned: 1. Solving the problem isn’t enough — handling edge cases properly matters 2. Two pointers is a powerful pattern when used correctly 3. Clean output requires careful thought, not just correct logic Starting to see patterns more clearly now. #DataStructures #Algorithms #CodingJourney #DSA #LearningInPublic
To view or add a comment, sign in
-
📌 Strengthening DSA Concepts through Problem Solving Recently, I solved LeetCode 204 – Count Primes It’s a problem that looks straightforward at first, but applying the right mathematical optimization makes it much more efficient. Problem: Given an integer n Each number from 0 → n-1 can either be prime or not We need to: 👉 Count how many prime numbers are strictly less than n 🎯 Goal: return the total count of primes Naive Approach: → Check every number individually → For each number, test divisibility But this fails because: ❌ It takes too long for large inputs ❌ Time complexity becomes O(n √n) Optimized Approach (Sieve of Eratosthenes) Instead of checking each number: 👉 Eliminate non-prime numbers in bulk 👉 Use a boolean array: false → prime true → not prime 🔑 Key Idea: Mark multiples of each number as non-prime: Start from: 2 (first prime) Mark 2×2, 2×3, 2×4... Then: Move to next unmarked number Repeat the process ⚙️ Implementation (Important Code Steps) 1️⃣ Initialize array boolean[] check = new boolean[n + 1]; check[0] = true; if (n > 0) check[1] = true; 2️⃣ Mark non-primes (core logic) for (int i = 2; i * i <= n; i++) { if (check[i] == false) { for (int j = i * i; j < n; j += i) { check[j] = true; } } } 3️⃣ Count primes int cnt = 0; for (int i = 0; i < n; i++) { if (check[i] == false) { cnt++; } } 🔄 Traversal: → Start from i = 2 → If number is unmarked → it's prime → Mark all its multiples from i*i Finally: → Count all unmarked values ⏱️ Complexity: Time complexity: O(n log log n) Space complexity: O(n) 💡 Learning: Some problems are not about checking each possibility… 👉 They are about eliminating invalid cases efficiently 👉 And recognizing classic patterns like Sieve of Eratosthenes Let’s keep learning and improving every day #LeetCode #Math #Sieve #DSA #ProblemSolving #CodingJourney #InterviewPreparation
To view or add a comment, sign in
-
#Day547 of #600DaysOfDSA Topics and Learnings: #BinarySearch Problems Re-revised: 167. #Leetcode #410 : Split Array Largest Sum Approach: Used #BinarySearch to solve this Complexity Analysis: TC: O(N * (log(sum - max) + 1)) SC: O(1) #600DaysLeetCodeChallenge #600DaysLeetCode #DataStructures #Algorithms #ProblemSolving #DSA #LeetCode #TakeUForward #TUF+ #SoftwareDevelopment #ContinuousLearning #ProfessionalGrowth #Coding
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
-
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