I dint know how to initialize circular array

https://hack.codingblocks.com/contests/c/509/1410

Circular array is same as array.
for(int i=0;i<N;i++)
cin>>arr[i];

now:

  1. if you want to reach element x positions behind i:
    arr[(i-x+N)%N]
  2. if you want to reach element x positions ahead i(not needed in this question):
    arr[(i+x)%N]

where N is size of array.

Using the above approach, you can easily solve the problem in O(N*Q) approach.

I made use of a simple observation and solved it in O(N).

Here is my solution.
https://ide.codingblocks.com/s/33762