I have a 2 dimensional integer array of size NxN with values from 0 to N^2-1. I'll be scanning these values in from the user so I need to check that all the integers entered are correct (there cannot be duplicates). Would it be easier to first organize the integers from smallest to largest and then simply check each neighbouring integers (which will also make finding the min and max easy) or would it be shorter and simpler to merely compare all the values?
I would prefer the second approach but I also couldn't think of how I'd start it.