ask. help me to compare two array of integers and the order does not matter.
- by stdnoit
[Example]
<1 2 3 4 = <3 1 2 4
<1 2 3 4 != <3 4 1 1
and ummm it is in java. cant use hashmap table or anything just pure without library.
I know there are two ways.
1. sort them and compare the array index by index
2. use two for loops and compare the outer index with the inner index. ( i have been trying with this but still not working)
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(a[i] != a[j] && j == n)
return false;
}
}
return true;
anything wrong with the code ? thanks