What is the difference between last index and first index?

both have the same base case and following with same index which is zero

For finding last index of element in increasing stack of recursion you have to add one more variable in function i.e. ans, and initially you pass ans = -1. While give recursive call if you find the element at that index reinitialize ans with that index and make recursive call with new ans and si + 1. At base condition I.e. si == end, you will simply just return the ans.

i am still not able to understand what is the difference between first index and the last index