letCode
qq_27168139
这个作者很懒,什么都没留下…
展开
-
leetCode#134 gas station
There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel fromstation i to its nex...原创 2018-06-19 15:31:08 · 100 阅读 · 0 评论 -
letCode Sort List (#148)
Sort a linked list in O(n log n) time using constant space complexity.解题思路:用归并排序的方法,因为表为链表,用快慢指针方法找到他的一半的位置,递归操作直到链表有序。代码如下:class ListNode: def __init__(self, x): self.val = x self...原创 2018-06-19 15:33:06 · 94 阅读 · 0 评论 -
letCode Merge K Sorted Lists (#23)
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5...原创 2018-06-19 15:34:20 · 102 阅读 · 0 评论 -
letCode Median of Two Sorted Arrays (#4)
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1, 3]nums2 ...原创 2018-06-19 15:35:46 · 124 阅读 · 0 评论