Ice Cream Parlor

  • + 0 comments
    public static List<Integer> icecreamParlor(int m, List<Integer> arr) {
            for (int i = 0; i < arr.size(); i++) {
                if (arr.subList(i + 1, arr.size()).contains(m - arr.get(i))) {
                    return Stream.of(i + 1, arr.lastIndexOf(m - arr.get(i)) + 1).sorted().collect(Collectors.toList());
                }
            }
            
            // WTF?
            return null;
        }