/**
* @param {string[]} words
* @return {number}
*//**
* @param {string[]} words
* @return {number}
*/// 思路 二进制换算// 这题还需要好好理解, 不熟悉functiongetCharCodeSet(word){
let num =0;for(let i =0; i < word.length; i++){
const bit =1<<(word[i].charCodeAt()-97);
num |= bit;}return num;}
var maxProduct =function(words){
const nums = words.map(getCharCodeSet);
let ans =0;for(let i =0; i < nums.length; i++){for(let j = i +1; j < nums.length; j++){if((nums[i]& nums[j])===0){
ans = Math.max(ans, words[i].length * words[j].length);}}}return ans;};
146.LRU 缓存
/**
* @param {number} capacity
*/// 思路 利用map进行操作// 读: 拿起 (删除) 放到最上面// 放: 如果有该书,拿起 (删除) 放到最上面,如果没有, 判断是否到最大值, 到了则删除最早的那个,再存入varLRUCache=function(capacity){this.capacity = capacity;this.map =newMap();};/**
* @param {number} key
* @return {number}
*/LRUCache.prototype.get=function(key){if(this.map.has(key)){const value =this.map.get(key);this.map.delete(key);this.map.set(key, value);return value;}return-1;};/**
* @param {number} key
* @param {number} value
* @return {void}
*/LRUCache.prototype.put=function(key, value){if(this.map.has(key)){this.map.delete(key);this.map.set(key, value);}else{this.map.size ==this.capacity
?this.map.delete(this.map.keys().next().value):null;this.map.set(key, value);}};/**
* Your LRUCache object will be instantiated and called as such:
* var obj = new LRUCache(capacity)
* var param_1 = obj.get(key)
* obj.put(key,value)
*/const map =newMap();
map.set("a",1);
map.set("b",2);
map.set("c",3);const mapIter = map.keys();
console.log(mapIter);// [Map Iterator] { 'a', 'b', 'c' }
console.log(mapIter.next().value);// a
console.log(mapIter.next().value);// b