LinkedList
再见小小ronnie
这个作者很懒,什么都没留下…
展开
-
Leetcode 21. Merge Two Sorted Lists
Non-recursive solution.public class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode head = new ListNode(0); ListNode last = head; w原创 2017-02-15 05:36:37 · 144 阅读 · 0 评论 -
Leetcode 92. Reverse Linked List II
public class Solution { public ListNode reverseBetween(ListNode head, int m, int n) { if (m >= n || head == null) { return head; } // create a dummy no原创 2017-02-16 03:15:33 · 159 阅读 · 0 评论 -
Leetcode 206. Reverse Linked List
Iterative approach.public class Solution { public ListNode reverseList(ListNode head) { ListNode newHead = null; while (head != null) { ListNode next = head.next;原创 2017-04-01 05:35:30 · 197 阅读 · 0 评论 -
Leetcode 160. Intersection of Two Linked Lists
Assume the length of the intersection part is x, length of list a l1, and length of list b is l2.Then l1 + l2 = l2 + l1 => l1 + l2 - x = l2 + l1 - x.If tow lists have no intersection, then two poi转载 2017-04-03 06:10:47 · 256 阅读 · 0 评论