CCRICLES - Editorial

And I agree with @anand20 too… Mine is just one more optimization advice…

You can have a look at my solution by using above link in the editorial…
I have uploaded my solution… (Author’s code link)

Use a smart way to update each of values from min to max…
i.e. one of the technique could be…
d[min]++;
d[max+1]–;
For each pair of circle…
Then do
d[i]+=d[i-1]
For each index in d…

This technique will excecute following code indirectly…
For i=min to max
d[i]++;

what is +1 and -1 logic, why d[min]++ and d[max+1]–,what is the need of prefix array?

Google “range updates using difference array”
Read gfg article, try to understand
Let me know if you still don’t get it.

i also having the same doubt! please anyone clarify.

i still didn’t get it . on gfg they created a difference array at first (where did you created ) and while printing they further performed operations . please explain. :slight_smile:

We don’t need the creation part as initially everything is 0
We did the update part with

then we did what they did while printing by