Count consecutive 0's in between values of 1 - MATLAB Cody - MATLAB Central

Problem 1678. Count consecutive 0's in between values of 1

Difficulty:Rate

So you have some vector that contains 1's and 0's, and the goal is to return a vector that gives the number of 0's between each one. for example:

Input = [0 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 0 0]

Output = [1 3 1 0 0 3 1 0 2]

Solution Stats

25.44% Correct | 74.56% Incorrect
Last Solution submitted on Nov 12, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...
🚀 MATLAB EXPO 2025 – Day 2 Starts Tomorrow, November 13!
Don’t miss out on two incredible keynotes that will shape the future...
0

Problem Recent Solvers486

Suggested Problems

More from this Author17

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!