We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
import java.util.Scanner;
import java.util.HashMap;
public class Solution {
public static void main(String[]args) {
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
while (t-->0) {
int m=scan.nextInt();
int n=scan.nextInt();
int[]costs=new int[n];
for(int i=0;imap=new HashMap();
for (int i=0;i
int otherCost=money-cost;
if (map.containsKey(otherCost)) {
System.out.println(map.get(otherCost)+" "+icecreamID);
}
map.putIfAbsent(cost,icecreamID);
}
}
}
Cookie support is required to access HackerRank
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
import java.util.Scanner; import java.util.HashMap; public class Solution { public static void main(String[]args) { Scanner scan=new Scanner(System.in); int t=scan.nextInt(); while (t-->0) { int m=scan.nextInt(); int n=scan.nextInt(); int[]costs=new int[n]; for(int i=0;imap=new HashMap(); for (int i=0;i int otherCost=money-cost; if (map.containsKey(otherCost)) { System.out.println(map.get(otherCost)+" "+icecreamID); } map.putIfAbsent(cost,icecreamID); } } }