Please check the code

Is the below code fine ?

public static int LastIndex1(int[] arr, int si, int data) {

	int idx = -1, x = -1;
	if (si != arr.length) {
		if (arr[si] == data) {
			idx = si;
		}

		x = LastIndex1(arr, si + 1, data);
		if (x > idx) {
			return x;
		} else {
			return idx;
		}
	} else {
		return -1;
	}
}

Hey @kakkarhk Yes Your code looks fine to me. You are good to go.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.