Last Index of Occurrence - Question | Recursion | Data Structures and Algorithms in JAVA

preview_player
Показать описание


#pepcoding #programming #freeonlinecourses
Рекомендации по теме
Комментарии
Автор

findX(arr, len-1, 8 );

static int findLastX(int[] arr, int idx, int x){
if(idx <0){ //not able to find the x and reached last
return -1;
}

if(arr[idx] == x){
return idx;
}
findX(arr, idx-1, x); // our faith that it will return first index from last
}

shrad