Chef and Binary String
All submissions for this problem are available.Chef provides you with a binary string 'S'. He can perform following operation any number of times on string 'S' ( including zero ). 1.) He can combine two consecutive '1' to form '0' 2.) He can combine two consecutive '0' to form '1' Help Chef to find the total number of strings he can form ? ###Input: - Input consist of single line String 'S'. ###Output: - Print a single line integer denoting number of strings can be formed ( including given string ). ###Constraints - $2 \leq |S| \leq 10^5$ ###Sample Input: 000 ###Sample Output: 3 ###EXPLANATION: -The number of strings that can be formed from given strings are : - string 1 :- 000 - string 2 :- 10 ( combining 0 at 1st and 2nd place ) - string 3 :- 01 ( combing 0 at 2nd and 3rd place ) - Hence the answer is 3.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.