Counting Duplicates
Problem: Given an array of n integers, count the number of duplicate integers in the array.
Example:
Input [1,2,3,1]
Output True
Input [1,2,3,4]
Output False
Input [1,2,3,3]
Output True
Solution: Using a HashSet, if the integer exists in the HashSet, return True else add that integer in to the HashSet.
Comments
Post a Comment