Algorithm of 12405 - Scarecrow

Problem Description Link
Algorithm:
This is a easy problem just you get a string
scan each character until length of string
if character is '.' then replace the next character by '#'  and
increase the counter value and set position=position+2;
some input/output:

6
4
#.#.
5
#.#.#
5
#..#.
11
...##....##
5
#####
11
...........
o/p:
Case 1: 1
Case 2: 1
Case 3: 2
Case 4: 3
Case 5: 0
Case 6: 4
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience