I was asked in an interview to rewrite this method without the nested for-loop. All I knew apart from this was that the arrays are of the same size. What's a good way to approach this ?
public int addTwo(int[] first, int[] second) {
int result = 0;
for (int k : first) {
for (int i : second) {
result += k * i;
}
}
return result;
}