The length of an array is n+1, the size of the inside of the number of the range is "1,n", according to the pigeon Nest principle, so there must be repeated numbers, now scheduled to repeat the number of 1, let you find this number!
http://bookshadow.com/weblog/2015/09/28/leetcode-find-duplicate-number/
Use the coordinates and values to convert each other! The problem of detection of rings widely known in the computer community.
On the internet to explain too much, a search a lot, the ring detection method is really the way to solve problems, ring solution in the link above, but let a person enlightened is in this solution is how reasonable useof subscript 0!!!! or the first analysis of the topic: Is that there are 1 to n,n a number, and then the size of the array is n+1, if you play that kind of dynamic puzzle game, then 0 this position is the puzzle disc on the Forever seat!!! Suppose a scene is repeating the number only repeated 1 times, then we all the number of different conversions, then in 0 this position is more than the number Ah! Then the strategy proposed in the approach is to find the entrance to the back ring! How to find it?! The subscript must have a ring from the 1->n? This is for proof! This is because the topic has been said to exist I and J, make A[i]=a[j] Ah, then how to ensure that I and J must be on this ring? "This is the reason why the idea can not run into our brains" or because the requirements of the topic is too tight, the number of 1->n, scattered in the space of 0,1->n, starting from 0 jump, then it is likely to jump to the repetition of the element may not, but how can you stick to the end, the entrance of the ring must come , in the following scenario:
0 1 2) 3 4
3 4 1) 2 4
A[0] = 3; A[3] = 2; A[2] = 1; A[1] = 4; A[4] = 4;
You are lucky to think how to let the elements do not form a ring, but found that forced to the end, you consume all the 1->n, no way, the last position can only be selected from the 1->n to fill!
Then use the classic list of solutions to solve it.
Problems with ring detection: Typical scenes--linked lists
Algorithm (9) Find the Duplicate number