First Free Spot

Easy · rating 850 · Strings, Arrays

A parking row is a string of 0 (free) and 1 (taken). Print the 0-based index of the first free spot, or -1 if the row is full.

Constraints: 1 ≤ length ≤ 105

Related problems

Open First Free Spot in Code Arena →