Back to problems

Longest Same-Character Run

Algorithm · Capital One · Easy

Requirements The input is a lowercase English string named source. Determine the longest adjacent sequence formed by one repeated character. When several runs share the greatest size, select the one occurring farthest to the right. Produce a string containing the run's character followed by its length. The input size satisfies 1 <= source.length <= 100. Examples The string contains two c groups of length 2, one a group of length 1, a d group of length 3, and an e group of…

Checking your access…