@@ -0,0 +1,1191 @@
+//%0A// Created by Joshua.cao, 2018/10/15%0A//%0A// https://leetcode.com/problems/find-the-duplicate-number/%0A//%0A%0Apublic class FindTheDuplicateNumber %7B%0A  // Accepted, beats 100%25%0A  public int findDuplicate(int%5B%5D nums) %7B%0A    int slow = nums.length;%0A    int fast = slow;%0A%0A    do %7B%0A      slow = nums%5Bslow - 1%5D;%0A      fast = nums%5Bnums%5Bfast - 1%5D - 1%5D;%0A    %7D while (slow != fast);%0A    // System.out.println(%22slow = fast = %22 + slow);%0A%0A    // why???%0A    slow = nums.length;%0A    while (slow != fast) %7B%0A      slow = nums%5Bslow - 1%5D;%0A      fast = nums%5Bfast - 1%5D;%0A    %7D%0A%0A    return slow;%0A  %7D%0A%0A  // Accepted, beats 0.99%25%0A  public int findDuplicate_2(int%5B%5D nums) %7B%0A    int duplicated = -1;%0A    for (int i = 0; i %3C nums.length; i++) %7B%0A      for (int j = 0; j %3C nums.length; j++) %7B%0A        if (i != j && nums%5Bi%5D == nums%5Bj%5D) %7B%0A          duplicated = nums%5Bi%5D;%0A          break;%0A        %7D%0A      %7D%0A    %7D%0A    return duplicated;%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    FindTheDuplicateNumber obj = new FindTheDuplicateNumber();%0A    int%5B%5D input_1 = %7B1, 3, 4, 2, 2%7D;%0A    int%5B%5D input_2 = %7B3, 1, 3, 4, 2%7D;%0A    System.out.println(obj.findDuplicate(input_1));%0A    System.out.println(obj.findDuplicate(input_2));%0A  %7D%0A%7D

287 find the duplicated number