JAVA_Contains Duplicate II_LeetCode 219 풀이 class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { if (k == 0) return false; HashMap<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int integer = nums[i]; if (map.containsKey(integer) && i - map.get(integer) <= k) return true; map.put(integer, i); } return false; } } * 출처 Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for you...
#ContainsDuplicateII_LeetCode219
#JAVA
#JAVA_ContainsDuplicateII
#JAVA_ContainsDuplicateII_LeetCode219
#JAVA_LeetCode219
원문링크 : JAVA_Contains Duplicate II_LeetCode 219