FunctionRacerProblemsRace

One Segment of Ones

BeginnerStringsPython, JavaScript, TypeScript, Java, C++

s is a binary string that starts with 1. Return True if all the 1 characters form one single block (nothing but 0s may follow the block), or False if the ones are split into two or more blocks.

Example 1

s "1100"
returns true

One block of ones.

Example 2

s "110011"
returns false

Two separate blocks.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems