What is wrong with my solution?
ProblemLink:
https://online.codingblocks.com/app/player/47935/content/33525/5302
Solution Link:
What is wrong with my solution?
ProblemLink:
https://online.codingblocks.com/app/player/47935/content/33525/5302
Solution Link:
Hey @mohitsethia there were couple of mistakes in the code
I didn’t get you. I think you didn’t save the code after rectification, so there is no change I can see.
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.
Please can you explain once why are we doing like this to calculate maximum sum. Can’t we just use the array elements twice, like in the sample input elements were 8 -8 9 -9 10 -11 12, we can take 8 -8 9 -9 10 -11 12 8 -8 9 -9 10 -11 12 and calculate the maximum sum
Yes it is possible to solve this question by taking each element twice but you have to make sure that your maximum window size doesnt exceed n which means you’ll have to write extra if conditions and all to make sure everything is working fine but in the “kadane algorithm” we can use the same piece of code to get the solution.