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 🚀
Validating Binary Search Tree with Recursive Approach
More Relevant Posts
-
🚀 Day 29/100 – LeetCode Challenge ✅ Problem Solved: Find Peak Element Today’s problem was a great application of Binary Search beyond traditional searching. The goal was to find a peak element — an element greater than its neighbors. Instead of checking every element, I used a binary search approach to efficiently narrow down the search space and find a peak in O(log n) time. 💡 Key Learning: Binary Search can be applied to decision-based problems Observing patterns (increasing/decreasing) helps reduce complexity Not all problems require checking every element ⚡ Complexity: Time: O(log n) Space: O(1) Learning to think smarter, not harder 🚀 #Day29 #100DaysOfCode #LeetCode #DSA #Cpp #CodingJourney #BinarySearch #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 51 of my LeetCode Journey Solved: Roman to Integer At first glance, this problem looks simple — just map symbols to numbers. But the real catch is handling subtractive cases like IV (4), IX (9), etc. 💡 Key Learning: Instead of blindly adding values, you need to compare current and next characters: If current < next → subtract Else → add This small twist is what separates a correct solution from a wrong one. 📊 Result: ✅ Accepted ⏱️ Runtime: 6 ms 📌 Takeaway: Even “easy” problems test your attention to detail. Don’t underestimate them. Consistency > Motivation. See you on Day 52. #LeetCode #DSA #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 11/100 — LeetCode Challenge Solved Capacity To Ship Packages Within D Days The problem is not about finding an element… It’s about finding the minimum capacity that satisfies a condition. 💡 Approach: The answer lies between: 👉 max(weights) and sum(weights) 1) Apply binary search on this range 2) For each capacity, simulate shipping: -Count how many days it takes -If days ≤ given → try smaller capacity -Else → increase capacity 👉 This is a mix of binary search + greedy validation 🧠 Time Complexity: O(n log n) 💾 Space Complexity: O(1) 💡 What I learned: Whenever the problem asks for minimum/maximum value under a constraint, there’s a high chance it can be solved using binary search on answer. This pattern is getting clearer now. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #Greedy #CodingJourney
To view or add a comment, sign in
-
-
Day 38 | LeetCode Learning Journal 🚀 Today I solved Valid Palindrome using the two-pointer approach. This problem helped me understand how to efficiently process strings while ignoring unnecessary characters! 🔑 Key Points: • Given a string, check if it is a palindrome. • Ignored non-alphanumeric characters (spaces, symbols). • Compared characters in a case-insensitive manner. • Used two pointers (left & right) for efficient checking. 🌱 What I Learned: • How to use the two-pointer technique for string problems. • Importance of handling edge cases (special characters). • Optimizing space complexity (no extra string needed). • Writing clean and efficient logic for real-world scenarios. #LeetCode #100DaysOfCode #DSA #CodingJourney #Day38 🚀
To view or add a comment, sign in
-
-
LeetCode Progress 48/50 — Guess Number Higher or Lower I worked on a fundamental problem focused on binary search and decision optimization 🧩 💡 The challenge was to guess a picked number by narrowing down the search space efficiently. 🧠 Approach: Used binary search strategy by repeatedly dividing the range into halves based on feedback (higher/lower), reducing the number of guesses required. ⏱ Time Complexity: O(log n) 💡 What I learned: This problem reinforced how binary search is not just for arrays, but also for optimizing decision-based problems by eliminating half the search space each step. 📈 Strengthening core binary search intuition and improving problem-solving efficiency. #LeetCode #DSA #BinarySearch #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
🧠 Day 32/75: Solving for the "End" from the "Beginning" Linked Lists can be tricky because you can't access elements by index. So, how do you remove the Nth element from the back without knowing the total length? Today’s LeetCode session was a deep dive into Pointer Logic. By maintaining a specific distance between two pointers, I was able to identify and delete the target node in a single traversal. Current Progress: 📅 32 Days Consecutive 🎯 Focus: Advanced Linked List Patterns ⚡ Result: 100% Beats Runtime Another day, another problem solved. The second month is off to a strong start! 💻🔥 #Consistency #100DaysOfCode #DSA #CodingJourney #JavaDeveloper #TechGrowth #LeetCodeChallenge #LinkedInLearning
To view or add a comment, sign in
-
-
🚀 Day 29/100 — LeetCode Challenge Today's problem: Find First and Last Position of Element in Sorted Array 🧠 Concept: Binary Search (Boundary Finding) 💡 Key Idea: Use binary search twice to find the first and last occurrence of a target element in a sorted array. ⚡ Time Complexity: O(log n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Understanding how to modify binary search to handle duplicates and find boundaries. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
🚀 LeetCode 378 — Kth Smallest Element in a Sorted Matrix | Solved ✅ Solved this interesting problem using Binary Search on Answer — a powerful pattern! 🔍 Problem Insight: Matrix is sorted row-wise and column-wise, but not flattened. 💡 Approach: • Applied binary search on value range • For each mid, counted elements ≤ mid using matrix properties ⚡ Time Complexity: O(n × log(max - min)) ✨ Key Learning: Not all binary search problems are about indices — sometimes we search in the answer space. 📈 Result: Accepted ✔️ From searching positions → to searching values That’s where problem-solving evolves 🔥 Grateful to Pratyush Narain for the guidance and clear explanations. #LeetCode #DSA #BinarySearch #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 29 – LeetCode Journey 🚀 Solved Two Sum II – Input Array Is Sorted using the Two Pointer technique, leveraging the sorted nature of the array for an optimal solution. 🔹 Time Complexity: O(n) 🔹 Runtime: 2 ms (Beats 96.37%) 🔹 Memory Usage: 48.58 MB This problem is a great reminder that recognizing patterns (like sorted arrays) can significantly reduce complexity and improve efficiency. Small optimizations, big impact 📈 Staying consistent and sharpening problem-solving skills every day. #LeetCode #DSA #ProblemSolving #CodingJourney #SoftwareEngineering #Consistency #Learning
To view or add a comment, sign in
-
-
100 LeetCode problems solved ! and honestly, it's taught me more about thinking than coding. When I started, I used to jump straight to the solution. Now I've learned to slow down — understand the problem, think brute force first, then optimize. Patterns I've been focusing on: → Sliding Window → Two Pointers → Stack & Queue → Kadane's Algorithm → Prefix Sum → Merge Intervals → Linked List The biggest shift wasn't in the number of problems solved — it was learning to recognize WHY a particular approach works, not just HOW. Still a long way to go. But consistency is starting to show results. 100 done. More to come. 🎯 #DSA #LeetCode #CodingJourney #SoftwareEngineering #100Problems
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