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
|
338 Discussions
|
Please Login in order to post a comment
I think this code works but it gives the Time limit exceeded error.
int count =0; for(int i = 0 ; i < t ; i++){ count++; for(int j = i-1 ; j >= 0 ; j--){ if(pair_left[i].equals(pair_left[j]) && pair_right[i].equals(pair_right[j])){ count--; break; } } System.out.println(count); }
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];
}