468,468 Members | 2,727 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,468 developers. It's quick & easy.

problems with a question.I'm using c++, don't need the code, just the logic to solve it, thanks!

the natural number is represented by the number of times the pattern "100" appears in the sequence.

For example, in the sequence 11101001010011110 the pattern appears twice and in the sequence 11101010111110111010101 it does not appear at all. You must implement a program that, given the sequence of zeros and ones, calculates how many times the pattern "100" appears in it.

Input
The first line of the input contains an integer NN, the length of the string. The second line contains the sequence of NN zeros and ones, separated by white space.

Exit
Your program must print an integer, how many times the pattern "100" appears in the sequence.
1 Week Ago #1
1 1540
dev7060
430 Expert 256MB
problems with a question.I'm using c++, don't need the code, just the logic to solve it, thanks!
What is your first thought and understanding of the question?
1 Week Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Traci | last post: by
18 posts views Thread by __PPS__ | last post: by
reply views Thread by manikandan | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.