Dear Sir,
I have written the code like this for finding the last index of number in an array. My code is little different form the code in course.
Can you check and let me know if my code is correct ? I have tested for -1 and non -1.
Do you see any issue with this code ?
public static int lastIndex(int[] arr, int si, int data){
int match = -1;
if(arr.length == si )
return -1;
if(arr[si] == data ) {
match = si;
}
int result = lastIndex(arr,si+1,data);
if( match > result )
return match;
else
return result;
}