What is the best approach to solve the following problem in Java?
There are 3 two-dimensional arrays that have equal number of rows and columns:
Array1:
[1]: {1, 2, 3}
[2]: {2, 2, 4}
[3]: {1, 1, 1}
Array2:
[1]: {1, 2, 0}
[2]: {1, 2, 3}
[3]: {1, 0, 1}
Array3:
[1]: {1, 1, 1}
[2]: {1, 2, 3}
[3]: {1, 0, 1}
I need to find out the indexes of rows that exist in all arrays. In the above example the answer should be: [1],[2],[2]
Array1
[1]: {1, 2, 3}
Array2:
[2]: {1, 2, 3}
Array3:
[2]: {1, 2, 3}
UPDATE: Is there any built-in function to do this? Or is the FOR loop the unique solution?
I would do the following:
hashcodeandequals.HashMapsHashMapsEdit #2, realized the mapping would need to be reversed.