Skip to content

Glossary: Coding Interviews in Java

Integer overflow

Also written: overflow, long

What happens when an `int` calculation passes about 2.1 billion and wraps around to a wrong, often negative, number. It can be avoided by using `long` (as in `n * (n + 1) / 2`) or, for an "infinity" value in DP, by using half of `Integer.MAX_VALUE`.

Where the book teaches it

Related terms

Dynamic programming (DP)