Problem 2 Number Of Runs 50 Pts Given An Integer Array Implement A Static Method Num0fruns Int Arr In Runs Java T 1 (61.07 KiB) Viewed 68 times
Problem 2: Number of runs 50 pts Given an integer array, implement a static method num0fRuns (int[] arr) in Runs.java, to compute the number of runs in the integer array arr. A run is defined as a non-decreasing sequence of numbers. For example, 1, 2, 3 is a run. An array {2, 3, 3, 2} has two runs: 2, 3, 3, and ● • 2. Check the Test Cases Console on the right for more details. The test cases will show when you click on the task.
Test Driver: TestRuns 1 import java.util.Scanner; 3 public class TestRuns { 4567AENT 2 8 9 10 11 12 13 14 15 16 17 } public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int num = stdin.nextInt(); int[] arr = new int[num]; for (int i arr } } = = 0; i < num; i++) { stdin.nextInt(); System.out.println(Runs.num0fRuns (arr)); stdin.close();
Test Case Information Title Input Output(LHS) vs Expected(RHS) test1 4 1 2 2 1 12 2 1 2 2
Test Case Information Title Input Output(LHS) VS Expected (RHS) test2 5 1 2 3 4 5 1 1 2 11 2
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!