Question: Java question In an array, a run occurs when 2 or more consecutive elements match. For example in the array {2, 3, 3, 3, 3,
Java question In an array, a "run" occurs when 2 or more consecutive elements match. For example in the array {2, 3, 3, 3, 3, 5, 5 6}, there is a run of threes, and a run of fives. length of the threes is 4 (because there are 4 threes in a row). Write a method that returns the length of the longest run. If no run occurs, return 0. max Run([2, 3, 3, 3, 3, 5, 5, 6]) rightarrow 4 max Run([1, 1, 1, 2, 2, 2]) rightarrow 3 maxRun([4, 5]) rightarrow 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
