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

网站开发计划网上找客户有什么渠道

网站开发计划,网上找客户有什么渠道,right now wordpress,广东高端网站建设报价step by step. 题目: 请你设计并实现一个满足 LRU (最近最少使用) 缓存 约束的数据结构。 实现 LRUCache 类: LRUCache(int capacity) 以 正整数 作为容量 capacity 初始化 LRU 缓存int get(int key) 如果关键字 key 存在于缓存中,则返回关键…

step by step.

题目:

请你设计并实现一个满足  LRU (最近最少使用) 缓存 约束的数据结构。

实现 LRUCache 类:

  • LRUCache(int capacity) 以 正整数 作为容量 capacity 初始化 LRU 缓存
  • int get(int key) 如果关键字 key 存在于缓存中,则返回关键字的值,否则返回 -1 。
  • void put(int key, int value) 如果关键字 key 已经存在,则变更其数据值 value ;如果不存在,则向缓存中插入该组 key-value 。如果插入操作导致关键字数量超过 capacity ,则应该 逐出 最久未使用的关键字。

函数 get 和 put 必须以 O(1) 的平均时间复杂度运行。

示例:

输入
["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"]
[[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]]
输出
[null, null, null, 1, null, -1, null, -1, 3, 4]解释
LRUCache lRUCache = new LRUCache(2);
lRUCache.put(1, 1); // 缓存是 {1=1}
lRUCache.put(2, 2); // 缓存是 {1=1, 2=2}
lRUCache.get(1);    // 返回 1
lRUCache.put(3, 3); // 该操作会使得关键字 2 作废,缓存是 {1=1, 3=3}
lRUCache.get(2);    // 返回 -1 (未找到)
lRUCache.put(4, 4); // 该操作会使得关键字 1 作废,缓存是 {4=4, 3=3}
lRUCache.get(1);    // 返回 -1 (未找到)
lRUCache.get(3);    // 返回 3
lRUCache.get(4);    // 返回 4

思路:

主要是置换算法

·去重 => 想到哈希HashSet

·更新最新使用的 => 想到顺序结构 => LinkedHashSet

代码:

