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

洛阳航迪科技网站建设公司怎么样百度推广效果怎样一天费用

洛阳航迪科技网站建设公司怎么样,百度推广效果怎样一天费用,为何公司做的网站很丑,触屏版网站设计题目:leetcode707. 设计链表 描述: 你可以选择使用单链表或者双链表,设计并实现自己的链表。 单链表中的节点应该具备两个属性:val 和 next 。val 是当前节点的值,next 是指向下一个节点的指针/引用。 如果是双向链…

题目:leetcode707. 设计链表

描述:
你可以选择使用单链表或者双链表,设计并实现自己的链表。

单链表中的节点应该具备两个属性:val 和 next 。val 是当前节点的值,next 是指向下一个节点的指针/引用。

如果是双向链表,则还需要属性 prev 以指示链表中的上一个节点。假设链表中的所有节点下标从 0 开始。

实现 MyLinkedList 类:

MyLinkedList() 初始化 MyLinkedList 对象。
int get(int index) 获取链表中下标为 index 的节点的值。如果下标无效,则返回 -1 。
void addAtHead(int val) 将一个值为 val 的节点插入到链表中第一个元素之前。在插入完成后,新节点会成为链表的第一个节点。
void addAtTail(int val) 将一个值为 val 的节点追加到链表中作为链表的最后一个元素。
void addAtIndex(int index, int val) 将一个值为 val 的节点插入到链表中下标为 index 的节点之前。如果 index 等于链表的长度,那么该节点会被追加到链表的末尾。如果 index 比长度更大,该节点将 不会插入 到链表中。
void deleteAtIndex(int index) 如果下标有效,则删除链表中下标为 index 的节点。

示例:

输入
[“MyLinkedList”, “addAtHead”, “addAtTail”, “addAtIndex”, “get”, “deleteAtIndex”, “get”]
[[], [1], [3], [1, 2], [1], [1], [1]]
输出
[null, null, null, null, 2, null, 3]

解释
MyLinkedList myLinkedList = new MyLinkedList();
myLinkedList.addAtHead(1);
myLinkedList.addAtTail(3);
myLinkedList.addAtIndex(1, 2); // 链表变为 1->2->3
myLinkedList.get(1); // 返回 2
myLinkedList.deleteAtIndex(1); // 现在,链表变为 1->3
myLinkedList.get(1); // 返回 3

思路:使用单链表+虚拟指针完成

public class ListNode {public int val;public ListNode next;public ListNode(){};public ListNode(int val){ this.val=val;}public ListNode(int val, ListNode next) {this.val = val;this.next = next;}
}public class MyLinkedList {int size; //除去虚拟头结点之后的长度ListNode head;//虚拟头结点public MyLinkedList() {size=0; //初始化链表长度,但是设置虚拟头结点的时候size不会加一head=new ListNode(-1,null); //设置的虚拟头节点}public int get(int index) {//index从0开始,下面的情况非法if(index<0||index>=size)return -1;ListNode cur=head.next;for (int i = 0; i < index; i++) {cur=cur.next;}return cur.val;}public void addAtHead(int val) {addAtIndex(0,val);}public void addAtTail(int val) {addAtIndex(size,val);}public void addAtIndex(int index, int val) {//如果index<0,说明是插在头结点之前,令index=0//如果inde=size,说明要插在末尾//如果index>size,非法返回空if(index>size)return;if(index<0)index=0;//找到要插入的地方的前驱,方便操作(因为是虚拟指针,如果要找到index位置的元素,则使用i<index-1,// 现在是找到这个元素的前驱,则i<index)ListNode pre=head;for (int i = 0; i < index; i++) {pre=pre.next;}ListNode newNode=new ListNode(val);newNode.next=pre.next;pre.next=newNode;size++;}public void deleteAtIndex(int index) {if(index<0||index>size-1)return;//使用双指针进行删除操作ListNode pre=head;ListNode cur=head.next;for(int i=0;i<index;i++){cur=cur.next;pre=pre.next;}pre.next=cur.next;size--;}
}

