Question: Write the method: public static int largestInCommon(int [] A, int [] B). This method takes two arrays A and B, each containing positive integers only
Write the method: public static int largestInCommon(int [] A, int [] B). This method takes two arrays A and B, each containing positive integers only (no error checking necessary) and returns the largest value that is common to both A and B. If there is no value that is contained in both A and B, return the value 1. Here are some examples:
If A = {3, 8, 5, 2, 7, 9} and B = {5, 1, 22, 7, 2, 15, 3}, the return value would be 7. If A = {35, 12, 19, 35, 45} and B = {55, 99, 12}, the return value would be 12. If A = {33, 11, 77, 44, 55} and B = {99, 88, 222, 66, 1000}, the return value would be 1
public static int largestInCommon(int [] A, int [] B) {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
