Problem · String
Rightmost Longest Character Run
Learn this problemProblem statement
Given a string source consisting of lowercase English letters, find its longest contiguous substring made of one repeated character.
If several runs have the same maximum length, choose the rightmost one. Return a string formed by concatenating the selected character with the decimal length of its run.
Function
rightmostLongestCharacterRun(source: String) → StringExamples
Example 1
source = "bbaccdbbab"return = "c3"The longest run is ccc, so the result is c3.
Example 2
source = "bbaacaa"return = "a2"Three runs have length 2. The rightmost is the final aa, so the result is a2.
Constraints
1 <= source.length <= 100sourcecontains only lowercase English letters.
More Capital One problems
- Compare Counts Around PivotOA · Seen Jul 2026
- Format a Newspaper PageOA · Seen Jul 2026
- Laser Robot Safe PathOA · Seen Jul 2026
- Match Consecutive Word BoundariesOA · Seen Jul 2026
- Reconstruct Landmark JourneyOA · Seen Jul 2026
- Track Received Byte RangesOA · Seen Jul 2026
- Alternate String EndsOA · Seen Jul 2026
- Round-Robin WDL OrderOA · Seen Jul 2026