十七

leetcode61. 旋转链表

分析将链表首尾相连,得到循环链表,只需要尾指针向后移动n-k%n个就能得到移动后的首节点,此时下一个节点就是头节点,并将尾节点置空。/** * Definition for singly-linked list. * struct ListNode { * int val; * Li

十七 Published on 2022-02-23

acwing826. 单链表

#include<iostream>using namespace std;const int N=1e5+10;int head,e[N],ne[N],idx;void init(){//初始化 head=-1; idx=0;}void add_to_head(int x)

十七 Published on 2022-01-06
Previous Next