Calculate the sum

Can someone help me with the appraoch of this question please like i understood the question but i am not able to find it’s approach

Hi Akshat,
refer this https://ide.codingblocks.com/s/627388

Hi, I hope it is clear now??

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

vaibhav this is based on vector please can you help me with the code of array

i haven’t studied anything of vector please if you can help me here with the modified code

Vector and array are just similar. U can use array over there

i want help in that only that’s why i asked for verified code

how to change the 21th and 29th line can you tell me?

https://ide.codingblocks.com/s/627388 I have replaced vector with array…
hope it clears all ur doubts…

Vaibhav can you please break down the code for me i mean what’s happening after while(q–)… and especcially what’s happenning at line 26

Vaibhav can you please break down the code for me i mean what’s happening after while(q–)…. and especcially what’s happenning at line 26

Try to dry run the code on sample test case… u will get better understanding

In line 26 it is the main operation that is asked in the question…

hi @akshat42bajpai
i hope it should be clear by now… if there is still anything do let me know or else i will be marking this doubt as resolved…

i still couldn’t understand the line 26 coz the main operation is final array modulus 10^9+7.

(i-x+n)%n
here i am doing +n inside the bracket to handle negative numbers… this is the property of mod so that value doesn’t go less than 0… thats all the logic for here…

ohh okay thank you and i am sorry for being so stupid i just wasn’t able to understand the logic

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.