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/java/001_Two_Sum.java at master · hrlr1230/leetcode Expand file tree/ Copy path001_Two_Sum.javaMore file actions 14 lines (14 loc) · 467 Bytes / Copy path001_Two_Sum.javaFile metadata and controls14 lines (14 loc) · 467 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public class Solution { // example in leetcode book public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int x = nums[i]; if (map.containsKey(target - x)) { return new int[]{map.get(target - x), i}; } map.put(x, i); } throw new IllegalArgumentException("No two sum solution"); } } |
| You are visitor 01402792 — 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. |