Amazon Interview Question
Java DevelopersCountry: United States
Its O(1),
The nextInt() method calls the "protected int next(int bits)" ,The next method has some predefined mathematical formulas to calculate the next number and then return to nextInt().
To more you can check on Java docs, the code for both the methods are there and it is easy to understand but the formula is little bit tricky.
Thanks,
It should be O(1)
- Joe May 05, 2017