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
N-Queens Backtracking Challenge on LeetCode
More Relevant Posts
-
Day 26 | LeetCode Learning Journal 🚀 Today I solved Permutations. This problem helped me understand the concept of recursion and backtracking more deeply! 🔑 Key Points: • Used backtracking to generate all possible arrangements. • Swapped elements to fix one position at a time. • Recursively solved for the remaining array. • Backtracked by swapping elements back to their original positions. • Explored all possible permutation paths systematically. 🌱 What I Learned: • Strong understanding of recursion tree and backtracking flow. • Importance of undoing changes (backtracking step). • How to generate all permutations efficiently. • Improved problem-solving approach for recursive problems. #LeetCode #100DaysOfCode #DSA #CodingJourney #Day26 🚀
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 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 3/100 — LeetCode Challenge Continuing my 100 Days of LeetCode journey to improve problem-solving skills. Today's problem: Product of Array Except Self 🧠 Concept: Prefix and Suffix Products 💡 Key Idea: Instead of recalculating the product for each element, we compute prefix and suffix products and combine them to achieve an efficient O(n) solution without using division. ⚡ Time Complexity: O(n) 📂 Solutions Repository https://lnkd.in/gkFh2mPZ Every problem is teaching me new ways to think about optimization and patterns. #100DaysOfLeetCode #DSA #LeetCode #CodingChallenge #SoftwareEngineering
To view or add a comment, sign in
-
💧 Day 5/100 – LeetCode DSA Challenge Problem: Water Bottles (#1518) 🎯 Goal: Given "numBottles" and "numExchange", determine the maximum number of bottles you can drink if you can exchange empty bottles for full ones. 💡 Key Insights: • The process follows a simple cycle: drink → collect empty bottles → exchange → repeat. • A greedy approach works effectively for this problem. • Time Complexity: O(log₍numExchange₎(numBottles)) Every day is a step forward in improving problem-solving and DSA skills 🚀 #100DaysOfCode #LeetCode #DSA #CodingChallenge #ProblemSolving
To view or add a comment, sign in
-
-
Day 8 of My 21-Day Today’s focus was on strengthening my problem-solving skills using stacks and efficient traversal techniques while solving problems on LeetCode. One of the key problems I worked on involved analyzing temperature patterns to determine the next warmer day. Instead of using a brute-force approach, I implemented an optimized stack-based solution, which significantly improves time complexity. Key Takeaways from Today: • Learned how monotonic stacks help in solving “next greater element” type problems efficiently • Improved understanding of time complexity optimization from O(n²) to O(n) • Practiced writing cleaner and more structured C++ implementations. Every day brings new patterns and deeper understanding. Mentors: Ankur Prajapati #Day8 #LeetCode #DSA #CodingChallenge #Cpp #ProblemSolving #SheryiansCodingSchool #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
🚀 Day 61 of #100DaysOfCode Today’s challenge: Service Lane problem on HackerRank Not every problem needs complex algorithms. Sometimes the real skill is: ✔ Understanding constraints ✔ Reading the question carefully ✔ Finding the simplest correct logic Today’s learning 👇 🔹 For every range query, the answer is simply the minimum value in that segment 🔹 Clean logic > Overcomplicated thinking 🔹 Writing optimized loops matters What this taught me: 💡 Many coding problems test clarity, not difficulty. 💡 If you understand the pattern, implementation becomes easy. 💡 Consistency > Motivation. 61 days done. 39 more to go. Building logic. Sharpening problem-solving. Becoming better than yesterday. #Day61 #100DaysOfCode #DSA #ProblemSolving #HackerRank #CProgramming #Consistency #DeveloperJourney
To view or add a comment, sign in
-
🚀 Day 3/100 — LeetCode Challenge I thought this needed nested loops at first. Turns out, it doesn’t. Solved LeetCode 53: Maximum Subarray My first instinct was to check all subarrays (O(n²)), but that’s inefficient. Then I came across a much cleaner idea: 👉 Instead of checking everything, just keep track of the current sum 1) If the current sum becomes negative → reset it to 0. 2) Keep updating the maximum sum along the way. This approach (Kadane’s Algorithm) makes the solution much more efficient. 💡 What I learned: You don’t always need to explore all possibilities — sometimes dropping bad states early leads to the optimal solution. 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) Small problem, but a very powerful pattern. #LeetCode #DSA #100DaysOfCode #Cpp #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
🚀 Day 85 of #100DaysOfCode Today I explored something deeper than just coding — proving that code is correct using the concept of Loop Invariants 🔍 💡 I worked on Insertion Sort, but instead of just implementing it, I understood why it works for every input. 👉 Key Learning: A Loop Invariant helps us prove correctness in 3 steps: 1️⃣ Initialization At the start, the first element is already sorted ✔️ 2️⃣ Maintenance With every iteration, the sorted portion grows while maintaining order 🔄 3️⃣ Termination At the end, the entire array becomes sorted ✅ ⚠️ Found a small but important bug in my code: I was using j > 0 instead of j >= 0, which skipped comparisons at index 0 😬 Fixing this made the algorithm work perfectly! 🧠 This taught me: Writing code is one thing… Proving it works for all cases is what makes you a real developer. 💻 Problem solved: Sort an array using Insertion Sort and print the final sorted result. 🔥 Example: Input: 7 4 3 5 6 2 Output: 2 3 4 5 6 7 📌 Day by day, improving not just coding skills but also problem-solving mindset. #Day85 #CodingJourney #DSA #InsertionSort #LoopInvariant #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
🚀 Day 70 of LeetCode Problem Solving Journey — 100 Days LeetCode Challenge Today, I solved LeetCode #507 — Perfect Number using C++, under the guidance of Trainer NEKAL SINGH SALARIA Singh at REGex Software Services. 🔍 Problem Summary: A perfect number is a positive integer that is equal to the sum of its positive divisors excluding the number itself. Given an integer num, return true if it is a perfect number, otherwise return false. 🧠 Approach Used (Divisor Summation): I calculated the sum of all divisors except the number itself: Traverse from 1 to num/2 Check if the number divides num evenly If yes → add it to the sum After the loop, compare the sum with num If both are equal → it is a perfect number This approach directly verifies the definition of a perfect number. 📚 Key Learnings of the Day ✔ Perfect numbers are equal to the sum of their proper divisors ✔ Checking divisors is a common technique in number theory problems ✔ Understanding mathematical definitions simplifies coding logic ✔ Brute-force solutions are sometimes useful as a starting point ⏱ Complexity • Time Complexity: O(n) • Space Complexity: O(1) 💡 Optimization Insight: The loop can be optimized by checking divisors only up to √n, which reduces the time complexity significantly. Another step forward in the challenge — see you on Day 71 🚀 #Day70 #100DaysLeetCodeChallenge #LeetCode #RegexSoftwareServices #NekalSingh #ProblemSolving #DSA #CPlusPlus #CodingChallenge #ProgrammingJourney #Math #KeepGrowing
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