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

南京企业建站系统付费推广的平台

南京企业建站系统,付费推广的平台,wordpress导入xml,平面设计实例网站设计循环双端队列 https://leetcode.cn/problems/design-circular-deque/description/ 描述 设计实现双端队列。 实现 MyCircularDeque 类: MyCircularDeque(int k) #xff1a;构造函数,双端队列最大为 k 。boolean insertFront()#xff1a;将一个元素添加到双端队列头部…设计循环双端队列 https://leetcode.cn/problems/design-circular-deque/description/ 描述 设计实现双端队列。 实现 MyCircularDeque 类: MyCircularDeque(int k) 构造函数,双端队列最大为 k 。boolean insertFront()将一个元素添加到双端队列头部。 如果操作成功返回 true 否则返回 false 。boolean insertLast() 将一个元素添加到双端队列尾部。如果操作成功返回 true 否则返回 false 。boolean deleteFront() 从双端队列头部删除一个元素。 如果操作成功返回 true 否则返回 false 。boolean deleteLast() 从双端队列尾部删除一个元素。如果操作成功返回 true 否则返回 false 。int getFront() )从双端队列头部获得一个元素。如果双端队列为空返回 -1 。int getRear() 获得双端队列的最后一个元素。 如果双端队列为空返回 -1 。boolean isEmpty() 若双端队列为空则返回 true 否则返回 false 。boolean isFull() 若双端队列满了则返回 true 否则返回 false 。 示例 1 输入 [MyCircularDeque, insertLast, insertLast, insertFront, insertFront, getRear, isFull, deleteLast, insertFront, getFront] [[3], [1], [2], [3], [4], [], [], [], [4], []] 输出 [null, true, true, true, false, 2, true, true, true, 4]解释 MyCircularDeque circularDeque new MycircularDeque(3); // 设置容量大小为3 circularDeque.insertLast(1); // 返回 true circularDeque.insertLast(2); // 返回 true circularDeque.insertFront(3); // 返回 true circularDeque.insertFront(4); // 已经满了返回 false circularDeque.getRear(); // 返回 2 circularDeque.isFull(); // 返回 true circularDeque.deleteLast(); // 返回 true circularDeque.insertFront(4); // 返回 true circularDeque.getFront(); // 返回 4提示 1 k 10000 value 1000insertFront, insertLast, deleteFront, deleteLast, getFront, getRear, isEmpty, isFull 调用次数不大于 2000 次 Typescript 版算法实现 1 ) 方案1数组 class MyCircularDeque {private capacity: number;private rear: number;private front: number;private elements: number[];constructor(k: number) {this.capacity k 1; // 使用 k1 来区分满和空的情况this.rear 0;this.front 0;this.elements new Arraynumber(this.capacity).fill(0);}insertFront(value: number): boolean {if (this.isFull()) {return false;}this.front (this.front - 1 this.capacity) % this.capacity;this.elements[this.front] value;return true;}insertLast(value: number): boolean {if (this.isFull()) {return false;}this.elements[this.rear] value;this.rear (this.rear 1) % this.capacity;return true;}deleteFront(): boolean {if (this.isEmpty()) {return false;}this.front (this.front 1) % this.capacity;return true;}deleteLast(): boolean {if (this.isEmpty()) {return false;}this.rear (this.rear - 1 this.capacity) % this.capacity;return true;}getFront(): number {if (this.isEmpty()) {return -1;}return this.elements[this.front];}getRear(): number {if (this.isEmpty()) {return -1;}return this.elements[(this.rear - 1 this.capacity) % this.capacity];}isEmpty(): boolean {return this.rear this.front;}isFull(): boolean {return (this.rear 1) % this.capacity this.front;} }/*** Your MyCircularDeque object will be instantiated and called as such:* var obj new MyCircularDeque(k)* var param_1 obj.insertFront(value)* var param_2 obj.insertLast(value)* var param_3 obj.deleteFront()* var param_4 obj.deleteLast()* var param_5 obj.getFront()* var param_6 obj.getRear()* var param_7 obj.isEmpty()* var param_8 obj.isFull()*/2 ) 方案2链表 // 定义节点结构 class Node {prev: Node | null null;next: Node | null null;val: number;constructor(value: number) {this.val value;} }class MyCircularDeque {head: Node | null null;tail: Node | null null;capacity: number;size: number 0;constructor(k: number) {this.capacity k;}// 在队列前端插入元素insertFront(value: number): boolean {if (this.isFull()) {return false;}const newNode new Node(value);if (this.isEmpty()) {this.head newNode;this.tail newNode;} else {newNode.next this.head;if (this.head) {this.head.prev newNode;}this.head newNode;}this.size;return true;}// 在队列末端插入元素insertLast(value: number): boolean {if (this.isFull()) {return false;}const newNode new Node(value);if (this.isEmpty()) {this.head newNode;this.tail newNode;} else {if (this.tail) {this.tail.next newNode;newNode.prev this.tail;}this.tail newNode;}this.size;return true;}// 从队列前端删除元素deleteFront(): boolean {if (this.isEmpty()) {return false;}if (this.head) {this.head this.head.next;if (this.head) {this.head.prev null;} else {this.tail null; // 如果删除后队列为空更新尾指针}}this.size--;return true;}// 从队列末端删除元素deleteLast(): boolean {if (this.isEmpty()) {return false;}if (this.tail) {this.tail this.tail.prev;if (this.tail) {this.tail.next null;} else {this.head null; // 如果删除后队列为空更新头指针}}this.size--;return true;}// 获取队列前端的元素getFront(): number {if (this.isEmpty()) {return -1;}return this.head?.val ?? -1;}// 获取队列末端的元素getRear(): number {if (this.isEmpty()) {return -1;}return this.tail?.val ?? -1;}// 检查队列是否为空isEmpty(): boolean {return this.size 0;}// 检查队列是否已满isFull(): boolean {return this.size this.capacity;} }/*** Your MyCircularDeque object will be instantiated and called as such:* var obj new MyCircularDeque(k)* var param_1 obj.insertFront(value)* var param_2 obj.insertLast(value)* var param_3 obj.deleteFront()* var param_4 obj.deleteLast()* var param_5 obj.getFront()* var param_6 obj.getRear()* var param_7 obj.isEmpty()* var param_8 obj.isFull()*/
http://www.w-s-a.com/news/763486/

