import java.util.Arrays; import java.util.HashSet; class Solution { static int similarPairs(String[] words) { var seenWords = new HashSet<String>(Arrays.asList(words)); return words.length - seenWords.size(); } }
import static java.util.Collections.addAll;- import java.util.Arrays;
- import java.util.HashSet;
- class Solution {
- static int similarPairs(String[] words) {
var seenWords = new HashSet<String>(words.length);addAll(seenWords, words);- var seenWords = new HashSet<String>(Arrays.asList(words));
- return words.length - seenWords.size();
- }
- }