217 Contains Duplicate

时间:2015-05-30 09:15:07   收藏:0   阅读:213
public class Solution {
    public boolean containsDuplicate(int[] nums) {
       HashSet<Integer> hs = new HashSet<Integer>();
       
       for (int i : nums) {
           if (hs.contains(i)) {
               return true;
           } else {
               hs.add(i);
           }
       }
       return false;
    }
}

 

原文:http://www.cnblogs.com/77rousongpai/p/4539784.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!