随笔分类 - LinkedList
摘要:Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significan
阅读全文
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the
阅读全文
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For
阅读全文
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 使用快慢指针, fast每次前进两
阅读全文
摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy
阅读全文
摘要:You are given two linked lists representing two non-negative numbers. The most significant digit comes first and each of their nodes contain a single
阅读全文
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2
阅读全文
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then l
阅读全文
摘要: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 a
阅读全文
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 归并排序o(nlgk); 法二 : 优先队列 维护一个长为n的队列 o(n *lgk)
阅读全文
摘要:Sort a linked list in O(n log n) time using constant space complexity. 双链表用快排 单链表用归并
阅读全文
摘要:Sort a linked list using insertion sort. 复杂度 o(n^2); 插入排序 (Insertion Sort) 设有一组关键字{K1, K2,…, Kn};排序开始就认为 K1 是一个有序序列;让 K2 插入上述表长为 1 的有序序列,使之成为一个表长为 2 的
阅读全文