Question: Problem 2 (35 points): Longest plateau: Consider a non-empty int array ints. A contiguous subarray ints start .. start + len -1) (with starting index

Problem 2 (35 points): Longest plateau: Consider a non-empty int array ints. A contiguous subarray ints start .. start + len -1) (with starting index start and length len) is called a flat if all elements of that subarray are equal. Furthermore, such a subarray is called a plateau if it is flat and each of the elements ints[start-1] and ints[start + len) that immediately proceed/succeed the subarray are either nonexistent (i.e., out of array's index range) or are strictly smaller than the elements of the subarray. Your task includes the design of a public static method longest Plateau(int[] ints) that returns (a compact description of) the longest plateau of the input array ints. You may break ties arbitrarily if ints has more than one longest plateau. The return type should be a 3-element array representing value, start, len}: The first indicates common element value ints[start] of the plateau, the second its starting index, the third its length. Implement the longest Plateau() method in the provided ArrayLongest Plateau class so that it performs as indicated. The main() method in this class runs some test cases on longest Plateau(). You should also add a few nontrivial and interesting test cases of your own at the end of main(). Write a java program that implements the following method * longestPlateau() returns the longest plateau of an array of ints. * @return an array int[3] of the form (value, start, len) representing the longest plateau of ints[] as a length len contiguous subarray starting at index start with common element values value. For example, on the input array (2, 3, 3, 3, 3, 6, 6, 1, 1, 1), it returns (6,5, 2], indicating the longest plateau of this array is the subarray [6, 6]; it starts at index 5 and has length 2. For example, on the input array [3, 3, 1, 2, 4, 2, 1, 1, 1, 1), it returns [3,0,2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
