black-shadows/InterviewBit-Topicwise-Solutions

How we are handling -ve values by sum of mod value 10^9+7.

Opened this issue · 1 comments

if(sum < 0) {
sum = sum + mod;
}

I didn't get this part. However -ve value is also possible then if we add 10^9+7 it will become +ve which is wrong. Please clarify this.

If you want to handle -ve values then you can perform

ans = (ans + MOD)  % MOD

at the end