The trick "rand() % n" may not fit the uniform distribution requirement as lower numbers are more likely to be picked by this operation, according to this post:

https://discuss.leetcode.com/topic/53979/straight-forward-c-solution

Then which function can truly generate the random numbers within a range in C++? I am not sure if std::uniform_int_distribution can do the job (http://www.cplusplus.com/reference/random/uniform_int_distribution/)...Suggestions are welcomed :)