7.36 Longest Run Given a array (filled with O's and 1's), find the maximum number of consecutive 1's in this array. Use
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
7.36 Longest Run Given a array (filled with O's and 1's), find the maximum number of consecutive 1's in this array. Use
7.36 Longest Run Given a array (filled with O's and 1's), find the maximum number of consecutive 1's in this array. Use the following when creating rd the Random object: Random rd = new Random(); // Do not change this line The size of the array is read as input. Write the following methods: public static int[] fillArray(int size){ // Fill the array with random numbers 0-1} public static void printArray(int[] values){ // Print the array} public static int findLongestRun(int[] values) { // Find and return the longest run of consecutive 1's) Examples Input 5 Output 11011
public static int findLongestRun(int[] values){ // Find and return the longest run of consecutive 1's} Examples Input 5 Output 11011 2 2 Input 10 Output 1101101011 2 Input 20 Output 11011010110001111010 4