随笔分类 -  in place--

摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 是在l1的基础上连接的, 所以要注意需要链接l1 l2.next = l1; 需要不断更新前一个节点pre = ... 阅读全文
posted @ 2017-08-07 17:15 apanda009 阅读(94) 评论(0) 推荐(0)
摘要:这道题是比较常见的链表反转操作,不过不是反转整个链表,而是从m到n的一部分。分为两个步骤,第一步是找到m结点所在位置,第二步就是进行反转直到n结点。反转的方法就是每读到一个结点,把它插入到m结点前面位置,然后m结点接到读到结点的下一个。总共只需要一次扫描,所以时间是O(n),只需要几个辅助指针,空间 阅读全文
posted @ 2017-08-07 16:15 apanda009 阅读(111) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/remove-element/#/description Given an array and a value, remove all instances of that value in place and return the new 阅读全文
posted @ 2017-07-01 19:03 apanda009 阅读(131) 评论(0) 推荐(0)