
高频
文章平均质量分 73
KiraYin--
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Remove N-th Node from the end of the list
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, t原创 2013-06-20 08:48:56 · 828 阅读 · 0 评论 -
[LeetCode] Unique Paths 2
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the原创 2013-06-21 02:29:08 · 1076 阅读 · 0 评论 -
[LeetCode]Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space.原创 2013-06-26 03:45:27 · 3039 阅读 · 1 评论 -
[LeetCode] Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to原创 2013-10-03 01:28:32 · 3970 阅读 · 0 评论 -
[LeetCode]Median of Two Sorted Arrays
There are two sorted arrays A and B 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)).参考:http://fisherlei.blogspot.co原创 2013-09-25 23:23:18 · 971 阅读 · 0 评论 -
[LeetCode] 2Sum, 3Sum, 4Sum, 3SUm closet
1. 2Sum: hash Table O(n*n)2. 3Sum: 2Sum + 1 : O(n*n)for loop + 左右夹逼法:O(N*N)class Solution {public: vector > threeSum(vector &num) { // Note: The Solution object is instantiated原创 2013-10-27 09:31:52 · 1892 阅读 · 0 评论