Question: Write the following method: public static int howManyInCommon(int [] A, int [] B). The method receives two integer arrays A and B as parameters. Both

Write the following method: public static int howManyInCommon(int [] A, int [] B).

The method receives two integer arrays A and B as parameters. Both A and B are already in sorted order from lowest to highest. Array A has no repeated integers, and array B has no repeated integers, but there may be integers that appear in both array A and array B. Arrays A and B do not necessarily have the same length.

The method is to return the number of values that appear in both array A and array B. For example, if A and B were the arrays below, the return value would be 3, since the arrays have 3 values in common: 15, 22, and 93.

0 1 2 3 4 5 6
A 6 8 15 22 77 93 98

0 1 2 3 4
B 5 15 22 44 93

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!