Longer Contiguous Segments of Ones than Zeros Problem
Longer Contiguous Segments of Ones than Zeros Problem — ExecCode Easy DSA Practice
Solve the Longer Contiguous Segments of Ones than Zeros problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise. Your task is to - For example, in s = "110100010" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3. Note that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's. Return the required answer exactly as shown in the examples.
Examples
Input {"s": "1101"}; Output True. Input {"s": "111000"}; Output False
Constraints
1 <= s.length <= 100 s[i] is either '0' or '1'.
Practice Longer Contiguous Segments of Ones than Zeros free on ExecCode. Browse DSA problems, topic map, and placement guides.