Count words without repetitions

Report a typo

Count the number of unique words ignoring case sensitivity for given lines with words.

The first line contains the number n. The next n lines contain words separated by a space.

Sample Input 1:

3
Word word wORD
line Line SplinE word
spline align Java java

Sample Output 1:

5
Write a program in Java 17
import java.util.*;
import java.util.stream.*;

public class Main {

/**
* Counts the number of unique words ignoring case sensitivity
* for given lines with words.
*
* @param n the n lines contain words
* @param lines the list of lines, each line is a list of words
* @return the number of unique words in lines ignoring case sensitivity
*/
public static long count(int n, List<List<String>> lines) {
// write your code here
}

// Don't change the code below
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());

List<List<String>> lines = Stream.generate(scanner::nextLine).limit(n)
.map(s -> Arrays.asList(s.split("\\s+")))
.collect(Collectors.toList());

System.out.println(count(n, lines));
}
}
___

Create a free account to access the full topic