Calculate two sums: sum and square sum.
In your example:
sum = 1+99+3...+100
sq_sum = 1^2+99^2+3^2+...+100^2
Assume y replaced x in the sequence.
sum = n(n+1)/2 -y+x.
sq_sum = n(n+1)(2n+1)/6 -x^2 +y^2
Now, solve for x & y.
Constant space and O(n) time.
How to solve for x and y
From equation:
x = sum - n(n+1)/2 +y
Substitute this in the second equation:
sq_sum = n(n+1)(2n+1)/6 -(sum - n(n+1)/2 +y)^2 +y^2
Note that y^2 cancels and you are left with a linear equation with only one unknown:y. Solve it!