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

东莞哪家做网站梵克雅宝为什么那么贵

东莞哪家做网站,梵克雅宝为什么那么贵,龙岩天宫山要门票吗,响应式网站无法做联盟广告hi#xff0c;bro—— 目录 5、 链表分割 6、 链表的回文结构 7、 相交链表 8、 环形链表 【思考】 —————————————— DEAD POOL —————————————— 5、 链表分割 /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), …hibro—— 目录 5、 链表分割 6、 链表的回文结构 7、 相交链表 8、 环形链表 【思考】 —————————————— DEAD POOL —————————————— 5、 链表分割 /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), next(NULL) {} };*/ #include functional class Partition { public:ListNode* partition(ListNode* pHead, int x){//创建新的大小链表ListNode* lessHead,*lessTail;lessHeadlessTail(ListNode*)malloc(sizeof(ListNode));ListNode* greaterHead,*greaterTail;greaterHeadgreaterTail(ListNode*)malloc(sizeof(ListNode));//创建新的头结点遍历数组ListNode* pcurpHead;while(pcur){if(pcur-valx){//尾插到小链表lessTail-nextpcur;lessTaillessTail-next;}else{//尾插到大链表greaterTail-nextpcur;greaterTailgreaterTail-next;}pcurpcur-next;}//大小链表首尾相连lessTail-nextgreaterHead-next;greaterTail-nextNULL;ListNode* retlessHead-next;free(lessHead);free(greaterHead);lessHeadNULL;greaterHeadNULL;return ret;} }; 6、 链表的回文结构 在链表中不可回找但是数组可以回找所以我们可以把链表中的数据放到数组中。 思路1创建新数组遍历原链表将链表中的值放到数组中然后在数组中判断是否为回文结构。 因为题目中提前对链表的长度进行了限制若不限制空间复杂度为ON就不符合题目的条件了 /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), next(NULL) {} };*/ class PalindromeList { public:bool chkPalindrome(ListNode* A) {int arr[900]{0};ListNode* pcurA;int i0;//将链表中的数据赋给数组while(pcur){arr[i]pcur-val;pcurpcur-next;}//i为链表中结点的个数//判断数组中的值是否为回文结构int left0;int righti-1;while(leftright){if(arr[left]!arr[right]){return false;}left;right--;}return true;} }; 思路2反转链表这种方法的时间复杂度为ON空间复杂度为O1 1找原链表的中间结点“快慢指针” 2将中间结点及之后的结点进行反转 3从原链表的头结点和新链表的头结点开始遍历比较。 /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), next(NULL) {} };*/ class PalindromeList { public://找中间结点ListNode* findMidNode(ListNode* phead){ListNode* slow,*fast;slowfastphead;while(fastfast-next){slowslow-next;fastfast-next-next;}return slow;}//反转链表ListNode* reverseList(ListNode* phead){ListNode* n1,*n2,*n3;n1NULL;n2phead;n3n2-next;while(n2){n2-nextn1;n1n2;n2n3;if(n3)n3n3-next;}return n1;}bool chkPalindrome(ListNode* A) {//1.找中间结点ListNode* midfindMidNode(A);//2.反转链表ListNode* rightreverseList(mid);//3.遍历比较ListNode* leftA;while(right){if(left-val!right-val)return false;leftleft-next;rightright-next;}return true;} }; 7、 相交链表 思路1判断两个链表是否相等 2返回两个单链表相交的起始结点 /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/typedef struct ListNode ListNode; struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {ListNode* l1headA;ListNode* l2headB;int countA0;int countB0;//求两个链表的长度while(l1){countA;l1l1-next;}while(l2){l2l2-next;countB;}//求链表长度差值的绝对值int gapabs(countA-countB);//判断哪个是长短链表ListNode* longListheadA;ListNode* shortListheadB;if(countAcountB){longListheadB;shortListheadA; }//让两个链表在同一起跑线while(gap--){longListlongList-next;}//判断两个链表是否相交while(longListshortList){//相交if(longListshortList){return longList;}longListlongList-next;shortListshortList-next;}//不相交return NULL; } 8、 环形链表 思路  /*** Definition for singly-linked list.* struct ListNode {* int val;* struct ListNode *next;* };*/typedef struct ListNode ListNode; bool hasCycle(struct ListNode *head) {ListNode* slowhead;ListNode* fasthead;while(fastfast-next){slowslow-next;fastfast-next-next;if(slowfast){return true;}}return false; } 【思考】 头好痒感觉要长脑子了 完——  Relaxing Time ! —————————————— DEAD POOL —————————————— https://t3.kugou.com/song.html?idc35Fp66CPV2https://t3.kugou.com/song.html?idc35Fp66CPV2 能力越大越没责任  Bye ~~~
http://www.eeditor.cn/news/126494/

相关文章:

  • 网站做充值和提现毕业设计查资料的网站
  • 秦皇岛建设路小学网站开发公司工程部主管岗位职责及工作内容
  • 苏州网络推广公司网站建设分销怎么做网站开发分销
  • 如何制作网站专题公司网站要什么做
  • 企业网站名是什么意思展馆设计图
  • 怎么做卡盟网站深圳网页设计培训班价格
  • 做网站网站彩票算犯法吗济南住房和城乡建设厅网站
  • 上海专业网站建设 公司wordpress 首页修改
  • 网站的登录注册页面怎么做点击图片是网站怎么做
  • 我公司网站开发技术优势企业小型网站要多少钱
  • 济宁城乡住房建设网站久久建筑网资料全吗
  • 山西做网站推广wordpress菜单栏添加
  • 做万词霸屏后网站关键词没有排名自己可以建设网站吗
  • 手机可以搭建网站么网站备案有什么作用
  • 如何做电影网站不违法免费个人域名邮箱
  • 建设网站哪里便宜网站后缀
  • 网站开发入什么费用海口柏特网络科技有限公司
  • 卡片式设计 网站wordpress医院模板下载
  • 装饰网站建设方案怎么做乞讨网站
  • 网站怎么做导航简洁又有高级感的ppt
  • 做网站 营业执照怎么利用互联网平台赚钱
  • 重庆网站建设公司下载网站建设公司岗位
  • 辽宁省网站制作公司排名中国艺术设计联盟
  • 建设厅网站查询有没有做网站
  • 手机网站发布页电脑版简介网络营销的概念
  • 网站建设报价表格式重庆市建设工程信息网、
  • 河北住建城乡建设网站十大免费行情软件在线观看
  • 网站大图分辨率做多大电商代运营公司
  • 设计通网站建设广东微信网站制作哪家好
  • 搬家公司网站建设价格画册设计公司收费