One String No Trouble
Practice
3.7 (81 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
92% Success 25440 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
A string \(s\) is called a good string if and only if two consecutive letters are not the same. For example, \(\texttt{abcab}\) and \(\texttt{cda}\) are good while \(\texttt{abaa}\) and \(\texttt{accba}\) are not.
You are given a string \(s\). Among all the good substrings of \(s\) ,print the size of the longest one.
Input format
A single line that contains a string \(s\) (\(1\leq |s| \leq 2 \cdot 10^5\)).
Output format
Print an integer that denotes the size of the longest good substring of \(s\).
Submissions
Please login to view your submissions
Similar Problems
Points:10
29 votes
Tags:
Basic ProgrammingC++
Points:10
291 votes
Tags:
Basic ProgrammingEasy
Points:10
185 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementationOpen
Editorial