Can i solve this number using recursion, ie using approach - whether to include a number in the sum or not ?
Recursive approach
Yes you can but it will take more time and space.
The best and optimal solution for this is Kadane algorithm .It will take O(n) time and O(1) space.
i got that, but can you please give me recursive code, if possible…as i have tried to write the recursive code,but its not working correctly…
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.