Find and replace a pattern in a row of zeroes and ones.
- Find 1 0 1 and replace it with 1 1 1
- Find 0 1 0 and replace it with 0 0 0
Example:
Input : [ 1 1 1 0 1 1 0 0 0 1 0 0 0 ] Output: [ 1 1 1 1 1 1 0 0 0 0 0 0 0 ]
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers158
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52683 Solvers
-
Swap the first and last columns
22514 Solvers
-
Numbers with prime factors 2, 3 and 5.
681 Solvers
-
537 Solvers
-
Output any real number that is neither positive nor negative
408 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Additional test cases have been added.
What about intersecting cases? like 1 0 1 0 or 0 1 0 1 ?