Given an array like [-1, 2, 3, 5, 4, 6] and it should print the 3 that is order of the array is equal to array element
Sigiloso
int a[] = { -1, 2, 3, 5, 4, 6}; for(int i=0; i < a.length; i++) { if(a[i]==i+1) System.out.println(a[i]); } then interviewer asked to improve the performance for large arrays. So how to improve array iteration in above case in java.?