{"size": 631, "ext": "js", "max_stars_repo_path": "2273-find-resultant-array-after-removing-anagrams.js", "max_stars_repo_name": "SRP007/leetcode-js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "2273-find-resultant-array-after-removing-anagrams.js", "max_issues_repo_name": "SRP007/leetcode-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "2273-find-resultant-array-after-removing-anagrams.js", "max_forks_repo_name": "SRP007/leetcode-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.1212121212, "max_line_length": 49, "alphanum_fraction": 0.4976228209}
/**
 * @param {string[]} words
 * @return {string[]}
 */
const removeAnagrams = function(words) {
  const res = []
  const n = words.length

  for(let i = 0; i < n;) {
    let j = i + 1
    while(j < n && isAna(words[i], words[j])) j++
    res.push(words[i])
    i = j
  }
  return res
  
  function isAna(s1, s2) {
    const arr = Array(26).fill(0)
    const a = 'a'.charCodeAt(0)
    for(let i = 0; i < s1.length; i++) {
      arr[s1.charCodeAt(i) - a]++
    }
    for(let i = 0; i < s2.length; i++) {
      arr[s2.charCodeAt(i) - a]--
    }
    for(const e of arr) {
      if(e !== 0) return false
    }
    return true
  }
};

