摘要: 题目描述:小明每天都在开源社区上做项目,假设每天他都有很多项目可以选,其中每个项目都有一个开始时间和截止时间,假设做完每个项目后,拿到报酬都是不同的。由于小明马上就要硕士毕业了,面临着买房、买车、给女友买各种包包的鸭梨,但是他的钱包却空空如也,他需要足够的money来充实钱包。万能的网友麻烦你来帮帮小明,如何在最短时间内安排自己手中的项目才能保证赚钱最多(注意:做项目的时候,项目不能并行,即两个项目之间不能有时间重叠,但是一个项目刚结束,就可以立即做另一个项目,即项目起止时间点可以重叠)。输入:输入可能包含多个测试样例。对于每个测试案例,输入的第一行是一个整数n(1 2 #include 3. 阅读全文
posted @ 2014-04-01 22:13 Eason Liu 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 题目描述:现在有一个8*8的棋盘,上面放着64个价值不等的礼物,每个小的棋盘上面放置一个礼物(礼物的价值大于0小于1000),一个人的初始位置在棋盘的左上角,每次他只能向下或向右移动一步,并拿走对应棋盘上的礼物,结束位置在棋盘的右下角,请设计一个算法使其能够获得最大价值的礼物。输入:输入包含多个测试用例,每个测试用例共有8行8列,第i行的第j列的数字代表了该处棋盘上的礼物的价值,每两个数之间用空格隔开。输出:对于每组测试用例,请输出你能够获得最大价值的礼物。样例输入:2 8 15 1 10 5 19 193 5 6 6 2 8 2 1216 3 8 17 12 5 3 1413 3 2 17 阅读全文
posted @ 2014-04-01 21:15 Eason Liu 阅读(411) 评论(0) 推荐(0) 编辑
摘要: 题目描述:最长不重复子串就是从一个字符串中找到一个连续子串,该子串中任何两个字符都不能相同,且该子串的长度是最大的。输入:输入包含多个测试用例,每组测试用例输入一行由小写英文字符a,b,c...x,y,z组成的字符串,字符串的长度不大于10000。输出:对于每组测试用例,输出最大长度的不重复子串长度... 阅读全文
posted @ 2014-04-01 20:58 Eason Liu 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题目描述:回文串就是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。回文子串,顾名思义,即字符串中满足回文性质的子串。给出一个只由小写英文字符a,b,c...x,y,z组成的字符串,请输出其中最长的回文子串的长度。输入:输入包含多个测试用例,每组测试用例输入一行由小写英文字符a,b,c...x,y,z组成的字符串,字符串的长度不大于200000。输出:对于每组测试用例,输出一个整数,表示该组测试用例的字符串中所包含的的最长回文子串的长度。样例输入:ababbbbbabba样例输出:344腾讯面试题,max_len初始为1,设为0会出错。 1 #include . 阅读全文
posted @ 2014-04-01 20:09 Eason Liu 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 题目描述:请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。输入:每个输入文件仅包含一组测试样例。对于每组测试案例,输入一行代表要处理的字符串。输出:对应每个测试案例,出经过处理后的字符串。样例输入:We Are Happy样例输出:We%20Are%20Happy从后向前处理数组。 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 int count; 7 int size; 8 s... 阅读全文
posted @ 2014-04-01 19:55 Eason Liu 阅读(257) 评论(0) 推荐(0) 编辑
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you mu 阅读全文
posted @ 2014-04-01 18:23 Eason Liu 阅读(384) 评论(0) 推荐(0) 编辑
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index.For example:A =[2,3,1,1,4], returntrue.A =[3,2,1,0,4], returnfalse.记录 阅读全文
posted @ 2014-04-01 11:34 Eason Liu 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest valid parentheses substring is"()", which has length = 2.Another example is")()())", where the longest 阅读全文
posted @ 2014-04-01 01:06 Eason Liu 阅读(3939) 评论(1) 推荐(1) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,5,7], [4,1,8,3]]The minimum path sum from top to bottom is11(i.e.,2+3+5+1= 11).在输入的数组中直接修改,这样就不需要额外的空间了,不知道这... 阅读全文
posted @ 2014-04-01 00:04 Eason Liu 阅读(238) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set toNULL.Initially, all next pointers are set toNULL.N... 阅读全文
posted @ 2014-03-31 22:32 Eason Liu 阅读(144) 评论(0) 推荐(0) 编辑