Could not understand why 2 is multiplied to the sum in the final answer.
Could not understand the final formula
As we are calculating answer for l r.
Can you please elaborate?
We can pick any value or l and r. We are only calculating answer for l<r so we are not considering the later case when r< l. But as both are similar we can directly multiply by two for the final answer. You can even look at the video again for much more explaination.