🚀 Day 6 of 100 Days LeetCode Challenge Problem: Check if Binary String Has at Most One Segment of Ones Today’s problem is all about pattern observation in strings—simple, but easy to overthink. 💡 Key Insight: The string should contain only one continuous block of '1's. 👉 That means: Once a 0 appears after a 1, There should be no more '1's later 🔍 Simplest Trick: Just check if the pattern "01" appears more than once OR even better → check if "10" appears followed by another "1" 💡 Cleaner approach: Traverse the string Count transitions from 1 → 0 If you ever see 1 again after that → ❌ Invalid 🔥 What I Learned Today: Many problems are just pattern validation Clean logic beats complex conditions Always try to reduce the problem to a simple rule 📈 Challenge Progress: Day 6/100 ✅ Consistency building strong! LeetCode, Strings, Pattern Recognition, Greedy, DSA Practice, Coding Challenge, Problem Solving, Algorithm Thinking, Programming #100DaysOfCode #LeetCode #DSA #CodingChallenge #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
LeetCode Challenge Day 6: Check Binary String with One Segment of Ones
More Relevant Posts
-
🚀 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
-
-
Day 77 on LeetCode Find Smallest Letter Greater Than Target 🔤🔍✅ Continuing the streak with a clean Binary Search application — keeping things simple and consistent during mids 💯 🔹 Approach Used in My Solution The goal was to find the smallest character strictly greater than the target in a sorted array, with wrap-around behavior. Key idea: • Apply binary search on the sorted array • Whenever letters[mid] > target, store it as a potential answer • Move left to find an even smaller valid character • If no such character exists, return letters[0] (wrap-around case) This ensures we always get the next greatest letter efficiently. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Practiced binary search for “next greater element” problems • Learned how to handle wrap-around edge cases • Reinforced writing clean and optimized search logic 🔥 Small wins every day consistency is the real progress. #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
🚀 Day 14 of 100 Days LeetCode Challenge Problem: The K-th Lexicographical String of All Happy Strings of Length n Today’s problem is a perfect blend of Backtracking + Lexicographical Ordering 🔥 💡 Key Insight: A happy string: Uses only 'a', 'b', 'c' No two adjacent characters are the same 👉 Instead of generating all strings blindly, we: Build valid strings using backtracking Maintain lexicographical order naturally 🔍 Core Approach: 1️⃣ Backtracking (DFS) Start building string character by character At each step: Choose from 'a', 'b', 'c' Skip if same as previous character 2️⃣ Lexicographical Order Always try characters in order: 'a' → 'b' → 'c' 3️⃣ Stop Early Once we reach the k-th string, stop recursion 👉 If total strings < k → return "" 🔥 What I Learned Today: Backtracking is powerful for constraint-based generation Ordering decisions early helps avoid extra sorting Early stopping = major optimization 📈 Challenge Progress: Day 14/100 ✅ 2 weeks strong! LeetCode, Backtracking, Recursion, Lexicographical Order, Strings, DFS, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Backtracking #Recursion #Strings #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🚀 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
To view or add a comment, sign in
-
-
Day 81 on LeetCode Remove Linked List Elements 🔗🧹✅ Still prioritizing consistency during busy days — and today’s problem was a solid linked list traversal & deletion practice 💯 🔹 Approach Used in My Solution The goal was to remove all nodes with a given value from a linked list. Key idea: • First, handle edge cases where head itself contains the target value • Move head forward until it points to a valid node • Then traverse the list using two pointers: – prev → last valid node – temp → current node • If temp->val == val → skip the node by linking prev->next • Otherwise → move both pointers forward This ensures all matching nodes are removed efficiently. ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 💡 Key Takeaways: • Practiced pointer manipulation in linked lists • Learned how to safely handle deletions, especially at head • Reinforced importance of edge case handling 🔥 Small consistent steps → strong fundamentals. #LeetCode #DSA #Algorithms #DataStructures #LinkedList #Pointers #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #Consistency #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 68 on LeetCode Guess Number Higher or Lower 🎯✅ Today’s problem reinforced the power of Binary Search on an answer space. 🔹 Approach Used in My Solution The goal was to identify a hidden number using the provided guess() API. Key idea in the solution: • Apply binary search between 1 and n • Pick mid and call guess(mid) • Based on the response: – 0 → correct number found – -1 → guessed number is too high → move left – 1 → guessed number is too low → move right • Continue narrowing the search space until the number is found This is a perfect example of searching efficiently using feedback. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Strengthened understanding of binary search with external APIs • Learned how to adjust search space based on feedback • Reinforced the concept of searching on answer space 🔥 Another solid step in mastering binary search patterns! #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #DivideAndConquer #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 69 on LeetCode Search in Rotated Array (Brute Force Insight) 🔍✅ Today’s problem initially felt tricky, but turned out to be one of the simplest when approached directly. 🔹 Approach Used in My Solution Instead of overcomplicating with rotation logic, I used a straightforward linear search. Key idea: • Traverse the array from start to end • Compare each element with the target • Return the index once found, otherwise -1 Sometimes, the simplest approach is the most reliable. 🔹 Initial Thought Process (Overthinking Phase 😅) • Considered rotating the array and then searching • Thought about adjusting indices using formulas like: (index - rotation + n) % n • But realized that all of this is unnecessary for basic search ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) 💡 Key Takeaways: • Not every problem needs an optimized approach — clarity > complexity • Avoid overengineering when a simple solution works perfectly • Always validate if a direct approach solves the problem efficiently enough 🔥 Great reminder: Sometimes the “easy way” is the smart way. #LeetCode #DSA #Algorithms #DataStructures #Arrays #LinearSearch #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
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
-
-
🔥 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
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