Recursion(LastIndex) Crux Online

How to find the last occuring index of the array in increasing stack of recursion instead of decreasing stack. (As you said in previous recursion video that we get 2 chances of getting the value from recursion, 1st is increasing stack/stack is building and 2nd is when the stack is decreasing in recursion)

Doubt Resolved: Solution algorithm is : 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.

Hii Pranshu, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.