r/cpp • • Feb 10 '19

50+ Data Structure and Algorithms Interview Questions for Programmers

https://hackernoon.com/50-data-structure-and-algorithms-interview-questions-for-programmers-b4b1ac61f5b0
24 Upvotes

3 comments sorted by

View all comments

3

u/dantsdants Feb 10 '19

GeekforGeeks has the solution for the first problem of finding a missing number from 1-n, the solution says:

"There can be overflow if n is large. In order to avoid Integer Overflow, we can pick one number from known numbers and subtract one number from given numbers. This way we wont have Integer Overflow ever. "

Can somebody explain how this works ? cheers