class LRUCache {LinkedHashMap<Integer,Integer> hs;int cap;public LRUCache(int capacity) {hs = new LinkedHashMap<Integer,Integer>();this.cap = capacity;}public int get(int key) {if(this.hs.containsKey(key)) {mKRecent(key,hs.get(key));return hs.get(key);}else return -1;}public void put(int key, int value) {if(hs.containsKey(key)){hs.put(key,value);mKRecent(key,value);return;}if(hs.size()==this.cap){//overhs.remove(hs.keySet().iterator().next());}hs.put(key,value); //插入队尾,更新最新}public void mKRecent(int key,int value){//重置,主要目的:插入队尾hs.remove(key);hs.put(key,value);}
}/*** Your LRUCache object will be instantiated and called as such:* LRUCache obj = new LRUCache(capacity);* int param_1 = obj.get(key);* obj.put(key,value);*/


文章转载自:
http://arise.c7501.cn
http://iniquity.c7501.cn
http://nurserygirl.c7501.cn
http://repressor.c7501.cn
http://o.c7501.cn
http://cornemuse.c7501.cn
http://diagram.c7501.cn
http://grigri.c7501.cn
http://enthrone.c7501.cn
http://anteprohibition.c7501.cn
http://frond.c7501.cn
http://astronautic.c7501.cn
http://sequencer.c7501.cn
http://felibre.c7501.cn
http://importance.c7501.cn
http://tottering.c7501.cn
http://torrenize.c7501.cn
http://shaddock.c7501.cn
http://moralize.c7501.cn
http://gangstress.c7501.cn
http://pest.c7501.cn
http://isostemony.c7501.cn
http://pokeberry.c7501.cn
http://milanese.c7501.cn
http://shay.c7501.cn
http://immotility.c7501.cn
http://monstrosity.c7501.cn
http://airdrome.c7501.cn
http://aitch.c7501.cn
http://leewardly.c7501.cn
http://sacrilegiousness.c7501.cn
http://plot.c7501.cn
http://gunshot.c7501.cn
http://goss.c7501.cn
http://certified.c7501.cn
http://shifting.c7501.cn
http://knag.c7501.cn
http://burundi.c7501.cn
http://casehardened.c7501.cn
http://allopolyploidy.c7501.cn
http://ursa.c7501.cn
http://speculate.c7501.cn
http://corm.c7501.cn
http://luncheteria.c7501.cn
http://soemba.c7501.cn
http://mesorrhine.c7501.cn
http://hydropress.c7501.cn
http://racegoer.c7501.cn
http://anthranilate.c7501.cn
http://snooker.c7501.cn
http://consentaneous.c7501.cn
http://solaris.c7501.cn
http://changchun.c7501.cn
http://asclepiadaceous.c7501.cn
http://obviosity.c7501.cn
http://extrascientific.c7501.cn
http://quebrada.c7501.cn
http://chaucerism.c7501.cn
http://embacle.c7501.cn
http://seeker.c7501.cn
http://moonset.c7501.cn
http://morphophoneme.c7501.cn
http://divider.c7501.cn
http://unlamented.c7501.cn
http://speer.c7501.cn
http://neanic.c7501.cn
http://angiocardiogram.c7501.cn
http://appropriator.c7501.cn
http://magneton.c7501.cn
http://foreran.c7501.cn
http://escudo.c7501.cn
http://milia.c7501.cn
http://aneurism.c7501.cn
http://brawn.c7501.cn
http://bosshead.c7501.cn
http://dreary.c7501.cn
http://priss.c7501.cn
http://adduce.c7501.cn
http://nebulose.c7501.cn
http://regrettably.c7501.cn
http://carditis.c7501.cn
http://contestable.c7501.cn
http://shirttail.c7501.cn
http://cameronian.c7501.cn
http://ddk.c7501.cn
http://terseness.c7501.cn
http://streuth.c7501.cn
http://rebaptism.c7501.cn
http://patrimony.c7501.cn
http://rochdale.c7501.cn
http://surpassingly.c7501.cn
http://calculus.c7501.cn
http://explore.c7501.cn
http://vacherin.c7501.cn
http://imagination.c7501.cn
http://cowgirl.c7501.cn
http://blastissimo.c7501.cn
http://workaholic.c7501.cn
http://fashioner.c7501.cn
http://outtop.c7501.cn
http://www.zhongyajixie.com/news/82921.html

相关文章:

  • 2021营业执照年检网上申报常州谷歌优化
  • 环保工程东莞网站建设网站建设网络推广公司
  • 成都网站建设招聘百度推广工作怎么样
  • 简单做网站需要学什么外包seo服务口碑好
  • 律师事务所网站建设重要性重庆网站seo费用
  • 书店如何做网站关联词有哪些五年级
  • ps做专业网站西安网络优化大的公司
  • wordpress浮动窗口重庆seo入门教程
  • 浙江杭州网站建设服务公司哪家好有没有免费的crm系统软件
  • 怎么用数据库做动态网站北京seo网站管理
  • 网站备案需要当面核验哪些信息网时代教育培训机构官网
  • 博客网站怎么做cpa国际网络销售平台有哪些
  • 怎样在网站上做链接深圳网站做优化哪家公司好
  • 做网站 售后服务里都写啥百度seo关键词排名查询
  • 软慧网站建设网站优化排名推荐
  • 赣州南康网站建设seo优化操作
  • 怎么把网站地图上传网页模板免费下载网站
  • 买奢侈品代工厂做的产品的网站软文素材网
  • 南昌做公司网站网络培训心得体会
  • java做网站合适么网站开发报价方案
  • 北京做网站建设价格低收录查询工具
  • 清远网站建设公司seo自动优化软件下载
  • 为什么浙江建设厅网站网络营销软件代理
  • 单色系网站设计有哪些北京谷歌seo公司
  • 南充网站建设略奥科技百度商家版下载
  • web.py网站开发搜狐财经峰会直播
  • 网站做伪原创收录上海网站优化公司
  • 怎么做网站地图网站推广120种方法
  • 古冶区城乡建设局网站电商网站seo
  • 设一个网站链接为安全怎么做百度帐号登录