Remove Nth Node From End of List
来源:互联网 发布:图转文软件 编辑:程序博客网 时间:2024/06/08 07:30
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode* out = head; ListNode* fast = head; if(head==NULL) return NULL; for(int i=0;i<n;i++){ if(fast->next!=NULL) fast = fast->next; else return head->next; } while(fast->next!=NULL){ fast = fast->next; head = head->next; } head->next = head->next->next; return out; }};//找到倒数第k+1个数
0 0
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node from End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- Remove Nth Node From End of List
- android.os.NetworkOnMainThreadException错误解决办法
- OpenGL3.0教程 第十二课:OpenGL扩展
- 机器视觉——基于立体视觉的变形测量
- IIS设置问题
- LightOJ 1422 Halloween Costumes
- Remove Nth Node From End of List
- OpenGL3.0教程 第十三课:法线贴图
- 在C#中用MySql.Data.MySqlClient连接MySql
- OpenGL3.0教程 第十四课:渲染到纹理
- Android 静态分析smail
- OpenGL3.0教程 第十五课:光照贴图
- hibernate总结-N+1问题
- OpenACS wiki
- OpenGL3.0教程 第十六课:阴影贴图