📅 Day 44 of #100DaysOfCode Problem: Minimum Number of Operations to Make Array Continuous (LeetCode 2009) Approach: 1️⃣ For each element, assumed it to be the starting point of the range. 2️⃣ Calculated what the range should end at → start + n - 1. 3️⃣ Iterated over all numbers, counted how many don’t fit in this range (those need to be replaced). 4️⃣ Kept track of the minimum replacements across all possible ranges. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #Algorithms #CodingChallenge #Programming #DeveloperLife #CodeNewbie #DailyDSA #SoftwareEngineering #CodingJourney #TechCommunity #KeepLearning #GrowthMindset #Motivation #LearningInPublic
"Day 44 of #100DaysOfCode: Minimum Operations to Make Array Continuous"
More Relevant Posts
-
📅 Day 45 of #100DaysOfCode Problem: Count Operations to Obtain Zero (LeetCode 2169) 🧩 Approach: 1️⃣ Used a simple loop while both numbers are greater than zero. 2️⃣ In each step, added num1 / num2 to the count — because instead of subtracting repeatedly, we can do it in one go. 3️⃣ Took modulus to simulate the remainder after multiple subtractions. 4️⃣ Swapped numbers and repeated the process until one hit zero. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #DailyDSA #MathLogic #SoftwareEngineering #TechCommunity #KeepLearning #GrowthMindset #Motivation #CodingJourney
To view or add a comment, sign in
-
-
📅 Day 50 of #100DaysOfCode Problem: Simplify Path (LeetCode 71) Approach: 1️⃣ Used a stringstream to split the path by '/'. 2️⃣ Ignored empty tokens and "." since they don’t change the directory. 3️⃣ For "..", popped the last directory from the stack (if any). 4️⃣ Rebuilt the canonical path from the stack in the correct order. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Stacks #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodingJourney #CodeNewbie #DailyDSA #SoftwareEngineering #KeepLearning #GrowthMindset #Motivation #TechCommunity #CleanCode
To view or add a comment, sign in
-
-
📅 Day 49 of #100DaysOfCode Problem: 3228. Maximum Number of Operations to Move Ones to the End (LeetCode) Approach: 1️⃣ Keep a counter of how many '1's you’ve seen as you go through the string. 2️⃣ When you see a '0' that’s right before a '1' or at the end, you can “move” all those previous '1's past this '0' — so add that counter to the result. 3️⃣ Every time you hit a '1', increment the counter; for '0', check the condition and reset logic as needed. 4️⃣ Return the total operations counted — it’s just one pass through the string = O(n) time, O(1) space. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #Algorithms #Greedy #CodingChallenge #Programming #DeveloperLife #CodeNewbie #DailyDSA #SoftwareEngineering #KeepLearning #TechCommunity #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 Day 31 of #100DaysOfCode Problem: Reverse Pairs (LeetCode 493) Approach: 1️⃣ Divide the array using merge sort to count pairs efficiently. 2️⃣ Count cross-pairs where nums[i] > 2 * nums[j] while merging. 3️⃣ Merge the halves back in sorted order to maintain correct comparisons. 4️⃣ Sum up counts from left, right, and cross halves for the final result. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #DailyDSA #SoftwareEngineering #CodingJourney #LearningInPublic #TechCommunity #KeepLearning #DivideAndConquer #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 Day 42 of #100DaysOfCode Problem: Subsets (LeetCode 78) Approach: 1️⃣ Used backtracking to explore every possibility — either include the current element or skip it. 2️⃣ When the index reaches the end, added the current subset to the result. 3️⃣ Backtracked properly to remove elements before exploring the next choice. 4️⃣ This ensures every possible combination is covered without duplicates. #100DaysOfCode #LeetCode #Backtracking #Recursion #DSA #Cplusplus #ProblemSolving #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #DailyDSA #TechCommunity #KeepLearning #GrowthMindset #SoftwareEngineering #LearningInPublic #Motivation
To view or add a comment, sign in
-
-
📅 Day 47 of #100DaysOfCode Problem: Combination Sum II (LeetCode 40) Approach: 1️⃣ Sorted the array to handle duplicates easily. 2️⃣ Used recursion to explore each number — either include it or skip it. 3️⃣ Reduced the target as I added elements, and when the target hit 0, that path became a valid combination. 4️⃣ Skipped duplicates using a simple check: if (i > idx && candidates[i] == candidates[i-1]) continue. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Backtracking #Recursion #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #DailyDSA #CodingJourney #KeepLearning #TechCommunity #Motivation #GrowthMindset
To view or add a comment, sign in
-
-
📅 Day 48 of #100DaysOfCode Problem: Search in Rotated Sorted Array II (LeetCode 81) Approach: 1️⃣ First, used a pivot function to find the smallest element’s index, skipping duplicate values on both sides. 2️⃣ Once the pivot was found, split the array into two sorted parts. 3️⃣ Applied normal binary search on both halves to find the target. 4️⃣ Combined both steps to handle rotations and duplicates efficiently. #100DaysOfCode #LeetCode #DSA #ProblemSolving #BinarySearch #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #CodingJourney #DailyDSA #KeepLearning #TechCommunity #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
📅 Day 46 of #100DaysOfCode Problem: Combinations (LeetCode 77) Approach: 1️⃣ Used recursion to build combinations incrementally. 2️⃣ For every number, we have two choices — include it or skip it. 3️⃣ Once we’ve picked k numbers, added that combination to the result. 4️⃣ Used backtracking (pop_back) to explore the next possibility cleanly. #100DaysOfCode #LeetCode #DSA #Backtracking #Recursion #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #Programming #DeveloperLife #CodeNewbie #SoftwareEngineering #CodingJourney #DailyDSA #KeepLearning #GrowthMindset #Motivation #TechCommunity
To view or add a comment, sign in
-
-
📅 Day 41 of #100DaysOfCode Problem: Merge k Sorted Lists (LeetCode 23) This one was all about optimization and clean recursion. Instead of merging lists one by one, I used a divide and conquer approach merge them in pairs, just like merge sort. Approach: 1️⃣ If there’s only one list, return it - base case. 2️⃣ Split the range of lists into two halves using recursion. 3️⃣ Merge both halves using a helper function that merges two sorted lists. 4️⃣ Keep dividing until everything is combined into one sorted list. #100DaysOfCode #LeetCode #DSA #Cplusplus #ProblemSolving #DivideAndConquer #Recursion #CodingChallenge #Algorithms #Programming #CodeNewbie #DeveloperLife #LearningInPublic #KeepLearning #SoftwareEngineering #TechCommunity #DailyDSA #GrowthMindset #Motivation
To view or add a comment, sign in
-
-
🌟 Day 78 of #100DaysOfCode Today I solved the “Lemonade Change” 🍋 problem — a great exercise in Greedy Algorithms and logical decision-making. 🧩 The Problem: You’re running a lemonade stand where each glass costs $5. Customers pay with $5, $10, or $20 bills — and you must give the correct change for every transaction in order. 💡 The Approach: Maintain counts of $5 and $10 bills. For each customer: If they pay with $5 → keep it. If they pay with $10 → give one $5 as change. If they pay with $20 → try to give one $10 + one $5 (prefer larger denominations first), else give three $5 bills. If at any point change can’t be given → return false. ⚙️ Concept Used: ➡️ Greedy Algorithm — always make the optimal local decision (use larger bills first) to ensure global success. ✅ Takeaway: A simple problem that strengthens understanding of conditional logic, greedy thinking, and resource tracking in real-world scenarios. 💻✨ #DSA #Coding #CPlusPlus #ProblemSolving #GreedyAlgorithm #Programming #CodeNewbie #100DaysOfCodeChallenge
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