swap nodes in pairs
来源:互联网 发布:能够翻译文档软件 编辑:程序博客网 时间:2024/06/10 21:38
/*Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.*//** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ /* 利用双指针来修改head指针的值 */struct ListNode* swapPairs(struct ListNode* head){struct ListNode *per,*re;struct ListNode** tmp=&head;while((per=*tmp) && (re=per->next)){per->next=re->next;re->next=per;*tmp=re;tmp=&(per->next);} return head;}
阅读全文
0 0
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes In Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- 解决MySQL不允许(其它IP)从远程访问的方法
- java基础之java内存模型
- gdb使用
- 一遍记住Java常用的八种排序算法与代码实现
- 爬虫自带抓取当日A股所有股票代码,名称,最新价,涨幅,涨价,成交量,成交额,今开盘,昨开盘,最低价,最高价
- swap nodes in pairs
- js面向对象
- 技术论坛分享
- linux下 C语言perror函数的作用
- linux高效操作命令
- html 其他标签
- View的事件分发机制
- i++和++i的区别
- ENE