This is conceptually almost the same as summing over all entries and comparing to the sum of all numbers in [1, n], except that the latter can be done more efficiently because that sum is simply n*(n+1)/2.
There are in fact legit use cases for XOR to speed things up or make algorithms simpler, but this is not the case here IMHO.
There are in fact legit use cases for XOR to speed things up or make algorithms simpler, but this is not the case here IMHO.