Input 7
abcd zesa cdab abc pqrst bacd saze
Output
Abcd cdab bacd
Zesa saze
Answers
Answered by
0
Answer:
Explanation:
public class Test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.nextLine();
String[] strArr = new String[N];
for (int i = 0; i < N; i++) {
strArr[i] = sc.nextLine();
}
System.out.println(fun(strArr));
}
public static int fun(String[] arr) {
TreeSet<String> treeSet = new TreeSet<>();
for (int i = 0; i < arr.length; i++) {
char[] chars = arr[i].toCharArray();
Arrays.sort(chars);
treeSet.add(chars.toString());
}
return treeSet.size();
Similar questions