This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int findDuplicate(int[] nums) { | |
if (nums.length > 1){ | |
int ptr1 = nums[0]; | |
int ptr2 = nums[nums[0]]; | |
while (ptr1 != ptr2) | |
{ | |
ptr1 = nums[ptr1]; | |
ptr2 = nums[nums[ptr2]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<List<Integer>> threeSum(int[] nums) { | |
Arrays.sort(nums); | |
Set<List<Integer>> result = new HashSet<List<Integer>>(); | |
Map<Integer, Integer> negC = new HashMap<>(); | |
for (int i = 0; i < nums.length; i++){ | |
negC.put(-nums[i], i); | |
} | |
boolean flag = false; |