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 orJava 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!