id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

norm.krumpe@muohio.edu > longestRun
prev  |  next  |  chance

In a string, a "run" is defined as the same character occurring multiple times consecutively. The length of the run is the number of times the character appears consecutively in that run. For example, in string "xaabcdeeeeax" "aa" which is a run of length 2, and "eeee" which is a run of length 4. We will say that the shortest possible run has length 2 (so, a single character is not considered a run). Given a string, return the length of its longest run. If the string does not contain a run, return 0.


longestRun("xaabcdeeeeax") → 4
longestRun("wwwxyyz") → 3
longestRun("www") → 3

...Save, Compile, Run (ctrl-enter)

int longestRun(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 300

Copyright Nick Parlante 2017 - privacy