Sequence

0

0 votes
Medium
Problem

Given an alphanumeric string, find the number of times a pattern 1(0+)1 occurs in the given string. Here, (0+) signifies the presence of non empty sequence of consecutive 0’s.

Examples:

Input : 1001010001

Output : 3

First sequence is in between 0th and 3rd index. Second sequence is in between 3rd and 5th index. Third sequence is in between 5th and 9th index. So total number of sequences comes out to be 3.

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

First sequence is in between 0th and 3rd index. Second valid sequence is in between 13th and 16th index. So total number of sequences comes out to be 2.

Editor Image

?