Day 24 | LeetCode Learning Journal 🚀 Today was all about tackling Problem 47: Permutations II, and it was a masterclass in the art of Backtracking. While the first permutations problem is about exploring possibilities, this one adds a layer of complexity: handling duplicates. It’s fascinating how a small constraint—like ensuring each permutation is unique—completely changes the strategy. It forced me to think deeply about state management and how to use sorting and conditional checks to "prune" the search tree, preventing redundant calculations. Key Takeaways from Today: Pruning is Power: Learning when not to explore a path is just as important as knowing how to traverse one. The Power of Recursion: Breaking down a complex combinatorial problem into smaller, repeatable logic steps is where the magic happens. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #Backtracking #LearningInPublic #KeepGrowing
Mastering Backtracking with LeetCode Problem 47
More Relevant Posts
-
Day 28 | LeetCode Learning Journal 🚀 Today I tackled Problem 37: Sudoku Solver, and this one was a true test of patience and algorithmic thinking. Moving from simple patterns to complex backtracking has been a game-changer. It’s fascinating how recursion allows us to explore thousands of possibilities, "pruning" the ones that don't work and pivoting until we find the perfect solution. It’s not just about writing code; it’s about teaching the program how to make decisions. Key takeaways from today: Backtracking Mastery: Understanding how to "undo" a choice is as important as making one. Validation Logic: Breaking down constraints (rows, columns, and 3x3 grids) into clean, reusable functions. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #Backtracking #LearningInPublic #KeepGrowing
To view or add a comment, sign in
-
-
Day 3 | LeetCode Learning Journal 🚀 Today I solved Combination Sum (Problem 39) on LeetCode another powerful backtracking problem. Compared to N-Queens, this one focused more on exploring combinations systematically while avoiding unnecessary paths. The interesting part was that we can reuse the same element multiple times, which changes how we design the recursive calls. The key learning was understanding how to: Keep track of the remaining target Use a start index to avoid duplicate combinations. Backtrack properly by removing the last added element after recursion .Instead of generating all possibilities blindly, I learned how pruning works if the current sum exceeds the target, we immediately stop exploring that path. This makes the solution much more efficient. 💡 🌱 What I learned: • How to generate combinations using recursion • Importance of pruning in backtracking • Managing state with push and pop operations • Thinking in terms of decision trees #LeetCode #100DaysOfCode #CodingJourney #Backtracking #DSA #Day3
To view or add a comment, sign in
-
-
Day 2 | LeetCode Learning Journal 🚀 Today I worked on N-Queens (Problem 51) on LeetCode another classic backtracking problem. After solving Sudoku on Day 1, I felt more prepared, but N-Queens had its own twist. The biggest challenge was managing diagonal attacks efficiently. Learning that row - col and row + col can uniquely track diagonals was a game-changing moment. 💡 Instead of checking the entire board every time, I used separate arrays for columns and diagonals to keep the solution optimized and clean. This really improved my understanding of how to structure recursive calls properly. 🌱 What I learned: • Backtracking works best with smart state management • Clean validation reduces time complexity • Confidence grows when you tackle hard problems consistently #LeetCode #100DaysOfCode #CodingJourney #Backtracking #DSA #Day2
To view or add a comment, sign in
-
-
Day 27 | LeetCode Learning Journal 🚀 Today I tackled Problem 40: Combination Sum II, and this one was a masterclass in the art of Backtracking. While Day 12 taught me the power of frequency mapping, today was all about managing state and avoiding duplicates. It’s fascinating how adding a single constraint—using each number only once—completely changes the strategy. It’s not just about finding a path to the target; it’s about efficiently pruning the search tree so you don't waste time on redundant calculations. Key takeaways from today: Sorting is Strategy: Sorting the input initially makes it much easier to skip duplicate elements during recursion. Pruning for Performance: Learning when to stop the recursion (if current > target) is the difference between a TLE (Time Limit Exceeded) and a 0ms runtime! 27 days in, and the "backtracking" mindset is finally starting to click. Seeing that 0ms (Beats 100%) result feels incredible—it's proof that clean logic beats brute force every time. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #Backtracking #LearningInPublic #KeepGrowing
To view or add a comment, sign in
-
-
Day 25 | LeetCode Learning Journal 🚀 Today I tackled the classic N-Queens problem. If Day 12 was about patterns and counting, today was all about Backtracking and visualizing the recursion tree. Key Takeaways: Backtracking is Art: It’s not just about trying every possibility; it’s about "pruning" the branches that don't work early on to save time. The isSafe Logic: Writing a clean helper function to check rows, columns, and diagonals is the heart of this problem. It really tests your ability to think spatially in a grid. Debugging Recursion: Seeing that "Accepted" green text for a Hard/Medium-Hard backtracking problem hits different. It’s a sign that my ability to trace complex code is sharpening. "Consistency matters more than perfection." 25 days down—a quarter of the way through the 100-day mark! The problems are getting tougher, but the logic is becoming more intuitive. Excited to keep pushing deeper into advanced algorithms. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #CPlusPlus #DSA #Backtracking #NQueens #LearningInPublic #KeepGrowing
To view or add a comment, sign in
-
-
Day 4 | LeetCode Learning Journal 🚀 Today I solved Permutations (Problem 46) on LeetCode another classic backtracking problem that really strengthens recursion fundamentals. Unlike Combination Sum where we focused on reaching a target, this problem was about generating all possible arrangements of given numbers. The main challenge was making sure that each element is used exactly once in every permutation. The key learning was understanding how to: Keep track of which elements are already used. Build permutations step by step. Backtrack properly by removing the last element and marking it unused after recursion. Instead of randomly arranging numbers, I learned how the decision tree works at every level we choose one unused number, explore deeper, and then backtrack to try other possibilities. This systematic exploration ensures we generate all permutations efficiently. 💡 🌱 What I learned: • How to generate permutations using recursion • Using a visited array / boolean tracking • Proper backtracking with push and pop • Visualizing recursion as a decision tree #LeetCode #100DaysOfCode #CodingJourney #Backtracking #DSA #Day4
To view or add a comment, sign in
-
-
Day 79 | #100DaysOfCode | #100DaysOfLearning 🧿 Still diving deeper into the Binary Tree pattern ✅ Solved: Symmetric Tree (Leetcode 101) This problem checks whether a binary tree is a mirror of itself around its center. 💡 Key Idea: Instead of comparing nodes in the same direction, we compare them crosswise: Left subtree of node A ↔ Right subtree of node B Right subtree of node A ↔ Left subtree of node B If both sides match at every level → the tree is symmetric. Approach (Recursion): If both nodes are NULL → symmetric If one is NULL → not symmetric Values must match Recursively compare: left.left with right.right left.right with right.left 📌 This problem strengthened my understanding of: ✔️ Mirror recursion in trees ✔️ Comparing two structures simultaneously ✔️ Thinking about trees from two directions at once Consistency continues… 79 days of showing up and learning something new. #100DaysOfCode #DSA #BinaryTree #Leetcode #CodingJourney #ProblemSolving #SoftwareEngineering #TechCommunity #Programmers #Developers #LearnInPublic
To view or add a comment, sign in
-
-
🚀 Day 19 | 100 Days of Coding Challenge #DrGViswanathanChallenge 📘 Problem Solved: Combination Sum III 🔧 Approach Used (Backtracking): • Generated combinations using numbers 1–9 • Ensured each number is used only once • Maintained a running sum and current combination • If the sum becomes 0 and the combination size equals k, we store the result • Used backtracking (Choose → Explore → Undo) to explore all valid possibilities ⏳ Complexity: Time: O(2⁹) (since numbers are from 1–9) Space: O(k) recursion stack 🧠 Key Learning: Backtracking is powerful for generating combinations with constraints like fixed size (k) and target sum (n). Using a starting index (last) ensures elements are not reused and avoids duplicate combinations. 📂 Topics Covered: Backtracking, Recursion, Combinations, Constraint-based Search #100DaysOfCode #DSA #LeetCode #CPP #CodingJourney #Backtracking #CompetitiveProgramming
To view or add a comment, sign in
-
-
Day 6 | LeetCode Learning Journal 🚀 Today I solved Palindrome Partitioning (Problem 131) on LeetCode. This problem was another strong backtracking challenge, but instead of focusing on sums or combinations, it focused on dividing a string into all possible palindromic partitions. The main challenge was checking palindromes efficiently while exploring every possible cut in the string. 🔑 Key Points: • Use backtracking to try every possible substring • Check if substring is palindrome before choosing it • If valid → push → recurse → pop • Base case when start index reaches string length • Carefully manage substring ranges (start to end) 🌱 What I Learned: • How to generate all possible partitions of a string • Combining recursion with condition checking (palindrome validation) • Difference between combination-style problems and partition-style problems • How recursion explores a decision tree of “cut” vs “don’t cut” • Strengthened understanding of backtracking patterns This problem really improved my clarity on how recursive partitioning works compared to problems like Combination Sum. The structure is similar, but the condition check (palindrome) changes the whole recursion flow. #LeetCode #100DaysOfCode #Backtracking #DSA #Day5 🚀
To view or add a comment, sign in
-
-
🚀 Day 17 | 100 Days of Coding Challenge #DrGViswanathanChallenge 📘 Problem Solved: Combination Sum II (LeetCode) 🔧 Approach Used (Backtracking + Sorting): • Sorted the array to handle duplicates efficiently • Used index-based recursion to ensure each number is used only once • Skipped duplicate elements to avoid repeated combinations ⏳ Complexity: Time: Exponential (bounded by valid combinations) Space: O(target) (recursion stack) 🧠 Key Learning: Sorting combined with smart pruning is key to avoiding duplicate results in backtracking problems. 📂 Topics Covered: Backtracking, Recursion, Arrays #100DaysOfCode #DSA #CPP #LeetCode #CodingJourney #CompetitiveProgramming
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