#C986. Longest Empty Segment
Longest Empty Segment
Longest Empty Segment
You are given a string s
that represents a rope. Each character in the string is either a dot ('.') indicating an empty cell or a hash ('#') indicating an obstacle. Your task is to calculate the length of the longest segment of consecutive empty cells.
In other words, you need to find the maximum number of consecutive dots in the string. Formally, if we denote the string by \(s\), you need to find the maximum \(L\) such that there exists an index \(i\) where \(s[i], s[i+1], \dots, s[i+L-1]\) are all equal to '.'.
Note: The input will be given through stdin
and the output should be written to stdout
.
inputFormat
The input consists of a single line containing a non-empty string s
representing the rope. The string contains only the characters .
and #
.
outputFormat
Output a single integer representing the length of the longest segment of consecutive empty cells (dots) in the string.
You must output the result to stdout
.
..##...#..
3