You are viewing a single comment's thread. Return to all comments →
Java solution
public static List<Integer> icecreamParlor(int m, List<Integer> arr) { List<Integer> result = new ArrayList<>(); for (int i = 0; i < arr.size()-1; i++) { if(arr.get(i) >= m) continue; for (int j = i+1; j < arr.size(); j++) { int sum = arr.get(i) + arr.get(j); if(sum == m){ result.add(i+1); result.add(j+1); break; } } } return result; }
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 solution