Skip to content

Instantly share code, notes, and snippets.

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]];
}
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;