← all problems

longestRun 🌶️🌶️

A run is a stretch of the same character repeated in a row. Write a method longestRun that takes a String s and returns the length of its longest run. The empty String has a longest run of 0.

For example, longestRun("aabbbcc") is 3 (the bbb), longestRun("abc") is 1, and longestRun("aabaaa") is 3.