摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?Code:class Solution {public: ListNode *detectCycle(ListNode *head) { ListNode *p=head; ListNode *cur=head; while(p){ i... 阅读全文
posted @ 2013-11-01 05:45 WinsCoder 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values inthe list, only nodesitself can bechanged.Code:class Solution {pub 阅读全文
posted @ 2013-11-01 05:35 WinsCoder 阅读(131) 评论(0) 推荐(0) 编辑