Why mod 1000000007?


#1

What is the relevance of returning the answer ‘modulo 1000000007’ ?


#2

It’s probably just a little trick to make sure the interviewee read the problem thoroughly


#3

In some programming contests where you’re asked to compute potentially huge sums (e.g. sum an array of a million large numbers), they make you modulo by some number to avoid integer overflow.


#4

This article answers the question very well:


#5

The reason behind this is to make sure that only efficient algorithms work in the problems containing large integers (integer overflow check) within allowed limited time.