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
LeetCode Day 4: Permutations Backtracking Fundamentals
More Relevant Posts
-
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 10 | LeetCode Learning Journal 🚀 Today I practiced Binary Tree Preorder Traversal (Problem 144) on LeetCode. This problem helped me understand how tree traversal works when we visit the root before its subtrees. 🔑 Key Points: • Traversal order: Root → Left → Right • Visit the current node first • Recursively traverse the left subtree • Then recursively traverse the right subtree • Can also be implemented using a stack (iterative approach) 🌱 What I Learned: • Basics of tree traversal techniques • How recursion naturally fits tree structures • Difference between recursive and iterative traversal • Importance of traversal order in trees • Strengthened understanding of tree fundamentals #LeetCode #100DaysOfCode #DSA #BinaryTree #PreorderTraversal #Day10
To view or add a comment, sign in
-
-
Day 5| LeetCode Learning Journal 🚀 Today I solved Combination Sum II (Problem 40) on LeetCode. Unlike Combination Sum (39), here each element can be used only once and we must avoid duplicate combinations. This small change made the recursion logic more careful and structured. 🔑 Key Points: • Sort the array before backtracking • Skip duplicates using if(i > index && candidates[i] == candidates[i-1]) continue; • Use i + 1 to avoid reusing elements • Proper push → recurse → pop (backtracking) • Stop early when element > remaining target. 🌱 What I Learned: • How to handle duplicates in backtracking problems • Difference between reuse allowed vs not allowed • Importance of pruning to reduce unnecessary recursion • How small constraints completely change the recursion tree • Improved understanding of decision tree visualization #LeetCode #100DaysOfCode #Backtracking #DSA #Day4
To view or add a comment, sign in
-
-
Day 8 | LeetCode Learning Journal 🚀 Today I solved Fibonacci Number (Problem 509) on LeetCode. This was a simple recursion problem, but it helped me clearly understand how recursive calls build on smaller subproblems. 🔑 Key Points: • Base case: if n ≤ 1 → return n • Recursive relation: F(n) = F(n-1) + F(n-2) • Each call breaks the problem into smaller Fibonacci numbers • Basic example of recursion with a clear recurrence relation • Optimized approach can be done using iteration (DP) 🌱 What I Learned: • Importance of defining correct base conditions • How recursion tree grows exponentially • Why simple recursion can be inefficient • Difference between brute-force recursion and optimized solution • Strengthened fundamentals of recursion before moving to complex backtracking problems #LeetCode #100DaysOfCode #Recursion #DSA #Day8 🚀
To view or add a comment, sign in
-
-
💡 LeetCode Practice – Increasing Triplet Subsequence Today I learned that not every problem can be solved using sorting. Maintaining the original order and thinking in terms of traversal is crucial. 📌 Key Learning: Importance of index order (i < j < k) Optimizing from brute force to O(n) Smart tracking instead of extra space Consistency is building confidence 🚀 #leetcode #codingjourney #webdevelopment #dsa
To view or add a comment, sign in
-
-
Day 18/50 — LeetCode First Bad Version taught me a key lesson: Linear search isn’t always enough Optimization matters for large inputs Binary Search reduces complexity from O(n) → O(log n) Learning to code smarter, not just harder. #Day18 #LeetCode #BinarySearch #DSA #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 16/100 — LeetCode Challenge (Revision Day) Today I focused on revising core problems from Arrays and Two Pointer techniques. Revisited: • Two Sum • Two Sum II • Container With Most Water 🧠 Key Learning: Revision helps reinforce patterns and improves problem-solving speed and confidence. Sometimes going back is the best way to move forward. 📂 Solutions Repository https://lnkd.in/gkFh2mPZ #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #Revision
To view or add a comment, sign in
-
Day 11 | LeetCode Learning Journal 🚀 Today I practiced Binary Tree Postorder Traversal (Problem 145) on LeetCode. This traversal visits the root after processing both subtrees, which makes it useful for problems like deleting trees or evaluating expressions. 🔑 Key Points: • Traversal order: Left → Right → Root • Traverse the left subtree first • Then traverse the right subtree • Visit the root node at the end • Can be implemented using recursion or stacks 🌱 What I Learned: • How postorder traversal processes children before the parent • Why this traversal is useful in tree deletion and evaluation problems • Differences between preorder, inorder, and postorder traversals • Strengthened understanding of recursive tree algorithms • Built a stronger foundation for advanced tree problems #LeetCode #100DaysOfCode #DSA #BinaryTree #PostorderTraversal #Day11
To view or add a comment, sign in
-
-
🚀 Day 62 of LeetCode Problem Solving Journey — 100 Days LeetCode Challenge Today, I solved LeetCode #414 — Third Maximum Number using C++, under the guidance of Trainer NEKAL SINGH SALARIA Singh at REGex Software Services. 🔍 Problem Summary: Given an integer array nums, return the third distinct maximum number in the array. If the third maximum does not exist, return the maximum number. 🧠 Approach Used (Tracking Maximum Values): I tracked the top three distinct maximum numbers while traversing the array: Maintain three variables → max, second, and third Update them while iterating through the array Skip numbers that are already counted to ensure distinct values If the third maximum exists → return it Otherwise → return the maximum number This approach avoids sorting and keeps the solution efficient. 📚 Key Learnings of the Day ✔ Tracking multiple maximum values can replace sorting ✔ Handling distinct values is important in ranking problems ✔ Careful conditional updates prevent duplicates ✔ Iterative comparison logic improves performance ⏱ Complexity • Time Complexity: O(n) • Space Complexity: O(1) 💡 Optimization Insight: Avoiding sorting reduces complexity from O(n log n) to O(n). Maintaining running maximum values is a powerful technique for similar problems. Consistency and discipline make the journey stronger — see you on Day 63 🚀 #Day62 #100DaysLeetCodeChallenge #LeetCode #RegexSoftwareServices #NekalSingh #ProblemSolving #DSA #CPlusPlus #CodingChallenge #ProgrammingJourney #Arrays #KeepGrowing
To view or add a comment, sign in
-
-
🚀 Day 62 of #100DaysOfCode 💻 Solved: Third Maximum Number (LeetCode 414) 🔍 Problem Statement: Given an integer array, return the third distinct maximum number. If it doesn’t exist, return the maximum number instead. 💡 Approach: The key here is “distinct” values — duplicates don’t count. First, focus on identifying unique numbers Then track the top 3 maximum distinct values If less than 3 distinct values exist → simply return the largest Instead of sorting (which adds extra cost), we can efficiently keep track of the top 3 values while traversing the array once. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) (if done optimally) 📌 Key Learning: This problem teaches how to optimize by avoiding sorting and how to maintain multiple maximums efficiently in a single pass. #Day62 #LeetCode #DSA #CodingJourney #PlacementPrep
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
👍