Contains Duplicate
leetcode description: Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Apparently I've done this a while ago and it looks pretty good
public boolean containsDuplicate(int[] nums){HashSet<Integer> t = new HashSet<>();for(int i : nums)if(!t.add(i))return true;return false;}
Just rolls through a hashset and checks what add() returns. In Java adding an element to a hashset returns true if the element already exists in that set.