摘要:
//t 牵引拔出元素cur.next,后面的位置,为后面连起来用// p2 牵引将要插入元素后面的位置,为后面连起来用public void reorderList(ListNode head) { if(head==null || head.next==null || head.ne... 阅读全文
摘要:
写了无数次,今天终于自己想明白了,但是好像还是记住后明白的plotting tool:http://flowchart.com/public class Solution { public ListNode detectCycle(ListNode head) { if(head... 阅读全文
摘要:
public class Solution { public boolean hasCycle(ListNode head) { if(head==null || head.next==null) return false; ListNode walk = head... 阅读全文
摘要:
public class Solution { public RandomListNode copyRandomList(RandomListNode head) { //http://www.cnblogs.com/springfor/p/3864457.html ... 阅读全文
摘要:
今天出来的新题,已经有大神出结果了,刚开始看还没看懂,就是dfs + 二维渲染 图http://www.cnblogs.com/easonliu/p/4402077.htmlpublic class Solution { public int numIslands(char[][] grid)... 阅读全文
摘要:
public class Solution { public TreeNode sortedListToBST(ListNode head) { if(head==null) return null; int len = 0; ListNode t =... 阅读全文
摘要:
public class Solution { public ListNode partition(ListNode head, int x) { if(head==null) return head; ListNode h = new ListNode(-1); ... 阅读全文
摘要:
和I 比起来其实很不一样,反而很类似于linkedlist reverse,不断的看pre.next的东西,我自己想了好久,开始用三个指针,完全糊涂,还是退回到原来的code,才明了public class Solution { public ListNode deleteDuplicates... 阅读全文
摘要:
看了别人讨论,双指针比较方便http://www.cnblogs.com/springfor/p/3862042.htmlpublic class Solution { public ListNode deleteDuplicates(ListNode head) { if(he... 阅读全文
摘要:
Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.小细节容易... 阅读全文