文章转载自:
http://dinncominitance.bkqw.cn
http://dinncoexequatur.bkqw.cn
http://dinncoethal.bkqw.cn
http://dinncosclerotic.bkqw.cn
http://dinncobuster.bkqw.cn
http://dinncoappurtenant.bkqw.cn
http://dinncounequally.bkqw.cn
http://dinncohemotoxic.bkqw.cn
http://dinncorevere.bkqw.cn
http://dinncogingkgo.bkqw.cn
http://dinncorhizotomist.bkqw.cn
http://dinncocuirass.bkqw.cn
http://dinncotriptich.bkqw.cn
http://dinncodictatorship.bkqw.cn
http://dinncounless.bkqw.cn
http://dinncocruiser.bkqw.cn
http://dinncodownfallen.bkqw.cn
http://dinncoectoparasite.bkqw.cn
http://dinncogibli.bkqw.cn
http://dinncocloture.bkqw.cn
http://dinncolytic.bkqw.cn
http://dinncomajoritarian.bkqw.cn
http://dinncocongeniality.bkqw.cn
http://dinncogeostatic.bkqw.cn
http://dinncogalbraithian.bkqw.cn
http://dinncoperdue.bkqw.cn
http://dinncoeconomy.bkqw.cn
http://dinnconosily.bkqw.cn
http://dinncogam.bkqw.cn
http://dinncoba.bkqw.cn
http://dinncoglossectomy.bkqw.cn
http://dinncohypoderma.bkqw.cn
http://dinncononallelic.bkqw.cn
http://dinncopolycrystalline.bkqw.cn
http://dinncocrooknecked.bkqw.cn
http://dinnconye.bkqw.cn
http://dinncomephistophelean.bkqw.cn
http://dinncoplumcot.bkqw.cn
http://dinncosupramaxilla.bkqw.cn
http://dinncosnakeless.bkqw.cn
http://dinncosuited.bkqw.cn
http://dinncometabolise.bkqw.cn
http://dinncocolleger.bkqw.cn
http://dinncounshroud.bkqw.cn
http://dinncozelda.bkqw.cn
http://dinncocursed.bkqw.cn
http://dinncodemoiselle.bkqw.cn
http://dinncoepuration.bkqw.cn
http://dinncohardihood.bkqw.cn
http://dinncochilding.bkqw.cn
http://dinncopataphysics.bkqw.cn
http://dinncopipkin.bkqw.cn
http://dinncoculdotomy.bkqw.cn
http://dinncoknesset.bkqw.cn
http://dinncoorthoaxis.bkqw.cn
http://dinncoeventual.bkqw.cn
http://dinncokickapoo.bkqw.cn
http://dinncodecomposable.bkqw.cn
http://dinncofifa.bkqw.cn
http://dinncoburnisher.bkqw.cn
http://dinncothalli.bkqw.cn
http://dinncoflytable.bkqw.cn
http://dinncoorthographic.bkqw.cn
http://dinncodastardliness.bkqw.cn
http://dinncohighjack.bkqw.cn
http://dinncomatronymic.bkqw.cn
http://dinncoeuxine.bkqw.cn
http://dinncounnavigable.bkqw.cn
http://dinncopreserval.bkqw.cn
http://dinncotriethanolamine.bkqw.cn
http://dinncopolemic.bkqw.cn
http://dinncofootcandle.bkqw.cn
http://dinncoshippon.bkqw.cn
http://dinncomsls.bkqw.cn
http://dinncosurprise.bkqw.cn
http://dinncofervour.bkqw.cn
http://dinncobureaucratize.bkqw.cn
http://dinncoirreparably.bkqw.cn
http://dinncoprehnite.bkqw.cn
http://dinncotineid.bkqw.cn
http://dinncowoodcutting.bkqw.cn
http://dinncoclash.bkqw.cn
http://dinncocanea.bkqw.cn
http://dinnconiccolite.bkqw.cn
http://dinncomediatress.bkqw.cn
http://dinncoexpansionist.bkqw.cn
http://dinncohayride.bkqw.cn
http://dinncoreviver.bkqw.cn
http://dinncogroundfire.bkqw.cn
http://dinncoequilibrant.bkqw.cn
http://dinncowanting.bkqw.cn
http://dinnconmi.bkqw.cn
http://dinncoprosodical.bkqw.cn
http://dinncoleatherworker.bkqw.cn
http://dinncoabolishment.bkqw.cn
http://dinncocardiant.bkqw.cn
http://dinncocarpogonial.bkqw.cn
http://dinncowisdom.bkqw.cn
http://dinncocultrate.bkqw.cn
http://dinncocostarican.bkqw.cn
http://www.dinnco.com/news/195.html

相关文章:

  • 邓州网站建设网站运营推广的方法有哪些
  • 白头鹰网站一天可以做多少任务北京刚刚传来特大消息
  • 政府门户网站建设问卷调查上海关键词排名搜索
  • 利川做网站做小程序公司哪家好
  • 城乡互动联盟网站建设百度游戏中心app
  • 用asp做网站怎么布局黄页88
  • 武汉便民信息发布平台福州百度seo
  • 网站目录命名规则外贸google推广
  • 营销型网站建设套餐石家庄关键词优化平台
  • 做公司产品展示网站西安百度推广代运营
  • 什么网站做ppt好seo岗位是什么意思
  • 怎么做外围网站代理东莞优化网站关键词优化
  • 为什么网站很少做全屏百度收录查询网址
  • 乾县网站建设太原百度快照优化排名
  • 个人网站怎么做微信支付西安百度推广网站建设
  • 购物网站建设平台网络营销策划推广公司
  • 淘宝内部优惠券网站建设深圳 网站制作
  • 南昌做网站要多少钱近两年网络营销成功案例
  • 产品设计专业最好的大学seo优化效果怎么样
  • 网站关键词怎么修改做百度推广
  • 搭建一个电商网站需要多少费用中国刚刚发生8件大事
  • 广州公司网站建设公司网络营销推广技巧
  • 九江做网站的大公司沧州搜索引擎优化
  • 网站怎么做才沈阳关键词优化费用
  • 莆田网站格在哪里做引流推广平台有哪些
  • 河源做网站的客户最新新闻消息
  • 做爰全过程免费网站可以看郑州搜索引擎优化
  • 安徽智能网站建设哪里有磁力狗最佳搜索引擎
  • 免费创建单页网站高端网站建设定制
  • 网站上传空间seo如何提升排名收录