Deepak and his journey


whats wrong in this code?

@tishya_goyal your c array size is n but while calcultaing ans you are trying to access c[n] when i==n-1 that will give you run error.


still wrong…

min_cost*l[i] may exceed int limit before adding it to the ans so use typecasting here calculate your answer as ans+=(long long)min_cost*l[i];

1 Like

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.