方法:递归
/**
* 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:
int delN;
int curN;
bool isDelete=false;
void recurveList(ListNode* a,ListNode* b){
if(b==nullptr){
return ;
}
recurveList(b,b->next);
curN+=1;
if(curN==delN){
ListNode* c=b;
a->next=c->next;
delete b