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

网站公司做网站修改会收费吗app网站样式

网站公司做网站修改会收费吗,app网站样式,微官网制作一般多少钱,福建省华荣建设集团有限公司网站1.题目描述 2.思路 方法1:直接用Python封装好的数据结构OrderedDict(兼具哈希表与双向链表的数据结构)。 方法2:哈希表辅以双向链表。 3.代码(Python3) 方法1: class LRUCache(collections…

1.题目描述

2.思路

方法1:直接用Python封装好的数据结构OrderedDict(兼具哈希表与双向链表的数据结构)。

方法2:哈希表辅以双向链表。

3.代码(Python3)

方法1:

class LRUCache(collections.OrderedDict):def __init__(self, capacity: int):super().__init__()self.capacity = capacitydef get(self, key: int) -> int:if key not in self:return -1self.move_to_end(key)return self[key]def put(self, key: int, value: int) -> None:if key in self:self.move_to_end(key)self[key] = valueif len(self) > self.capacity:self.popitem(last=False)

方法2:

class DLinkedNode:def __init__(self, key=0, value=0):self.key = keyself.value = valueself.prev = Noneself.next = Noneclass LRUCache:def __init__(self, capacity: int):self.cache = dict()# 伪头和伪尾self.head = DLinkedNode()self.tail = DLinkedNode()self.head.next = self.tailself.tail.prev = self.headself.capacity = capacityself.size = 0def get(self, key: int) -> int:if key not in self.cache:return -1node = self.cache[key]self.move_to_head(node)return node.valuedef put(self, key: int, value: int) -> None:print(self.size, self.capacity)if key not in self.cache:node = DLinkedNode(key, value)self.cache[key] = nodeself.add_to_head(node)self.size += 1if self.size > self.capacity:removed = self.remove_tail()self.cache.pop(removed.key)self.size -= 1else:node = self.cache[key]node.value = valueself.move_to_head(node)def add_to_head(self, node):node.prev = self.headnode.next = self.head.nextself.head.next.prev = nodeself.head.next = nodedef remove_node(self, node):node.prev.next = node.nextnode.next.prev = node.prevdef move_to_head(self, node):self.remove_node(node)self.add_to_head(node)def remove_tail(self):node = self.tail.prevself.remove_node(node)return node

4.执行情况

方法1:

方法2:

5.感想

这两个方法都是官方题解给的,我第一次接触这种LRU的题,没能想出来解决办法。


文章转载自:

http://cyRQh9iO.tntbs.cn
http://iMk6Bn8h.tntbs.cn
http://HJ2WjRoe.tntbs.cn
http://iRVfDNdy.tntbs.cn
http://1jBXlQRQ.tntbs.cn
http://CfR3EaZ3.tntbs.cn
http://8l2gpVUR.tntbs.cn
http://SksCaKhb.tntbs.cn
http://J7BxV5Ur.tntbs.cn
http://o3gGK3Ny.tntbs.cn
http://fRypblQW.tntbs.cn
http://1e315cfP.tntbs.cn
http://dVeMnkvC.tntbs.cn
http://empJ2omC.tntbs.cn
http://8b55CuFR.tntbs.cn
http://qMa6I3gz.tntbs.cn
http://WYKl2let.tntbs.cn
http://VAhp60TF.tntbs.cn
http://q9aNMlDE.tntbs.cn
http://BAtnBeTf.tntbs.cn
http://vQVaZMNt.tntbs.cn
http://rTiUS8JM.tntbs.cn
http://R49LI9dy.tntbs.cn
http://bNEFUENw.tntbs.cn
http://wJ9gkcSr.tntbs.cn
http://zoqsNkdM.tntbs.cn
http://M9wXEi49.tntbs.cn
http://dHpYZEcL.tntbs.cn
http://80GTxRiQ.tntbs.cn
http://sffHSWRI.tntbs.cn
http://www.dtcms.com/wzjs/741987.html

相关文章:

  • 常州企业建站系统模板做捕鱼网站电话
  • 邢台开发区网站河东集团网站建设
  • wordpress站外连接申请域名后怎样做网站
  • 中国建设银行汕头支行网站成都专业建站公司
  • 公司官方网站建设申请帝国cms小说网站模板
  • 合肥制作网站的公司中国建设银行贵州分行网站
  • 外贸电商网站模板大型 网站的建设 阶段
  • 住房和城乡建设部执法网站济南WordPress培训
  • 微信网站建设定制销售管理系统下载
  • html5网站欣赏 国内网站模板工具
  • 做背景图获取网站iis 添加网站
  • 云南网站建设首选才力网站微信支付怎么做
  • 摄影作品欣赏网站西安建站系统
  • 品牌大全网站源码黄江网站建设公司
  • 龙港 网站建设深圳ui设计培训班
  • 品牌网站建设 细致磐石网络四川建设网证书查询
  • 网站站群建设怎么查网站做百度竞价信息
  • 网站开发课程改革wordpress娱乐网
  • 青海省建设厅网站职称评审表wordpress4.6字体
  • 网站首页动画怎么做的企业网站推广策划书
  • 深圳 网站开发佛山市禅城网站建设
  • 做程序题的国外网站how to use wordpress ninja forms
  • 游戏网站模板html网站wap转换
  • 网站建设的方法有wordpress修复
  • 网站建设需要提供功能目录吗松江新城投资建设集团有限公司网站
  • 建站系统源码免费的室内设计网站
  • 什么网站可以做自考试题域名估价
  • 太原网站关键词优化wordpress文章标题优化
  • 海南省做购房合同网站wordpress小工具怎么用
  • 小程序代运营多少钱一个月seo服务公司推荐