/
githubmirror
/
interviews
Обзор
Документация
Войти
/
githubmirror
/
interviews
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
leetcode/hash-table/ContainsDuplicate.java
17 строк
575 B
Kevin Naughton Jr
added yahoo and palantir directories
30 мар 2018, 06:26
30 мар 2018, 06:26
4e65c9a
Код
Авторство
О чём код?
//Given an array of integers, find if the array contains any duplicates. Your function should return //true if any value appears at least twice in the array, and it should return false if every element is distinct. class ContainsDuplicate { public boolean containsDuplicate(int[] nums) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i: nums) { if(map.containsKey(i)) { return true; } else { map.put(i, 1); } } return false; } }