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