Interview Query

Most Repetition

3
Have you seen this question before?

Given a string str of any length, write an algorithm max_repeating to return which character has the longest string of continuous repetition.

If two characters are tied for most continuous repetition, return the character whose longest continuous repetition occurs earliest in str.

Example 1:

Input:

str = 'aabbaaccbbbaa'
def max_repeating(str) -> b

Example 2:

Input:

str = 'adccccbbbbc'
def max_repeating(str) -> c
Next question: 2X - Y
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code