Skip to content

Practice Longer Contiguous Segments of Ones than Zeros

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1869
LeetCode Problem

Longer Contiguous Segments of Ones than Zeros

Problem Statement

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. 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.

Source: Longer Contiguous Segments of Ones than Zeros on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "1101"
Output
true

# Example 2

Input
s = "111000"
Output
false

# Example 3

Input
s = "110100010"
Output
false

Constraints

1 <= s.length <= 100
s[i] is either '0' or '1'.

Related LeetCode Problems

Practice more problems similar to Longer Contiguous Segments of Ones than Zeros.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.