Why do we want to find answer for f(i,n+i-1) for i = 0 to n

why do we want to find answer for f(i,n+i-1) for i = 0 to n.Why not jus f(0,n-1)

because it is circular array

we can  combine first and last also

let's consider this sample input
3
10 12 1

for i=0 -> f(0,2)
   here array is same 10 12 1
for i=1 -> f(1,3)
  here our array is lilke 12 1 10
for i=2 -> f(2,4)
  here array look like 1 10 12

the difference int these 3 is
in first one you can combine (10 12) ( 12 1) but not (1,10) which you can combine in 3 rd case

so basically using these case we are trying to cover all cases of circular array into a straight array

i hope now it is clear
1 Like