上一页 1 2 3 4 5 6 ··· 14 下一页
摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2014-10-01 12:19 小菜刷题史 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".补充说明:单词是指空格之间的字符序列。输入中可能有首部或尾部... 阅读全文
posted @ 2014-10-01 11:53 小菜刷题史 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2014-09-25 11:55 小菜刷题史 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 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 小菜刷题史 阅读(401) 评论(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 小菜刷题史 阅读(133) 评论(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 小菜刷题史 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 问题描述:给定一个迷宫和一个起点一个终点,求起点到终点的最短路径长度。Sample Input(说明:5行5列的迷宫,‘#’为墙,‘.’为路,起点为(0,3), 终点为(4,4))Sample Output11(若不可达输出-1)解答:用BFS的方法,借助一个队列实现。 1 #include 2 #... 阅读全文
posted @ 2014-06-09 19:36 小菜刷题史 阅读(475) 评论(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 小菜刷题史 阅读(224) 评论(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 小菜刷题史 阅读(333) 评论(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 小菜刷题史 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 14 下一页