📅 Day 55 — 100 Days of Coding Challenge 🧠 Problem Solved: Combination Sum (LeetCode 39) Today’s problem focused on finding all unique combinations where numbers can be used unlimited times to reach a target sum. 🔍 Problem Highlights 1️⃣ Candidates are distinct integers 2️⃣ Each number can be reused multiple times 3️⃣ Order of combinations doesn’t matter 4️⃣ Only unique combinations are allowed ⚙️ Approach Used — Backtracking 1️⃣ Start from a given index to avoid duplicates 2️⃣ Pick a number → reduce target 3️⃣ Recurse with the same index (reuse allowed) 4️⃣ Backtrack after each recursive call 5️⃣ Stop when target becomes 0 or negative 💡 Key Takeaways 1️⃣ Index-based recursion prevents duplicate combinations 2️⃣ Backtracking is ideal for combination problems 3️⃣ Unlimited reuse requires careful index handling Day 55 completed 🚀 Onward to the next problem! #100DaysOfCode #LeetCode #Backtracking #Recursion #DSA #ProblemSolving #CodingJourney
Combination Sum LeetCode 39 Solution
More Relevant Posts
-
Stop using `.pop()` or `delete` inside loops. It’s a silent O(n²) performance trap. 🛑 On Day 25, I solved LeetCode 26 and locked in a critical mindset shift: Overwrite, don’t delete. Day 25 — LeetCode 26: Remove Duplicates from Sorted Array Pattern: Two Pointers (Same Direction / Read–Write) Key Insight: Physically deleting elements forces costly shifts. Instead, overwrite “junk” values by copying unique elements forward into a prefix. Everything after the unique count is logically irrelevant. Invariant: nums[0..slow] always contains unique, sorted elements. Outcome: • Solved & submitted — O(n) time, O(1) space • Replaced expensive deletions with pointer-based overwrites • Fixed a common beginner mistake in in-place array problems Question: How do you handle array clean-up when performance matters? Code / Practice: GitHub → https://lnkd.in/du4FcjyK #LeetCode #DSA #TwoPointers #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
🚀 [Day 15/30] Coding Challenge with @Educative.io 💻 💡 Problem: Subarrays with K Different Integers Today’s challenge was a great exercise in sliding window + counting techniques. The goal was to count subarrays that contain exactly K distinct integers. The key insight that made this problem click: 👉 Counting “exactly K” is easier if we count (at most K) − (at most K − 1). My approach: 1️⃣ Used a sliding window with a frequency map to count subarrays with at most K distinct integers 2️⃣ Reused the same logic to compute at most (K − 1) 3️⃣ Subtracted the two results to get exactly K distinct subarrays This avoided nested loops and kept the solution in O(n) time. ✨ Small win: Turning a complex “exactly” condition into two simpler “at most” problems made the solution both elegant and efficient. 🔍 Key Learnings: Sliding window patterns are extremely powerful for subarray problems Breaking problems into reusable components simplifies logic “Exactly K” often hides a smart counting trick #30DaysOfCode #Day14 #CodingChallenge #Educative #DSA #SlidingWindow #HashMap #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
To view or add a comment, sign in
-
Ever thought “clean” code could secretly slow you down? 🛑 On Day 26, I tackled LeetCode 27 — Remove Element — and locked in another critical mindset: **overwrite, don’t delete**. Daily Engineering Practice — Day 26: LC 27 — Remove Element Pattern: Two Pointers — Same Direction (Read/Write) Key Insight: Deleting elements while iterating triggers repeated shifts — O(n²) silently. Instead, use a slow “write” pointer and a fast “scan” pointer to overwrite unwanted values in-place. Everything beyond the slow pointer is logically ignored, ensuring linear-time operations. Invariant: nums[0..slow-1] contains valid elements slow = number of valid elements Outcome: • Solved LC 27 on LeetCode — O(n) time, O(1) space • Re-enforced the slow/fast pointer pattern • Internalized overwrite as the go-to strategy for in-place array manipulation Question: How do you handle in-place array clean-up efficiently in your projects? Share your tips below! 👇 Code / Practice: GitHub link in the first comment! 👇 #LeetCode #DSA #TwoPointers #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
Day33 of LeetCode Problem Solving Journey Today I continued my solving Move Zeroes on LeetCode ---under the guidance of Prajjal Dhar at REGex Software Services Problem Summary: Move Zeroes Task: Rearrange the elements of an integer array so that all zeroes are moved to the end, while keeping the relative order of the non-zero elements unchanged. Input: A vector of integers (e.g., [0,1,0,3,12]). Output: The same vector modified in-place (e.g., [1,3,12,0,0]). Constraints: Must be done in-place (no extra array used). Minimize the number of operations. Key Points The problem is a two-pointer array manipulation challenge. Efficiency matters: the optimal solution runs in O(n) time with O(1) extra space. Your solution uses one pointer (i) to track the position for non-zero elements and another (j) to iterate through the array, swapping when needed. 👉 In short: it’s a classic array problem testing in-place rearrangement and pointer logic, and your solution nailed it with optimal performance. Would you like me to also break down step-by-step how your code works on an example input (like [0,1,0,3,12]) so you can see the pointer movement in action? #Day33 #100DayOfLeetCode #ProblemSolving #LeetCode #ProgramingJourney #C++ #KeepGrowing #LearningWithPrajjalDhar #Regexsoftwareservices
To view or add a comment, sign in
-
-
🧩 LeetCode Challenge – Day 33 ✅ Today’s problem was a good reminder that some questions are more about patterns than brute-force generation. 🔗 LeetCode 89 – Gray Code The key insight here is understanding how each successive number differs by only one bit, and how reflecting and prefixing previous results helps build the sequence cleanly. 💡 Key Takeaways: • Pattern recognition can simplify seemingly complex generation problems • Bit manipulation often works best when combined with recursive or iterative construction • Understanding the property first saves a lot of trial-and-error coding #Day33 #LeetCodeChallenge #365DaysOfCode #DSA #CodingJourney #ProblemSolving #BitManipulation #Recursion
To view or add a comment, sign in
-
-
Day 6 | Copy-Paste to Logic-Based 🚀 Today’s problem may look simple at first glance, but it strongly reinforces conditional thinking and clean control flow. Solved Fizz Buzz (LeetCode 412) — a classic problem that tests how well you understand conditions, order of checks, and edge cases, rather than just syntax. 🧠 Key Learnings: • The order of conditions matters more than the conditions themselves • Always check the most restrictive case first (divisible by both 3 & 5) • Writing readable conditional logic is as important as correctness • Simple problems help build strong foundations for complex logic later • Clean if-else chains improve both clarity and maintainability 🔍 Approach (Brief): • Iterate from 1 to n • Check divisibility by 3 and 5 in the correct order • Push the appropriate string into the result array ⏱️ Time & Space Complexity: • Time Complexity: O(n) • Space Complexity: O(n) FizzBuzz isn’t about difficulty — it’s about thinking clearly, structuring logic properly, and mastering fundamentals. Day 6 done. Consistency > Motivation. 💪📈 ⸻ #CopyPasteToLogicBased #Day6 #DSA #DataStructures #Algorithms #LeetCode #ProblemSolving #Coding #Programming #CPlusPlus #Cpp #SoftwareEngineering #ComputerScience #Developer #DevelopersOfLinkedIn #LearningInPublic #CodingJourney #DailyCoding #Consistency #Discipline #GrowthMindset #TechJourney #InterviewPreparation #PlacementPreparation #LogicBuilding #BeginnerToAdvanced #CodeNewbie #StudentDeveloper #FutureEngineer #TechCommunity
To view or add a comment, sign in
-
-
I thought I “knew backtracking” after solving LeetCode 46. Then LeetCode 47 humbled me. Same code. Same logic. Still wrong. Because duplicates don’t care about your confidence. Here’s the uncomfortable truth: Most of us don’t struggle with new concepts — we struggle when a problem adds one extra constraint and exposes shallow understanding. Permutations II isn’t hard. What’s hard is realizing: Copy-pasting LC 46 logic doesn’t work “Used array” alone isn’t enough If you don’t control duplicates, your recursion will happily lie to you Sorting + skipping duplicates isn’t a trick. It’s the difference between knowing a pattern and understanding it.
To view or add a comment, sign in
-
-
Day 99 of 100 days code challenge 🔥👏 Key takeaways you covered: ✅ Creating & Consuming Promises new Promise() resolve() reject() ✅ Async / Await (cleaner way to handle async code) ✅ String Manipulations (super common in coding rounds)
To view or add a comment, sign in
-
-
🔥 Day 22 | Round 4 — Handling Duplicates with Backtracking! 🔥 Solved a LeetCode problem — Permutations II 💡 This problem focuses on generating all unique permutations using backtracking while carefully handling duplicate elements. By using a set at each recursion level and swapping elements in place, the solution avoids repeated permutations efficiently 💪 Great practice for mastering recursion with constraints 🚀 🔹 Concepts Used: Backtracking | Recursion | Hash Set 🔹 Key Takeaway: Pruning duplicate choices early saves a lot of unnecessary computation 🧠 #30DaysOfCode #Round4 #Day22 #LeetCode #Backtracking #Recursion #Permutations #DSA #ProblemSolving #CodingChallenge #DeveloperJourney #CodeEveryday #CPlusPlus #LearnByDoing #ConsistencyIsKey 🚀
To view or add a comment, sign in
-
-
Day 1/60: The Coding Grind Begins! I’m officially committing to a 60-day Coding Challenge. Why 60 days? Because consistency beats intensity every time. My goal is to master complex data structures, refine my problem-solving logic, and prepare for the next level in my engineering journey. Day 1 Deep Dive: Priority Queues (PQ) Today, I tackled a LeetCode problem using a Priority Queue. If a standard Queue is a "First-In-First-Out" line at a coffee shop, a Priority Queue is the Emergency Room the most urgent case gets treated first, regardless of when they arrived. Key Takeaways: 1. The "Why": Standard queues are O(n) if you need to find the "best" element. A Priority Queue (implemented via a Heap) allows you to find the Min/Max in O(1) and insert/delete in O(\log n) 2. The Implementation: In most languages, this is backed by a Binary Heap. It maintains a partial order, ensuring the root is always the highest (or lowest) priority. 3. Real-World Use: Think of CPU task scheduling, Dijkstra’s Shortest Path algorithm, or even data compression (Huffman Coding). When to use it in LeetCode? Look for keywords like: A - "Top K elements" B - "K-th largest/smallest" C - "Merge K sorted lists" D - "Find the median in a stream" Join Me! If you’ve been waiting for a sign to start your own streak this is it. Whether it's 1 problem a day or 10, let’s hold each other accountable. Comment "I'm in!" below if you want to start your own challenge or if you have a favorite LeetCode problem involving Heaps! #CodingChallenge #60DaysOfCode #LeetCode #DataStructures #SoftwareEngineering #PriorityQueue #CareerGrowth Anchal Sharma Ikshit ..
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