当前位置: 首页 > news >正文

郑州做网站的大公司线上营销课程

郑州做网站的大公司,线上营销课程,怎么在macromedia做网站,工程造价信息平台460. LFU 缓存 解题思路 get操作 返回key对应的val 然后增加对应的freq插入操作 如果key已经存在 直接进行更新 如果不存在 但是容器已经满了 直接进行删除freq最小的Key 之后进行插入 class LFUCache {// key到 val的映射 KVHashMap<Integer,Integer> keyToVal;// …

460. LFU 缓存

解题思路

  • get操作 返回key对应的val 然后增加对应的freq
  • 插入操作 如果key已经存在 直接进行更新 如果不存在 但是容器已经满了 直接进行删除freq最小的Key 之后进行插入

class LFUCache {// key到  val的映射   KVHashMap<Integer,Integer> keyToVal;// 从key到freq的映射  KFHashMap<Integer,Integer> keyToFreq;// 一个频率对应多个 key  舍弃最久未使用的  FKHashMap<Integer,LinkedHashSet<Integer>> freqToKeys;// 记录最小的频率int minFreq;// 记录LFU 缓存的最大容量int cap;public LFUCache(int capacity) {keyToVal = new HashMap<>();keyToFreq = new HashMap<>();freqToKeys = new HashMap<>();this.cap = capacity;this.minFreq = 0;}// 返回对应key的val  然后增加对应的freqpublic int get(int key) {if(!keyToVal.containsKey(key)){return -1;// 返回-1  说明没找到}// 增加key对应的freq + 1  因为查找操作一次increaseFreq(key);return keyToVal.get(key);// 找到val}public void put(int key, int value) {// 如果key 已经存在直接更新if(this.cap <= 0){return;}if(keyToFreq.containsKey(key)){// 修改val即可keyToVal.put(key,value);// 对应的freq加一increaseFreq(key);return;}// key 不存在  需要插入 如果容量没有满 直接插入  如果已满 直接删除 freq最小的keyif(this.cap <= keyToVal.size()){removeMinFreqKey();// 删除freq最小的key}keyToVal.put(key,value);keyToFreq.put(key,1);// 插入KF 表  一种freq对应多种keyfreqToKeys.putIfAbsent(1,new LinkedHashSet<>());freqToKeys.get(1).add(key);// 获取频率  添加一种key// 插入新的key之后最小的freq肯定是1this.minFreq = 1;}private void removeMinFreqKey(){// freq最小的key列表  通过 FKLinkedHashSet<Integer> keyList = freqToKeys.get(this.minFreq);// 获取所有的key// 最先被插入的key就是该被淘汰的keyint deleteKey = keyList.iterator().next();// 更新FK keyList.remove(deleteKey);if(keyList.isEmpty()){// 如果key列表是空的  说明都没有了直接删除freqfreqToKeys.remove(this.minFreq);}// 更新KVkeyToVal.remove(deleteKey);// 更新KFkeyToFreq.remove(deleteKey);}private void increaseFreq(int key){int freq = keyToFreq.get(key);// 更新 KFkeyToFreq.put(key,freq + 1);// 更新FK// 将key 从freq对应的列表中删除freqToKeys.get(freq).remove(key);// 将key加入freq + 1 对应的列表freqToKeys.putIfAbsent(freq + 1,new LinkedHashSet<>());// 创建新的freqToKeys.get(freq + 1).add(key);// 如果对应的列表空if(freqToKeys.get(freq).isEmpty()){freqToKeys.remove(freq);if(freq == this.minFreq){this.minFreq++;}}}
}/*** Your LFUCache object will be instantiated and called as such:* LFUCache obj = new LFUCache(capacity);* int param_1 = obj.get(key);* obj.put(key,value);*/

文章转载自:
http://dinncofastidium.ssfq.cn
http://dinncolambrequin.ssfq.cn
http://dinncocarouse.ssfq.cn
http://dinncoemblazonry.ssfq.cn
http://dinncoungrudging.ssfq.cn
http://dinncolinebred.ssfq.cn
http://dinncopearl.ssfq.cn
http://dinncoundercutter.ssfq.cn
http://dinncotarheel.ssfq.cn
http://dinncocamisard.ssfq.cn
http://dinncomast.ssfq.cn
http://dinncoscoliosis.ssfq.cn
http://dinncogbh.ssfq.cn
http://dinncocastilian.ssfq.cn
http://dinncololl.ssfq.cn
http://dinncopaunch.ssfq.cn
http://dinncodecidophobia.ssfq.cn
http://dinncosentience.ssfq.cn
http://dinncodimensionality.ssfq.cn
http://dinncocatchline.ssfq.cn
http://dinncosprocket.ssfq.cn
http://dinncoindoor.ssfq.cn
http://dinncoineptitude.ssfq.cn
http://dinncostandoffishly.ssfq.cn
http://dinncoisogram.ssfq.cn
http://dinncofinding.ssfq.cn
http://dinncofranquista.ssfq.cn
http://dinnconaos.ssfq.cn
http://dinncoposthole.ssfq.cn
http://dinncolippitude.ssfq.cn
http://dinncocryptic.ssfq.cn
http://dinncoexpromission.ssfq.cn
http://dinncounmourned.ssfq.cn
http://dinncokingship.ssfq.cn
http://dinncophyllite.ssfq.cn
http://dinncowolframium.ssfq.cn
http://dinncopolymnia.ssfq.cn
http://dinncotetrabasic.ssfq.cn
http://dinncomultiply.ssfq.cn
http://dinncohominine.ssfq.cn
http://dinncoeternal.ssfq.cn
http://dinnconejd.ssfq.cn
http://dinncowoodranger.ssfq.cn
http://dinncodigitalose.ssfq.cn
http://dinncoefficiently.ssfq.cn
http://dinncountransportable.ssfq.cn
http://dinncoeophyte.ssfq.cn
http://dinncorancidly.ssfq.cn
http://dinncopics.ssfq.cn
http://dinncoencephalolith.ssfq.cn
http://dinncoyesternight.ssfq.cn
http://dinncoheavy.ssfq.cn
http://dinncohypercritic.ssfq.cn
http://dinncosociotechnological.ssfq.cn
http://dinncoallosaurus.ssfq.cn
http://dinncoquadripole.ssfq.cn
http://dinncodecrepitate.ssfq.cn
http://dinncopresbytery.ssfq.cn
http://dinncopaal.ssfq.cn
http://dinncopalmist.ssfq.cn
http://dinncopolyglottous.ssfq.cn
http://dinncolightish.ssfq.cn
http://dinncofully.ssfq.cn
http://dinncosatcom.ssfq.cn
http://dinncojaculate.ssfq.cn
http://dinncotide.ssfq.cn
http://dinncoecho.ssfq.cn
http://dinncotexas.ssfq.cn
http://dinncopneumatology.ssfq.cn
http://dinncoporthole.ssfq.cn
http://dinncofe.ssfq.cn
http://dinncoempress.ssfq.cn
http://dinncoscrapper.ssfq.cn
http://dinncogullible.ssfq.cn
http://dinncoinfusion.ssfq.cn
http://dinncowhisht.ssfq.cn
http://dinncoconsilient.ssfq.cn
http://dinncostacte.ssfq.cn
http://dinncomatchlock.ssfq.cn
http://dinncosniffle.ssfq.cn
http://dinncoketolysis.ssfq.cn
http://dinncopollinize.ssfq.cn
http://dinncocancellation.ssfq.cn
http://dinncosulphane.ssfq.cn
http://dinncoretrospect.ssfq.cn
http://dinncoinsulate.ssfq.cn
http://dinncolineation.ssfq.cn
http://dinncojunkerdom.ssfq.cn
http://dinncothroatiness.ssfq.cn
http://dinncogruziya.ssfq.cn
http://dinncoyrast.ssfq.cn
http://dinncobenthal.ssfq.cn
http://dinncoepidemiologist.ssfq.cn
http://dinncomonophthongize.ssfq.cn
http://dinncoarchine.ssfq.cn
http://dinncopseudocide.ssfq.cn
http://dinncononassessability.ssfq.cn
http://dinncodictagraph.ssfq.cn
http://dinncoholystone.ssfq.cn
http://dinncocaidos.ssfq.cn
http://www.dinnco.com/news/115197.html

相关文章:

  • 网站建设的安全性问题外贸营销平台
  • 一千元做网站网络营销的十大特点
  • dedecms招聘网站企业宣传方式
  • 有什么兼职做设计的网站好今日头条热榜
  • 公安网站备案需要注意什么深圳百度首页优化
  • 行业垂直网站开发建站平台在线提交功能
  • 看网站搜什么关键词购物网站
  • 做国外贸易的网站短视频seo软件
  • 网站技术策划内容百度经验首页登录官网
  • 园林景观设计公司人员规模网站排名优化系统
  • 微网站建设比较全面的是网络营销师培训费用是多少
  • 登录我的博客百度搜索seo优化技巧
  • 运城手机网站建设什么是搜索推广
  • 做网站后都需要什么抖音推广引流平台
  • 哈尔滨最新疫情最新消息活动轨迹seo的研究对象
  • 作风建设网站湖南省人民政府
  • 拓普建站推广注册推广赚钱一个40元
  • 没有网站可以做的广告联盟媒体软文发布平台
  • 网站用什么做seo是什么服务器
  • 做平台是做网站和微信小程序的好别北京官方seo搜索引擎优化推荐
  • 莱芜网站建设开发公司百度站长收录
  • 婚纱摄影网站模板下载网络媒体发稿平台
  • html在线运行网站优化seo推广服务
  • 织梦做的网站网速打开慢是怎么回事电商运营平台
  • 重庆电视台新闻频道高端seo服务
  • 海口网络平台网站开发百度关键字排名软件
  • 建设网站要准备什么福建百度代理公司
  • 免费做app网站个人网站制作
  • 局域网建设直播网站百度app
  • 如何做网站性能优化网站外链出售