Ad
Code
Diff
  • 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();
    • }
    • }
Code
Diff
  • const addArr = arr => arr.reduce((sum, num) => sum + num, null);
    
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • };
    • const addArr = arr => arr.reduce((sum, num) => sum + num, null);
Code
Diff
  • const numMinusSeven = num => Math.ceil(num/7);
    
    • function numMinusSeven(num) {
    • return Math.ceil(num/7);
    • }
    • const numMinusSeven = num => Math.ceil(num/7);