🚀 Day 14 of My LeetCode Journey Today I solved an interesting problem on LeetCode: “Check if Binary String Has at Most One Segment of Ones.” 🧠 Problem Statement: Given a binary string, check whether it contains at most one continuous segment of '1's. 📌 Example: Input: "111000" → ✅ True Input: "110011" → ❌ False 💡 Key Idea: If the string contains "01", it means the sequence of `1`s ended and `0`s started. If another `1` appears later, there are multiple segments of `1`s, which makes the answer false. 🎯 Learning: Many coding problems become easier when we look for patterns instead of writing complex logic. Consistency is the key to improving problem-solving and programming skills. #LeetCode #Java #CodingJourney #ProblemSolving #100DaysOfCode #SoftwareDevelopment
LeetCode Challenge: Check Binary String Segments
More Relevant Posts
-
🚀 Day 58 — LeetCode Practice 🚀 Today’s problem: Shuffle String (LeetCode 1528) 💡 Key Learning: • Learned how to rearrange characters using index mapping • Understood how placing elements at correct positions simplifies the problem • Practiced writing clean and efficient O(n) solutions • Strengthened thinking for array + string manipulation 🧠 Approach in simple words: Instead of modifying the original string, create a new array and place each character at its correct index using the given indices. ✨ Takeaway: Sometimes the simplest idea — “put the element in its right place” — gives the most optimal solution. Consistency is the real game 💪 #Day58 #LeetCode #DSA #CodingJourney #Java #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 16/100 Days of Code Challenge Solved the classic “Sort Colors” problem (LeetCode 75) today! 🎯 🔹 Problem Summary: Given an array containing 0s, 1s, and 2s (representing colors), sort them in-place without using built-in sort. 🔹 Approach Used: Maintained three pointers: low, mid, high Efficiently partitioned the array in a single pass 🔹 Key Learning: ✔️ In-place sorting can be done in O(n) time ✔️ Using pointers smartly avoids extra space 💡 Time Complexity: O(n) 💡 Space Complexity: O(1) 🔹 Code Highlight : Used swapping and pointer movement to organize elements in one traversal. Consistency is the key 🔑 — one step closer to mastering DSA! #Day16 #100DaysOfCode #DSA #Java #CodingChallenge #LeetCode #ProblemSolving #TechJourney
To view or add a comment, sign in
-
-
🚀 Day 17 of My LeetCode Journey 📌 Solved: LeetCode #11 – Container With Most Water Today’s problem was a great example of applying the Two Pointer Approach efficiently. 🔍 Problem Summary: Given an array of heights, find two lines that together with the x-axis form a container that holds the maximum amount of water. 💡 Approach Used: Started with two pointers at both ends Calculated area using: min(height[left], height[right]) × width Moved the pointer with smaller height to maximize area ⚡ Key Learning: Instead of checking all pairs (O(n²)), we can optimize to O(n) using the two-pointer technique. 🧠 Time Complexity: O(n) 📦 Space Complexity: O(1) 🔥 Consistency is the key — learning something new every day! #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 60 — LeetCode Practice 🚀 ✅ Problem Solved: Kth Missing Positive Number 💡 What I learned today: • Understood how to find missing numbers in a sorted array • Learned how to compare expected vs actual values • Practiced reducing k step by step to reach the answer • Realized that simple looping logic can solve tricky problems 📊 Approach: • Start from number 1 and compare with array • If number is missing → decrease k • If number is present → move pointer • When k becomes 0 → that number is the answer ⏱ Time Complexity: O(n + k) 📦 Space Complexity: O(1) This problem improved my thinking about sequences and missing elements 🔥 Consistency is the key — Day 60 done! 💪✨ #Day60 #LeetCode #DSA #Java #CodingJourney #KeepGoing
To view or add a comment, sign in
-
-
🚀 Day 6 / 100 – LeetCode Challenge Today I solved Number of Steps to Reduce a Number to Zero on LeetCode. 🧠 Problem Idea: Given a number "num", reduce it to "0" using these rules: - If the number is even → divide it by 2 - If the number is odd → subtract 1 Count how many steps it takes until the number becomes "0". 💡 Key Learning - Practiced loops and conditions - Understood how to update variables inside a loop - Learned how small logical steps reduce a number efficiently 💻 Approach 1. Run a loop until the number becomes "0" 2. Check if the number is even or odd 3. Update the number according to the rule 4. Count each step 📈 Takeaway: Simple problems help build strong fundamentals in logic, loops, and problem-solving, which are essential for mastering DSA. 🔗 Problem: Number of Steps to Reduce a Number to Zero #LeetCode #100DaysOfCode #Java #DSA #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 42 LeetCode – Maximum Product of Two Elements in an Array Today I solved a problem focused on array traversal and greedy selection. 🔎 Problem: Given an integer array nums, choose two different indices such that the value of (nums[i] - 1) * (nums[j] - 1) is maximized. 💡 Approach: Instead of checking all pairs, I focused on finding the two largest elements in the array. ✔ Traverse the array once ✔ Track the largest and second largest values ✔ Apply the formula (max1 - 1) * (max2 - 1) This approach avoids unnecessary comparisons and improves efficiency. ⚡ Why this works: The maximum product will always come from the two biggest numbers in the array. Problems like this help improve optimization thinking and clean coding skills. #LeetCode #DSA #100DaysOfCode #ProblemSolving #Java #CodingJourney #SoftwareDeveloper #TechGrowth 🚀
To view or add a comment, sign in
-
-
🔥 Day 13/100 Days Coding Challenge ✅ Problem Solved: Max Consecutive Ones Today’s problem was about finding the maximum number of consecutive 1’s in a binary array. 💡 Key Idea: Traverse the array, count consecutive 1’s, and reset when encountering 0 — while tracking the maximum count. 🧠 What I Learned: Importance of maintaining a running count Using Math.max() efficiently Solving problems in O(n) time with constant space 💻 Approach: Initialize count = 0, max = 0 Loop through array If element is 1 → increment count Else → reset count Update max at each step Consistency is key 🔑 — small steps every day lead to big results! #Day13 #100DaysOfCode #Java #DSA #CodingChallenge #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
LeetCode Challenge – Day 13 Today I solved Problem 13: Roman to Integer (Easy). Roman numerals use seven symbols Roman numerals are usually written from largest to smallest. But when a smaller numeral appears before a larger one, we subtract it instead of adding it. Approach: Store Roman numeral values in a HashMap. Traverse the string from left to right. If the current value is less than the next value → subtract it. Otherwise → add it to the result. Time Complexity: O(n) Space Complexity: O(1) Practicing problems daily helps strengthen problem-solving and coding skills. #LeetCode #Day13 #Java #CodingChallenge #ProblemSolving #Programming #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 63 of #LeetCode Practice Solved: Count Equal and Divisible Pairs in an Array (Easy) 🔹 Problem Summary: Given an array and an integer k, find the number of pairs (i, j) such that: • nums[i] == nums[j] • (i * j) is divisible by k 🔹 Approach: • Used two nested loops to check all pairs • Compared elements to find equal values • Checked if (i * j) % k == 0 • Counted valid pairs 🔹 Key Learning: Brute-force helps build a strong foundation and improves problem understanding before optimization. 💡 Consistency, patience, and small daily improvements lead to big results over time. #LeetCode #DSA #Java #CodingJourney #Consistency #KeepLearning
To view or add a comment, sign in
-
-
🚀 Day 52 — LeetCode Practice 🚀 Today’s focus was on understanding number properties and simplifying logic. ✅ Problem solved today: 🔹 Ugly Number 💡 Key learnings from today: • Learned that ugly numbers have only 2, 3, and 5 as prime factors • Understood how repeated division can simplify factor checking • Avoided unnecessary factor calculations by focusing only on valid primes • Practiced writing clean and simple conditional logic • Strengthened understanding of loops and number reduction techniques Initially, I thought of checking all possible factors, which made the logic messy. But then I realized I only need to divide the number by 2, 3, and 5 until it reduces. If the number becomes 1 → it’s an ugly number If it gets stuck → it’s not This problem taught me an important lesson: Not every problem needs complex logic — sometimes focusing on the right conditions is enough. Logical thinking. Simplicity. Clean execution. Step by step, getting better 💪 On to Day 53 🚀 #Day52 #DSA #LeetCode #ProblemSolving #Java #CodingJourney #Consistency #FutureEngineer
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