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

wordpress免费商城主题seo矩阵培训

wordpress免费商城主题,seo矩阵培训,如何注册网站,wordpress页面的设置理论 链表的增删操作时间复杂度O(1),查询时间复杂度O(n),因为要从头结点开始。使用场景和数据完全相反 链表的储存地址是不连续的。也和数组不同。 移除链表元素 利用虚拟头结点可以同意操作。不然删除头结点需要额外写。 记得返回的是虚拟头结点的next而不是虚拟头结点retu…

理论

链表的增删操作时间复杂度O(1),查询时间复杂度O(n),因为要从头结点开始。使用场景和数据完全相反
链表的储存地址是不连续的。也和数组不同。

移除链表元素

利用虚拟头结点可以同意操作。不然删除头结点需要额外写。
记得返回的是虚拟头结点的next而不是虚拟头结点return dummyhead。哈哈哈

class Solution {
public:ListNode* removeElements(ListNode* head, int val) {ListNode* dummyhead = new ListNode(60);dummyhead->next=head;ListNode* cur=dummyhead;while(cur->next!=NULL){if(cur->next->val == val){ListNode* temp=cur->next;cur->next = cur->next->next;delete temp;}else{cur=cur->next;}}return dummyhead->next;}
};

设计链表

总是忘记判定插入或者删除的位置是否有效。

class MyLinkedList {
public:struct ListNode {int val;ListNode *next;ListNode(int val) : val(val), next(nullptr) {}};MyLinkedList() {dummyhead=new ListNode(0);size=0;}int get(int index) {if(index>size-1)return -1;ListNode* cur=dummyhead->next;for(int i=0;i<index;i++){cur=cur->next;}return cur->val;}void addAtHead(int val) {ListNode* head= new ListNode(val);head->next=dummyhead->next;dummyhead->next=head;size++;}void addAtTail(int val) {if(size==0) dummyhead->next=new ListNode(val);else{ListNode* cur=dummyhead->next;while(cur->next != NULL){cur=cur->next;}cur->next= new ListNode(val);}size++;}void addAtIndex(int index, int val) {if(index>size) return;ListNode* cur=dummyhead;for(int i=0;i<index;i++){cur=cur->next;}ListNode* temp=new ListNode(val);temp->next=cur->next;cur->next=temp;size++;}void deleteAtIndex(int index) {if(index>=size) return;ListNode* cur=dummyhead;for(int i=0;i<index;i++){cur=cur->next;};ListNode* temp=cur->next;cur->next=cur->next->next;delete temp;size--;}//void printLinkedList(){//}
private:int size;ListNode* dummyhead;
};

翻转链表

中间过程想到了用三个指针,双指针+储存临时下一个的指针。
但是开头和结尾的处理过程没想出来。
直接让pre=head,这样的话还得加上head->next=nullptr才表示一条链表结束了。
所以让pre=null就不用特殊处理开头和结尾了。

    ListNode* reverseList(ListNode* head) {//if(head->next==nullptr) return nullptr;//ListNode* dummyhead= new ListNode(0);//dummyhead->next=head;//ListNode* pre=head;//ListNode* cur=pre->next;//ListNode* next=cur->next;//cur->next=pre;//head=reversal(cur,next);//return head;if(head==nullptr) return nullptr;ListNode* pre=nullptr;ListNode* cur=head;while(cur!=nullptr){ListNode* next=cur->next;cur->next=pre;pre=cur;cur=next;}return pre;}

快忘记递归怎么写啦,就是递归套递归。

class Solution {
private:ListNode* reversal(ListNode* pre,ListNode* cur){if(cur==nullptr) return pre;ListNode* temp=cur->next;cur->next=pre;return reversal(cur,temp);}
public:ListNode* reverseList(ListNode* head) {ListNode* pre=nullptr;ListNode* cur=head;return reversal(pre,cur);}};
http://www.hkea.cn/news/395972/

相关文章:

  • 专门做图片的网站吗如何建网站要什么条件
  • 卢氏县住房和城乡建设局网站站长统计 站长统计
  • 济南 网站制作旺道营销软件
  • 新上线网站如何做搜索引擎站长素材网站
  • 做网站编辑深圳疫情防控最新消息
  • PHP网站开发项目式教程google下载手机版
  • 国外专门用于做网站图片的做网站要多少钱
  • 网站维护费用计入什么科目媒介星软文平台官网
  • 网站建设seo 视频做网站哪个平台好
  • 旅行社网站建设方案论文百度seo公司
  • 长沙网站建设与维护百度开户联系方式
  • 做pcr查基因序列的网站南京百度网站快速优化
  • 数据服务网站策划方案关键词快速优化排名软件
  • 响应式网站缺点学大教育培训机构电话
  • 江苏天德建设工程有限公司网站一个平台怎么推广
  • 石家庄做网络推广的网站推广平台收费标准
  • 贵阳天柱网站建设招聘域名注册平台有哪些
  • 网站建设电话营销百度问一问官网
  • 网站优化建设河南怎么关闭seo综合查询
  • 自贡做响应式网站开发公司google搜索引擎入口google
  • 东莞哪种网站推广好微信朋友圈推广文案
  • 现在学做网站赚钱吗东莞市优速网络科技有限公司
  • 宁津做网站公司宣传推广图片
  • 陕西的建设厅官方网站数据分析报告
  • 企业网站建设的定位互联网
  • 注册域名之后如何做网站优化清理大师
  • wordpress+在线播放推广seo网站
  • 丽水网站建设明恩玉杰网站开发框架
  • 如何设计网站中的上传功能搜索引擎技术基础
  • 余江区建设局网站百度搜索引擎优化的方法