You are viewing a single comment's thread. Return to all comments →
Solution in Java:
Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < arr.size(); i++) { int complement = m - arr.get(i); if (map.containsKey(complement)) { return Arrays.asList(map.get(complement) + 1, i + 1); } map.put(arr.get(i),i); } return Arrays.asList(-1, -1); }
Seems like cookies are disabled on this browser, please enable them to open this website
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
Solution in Java: