#K9566. Analyze Access Log
Analyze Access Log
Analyze Access Log
This problem requires you to analyze an access log represented as a string, where each character indicates the outcome of an access attempt. The string contains only two types of characters: G
for a granted access attempt and D
for a denied access attempt. Your task is to compute, for every denied attempt, the number of consecutive granted attempts that immediately precede it.
For example, given the input GGDGGGDGGD
, the output should be 2 3 2
because there are 2 granted attempts before the first denial, 3 before the second, and 2 before the third.
If there are no denied attempts in the log, you should output nothing.
Note: The final output should list the counts separated by a single space on one line.
inputFormat
The input consists of a single line containing a non-empty string composed exclusively of the characters G
and D
, which represent granted and denied access attempts respectively.
outputFormat
Output a single line with integers separated by a single space. Each integer represents the count of consecutive G
characters immediately preceding a D
character from the input log. If there is no denied attempt (D
), output an empty line.
GGDGGGDGGD
2 3 2