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.
Scanner scan = new Scanner(System.in);
int numString = scan.nextInt();
int count = 0;
int [] arrayChars = new int[26];
Set<Character> charSet = new HashSet<Character>();
for(int i = 0; i< numString; i++) {
String str = scan.next();
for (char c : str.toCharArray()) {
charSet.add(c);
}
for (char s : charSet) {
int x = (int)s-97;
arrayChars[x]++;
if(arrayChars[x] >= numString){
count++;
}
}
charSet.clear();
}
System.out.println(count);
i keep space usage as low as i can, ive been seeing some bitwise AND in the answer,and maybe knowledge of BitSet class makes it easier. but not the most efficient for sure
Gemstones
You are viewing a single comment's thread. Return to all comments →
a java Solution
i keep space usage as low as i can, ive been seeing some bitwise AND in the answer,and maybe knowledge of BitSet class makes it easier. but not the most efficient for sure