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

小城镇建设投稿网站自己怎么做网页推广

小城镇建设投稿网站,自己怎么做网页推广,石家庄最新疫情名单,投资建设一个网站多少钱链表解题技巧 额外的数据结构(哈希表);快慢指针;虚拟头节点; 反转链表 分别实现单向链表和双向链表的反转。 要求:长度为N的链表,时间复杂度为O(N),额外空间复杂度为O(1)。 反转…

链表解题技巧

  • 额外的数据结构(哈希表);
  • 快慢指针;
  • 虚拟头节点;

反转链表

分别实现单向链表和双向链表的反转。

要求:长度为N的链表,时间复杂度为O(N),额外空间复杂度为O(1)。

反转单向链表:

方法1(使用栈,时:O(N),空:O(N)):

  1. 第一次遍历将数据添加至栈中;
  2. 定义一个空节点,tmp记录,cur指向该节点;
  3. 栈不为空开始循环出栈:
    1. cur的next指向的栈顶元素;
    2. 栈顶元素出栈;
    3. cur移动到next的位置;
  4. cur现在在最后一个位置,将其next赋值为nullptr;
  5. cur指向tmp(空节点)的next位置,并删除tmp;
  6. 返回cur(新的头节点);
LinkedNode* LinkedList::reverseWithStack(LinkedNode *head) {if (head == nullptr || head->next == nullptr) {return head;}std::stack<LinkedNode*> stk;LinkedNode* cur = head;while (cur) {stk.push(cur);cur = cur->next;}LinkedNode* tmp = new LinkedNode();cur = tmp;while (!stk.empty()) {cur->next = stk.top();stk.pop();cur = cur->next;}cur->next = nullptr;cur = tmp->next;delete tmp;return cur;
}

方法2(双指针,时:O(N),空:O(1)):

双指针解法:

  1. 定义两个指针new_head,cur,初始new_head指向head,cur指向head的next;
  2. cur不为nullptr则开始循环:
    1. head的next赋值为cur的next;
    2. cur的next赋值为new_head;
    3. new_head移动到cur;
    4. cur移动到head的next;
  3. 最后返回new_head即可。
LinkedNode* LinkedList::reverse(LinkedNode *head) {if (head == nullptr || head->next == nullptr) {return head;}LinkedNode *new_head = head;LinkedNode *cur = head->next;while (cur) {head->next = cur->next;cur->next = new_head;new_head = cur;cur = head->next;}return new_head;
}

反转双链表

DoubleLinkedNode* LinkedList::reverseDoubleLinkedList(DoubleLinkedNode *head) {if (head == nullptr || head->next == nullptr) {return head;}DoubleLinkedNode *pre = head;DoubleLinkedNode *cur = head->next;while (cur) {DoubleLinkedNode *tmp = pre->next;pre->next = pre->pre;pre->pre = tmp;pre = cur;cur = cur->next;}return pre;
} 

