FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

// Time: O(n) // Space: O(n) class Solution { public int[] twoSum(int[] nums, int target) { Map lookup = new HashMap(); for (int i = 0; i < nums.length; i++) { if (lookup.containsKey(target - nums[i])) { return new int[] { lookup.get(target - nums[i]), i }; } lookup.put(nums[i], i); } return null; } }

Back | FazBrowse Home | New Git URL