06 2014 档案

摘要:Sort a linked list using insertion sort. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *nex... 阅读全文
posted @ 2014-06-09 22:49 小菜刷题史 阅读(420) 评论(0) 推荐(0)
摘要:Sort a linked list inO(nlogn) time using constant space complexity.单向链表排序O(nlogn),Mergesort可以实现。 1 /** 2 * Definition for singly-linked list. 3 * st... 阅读全文
posted @ 2014-06-09 21:27 小菜刷题史 阅读(145) 评论(0) 推荐(0)
摘要:Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.每次固定一个点,然后遍历所有其它点,记录每种斜率出现的次数。需要考虑两种特殊情况:斜率不存在和点与固定点重... 阅读全文
posted @ 2014-06-09 20:51 小菜刷题史 阅读(170) 评论(0) 推荐(0)
摘要:问题描述:给定一个迷宫和一个起点一个终点,求起点到终点的最短路径长度。Sample Input(说明:5行5列的迷宫,‘#’为墙,‘.’为路,起点为(0,3), 终点为(4,4))Sample Output11(若不可达输出-1)解答:用BFS的方法,借助一个队列实现。 1 #include 2 #... 阅读全文
posted @ 2014-06-09 19:36 小菜刷题史 阅读(494) 评论(0) 推荐(0)
摘要:问题描述:Given a string consisting of a,b and c's, we can perform the following operation: Take any two adjacent distinct characters and replace it with t... 阅读全文
posted @ 2014-06-09 17:00 小菜刷题史 阅读(259) 评论(0) 推荐(0)
摘要:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文
posted @ 2014-06-03 20:51 小菜刷题史 阅读(342) 评论(0) 推荐(0)
摘要:Divide two integers without using multiplication, division and mod operator. 1 class Solution { 2 public: 3 int divide(int dividend, int divisor) ... 阅读全文
posted @ 2014-06-03 19:40 小菜刷题史 阅读(133) 评论(0) 推荐(0)
摘要:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文
posted @ 2014-06-03 18:26 小菜刷题史 阅读(188) 评论(0) 推荐(0)
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文
posted @ 2014-06-03 16:24 小菜刷题史 阅读(168) 评论(0) 推荐(0)