Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

ERROR - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Vivek Hamirwasia
Tester:Gerald Agapov
Editorialist:Jingbo Shang

DIFFICULTY:

Cakewalk

PREREQUISITES:

Programming Language.

PROBLEM:

Determine whether the given binary string contains the substring (consecutive) "010" or "101".

EXPLANATION:

You can use a loop and condition clauses to check directly. Also, you can use some built-in functions to solve this problem too.

For example, C++, we can use

int position = strstr(s, "010") - s;

to get the first occurrence of "010" and check whether this position is in range. Or, if string is used in C++, then

int position = s.find("010");

will work for string.

Similarly, Java, Python, etc... a lot of languages have such functions. Post your accepted solution and let's find which one is the shortest! I think it will be interesting :P

AUTHOR'S AND TESTER'S SOLUTIONS:

Solutions will be uploaded soon. Author's solution can be found here.
Tester's solution can be found here.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>