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