Explore
ProGrad Programs
Placement Prep
TCS Codevita
Live Placement Training
Webinars
About Us

Edit
Reply




Edit

Program to find all the patterns of 0(1+)0 in the given string | FACE Prep

Published on 11 Mar 2020

Program to find all the patterns of 0(1+)0 in the given string is discussed here. Given a string containing 0's and 1's, find the total number of 0(1+)0 patterns in the string and output it.


0(1+)0 - There should be at least one '1' between the two 0's.

For example, consider the following string.


Input: 01101111010


Output: 3


Explanation:


01101111010 - count = 1

01101111010 - count = 2

01101111010- count = 3


Algorithm to find all the patterns of 0(1+)0 in the given string


  • Input the given string.
  • Scan the string, character by character.
  • If the given pattern is encountered, increment count.
  • Print count.


Program to find all the patterns of 0(1+)0


C
C++
Java
Python 3

Output
Input - Enter the string : 01101111010 Output - Number of patterns found : 3


Recommended Programs






If you have any feedback about this article and want to improve this, please write to enquiry@faceprep.in