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.
The issue with test case 6 is how the problem is formulated:
The original problem statement says that order matters, but test case 6 behaves as if order does not matter.
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
Set<String> set = new HashSet<>();
for (int i = 0; i < t; i++) {
String a = sc.next();
String b = sc.next();
String key = (a.compareTo(b) <= 0) ? (a + " " + b) : (b + " " + a);
set.add(key);
System.out.println(set.size());
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Hashset
You are viewing a single comment's thread. Return to all comments →
The issue with test case 6 is how the problem is formulated:
The original problem statement says that order matters, but test case 6 behaves as if order does not matter.
public class Solution {
}