Pls tell the mistakes
@angivanshikaangi
Two issues in your code.
First is the issue with the input statement for the array. Line No. 25 - It should be cin >> a[ i ] instead of a [ n ] .
Secondly your code fails for the case when the key element is present at the last index of the array.
Such as
Input :
5
1 1 2 3 2
2
Expected Output :
2 4
Your Output :
2
This issue is occuring because of the value of n that you are passing to your recursive function.
A small change in your Line No. 29 and this can easily be resolved.
thank you sir. It worked:grinning:
@angivanshikaangi
Please mark your doubt as resolved in your Doubt Section. If you need any further help regarding your doubt , let me know .
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.