Approach hintTry it first, then revealHide
Count how often each value from 1 to n occurs using an array indexed by value; the value seen twice and the value never seen are the two answers. A sum and sum-of-squares argument avoids the array.
Count how often each value from 1 to n occurs using an array indexed by value; the value seen twice and the value never seen are the two answers. A sum and sum-of-squares argument avoids the array.