Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
What’s a good way to keep track of intervals that you have already painted?
Create an array of all 1’s, and when you have painted an interval, set the values in that interval to 0.
Using this array, how can you quickly calculate the amount of new area that you paint on a given day?
Calculate the sum of the new array in the interval that you paint.