Day 60 of My 90-Day Coding Challenge Today I worked on a classic recursion + backtracking problem — and it really tested how well I understand breaking problems into smaller decisions. At first, it feels messy: multiple partitions, multiple choices, and many possible paths. But once you start thinking in terms of: -“Try every possible cut and validate it” the structure becomes clear. Key learning: • Recursion is about exploring all paths, not rushing to the answer • Validity checks (like palindrome here) are what control the tree • Clean backtracking (add → recurse → remove) is everything One thing that really helped today: Even if you don’t know where to start, just begin drawing the recursion tree. As you expand it step by step, the logic starts revealing itself — what choices to make, when to stop, and how to backtrack. What stood out today: Clarity in recursion doesn’t come from memorizing patterns — it comes from visualizing the process. Still improving. #90DaysOfCode #DSA #Java #Recursion #Backtracking #LeetCode #ProblemSolving
Recursion and Backtracking in 60 Days
More Relevant Posts
-
🚀 Day 54 – 100 Days Coding Challenge 📌 Problem: Three Sum ⚙️ Approach • First, sort the array to make it easier to apply the two-pointer technique • Iterate through the array and fix one element at a time • For each fixed element, use two pointers (left and right) to find pairs whose sum equals the negative of the fixed element • Skip duplicate elements to avoid repeating triplets • Move pointers based on the sum: – If sum == 0 → store the triplet and move both pointers – If sum < 0 → move left pointer forward – If sum > 0 → move right pointer backward 🧠 Logic Used • Sorting + Two Pointer Technique • Handling duplicates efficiently to ensure unique triplets • Reducing time complexity from brute force O(n³) to O(n²) 🔗 GitHub: https://lnkd.in/g_3x55n8 ✅ Day 54 Completed #100DaysOfCode #Java #DSA #ProblemSolving #Algorithms #DataStructures #LeetCode #CodingPractice #TwoPointers #ArrayProblems
To view or add a comment, sign in
-
-
🚀 Day 8 of 30 Days Coding Challenge Today I solved a problem on LeetCode: Minimum Distance Between Three Equal Elements. 🔍 Approach: Initially implemented a brute-force solution using three nested loops (O(n³)). It worked for smaller constraints but highlighted the importance of optimizing. 💡 Key Learning: Instead of checking all possible triplets, grouping indices of identical elements and analyzing consecutive occurrences leads to a much more efficient solution. ⚡ Optimization Insight: Reduced time complexity from O(n³) → O(n) Leveraged HashMap to store indices and process only relevant combinations. 📈 Takeaway: This problem reinforced an important concept: 👉 When dealing with repeated elements, think in terms of grouping and patterns rather than brute force. Consistency is key — learning something new every day and improving step by step. #Day8 #30DaysOfCode #CodingChallenge #LeetCode #Java #DataStructures #Algorithms #ProblemSolving #CodingJourney #SoftwareDevelopment #LearnToCode #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 13 / 50 – Wild Coding Kickoff 🔥 Today’s problem looked like it wanted a complicated solution… but it ended up teaching me something much simpler. I read the question and instantly thought: “Okay, substring search… this might get tricky.” 👀 Loops, comparisons, edge cases… my mind started going there. But then I stopped and asked: 👉 “Is there a simpler way?” That’s when I used this: class Solution { public int strStr(String haystack, String needle) { int index = haystack.indexOf(needle); return index; } } 💡 What does indexOf() actually do? It searches for the first occurrence of needle inside haystack Returns: ✅ The starting index if found ❌ -1 if the substring is not present 🔥 Example haystack = "sadbutsad" needle = "sad" 👉 Output: 0 (because "sad" starts at index 0) 🧠 What I learned today Sometimes we try to prove we know everything… But real skill is knowing when to keep things simple. Using built-in methods effectively is also a skill. #Day13 #50DaysOfCode #WildCodingKickoff #LeetCode #Java #CodingJourney #Consistency #KeepItSimple #ProblemSolving
To view or add a comment, sign in
-
-
Day 5 / 100 Days of Coding : Solved: Best Time to Buy and Sell Stock Today’s problem looked simple but taught a powerful concept — tracking minimums and maximizing profit in a single pass. Key Learning: Instead of checking all pairs (which is slow), we maintain: Minimum price so far Maximum profit so far This reduces complexity from O(n²) → O(n) Consistency is the real game. Showing up every day matters more than perfection. #100DaysOfCode #DSA #LeetCode #Java #CodingJourney #ProblemSolving #GreedyAlgorithm
To view or add a comment, sign in
-
-
Day 55 of 100 Days of LeetCode 💻 Today I solved Longest Consecutive Sequence — and honestly, this one taught me more about coding discipline than algorithms. At first, my approach was correct: Used HashSet for O(1) lookup Applied the “start of sequence” logic But I still got TLE. The reason? A tiny mistake: if(!set.contains(num-1)); That single ; made my condition useless and turned my O(n) solution into O(n²). 💡 Lesson learned: Don’t just think your logic is right → verify what your code actually does Small syntax mistakes can completely break optimal solutions Debugging is just as important as problem-solving Finally fixed it and got Accepted ✅ Slowly improving not just in DSA, but in writing cleaner and more careful code. #100DaysOfLeetCode #DSA #Java #CodingJourney #Learning
To view or add a comment, sign in
-
-
Day 14 of #50DaysOfLeetCode Challenge Today’s coding challenge was Rotate List (LeetCode 61). The goal is to rotate a linked list to the right by k places. At first, it sounds like you need to move nodes one by one, but that’s inefficient. The key to a high-performance solution is to treat the list like a loop! The Efficiency Strategy: 1. Calculate Length: First, find the total length of the list (n). 2. Handle Large K: If k is larger than n, we only need to rotate k % n times. This avoids unnecessary cycles. 3. Make it a Circle: Connect the last node's "next" pointer to the original head to create a temporary circular list. 4. Find the New Break: Move (n - (k % n)) steps from the head to find the new tail of the rotated list. 5.Break the Loop: Save the node after the new tail as the new head, and then set the new tail's "next" to null. #LeetCode #BitManipulation #Java #Coding #Efficiency #TechLearning
To view or add a comment, sign in
-
-
Day 8/30 of my #30DaysDSAChallenge 🚀 Solved Problem 70 on LeetCode: Climbing Stairs 🧗♂️ At first glance, it looks simple — but the real learning was in identifying the pattern. This problem is a classic example of how Dynamic Programming works behind the scenes. 💡 Key Insight: To reach step n, you can either come from n-1 or n-2. Which leads to a Fibonacci-like relation: 👉 ways(n) = ways(n-1) + ways(n-2) Instead of using recursion (which is inefficient), I implemented an optimized iterative approach with O(n) time and O(1) space. 📚 What I learned today: Recognizing DP patterns in problems Converting recursion → optimized iteration Importance of space optimization Small steps every day, but getting stronger with problem-solving 💪 #DSA #LeetCode #Java #ProblemSolving #CodingJourney #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀Solved Validate Stack Sequences by simulating the stack using a simple array instead of relying on built-in stack classes. This helped reduce overhead and kept the operations efficient. Focused on writing clean logic with optimal time complexity. 😊 Result: 💯 Achieved 0 ms runtime beating 100% of submissions, with memory usage around 45.52 MB performing in the top percentile. 💥 #LeetCode #DSA #Java #Coding #ProblemSolving #Preparation #Anurag_University 🚀🚀
To view or add a comment, sign in
-
-
🎉 Day 8 of My 100-Day Programming Challenge! 🚀 Today, I solved the “Sqrt(x)” problem on LeetCode. The task is to compute the square root of a non-negative integer and return the result rounded down to the nearest integer, without using built-in functions like pow() or sqrt(). 🧩 🔍 Approach: I used the Binary Search technique to efficiently find the square root. ⚙️ Steps: • Define the search space from 1 to x. • Calculate the middle value (mid). • Check if mid * mid is equal to x. • If less than x, move right and store the potential answer. • If greater than x, move left. • Continue until the search space is exhausted. 💡 Key Insights: ✔ Binary Search reduces time complexity significantly. ✔ Avoids overflow using mid <= x / mid instead of mid * mid. ✔ Efficient way to compute roots without built-in functions. 🧠 Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) Another great problem to strengthen Binary Search fundamentals and mathematical problem-solving skills. On to the next challenge! 💻🔥 #100DaysOfCode #Java #LeetCode #DSA #BinarySearch #Programming #CodingChallenge
To view or add a comment, sign in
-
-
🚀 Solved LeetCode Problem #58 – Length of Last Word Today I worked on a simple yet insightful string manipulation problem that emphasizes attention to edge cases. 🔍 Problem Insight: Given a string containing words and spaces, the goal is to find the length of the last word, ignoring any trailing spaces. 💡 Approach Used: Instead of using built-in methods like split(), I implemented an optimized approach by: Traversing the string from the end Skipping trailing spaces Counting characters until the next space is encountered This approach avoids extra space usage and improves efficiency. 🧠 Key Learning: Importance of handling edge cases like trailing spaces How reverse traversal can simplify string problems Writing memory-efficient solutions 📈 Complexity: Time: O(n) Space: O(1) ✨ Problems like this help strengthen: String manipulation skills Logical thinking Writing clean and optimized code Consistency is key—one step closer to mastering DSA! 💪 #LeetCode #DSA #StringManipulation #Coding #ProblemSolving #Java #TechJourney
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