I came across this problem in a career cup. I came up with a solution or at least I think it works perfectly fine. Below I have the questions and the Java solution. I was just wondering if anyone could scrutinize my code and tell me if there are any improvements and, or better coding practices that I should know, as I am working on being able to produce proficient codes. Thank you all in advance.
Write a program to accept a nonempty string of alphanumeric characters. Define a “run” as a
consecutive sequence of a single character. For example, “aaaa” is a run of length 4. The program will
print the longest run in the given string. If there is no single longest run, then you may print any of
those runs whose length is at least as long as all other runs in the stringcode.
Example input: a
Example output: a
Example input: aab
Example output: aa
Example input: abbbbbcc
Example output: bbbbb
Example inputProblem statement: aabbccdd
Example output: aa
Write a program to accept a nonempty string of alphanumeric characters. Define a
runas a consecutive sequence of a single character. For example,aaaais a run of length \$4\$. The program will print the longest run in the given string. If there is no single longest run, then you may print any of those runs whose length is at least as long as all other runs in the string.Example input: a Example output: a Example input: aab Example output: aa Example input: abbbbbcc Example output: bbbbb Example input: aabbccdd Example output: aa
Java Solution: