You are viewing a single comment's thread. Return to all comments →
Java
public static List<Integer> icecreamParlor(int m, List<Integer> arr) { Map<Integer, Integer> flavorMap = new HashMap<>(); for (int i = 0; i < arr.size(); i++) { int currentFlavorCost = arr.get(i); int complementCost = m - currentFlavorCost; if (flavorMap.containsKey(complementCost)) { return Arrays.asList(flavorMap.get(complementCost) + 1, i + 1); } flavorMap.put(currentFlavorCost, i); } return null; }
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 →
Java