i have used calc function to calculate the total count of lengths for that particular subarray and i am adding it to ans
my solution link
What is the problem with the following code?
hey, instead of passing (r-l) to the calc function just calculate your answer as ans+=((r-l)*(r-l+1))/2 and at the end calculate the same while(l<n);
and don’t check p conditions
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.