Longest run of identical characters MEDIUM Siruri (BAC) 25 XP 0 solved
Mobile coding works. A laptop is faster for long sessions.

Problem

Read from standard input a string `s` of at most `255` characters, containing only lowercase letters of the English alphabet. Find the longest run of consecutive identical characters and print the character that appears in that run, followed by a space and the run's length. If there are several runs of equal maximum length, print the one that appears first in the string.

Input format

Input input.txt

The program reads from standard input a single line containing the string `s`. - the string has between `1` and `255` characters - the string contains only lowercase letters `a`-`z` - if there are several runs of maximum length, print the first one

Output format

Output output.txt

The program prints to standard output the character and the length of the longest run of consecutive identical characters, separated by a space, followed by a newline.

Example

input
aaabbccccdd
output
c 4

Ready to solve this challenge?

Create a free account to write code, submit solutions, and track your progress.

⌨️ Keyboard Shortcuts

Code Editor
Run Code
Ctrl Enter
Submit Code
Ctrl Shift Enter
Format Code
Shift Alt F
Toggle Comment
Ctrl /
Undo
Ctrl Z
Redo
Ctrl Y
Navigation
Global Search
/
Show Shortcuts
?
Close Modal
Esc

🔍 Interactive Debugger

0 / 0

Analyzing your code...

📦 Variables

No variables yet

📚 Call Stack
main() line 1
📤 Output
We use cookies

Essential cookies are always active. You can choose to enable preference and analytics cookies. Learn more