@@ -0,0 +1,2420 @@
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.util.*;%0A%0A// https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem%0Apublic class IceCreamParlor %7B%0A%0A  private static final String SPACE = %22 %22;%0A  private static final int SENTINEL = -1;%0A%0A  private long%5B%5D getCosts(BufferedReader reader) throws IOException %7B%0A    String%5B%5D split = reader.readLine().split(SPACE);%0A    return Arrays.stream(split).mapToLong(Long::parseLong).toArray();%0A  %7D%0A%0A  private Map%3CLong, List%3CInteger%3E%3E getFrequencies(long%5B%5D costs) %7B%0A    Map%3CLong, List%3CInteger%3E%3E frequencies = new HashMap%3C%3E();%0A    for (int i = 0; i %3C costs.length; i++) %7B%0A      long cost = costs%5Bi%5D;%0A      List%3CInteger%3E indexList = frequencies.getOrDefault(cost, new ArrayList());%0A      indexList.add(i);%0A      frequencies.put(cost, indexList);%0A    %7D%0A    return frequencies;%0A  %7D%0A%0A  private int getDifferentIndex(int index, List%3CInteger%3E indices) %7B%0A    for (int indexFromList : indices) %7B%0A      if (indexFromList != index) %7B%0A        return indexFromList;%0A      %7D%0A    %7D%0A    return SENTINEL;%0A  %7D%0A%0A  private String getIdsToSpendAllBudget(long budget, long%5B%5D costs) %7B%0A    Map%3CLong, List%3CInteger%3E%3E frequencies = getFrequencies(costs);%0A    for (int i = 0; i %3C costs.length; i++) %7B%0A      long cost = costs%5Bi%5D;%0A      long difference = budget - cost;%0A      List%3CInteger%3E secondCost = frequencies.getOrDefault(difference, null);%0A      if (secondCost != null) %7B%0A        int secondIndex = secondCost.get(0);%0A        if (cost == difference) %7B%0A          secondIndex = getDifferentIndex(i, secondCost);%0A          if (secondIndex == SENTINEL) %7B%0A            continue;%0A          %7D%0A        %7D%0A        return (i + 1) + SPACE + (secondIndex + 1);%0A      %7D%0A    %7D%0A    throw new IllegalStateException(%22There is no answer%22);%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    IceCreamParlor parlor = new IceCreamParlor();%0A    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) %7B%0A      int testCases = Integer.parseInt(reader.readLine());%0A      for (int i = 0; i %3C testCases; i++) %7B%0A        long budget = Long.parseLong(reader.readLine());%0A        reader.readLine(); // Skip the size of the array.%0A        long%5B%5D costs = parlor.getCosts(reader);%0A        String idsSeparatedBySpace = parlor.getIdsToSpendAllBudget(budget, costs);%0A        System.out.println(idsSeparatedBySpace);%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Add solution for Ice cream parlor problem.