Number of years relation

How can we calculate the current year using i and j?

Number of bottles used + 1 = current year
now number of bottles used = i + (n-1-j)
so current year = i + (n-1-j) + 1 = n-i-j

Hi Mayank, using this method for the state i=1,j=2

We will get current year as 3-1-2 = 0

which is wrong as one year has passed

it was a typing mistake by me

cur_year = n+i-j

Can you explain the logic behind adding that +1 at last?

At start 0 bottles are used and year is 1, that’s why we add 1
I hope this resolves your doubt