Interview Query

Most Repetition

Start Timer

0:00:00

Upvote
8
Downvote
Save question
Mark as completed
View comments (15)
Next question

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
.
.
.
.
.


Comments

Loading comments