🚀 Day 73 / 100 Days of LeetCode Question: Check if Binary String Has at Most One Segment of Ones Given a binary string s, determine whether it contains at most one continuous segment of '1's. Solved in Java by checking whether the pattern "01" exists in the string. If "01" appears, it means a new segment of 1s starts after a 0, which violates the condition. This provides a clean and efficient solution. Consistency > perfection. Day 74 loading 🔥 #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving
Check Binary String for One Segment of Ones in Java
More Relevant Posts
-
🚀 Day 47/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 448. Find All Numbers Disappeared in an Array Used an in-place marking technique by treating indices as a hash map and marking visited numbers as negative to identify missing elements. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) (excluding output list) Strengthening understanding of array manipulation and in-place hashing tricks. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 24/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 2859. Sum of Values at Indices With K Set Bits Used bit manipulation to count the number of set bits in each index and summed the values whose index contains exactly k set bits. ⏱️ Time Complexity: O(n log n) 📦 Space Complexity: O(1) Strengthening understanding of bitwise operations and binary representation through consistent practice. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 46/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 2315. Count Asterisks Used a boolean flag approach to track whether the current position is inside a pair of '|' and count only the valid '*' outside those sections. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) Strengthening understanding of state-based string traversal and conditional counting. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 48/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 1534. Count Good Triplets Used a brute-force triple nested loop to check all possible triplets and validate the given conditions using absolute differences. ⏱️ Time Complexity: O(n³) 📦 Space Complexity: O(1) Strengthening understanding of nested loop patterns and condition-based filtering. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 88 - LeetCode Journey Solved LeetCode 24: Swap Nodes in Pairs in Java ✅ This problem is a great exercise in pointer manipulation in linked lists. Instead of changing values, I swapped the actual nodes by carefully adjusting the next pointers. Using a dummy node made the process much cleaner and helped handle edge cases smoothly. Step by step, I swapped pairs while moving forward in the list. Key takeaways: • Deep understanding of pointer manipulation • Importance of dummy node in linked list problems • Clean handling of edge cases • Iterative approach for swapping nodes ✅ All test cases passed ⚡ Efficient O(n) time and O(1) space Linked list problems like this really sharpen your fundamentals 🔥 #LeetCode #DSA #Java #LinkedList #Pointers #ProblemSolving #CodingJourney #InterviewPrep #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 34/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 709. To Lower Case Used ASCII manipulation to convert uppercase letters to lowercase by adding 32, without using built-in functions. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) Strengthening understanding of character encoding and string manipulation basics. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 14/100 – LeetCode Challenge 🚀 Problem: #169 Majority Element Difficulty: Easy Language: Java Approach: Sorting + Middle Element Time Complexity: O(n log n) Space Complexity: O(1) 🔍 Key Insight: The majority element appears **more than ⌊n / 2⌋ times** in the array. If we **sort the array**, the majority element must occupy the **middle position** because it appears more than half of the time. Therefore, the element at index **n/2** will always be the majority element. 🧠 Solution Brief: First sorted the array using `Arrays.sort()`. Since the majority element appears more than half of the array length, it will always be positioned at the middle index. Finally returned `nums[nums.length / 2]` as the majority element. 📌 What I Learned: Understanding problem constraints can simplify the solution significantly. Sometimes a simple observation (like majority occupying the middle after sorting) can avoid more complex implementations. #LeetCode #Day14 #100DaysOfCode #Java #DSA #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 59 — LeetCode Progress (Java) Problem: Count the Number of Consistent Strings Required: Given a string allowed and an array of strings words, return the number of consistent strings (strings that contain only characters from allowed). Idea: Use a HashSet for fast lookup to check whether each character in a word is allowed. Approach: Store all characters of allowed in a HashSet. Iterate through each word: Check every character in the word If any character is not in the set, the word is invalid Count all valid (consistent) words. Time Complexity: O(n × m) Space Complexity: O(1) #LeetCode #DSA #Java #HashSet #Strings #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 12/100 – LeetCode Challenge Problem: Middle of the Linked List Today’s problem focused on finding the middle node of a singly linked list. Approach: Used the Two-Pointer Technique (Slow & Fast pointers). slow moves one step at a time fast moves two steps at a time When fast reaches the end of the list, slow will be at the middle node Complexity: Time: O(n) Space: O(1) Concepts Practiced: Linked List traversal Two-pointer technique Efficient single-pass solution #100DaysOfCode #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 41/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 3427. Sum of Variable Length Subarrays Used a nested loop approach to calculate subarray sums for each index by dynamically determining the starting point using max(0, i - nums[i]). ⏱️ Time Complexity: O(n²) 📦 Space Complexity: O(1) Strengthening understanding of subarray problems and index-based range calculations. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
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