🚀 Day 7 of 100 Days LeetCode Challenge Problem: Minimum Number of Flips to Make the Binary String Alternating Today’s problem leveled up the difficulty with a mix of sliding window + string rotation + greedy logic. 💡 Key Insight: We can rotate the string (Type-1 operation), which means we should consider all possible rotations of the string. 👉 Trick: Double the string → s + s to simulate rotations Compare every window of size n with: "010101..." "101010..." 🔍 Approach: Use sliding window on the doubled string Count mismatches for both patterns Minimum flips across all windows = final answer 🔥 What I Learned Today: Rotation problems → think of string doubling Sliding window helps optimize repeated checks Combining multiple concepts = real DSA growth 📈 Challenge Progress: Day 7/100 ✅ One full week completed! LeetCode, Sliding Window, Strings, Greedy Algorithm, Pattern Matching, DSA Practice, Coding Challenge, Problem Solving, Optimization #100DaysOfCode #LeetCode #DSA #CodingChallenge #SlidingWindow #Strings #GreedyAlgorithm #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
LeetCode Challenge: Minimum Flips to Alternating Binary String
More Relevant Posts
-
I stopped solving random LeetCode problems. And suddenly… patterns started repeating. This week, I focused only on the Sliding Window. Not 50 problems. Just a few deeply. Here’s what I realized: Problems that looked completely different… were testing the same idea. • Minimum Size Subarray Sum • Fruits into Baskets • Subarray Product Less Than K • Maximum Points from Cards • Max Consecutive Ones • Longest Continuous Increasing Subsequence • Maximum Average Subarray I • Longest Mountain in Array Different stories. Same pattern. That’s when it clicked. Sliding Window isn’t a trick. It’s control. You’re not solving problems. You’re managing a window: Expand when conditions break. Shrink when constraints are satisfied. That’s it. Here are the signals I now look for instantly: • “Subarray” + “minimum/maximum” • “Continuous” or “longest” • Fixed vs variable window size • Constraint-driven shrinking Once you see it… you can’t unsee it. Next week, I’m starting Prefix Sums. Let’s see if the same thing happens again. Be honest :- Which DSA pattern took you the longest to truly understand? #DSA #LeetCode #SlidingWindow #CodingInterviews #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 29 of 100 Days LeetCode Challenge Problem: Check if Strings Can be Made Equal With Operations I Day 29 is a short but pattern + constraint observation problem 🔥 💡 Key Insight: We can only swap characters where: 👉 j - i = 2 For a string of length 4, possible swaps: Index 0 ↔ 2 Index 1 ↔ 3 👉 That means: Positions (0,2) form one group Positions (1,3) form another group 🔍 Core Approach: 1️⃣ Group Characters Extract characters from: Even indices → [0, 2] Odd indices → [1, 3] 2️⃣ Compare Groups Sort both groups for s1 and s2 If both corresponding groups match → ✅ true Else → ❌ false 💡 Why This Works: You can rearrange freely within each group But cannot mix between groups 🔥 What I Learned Today: Limited operations define independent groups Think in terms of index grouping Small problems still test logical clarity 📈 Challenge Progress: Day 29/100 ✅ One day to 30! LeetCode, Strings, Swapping, Greedy, Pattern Recognition, Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
#Day37/50 LeetCode Practice Update 🧩 Solved Minimum Cost to Merge Stones(leetcode) 💡 Problem Insight: Given piles of stones, we need to merge them with minimum cost Constraint: Only k consecutive piles can be merged at a time This makes it more complex than typical greedy merge problems 🧠 Approach & Intuition: ✔️ Greedy (min heap) does NOT work here ✔️ Applied Interval Dynamic Programming (DP) ✔️ Used Prefix Sum for efficient range sum calculation ◾ Break the problem into smaller subarrays ◾ First merge piles into k groups, then finally into 1 pile ◾ Try all valid partitions and take the minimum cost ✅ Key Condition: (n - 1) % (k - 1) == 0 → otherwise return -1 💢 Complexity: Time: O(n³ / k) Space: O(n²) 📌 Key Learnings: Not all merge problems can be solved using greedy Interval-based constraints often hint towards DP Always check feasibility conditions before solving Pattern recognition is the real game changer in DSA 📈 Improving problem-solving skills step by step! #LeetCode #DSA #DynamicProgramming #Cpp #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🔥 Day 98 of #100DaysOfCode Today’s problem was all about string manipulation and greedy thinking — solving the Alternating Characters challenge. 💡 Problem Summary: Given a string of only A and B, the goal is to make sure no two adjacent characters are the same by deleting the minimum number of characters. 🧠 Approach: Instead of trying all possibilities, I used a simple and efficient strategy: Traverse the string once Compare each character with the previous one If they are the same → increment deletion count ⚡ Key Insight: Every pair of matching adjacent characters contributes exactly 1 deletion. 📊 Complexity: Time: O(n) Space: O(1) 🧪 Example: AAABBB → 4 deletions ABABAB → 0 deletions ✨ What I Learned: Sometimes the simplest greedy approach beats complex logic. Recognizing patterns in strings is a powerful skill in problem-solving! 💻 Language Used: C #Day98 #100DaysOfCode #CodingChallenge #DataStructures #Algorithms #CProgramming #ProblemSolving #DeveloperJourney
To view or add a comment, sign in
-
100 LeetCode problems solved ! and honestly, it's taught me more about thinking than coding. When I started, I used to jump straight to the solution. Now I've learned to slow down — understand the problem, think brute force first, then optimize. Patterns I've been focusing on: → Sliding Window → Two Pointers → Stack & Queue → Kadane's Algorithm → Prefix Sum → Merge Intervals → Linked List The biggest shift wasn't in the number of problems solved — it was learning to recognize WHY a particular approach works, not just HOW. Still a long way to go. But consistency is starting to show results. 100 done. More to come. 🎯 #DSA #LeetCode #CodingJourney #SoftwareEngineering #100Problems
To view or add a comment, sign in
-
-
🚀 Day 19 of 100 Days LeetCode Challenge Problem: Count Submatrices With Equal Frequency of X and Y Today’s problem was a solid combination of 2D Prefix Sum + Hashing concept 🔥 💡 Key Insight: We need submatrices that: Include the top-left cell (0,0) Have equal number of 'X' and 'Y' Contain at least one 'X' 👉 Trick: Convert the grid into values: 'X' → +1 'Y' → -1 '.' → 0 🔍 Core Approach: 1️⃣ 2D Prefix Sum Transformation Build prefix sum based on above conversion 2️⃣ Check Each Submatrix (0,0 → i,j) If sum == 0 → equal number of X and Y ✅ 3️⃣ Extra Condition: Ensure at least one 'X' exists 👉 Track X count separately using another prefix matrix 🔥 What I Learned Today: Transforming problems into numbers simplifies logic Prefix sums + condition checks = powerful combo Always handle extra constraints carefully 📈 Challenge Progress: Day 19/100 ✅ Almost hitting Day 20! LeetCode, Prefix Sum, Matrix, Hashing, Problem Transformation, Algorithms, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #PrefixSum #Matrix #Hashing #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
LeetCode Progress 42/50 — Find the Difference Today I worked on a fundamental problem focused on string manipulation and character analysis 🧩 💡 The challenge was to find the extra character in one string compared to another. 🧠 Approach: Used XOR / frequency mapping to efficiently cancel matching characters and directly identify the added character. ⏱ Time Complexity: O(n) 💡 What I learned: This problem strengthened my understanding of how bit manipulation and hashing techniques can simplify string comparison problems. 📈 Improving efficiency in problem-solving and strengthening core DSA fundamentals. #LeetCode #DSA #Strings #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
🚀 Day 10 of Coding Solved Problem #844 – Backspace String Compare 💡 🔍 Problem Statement: Given two strings s and t, return true if they are equal when both are typed into empty text editors. # means a backspace character. 🧠 Key Learning: ✔ Mastered two-pointer approach from the end ✔ Learned how to handle backspace operations efficiently ✔ Avoided extra space by not building new strings ⚡ Approach: 👉 Traverse both strings from right to left 👉 Use counters to skip characters affected by # 👉 Compare valid characters one by one 👉 Return false if mismatch occurs 💻 Tech Stack: C++ | STL ✅ Result: ✔ Accepted ✔️ ✔ Optimized with O(n) time and O(1) space 🔥 Another step forward in consistency and problem-solving! #Day10 #LeetCode #DSA #CodingJourney #CPP #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Staying consistent and refining core concepts through practice. LeetCode Progress 16/50 — Reverse String I worked on a fundamental problem focused on string manipulation 🧩 💡 The challenge was to reverse a given character array in-place without using extra memory. 🧠 Approach: Used a two-pointer technique — one starting from the beginning and the other from the end. Swapped characters step by step until both pointers met, achieving in-place reversal efficiently. ⏱ Time Complexity: O(n) 💡 What I learned: This problem reinforced how simple techniques like two-pointer approaches can lead to clean and efficient solutions without extra space. 📈 Strengthening basics and improving clarity in handling strings and in-place operations. #LeetCode #DSA #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
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