first testcase was wrong
Found at last in c++
Hello @Chandra123,
Did i answer this doubt before?
It seems like if i have modified this code before.
As I pointed out the mistake earlier, you have to pass n instead of n-1.
If you’ll pass n-1, then it will fail for the case when the last element is present at last index(i.e. n-1)
Reason:
Your base case will terminate recursion for i=n-1 without checking for the element present at it.
Hope, this would help.
Give a like if you are satisfied.