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.
- Prepare
- Java
- Data Structures
- Java Hashset
- Discussions
Java Hashset
Java Hashset
Sort by
recency
|
354 Discussions
|
Please Login in order to post a comment
I've looked through several solutions and I'm quite surprised. If the problem involves handling pairs and they're already split into two arrays, why combine them back into a single string? Instead, there's a more elegant approach using the SimpleEntry class. You can simply use
Set<AbstractMap.SimpleEntry<String, String>> uniquePairs = new HashSet<>();
to handle the pairs directly.
hi guys i think converting the both arrays into string and adding it into a set is much easy process
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); String [] pair_left = new String[t]; String [] pair_right = new String[t];
}
import java.io.; import java.util.;
public class Solution {
}