摘要: 1 class Solution { 2 public: 3 ListNode *removeNthFromEnd(ListNode *head, int n) { 4 5 ListNode* fake = new ListNode(-1); 6 fake->next = head; 7 ListNode* p = fake... 阅读全文
posted @ 2017-05-19 10:51 wxquare 阅读(345) 评论(0) 推荐(0) 编辑
摘要: Given a list, rotate the list to the right by kplaces, where k is non-negative. For example:Given1->2->3->4->5->NULLand k =2,return4->5->1->2->3->NULL 阅读全文
posted @ 2017-05-19 10:47 wxquare 阅读(298) 评论(0) 推荐(0) 编辑
摘要: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 阅读全文
posted @ 2017-05-19 10:44 wxquare 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 面试中经常会碰到单链表的排序,主要是插入排序和归并排序 插入排序: 归并排序: 阅读全文
posted @ 2017-05-19 10:35 wxquare 阅读(354) 评论(0) 推荐(0) 编辑
摘要: ListNode* reverseList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; ListNode* dummy = new ListNode(-1); dummy->next = head; ListNode* p = head->next; ... 阅读全文
posted @ 2017-05-19 10:28 wxquare 阅读(246) 评论(0) 推荐(0) 编辑