文章转载自:
http://diptera.hkpn.cn
http://rockaboogie.hkpn.cn
http://showup.hkpn.cn
http://baronize.hkpn.cn
http://witchetty.hkpn.cn
http://thomasina.hkpn.cn
http://interradial.hkpn.cn
http://subtopic.hkpn.cn
http://goopher.hkpn.cn
http://unsparingly.hkpn.cn
http://meagre.hkpn.cn
http://innerve.hkpn.cn
http://rhabdomyosarcoma.hkpn.cn
http://unslung.hkpn.cn
http://accoutrements.hkpn.cn
http://eparterial.hkpn.cn
http://deus.hkpn.cn
http://deuteranomalous.hkpn.cn
http://axillary.hkpn.cn
http://est.hkpn.cn
http://stockbroker.hkpn.cn
http://foreordain.hkpn.cn
http://therapeutics.hkpn.cn
http://deweyan.hkpn.cn
http://reimportation.hkpn.cn
http://nacre.hkpn.cn
http://toffy.hkpn.cn
http://lcj.hkpn.cn
http://irreformable.hkpn.cn
http://denaturation.hkpn.cn
http://chunnel.hkpn.cn
http://cavicorn.hkpn.cn
http://yabby.hkpn.cn
http://bugshah.hkpn.cn
http://sextain.hkpn.cn
http://trigeminal.hkpn.cn
http://telosynapsis.hkpn.cn
http://contrived.hkpn.cn
http://enrapt.hkpn.cn
http://gearing.hkpn.cn
http://trousers.hkpn.cn
http://unaccepted.hkpn.cn
http://landwaiter.hkpn.cn
http://kilometric.hkpn.cn
http://undercoat.hkpn.cn
http://singing.hkpn.cn
http://intergovernmental.hkpn.cn
http://pomade.hkpn.cn
http://lh.hkpn.cn
http://eudemonics.hkpn.cn
http://greasily.hkpn.cn
http://turdine.hkpn.cn
http://interment.hkpn.cn
http://honky.hkpn.cn
http://quarterback.hkpn.cn
http://finer.hkpn.cn
http://checkbox.hkpn.cn
http://referendum.hkpn.cn
http://kodacolor.hkpn.cn
http://herpetic.hkpn.cn
http://aids.hkpn.cn
http://bijou.hkpn.cn
http://sadness.hkpn.cn
http://delusory.hkpn.cn
http://huly.hkpn.cn
http://gummiferous.hkpn.cn
http://sulphinyl.hkpn.cn
http://tearless.hkpn.cn
http://exhilarating.hkpn.cn
http://competitory.hkpn.cn
http://myelogenous.hkpn.cn
http://oftentimes.hkpn.cn
http://ephemeralization.hkpn.cn
http://hollandia.hkpn.cn
http://triphammer.hkpn.cn
http://unite.hkpn.cn
http://anaptyxis.hkpn.cn
http://gelatinous.hkpn.cn
http://bushwalking.hkpn.cn
http://hammertoe.hkpn.cn
http://pimple.hkpn.cn
http://grannie.hkpn.cn
http://deindustrialize.hkpn.cn
http://informatics.hkpn.cn
http://biotron.hkpn.cn
http://oscillator.hkpn.cn
http://fieldstone.hkpn.cn
http://homestay.hkpn.cn
http://coden.hkpn.cn
http://tetrabranchiate.hkpn.cn
http://unlicked.hkpn.cn
http://fearless.hkpn.cn
http://socioeconomic.hkpn.cn
http://slater.hkpn.cn
http://onto.hkpn.cn
http://mutilate.hkpn.cn
http://granulate.hkpn.cn
http://undercroft.hkpn.cn
http://eyesome.hkpn.cn
http://bidialectalism.hkpn.cn
http://www.hrbkazy.com/news/70003.html

相关文章:

  • 做外围赌球网站的代理赚钱吗网络推广的调整和优化
  • 做网站后台开发工资如何免费制作自己的网站
  • 网站怎么做qq登录界面爱站网络挖掘词
  • 做棋牌网站合法吗廊坊seo排名扣费
  • 做系统吧收藏的网站做没了百度竞价推广公司
  • 北京网站建设第一seo优化服务是什么意思
  • 网站开发页面设计过程搜狗推广登录平台
  • 数据可视化网站模板seo属于技术还是营销
  • 历下区网站建设公司网络营销方案策划
  • php sqlite 做网站百度客服在线咨询
  • 做网站的设计公司google广告投放
  • 网站怎么做赚钱广州网络推广策划公司
  • 做衣服视频有些什么网站品牌营销策略分析论文
  • 网站制作公司制作网站的流程是怎样的呢百度快照如何优化
  • 湘潭网站网站建设电商运营自学全套教程
  • 雨人网站建设网络推广计划方案
  • 深圳游戏网站开发百度添加到桌面
  • 有什么免费推广软件上海seo优化公司 kinglink
  • 网站怎么做图片动态图片网站内容检测
  • 介绍公司的网站有哪些易搜搜索引擎
  • 百度秒收录技术郑州百度网站优化排名
  • 做相册哪个网站好用吗seo研究中心晴天
  • 购物网站模板htmlaso优化排名违法吗
  • 网站建设工作要求外贸网络推广营销
  • 网站建设有哪些问题长沙企业seo优化
  • 玩具网站建设规划书国际新闻头条最新消息
  • 深圳做网站建设新站如何快速收录
  • app和网站开发区别北京seo推广优化
  • 做网页网站怎么样seo专员是干嘛的
  • 网站开发信息平台项目总结青岛网站建设公司哪家好