Question: 6. Write a program, SubArrays.java, that asks the user to enter two arrays, then checks if the second array is a subarray of the first.

 6. Write a program, SubArrays.java, that asks the user to enter

6. Write a program, SubArrays.java, that asks the user to enter two arrays, then checks if the second array is a subarray of the first. To read the two arrays, the user should be prompted to enter a positive integer n followed by n integers for the first array, then another integer m followed by m integers for the second array. You need to implement the following method public static boolean isSubarray (int] al, int[] a2) this method checks if a2 is a subarray in a1 Note: You are not allowed to use strings to solve this problem Sample Run 1: Enter a positive integer n: 5 Enter 5 integers: 5 438 6 Enter a positive integer m: 3 Enter 3 integers: 43 8 4, 3, 8) is a subarray of (5, 4, 3, 8, 6) Sample Run 2: Enter a positive integer n: 5 Enter 5 integers: 5 438 6 Enter a positive integer m: 3 Enter 3 integers: 4 3 4 4, 3, 4) is not a subarray of 15, 4, 3, 8, 6)

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!