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

可以用wpf做网站吗网页设计需要什么书

可以用wpf做网站吗,网页设计需要什么书,黄骅住房和城乡建设局网站,大良建设网站hi,bro—— 目录 5、 链表分割 6、 链表的回文结构 7、 相交链表 8、 环形链表 【思考】 —————————————— DEAD POOL —————————————— 5、 链表分割 /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), …

hi,bro——

目录

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;lessHead=lessTail=(ListNode*)malloc(sizeof(ListNode));ListNode* greaterHead,*greaterTail;greaterHead=greaterTail=(ListNode*)malloc(sizeof(ListNode));//创建新的头结点遍历数组ListNode* pcur=pHead;while(pcur){if(pcur->val<x){//尾插到小链表lessTail->next=pcur;lessTail=lessTail->next;}else{//尾插到大链表greaterTail->next=pcur;greaterTail=greaterTail->next;}pcur=pcur->next;}//大小链表首尾相连lessTail->next=greaterHead->next;greaterTail->next=NULL;ListNode* ret=lessHead->next;free(lessHead);free(greaterHead);lessHead=NULL;greaterHead=NULL;return ret;}
};

6、 链表的回文结构

在链表中不可回找,但是数组可以回找,所以我们可以把链表中的数据放到数组中。

思路1:创建新数组,遍历原链表,将链表中的值放到数组中,然后在数组中判断是否为回文结构。

因为题目中提前对链表的长度进行了限制,若不限制,空间复杂度为O(N)就不符合题目的条件了
/*
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* pcur=A;int i=0;//将链表中的数据赋给数组while(pcur){arr[i++]=pcur->val;pcur=pcur->next;}//i为链表中结点的个数//判断数组中的值是否为回文结构int left=0;int right=i-1;while(left<right){if(arr[left]!=arr[right]){return false;}left++;right--;}return true;}
};

思路2:反转链表,这种方法的时间复杂度为O(N),空间复杂度为O(1)

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;slow=fast=phead;while(fast&&fast->next){slow=slow->next;fast=fast->next->next;}return slow;}//反转链表ListNode* reverseList(ListNode* phead){ListNode* n1,*n2,*n3;n1=NULL;n2=phead;n3=n2->next;while(n2){n2->next=n1;n1=n2;n2=n3;if(n3)n3=n3->next;}return n1;}bool chkPalindrome(ListNode* A) {//1.找中间结点ListNode* mid=findMidNode(A);//2.反转链表ListNode* right=reverseList(mid);//3.遍历比较ListNode* left=A;while(right){if(left->val!=right->val)return false;left=left->next;right=right->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* l1=headA;ListNode* l2=headB;int countA=0;int countB=0;//求两个链表的长度while(l1){countA++;l1=l1->next;}while(l2){l2=l2->next;countB++;}//求链表长度差值的绝对值int gap=abs(countA-countB);//判断哪个是长短链表ListNode* longList=headA;ListNode* shortList=headB;if(countA<countB){longList=headB;shortList=headA; }//让两个链表在同一起跑线while(gap--){longList=longList->next;}//判断两个链表是否相交while(longList&&shortList){//相交if(longList==shortList){return longList;}longList=longList->next;shortList=shortList->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* slow=head;ListNode* fast=head;while(fast&&fast->next){slow=slow->next;fast=fast->next->next;if(slow==fast){return true;}}return false;
}

【思考】

头好痒,感觉要长脑子了


完—— 

Relaxing Time !

         —————————————— DEAD POOL ——————————————

https://t3.kugou.com/song.html?id=c35Fp66CPV2icon-default.png?t=N7T8https://t3.kugou.com/song.html?id=c35Fp66CPV2

能力越大越没责任 

Bye ~~~ 

http://www.yayakq.cn/news/786571/

相关文章:

  • 自己建设个人网站要花费多少网站建设案例百度云
  • 网站响应式布局简单网页源代码
  • 网站维护推广龙岩网站设计找哪家公司
  • 免费主页空间申请网站织梦网站被做跳转
  • 南宁网站建设公司电话共享影院 wordpress
  • 学校网站建设过程广州网站建设推广专家团队
  • 做电商网站都需要学什么花西子网络营销策划方案
  • 用手机建立自己的网站wordpress怎么设计
  • 网站建设全视频教程下载网站建设在线商城
  • 公司网站开通晓风彩票门户网站建设
  • 小程序网站制作公司wordpress无法设置主页
  • 浅谈国内高校英文网站的建设现状c2c商业模式有哪些
  • wordpress 一站多主题remix做歌网站
  • php网站开发if的代码蚌埠做网站公司
  • 烟台网站排名优化报价wordpress不能发文章
  • 上海网站制作公司报价企业网站设计期末考试
  • seo网站优化外包商丘网络营销公司
  • 网站开发服务器网页价格是什么意思
  • 网站浏览记录怎么做常州网页设计制作
  • 做团购的网站有哪些wordpress调用置顶文章
  • 怎么做视频网站首页长泰县建设局网站
  • 英文网站注意事项建站模板行情
  • 淘宝网站优惠券统一修改怎么做网站开发编写籍贯代码
  • 莱芜车管所网站企业网站建设的意义
  • 站长工具之家云南住房和城乡建设局网站
  • 公司网站建设找谁湘西网站建设
  • 网站建设优化课程网站的横幅怎么做的
  • 合肥网站建设平台钓鱼网站怎么做防护教程
  • 山东省建设厅网站 - 百度网站控制面板中设置目录权限
  • 网站建设代理怎么做wordpress主题 手机版