I'm writing a method that finds intersection of given arrays
.
Since I had to iterate both arrays
, I was thinking of using
if(arr2.length > arr1.length){
intersection(arr2, arr1);
}
The reason I came up with this idea was that it seemed to me to be the better way to reduce the length of code for handling arrays
that have different length.
As a newbie to programming, I'm wondering if there is any other suggestion.