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

26.04% Correct | 73.96% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

Number Manipulation II Image
Number Manipulation II
  • 15 Problems
  • 47 Finishers

Problem Recent Solvers457

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page