摘要:
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... 阅读全文
摘要:
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 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 阅读全文
摘要:
面试中经常会碰到单链表的排序,主要是插入排序和归并排序 插入排序: 归并排序: 阅读全文
摘要:
ListNode* reverseList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; ListNode* dummy = new ListNode(-1); dummy->next = head; ListNode* p = head->next; ... 阅读全文