🔥 Day 95/100 of Code – Combination Sum: Backtracking with Unlimited Reuse! Today returned to a classic backtracking problem — foundational for combinatorial search: ✅ Problem 39: Combination Sum Task: Find all unique combinations (with repetition allowed) that sum to target. Approach: Recursive backtracking with index control: At each step, decide to include current candidate (if ≤ remaining target) or skip it If included, stay at same index (allow reuse) If target reaches 0, add current combination to result Use pruning to avoid unnecessary recursion Key Insight: By staying at same index when including, we allow unlimited reuse. By moving to next index when skipping, we ensure all combinations are explored without duplicates. Complexity: O(2^target) worst-case time, O(target) recursion depth. A perfect example of how backtracking elegantly handles "choose with repetition" problems — building solutions incrementally! 🧩🔢 #100DaysOfCode #LeetCode #Java #Backtracking #DFS #Combinations #Algorithm
Combination Sum: Backtracking with Unlimited Reuse
More Relevant Posts
-
📌 17. Letter Combinations of a Phone Number (Medium) Today’s problem was all about Backtracking & Recursion. 🧠 Problem Summary Given digits from 2–9, return all possible letter combinations based on phone keypad mapping. Example: Input: "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] 💡 Key Insight This is a classic Cartesian Product problem. Each digit expands into multiple choices → Perfect use case for Backtracking. 🚀 Approach Create a digit → letter mapping Use recursion to build combinations When current string length == digits length → Add to result Backtrack and explore next possibilities ⏱ Complexity Time: O(4ⁿ) Space: O(n) recursion stack Max combinations = 256 (since n ≤ 4) 🎯 What I Practiced Today ✅ Recursion Tree Thinking ✅ Backtracking Pattern ✅ StringBuilder Optimization ✅ Clean Code Structure Consistency > Motivation 💪 Day 18 completed. #LeetCode #Java #DataStructures #Algorithms #Backtracking #100DaysOfCode
To view or add a comment, sign in
-
-
Day 9 – DSA Journey | Arrays 🚀 Today’s problem helped me understand backtracking with re-use of elements 🔁 and how recursion explores all valid combinations. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • ➕ Combination Sum 🔹 Combination Sum 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 • 🔁 Used backtracking to build combinations • 🎯 Reduced the remaining target at each step • ♻️ Reused the same element by passing the current index again • 📌 Stored a valid path only when the remaining target becomes zero 𝐇𝐨𝐰 𝐢𝐭 𝐖𝐨𝐫𝐤𝐬 • ➡️ Start from a given index to avoid duplicate combinations • ➕ Add the current number to the path • 🔽 Recurse with reduced remaining sum • ⏪ Backtrack by removing the last added number 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • 🧠 Backtracking explores all valid paths systematically • ♻️ Passing the same index allows unlimited reuse of elements • 🎯 Base conditions control recursion flow • 🧹 Clean backtracking keeps the solution correct 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • ⏱ Time: Exponential (depends on number of combinations) • 📦 Space: O(target) (recursion depth + path) 🧠 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Backtracking isn’t about speed — It’s about exploring all possibilities correctly 🔍 On to Day 10 🔁🚀 #DSA #Arrays #Backtracking #Recursion #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
Most ML deployments still look like this: Model file Runtime Prediction server Calibration layer Explanation service ClearBand compiles all of it into a single deterministic decision artifact. 10 KB. No runtime dependency. No backend required. Fully inspectable. This demo runs entirely in the browser — including calibrated probability, band logic, and per-decision explanations. Not interpreted. Compiled. If you work in regulated ML, credit risk, or model governance — this is the deployment conversation that matters. See it live → https://lnkd.in/ejDc-Je3
I compiled a 10 MB XGBoost credit risk model into a 10 KB deterministic artifact. 99.8% AUC retention. No API calls. No backend. No opaque scoring endpoint. The entire deployment unit is compiled into a single JSON file: • Model weights • Calibrated PD • Explicit band logic • Deterministic explanations • Feature metadata No Python runtime. No model server. No SHAP service. Everything runs locally in pure JavaScript. Every rule is readable. Every decision reproducible. The comparison isn’t “smaller than XGBoost.” It’s this: A 10 KB artifact replacing a 10 MB model, a runtime, a prediction server, a calibration layer, and an explanation service — while preserving 99.8% of the original AUC. If you work in regulated ML or credit infrastructure, open DevTools and inspect it. See it live → https://lnkd.in/eSJAkNEw
To view or add a comment, sign in
-
🔥 Day 307 – Daily DSA Challenge! 🔥 Problem: 🧠 Gray Code Given an integer n, return a sequence of 2ⁿ integers representing the n-bit Gray code sequence — where two consecutive values differ by exactly one bit. 💡 Key Insights: 🔹 Gray Code follows a beautiful bit-manipulation pattern. 🔹 The formula to generate the ith Gray code is: 👉 gray(i) = i ^ (i >> 1) 🔹 This guarantees that adjacent numbers differ by only one bit. 🔹 No recursion or backtracking needed — just pure bitwise magic ✨ 🔹 Total sequence length is always 2ⁿ. ⚡ Optimized Plan: ✅ Compute total size as 1 << n ✅ Iterate from 0 to 2ⁿ - 1 ✅ Convert each number to Gray code using XOR and right shift ✅ Store results in a list and return ✅ Time Complexity: O(2ⁿ) ✅ Space Complexity: O(2ⁿ) 💬 Challenge for you: 1️⃣ Why does i ^ (i >> 1) always change only one bit at a time? 2️⃣ Can you generate Gray code using a recursive reflection method? 3️⃣ How would you print the result in binary string format instead of integers? #DSA #Day307 #LeetCode #GrayCode #BitManipulation #Math #Java #ProblemSolving #KeepCoding #100DaysOfCode
To view or add a comment, sign in
-
-
LeetCode 3010: Divide an Array Into Subarrays With Minimum Cost I — a neat “read the definition carefully” problem I enjoyed this one because it looks like a partitioning problem… but the optimal solution is just a simple scan. Key insight: When you split the array into 3 subarrays, the cost = sum of the first element of each subarray. The first subarray must start at index 0, so nums[0] is always included. You’re free to choose where subarray 2 and 3 start (somewhere in nums[1..]). To minimize cost, you simply pick the two smallest values from nums[1..]. So the answer is: nums[0] + smallest(nums[1..]) + secondSmallest(nums[1..]) Leetcode problem link:https://lnkd.in/gUrES9Td #leetcode #java #datastructures #algorithms #problemsolving
To view or add a comment, sign in
-
-
⚡ 𝗗𝗮𝘆 𝟳𝟱 𝗼𝗳 𝗠𝘆 𝟭𝟬𝟬 𝗗𝗮𝘆𝘀 𝗼𝗳 𝗗𝗦𝗔 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲! 𝘛𝘰𝘥𝘢𝘺’𝘴 𝘱𝘳𝘰𝘣𝘭𝘦𝘮 𝘸𝘢𝘴 𝘢 𝘨𝘳𝘦𝘢𝘵 𝘮𝘪𝘹 𝘰𝘧 𝙨𝙩𝙧𝙞𝙣𝙜 𝙥𝙧𝙤𝙘𝙚𝙨𝙨𝙞𝙣𝙜 𝙖𝙣𝙙 𝙢𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙖𝙡 𝙩𝙝𝙞𝙣𝙠𝙞𝙣𝙜, 𝘪𝘯𝘴𝘱𝘪𝘳𝘦𝘥 𝘣𝘺 𝘢 𝘳𝘦𝘢𝘭-𝘸𝘰𝘳𝘭𝘥 𝘴𝘺𝘴𝘵𝘦𝘮 𝘸𝘦 𝘢𝘭𝘭 𝘳𝘦𝘤𝘰𝘨𝘯𝘪𝘻𝘦 𝘌𝘹𝘤𝘦𝘭 𝘤𝘰𝘭𝘶𝘮𝘯𝘴. 📌 Problem Solved: 1️⃣ 𝗟𝗲𝗲𝘁𝗰𝗼𝗱𝗲 171: Excel Sheet Column Number ✨ Key Learnings: 🔹 This problem is essentially about 𝗯𝗮𝘀𝗲-𝟮𝟲 𝗻𝘂𝗺𝗯𝗲𝗿 𝗰𝗼𝗻𝘃𝗲𝗿𝘀𝗶𝗼𝗻, where characters act as digits instead of numbers. 🔹 Iterating through the string and updating the result as result = result * 26 + currentCharValue helps build the column number efficiently. 🔹 It reinforced how 𝗰𝗵𝗮𝗿𝗮𝗰𝘁𝗲𝗿-𝘁𝗼-𝗻𝘂𝗺𝗯𝗲𝗿 𝗺𝗮𝗽𝗽𝗶𝗻𝗴 ('A' → 1 to 'Z' → 26) plays a crucial role in many string-based problems. 🧠 Big Takeaway: Problems that look string-heavy often boil down to 𝘀𝗶𝗺𝗽𝗹𝗲 𝗺𝗮𝘁𝗵 + 𝗶𝘁𝗲𝗿𝗮𝘁𝗶𝗼𝗻 once the pattern is clear. Day 75 completed — slowly but surely stacking fundamentals! 💪🔥 #100DaysOfCode #DSA #Java #Strings #ProblemSolving #LogicBuilding #InterviewPreparation #LeetCode #LearningInPublic #Developers
To view or add a comment, sign in
-
-
Day 5 of Daily DSA 🚀 Solved LeetCode 268: Missing Number Approach: Used the mathematical sum formula to calculate the expected sum of numbers from 0 to n. Subtracted the actual sum of array elements to find the missing number in a single pass. Complexity: • Time: O(n) • Space: O(1) LeetCode Stats: • Runtime: 0 ms (Beats 100%) • Memory: 47.57 MB A simple yet powerful problem that shows how math can replace extra space and lead to clean, efficient solutions. #DSA #LeetCode #Java #ProblemSolving #Arrays #Consistency
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟯𝟲/𝟭𝟬𝟬 | 𝗠𝗲𝗿𝗴𝗲 𝗧𝘄𝗼 𝗦𝗼𝗿𝘁𝗲𝗱 𝗟𝗶𝘀𝘁𝘀 Day 36 ✅ — Recursion over iteration. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟮𝟭: Merge Two Sorted Lists (Easy) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Merge two sorted linked lists. Instead of the iterative dummy node approach, I used 𝗿𝗲𝗰𝘂𝗿𝘀𝗶𝗼𝗻. Compare the heads. Attach the smaller one, then recursively merge the rest. Base case: if one list is empty, return the other. Elegant. Three lines of logic. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Base cases: if l1 is null, return l2 (and vice versa) 👉 Compare l1.val and l2.val 👉 Attach smaller node and recurse with remaining lists Time: O(n + m), Space: O(n + m) for recursion stack 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Seven linked list problems, and recursion just made this one cleaner than iteration. Sometimes the simplest code is the most powerful. 𝗖𝗼𝗱𝗲:🔗 https://lnkd.in/g4f4_B69 𝗗𝗮𝘆 𝟯𝟲/𝟭𝟬𝟬 ✅ | 𝟲𝟰 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #Recursion #DataStructures #CodingInterview #SoftwareEngineer #Java #Algorithms #Programming
To view or add a comment, sign in
-
🔥 Day 98/100 of Code – Permutations: In-Place Backtracking with Swapping! Today revisited the classic permutation problem using an elegant in-place swapping approach: ✅ Problem 46: Permutations Task: Generate all permutations of distinct integers. Approach: Recursive swapping with index tracking: Fix elements step-by-step by swapping them into position At level i, swap nums[i] with each nums[j] where j ≥ i Recurse to i+1, then backtrack by swapping back Base case: when i == nums.length, store current array state Key Insight: By swapping in-place, we avoid extra space for temporary lists and naturally generate permutations without duplicate checks (since elements are distinct). Complexity: O(n × n!) time, O(n) recursion depth — optimal for generating all permutations. A clean, memory-efficient backtracking technique — fundamental for combinatorial generation! 🔄🧩 #100DaysOfCode #LeetCode #Java #Backtracking #Permutations #DFS #Algorithm
To view or add a comment, sign in
-
-
Day 3 – DSA Journey | Arrays 🚀 Today’s focus was on 3-sum variations, where sorting + two pointers do most of the heavy lifting. ✅ Problems Solved 📌 3Sum 📌 3Sum Closest 🔹 3Sum Approach: Sorted the array Fixed one element and used two pointers to find valid triplets Skipped duplicates to avoid repeated results Key Learning: ✅ Sorting simplifies multi-pointer logic ✅ Duplicate handling is critical for correctness Complexity: ⏱ Time: O(n²) 📦 Space: O(1) (excluding output) 🔹 3Sum Closest Approach: Sorted the array Fixed one element and adjusted pointers based on how close the sum was to the target Updated the closest sum whenever a better match was found Key Learning: ✅ Greedy updates help converge quickly ✅ Absolute difference comparison is a powerful pattern Complexity: ⏱ Time: O(n²) 📦 Space: O(1) 🧠 Takeaway Once you understand sorting + two pointers, many array problems start looking familiar. Consistency > Complexity. On to Day 4 🔁🚀 #DSA #Arrays #TwoPointers #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
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