You are viewing a single comment's thread. Return to all comments →
Please advise on why test case fails even though output matches. I believe its an minor mistake.
public class DuplicateWords {
public static void main(String[] args) { Scanner in = new Scanner(System.in); int numSentences = Integer.parseInt(in.nextLine()); while(numSentences > 0) { String input = in.nextLine(); List<String> list = Arrays.asList(input.split(" ")); Set<String> ans = new HashSet<>(); String answer = list.stream() .filter(str -> ans.add(str.toLowerCase())) .collect(Collectors.joining(" ")).trim(); System.out.println(answer); numSentences--; } in.close(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Regex 2 - Duplicate Words
You are viewing a single comment's thread. Return to all comments →
Please advise on why test case fails even though output matches. I believe its an minor mistake.
public class DuplicateWords {
}