您现在的位置是:主页 > news > 上海在建工程查询/seo按照搜索引擎的什么对网站
上海在建工程查询/seo按照搜索引擎的什么对网站
admin2025/5/26 7:51:41【news】
简介上海在建工程查询,seo按照搜索引擎的什么对网站,龙岩网站设计 都找推商吧系统,太原贴吧https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/ 思路一:正着做,假设当前节点为curcurcur,前一节点为preprepre,那么只需要把curcurcur接到preprepre前面即可,当然需要一个临时变量预先存储下一节点nxt…
上海在建工程查询,seo按照搜索引擎的什么对网站,龙岩网站设计 都找推商吧系统,太原贴吧https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/
思路一:正着做,假设当前节点为curcurcur,前一节点为preprepre,那么只需要把curcurcur接到preprepre前面即可,当然需要一个临时变量预先存储下一节点nxt…
https://leetcode-cn.com/problems/fan-zhuan-lian-biao-lcof/
思路一:正着做,假设当前节点为curcurcur,前一节点为preprepre,那么只需要把curcurcur接到preprepre前面即可,当然需要一个临时变量预先存储下一节点nxtnxtnxt。
/*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {if(!head||!head->next)return head;ListNode *pre=nullptr;ListNode *tmp;while(head){tmp=head->next;head->next=pre;pre=head;head=tmp;}return pre;}
};
思路二:递归。把后继的后继改为自己即可做到反转。
/*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/
class Solution {
public:ListNode* reverseList(ListNode* head) {if(!head||!head->next)return head;ListNode *tmp=reverseList(head->next);//返回的一直都是最后一个节点head->next->next=head; //修改下一节点的后继位自身head->next=nullptr;//其实只是为了把尾节点的后继置为空return tmp;}
};