随笔分类 - LinkedList
摘要:1 [抄题]: 给定一个链表,判断它是否有环。 [思维问题]: 反而不知道没有环怎么写了:快指针fast(奇数个元素)或fast.next(偶数个元素) == null [一句话思路]: 快指针走2步,慢指针走1步。 [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不
        阅读全文
                
摘要:[抄题]: Given a linked list, remove the nth node from the end of list and return its head. Given linked list: 1->2->3->4->5, and n = 2. After removing t
        阅读全文
                
摘要:链表排序 · Sort List [抄题]: [思维问题]: [一句话思路]: [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图]: quick sort 整体-局部(先找大小值,再局部递归) 里面不稳定 最坏n2, 最好 平均 nlgn 数组
        阅读全文
                
摘要:[抄题]: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserv
        阅读全文
                
摘要:全部 [抄题]: Reverse a singly linked list. [思维问题]: 以为要用dummy node [一句话思路]: 直接全部转过来就行了,用dummy node反而多余 [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图
        阅读全文
                
摘要:不留: [抄题]: 给定一个排序链表,删除所有重复的元素只留下原链表中没有重复的元素。 [思维问题]: 给出 1->2->3->3->4->4->5->null,返回 1->2->5->null 给出 1->1->1->2->3->null,返回 2->3->null [一句话思路]: dummy 
        阅读全文
                
 
                    
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号