← Back to challenges

Longest Sequence of Consecutive Zeroes

PythonHardstringsloopslanguage_fundamentals

Instructions

Write a function that returns the longest sequence of consecutive zeroes in a binary string.

Examples

longest_zero("01100001011000") ➞ "0000"

longest_zero("100100100") ➞ "00"

longest_zero("11111") ➞ ""

Notes

If no zeroes exist in the input, return an empty string.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sum of Resistance in Parallel Circuits