Given two strings s and t, return true if t is an anagram of s, and false otherwise.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
給定兩個 string, s 和 t,如果 s 和 t 用到的 chart 數量一樣則回傳 true 反之回傳 false,一樣利用 hash-table 分別紀錄兩個 string 中 chart 出現的次數,最後將兩個 hash-table 的內容作比較即可。
Input: s = "anagram", t = "nagaram"
Output: true
Input: s = "rat", t = "car"
Output: false
var isAnagram = function(s, t) {
  if (s.length !== t.length) return false
  const sObj = {}, tObj = {};
  s.split('').forEach(s => {
    if (!sObj[s]) {
      sObj[s] = 1;
    } else {
      sObj[s]++;
    }
  })
  t.split('').forEach(t => {
    if (!tObj[t]) {
      tObj[t] = 1;
    } else {
      tObj[t]++;
    }
  })
  for (const key in sObj) {
    if (Object.hasOwnProperty.call(sObj, key)) {
      if (!tObj[key]) return false;
      if (sObj[key] !== tObj[key]) return false;
    }
  }
  return true;
};
hash-table 的 get 為 O(1) 而 for-loop 兩個 string 的遍歷為 O(2n) -> O(n)