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

新乡网站建设多少钱吉林关键词排名优化软件

新乡网站建设多少钱,吉林关键词排名优化软件,如何建设网站功能设计,网站建设好处题目链接 反转链表:206. 反转链表 - 力扣(LeetCode)K个一组翻转链表:25. K 个一组翻转链表 - 力扣(LeetCode)回文链表:234. 回文链表 - 力扣(LeetCode) 实现思路 代码实…

题目链接

  • 反转链表:206. 反转链表 - 力扣(LeetCode)
  • K个一组翻转链表:25. K 个一组翻转链表 - 力扣(LeetCode)
  • 回文链表:234. 回文链表 - 力扣(LeetCode)

实现思路

代码实现

  • 反转链表:
/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {ListNode* pre = nullptr;ListNode* cur = head;while(cur) {ListNode* next = cur -> next;cur -> next = pre;pre = cur;cur = next;}return pre;}
};
  • K个一组翻转链表
/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:vector<ListNode*> reverse(ListNode* head, ListNode* next) {ListNode* pre = next;ListNode* cur = head;while (cur != next) {ListNode* nextNode = cur -> next;cur -> next = pre;pre = cur;cur = nextNode;}return {pre, head}; // pre是反转之后的头节点,head是反转之后的尾节点}ListNode* reverseKGroup(ListNode* head, int k) {int cnt = 0;ListNode* cur = head;ListNode* preHead = new ListNode(-1);preHead -> next = head;ListNode* pre = preHead;while (cur) {cnt++;if (cnt % k == 0) {cnt = 0;vector<ListNode*> res = reverse(pre->next, cur->next);pre->next = res[0];cur = res[1];pre = cur;}cur = cur -> next;}return preHead -> next;}
};
  • 回文链表
/*** Definition for singly-linked list.* struct ListNode {*     int val;*     ListNode *next;*     ListNode() : val(0), next(nullptr) {}*     ListNode(int x) : val(x), next(nullptr) {}*     ListNode(int x, ListNode *next) : val(x), next(next) {}* };*/
class Solution {
public:ListNode* reverse(ListNode* head) {ListNode* pre = nullptr;ListNode* cur = head;while (cur) {ListNode* next = cur -> next;cur -> next = pre;pre = cur;cur = next;}return pre;}bool isPalindrome(ListNode* head) {if (head -> next == nullptr) return true;ListNode* preHead = new ListNode();preHead -> next = head;ListNode* slow = preHead;ListNode* fast = preHead;while (fast != nullptr && fast -> next != nullptr) {slow = slow -> next;fast = fast -> next -> next;}// 反转slow->next到tail的部分ListNode* head1 = slow -> next;head1 = reverse(head1);ListNode* cur = head;ListNode* cur1 = head1;while (cur1) {if (cur -> val != cur1 -> val) {return false;}cur = cur -> next;cur1 = cur1 -> next;}return true;}
};

http://www.dtcms.com/wzjs/44680.html

相关文章:

  • 深圳公司招聘推广seo是什么意思
  • 网站建设公司那家好网址查询注册信息查询
  • 东莞网站建设公司怎么做30个免费货源网站
  • 域名服务商网站东莞疫情最新消息
  • 北京市政府部门网站建设互联网公司排名100强
  • 如何评判网站建设岗位广州seo优化公司排名
  • 如何在国际上做网站深圳网站优化公司哪家好
  • 网站建设中出现的错误代码投放广告的网站
  • 网站建设及运营服务流程app营销策略都有哪些
  • 河南怎么样做网站天猫店铺申请条件及费用
  • 营销型网站有哪些平台seo优化设计
  • wordpress编辑模板seo销售好做吗
  • 快速做网站详情页合肥网络推广软件
  • wordpress+访问加速seo多久可以学会
  • 网站开发有哪些方式百度竞价防软件点击软件
  • 深圳有哪些做网站公司怎么建立网站
  • 兴隆大院网站哪个公司做的百度指数分析数据
  • 中国海员建设工会全国委员会网站web网页
  • 网站设计的价格网站搜索排名查询
  • 物业网站宣传册怎么做搜索引擎大全全搜网
  • 网站怎么做第二个页面个人网站怎么做
  • 免费建网站的服务器少女长尾关键词挖掘
  • 为什么要建设个人网站制作网站的全过程
  • 公司做网站设计要注意网站搭建需要多少钱?
  • 网站的邀请怎么做的网络宣传方式
  • 做网站要学习什么今日头条新闻消息
  • 湛江免费做网站网络营销外包网络推广
  • wordpress 文章收缩seo关键词推广方式
  • 网站建设硬件seo技术自学
  • 苏州网站建立公司宁德市