相关文章:

  • 如何查询网站建设时间赤峰建网站的电话
  • 域名购买网站有哪些公司企业邮箱管理制度
  • 阿里云服务起做网站抖音seo推荐算法
  • 免费建站工具机械网站建设公司推荐
  • 怎么用自己主机做网站_如何做简单的网站
  • 阿里巴巴国际站跨境电商平台为什么有点网站打不开
  • 甘肃做网站哪家好网站开发 都包含什么语言
  • 合肥哪里有做网站的广告型网站怎么做的
  • 用dede做的网站国外免费空间哪个好
  • dede个人网站模板企点
  • 韩雪个人网站wordpress 怎么添加网站备案信息
  • 个人网站可以做地方技能培训班
  • 品牌营销策略研究无锡 网站 seo 优化
  • 在线推广网站的方法有哪些织梦网站首页目录在哪
  • 做爰全过程免费网站的视频做网站的几个步骤
  • cpa建站教程青海西宁制作网站企业
  • 简易的在线数据库网站模板网站多服务器建设
  • 成都seo网站建设花店网页模板html
  • 义乌市网站制作网络营销策略名词解释
  • 高端品牌网站建设图片wordpress 资源站主题
  • 上海建设工程监督总站网站电商网站wordpress
  • 网站建设 医院菏泽网站建设熊掌号
  • 成都网站建设企业预约网免费建站流程
  • 网站建设胶州中国政务网站建设绩效评估
  • 合肥知名网站推广胶东国际机场建设有限公司网站
  • asp.ney旅游信息网站下载 简洁濮阳微信网站开发
  • 建设网站专业怎么上传网站程序到空间
  • 县城乡建设局网站微商城小程序哪个好
  • 博物馆门户网站建设优势重庆seo排名系统运营
  • 哪有app制作公司上海seo排名