GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Leetcode-Algorithms/src/leetcode/ContainsDuplicate.java at master · edyluisrey/Leetcode-Algorithms Expand file tree/ Copy pathContainsDuplicate.javaMore file actions 24 lines (18 loc) · 512 Bytes / Copy pathContainsDuplicate.javaFile metadata and controls24 lines (18 loc) · 512 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 package leetcode; import java.util.HashMap; import java.util.Map; public class ContainsDuplicate { public static void main(String[] args) { ContainsDuplicate test = new ContainsDuplicate(); System.out.println(test.containsDuplicate(new int[] {1,2,3,1})); } public boolean containsDuplicate(int[] nums) { Map<Integer,Integer> map = new HashMap<>(); for(int n:nums){ if(map.containsKey(n)) return true; map.put(n,0); } return false; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |