easy9 [Algorithm][Array] 문제 풀이 #2 - Two Sum 문제 링크 - https://leetcode.com/problems/two-sum/ 문제 풀이 public static int[] twoSum(int[] nums, int target) { Map map = new HashMap(); for (int i = 0; i < nums.length; i++) { int rest = target - nums[i]; if(map.containsKey(rest)) return new int[] {map.get(rest), i}; map.put(nums[i], i); } return new int[] {}; } 테스트 케이스 통과 비율 아직은 이지 정도에서 더 갈고 닦아야 미디엄으로 올라갈 수 있을것 같다. 오늘 1시간 동안 미디엄 문제 풀다 테스트 케이스 50% 맞추.. 2022. 7. 16. 이전 1 2 3 다음