Best Time to Buy and Sell Stock IIISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the...
分类:
其他好文 时间:
2014-10-26 22:43:56
阅读次数:
178
这道题就是一个模拟题,所以写代码时要有清晰的思路,一开始我思路很清晰,结果由于时间原因,代码敲反了.....
题目的输入是有多组的,每一组有两行,第一行是命令,第二行是一串字符串!
所以这道题有两个操作:
当输入 1 的时候表示:将第二行所输入的命令翻译为16位2进制;
当输入 0 的时候表示:将第二行所输入的16位2进制翻译为命令;
先说下怎么将命令翻译为2进制:eg:AD...
分类:
其他好文 时间:
2014-10-26 18:29:57
阅读次数:
146
题意很简单,就是给出父母的名字,然后根据父母的名字来给孩纸取名字!
可以将此题简化为:
孩纸的名字=父亲的frist name+字符串(_small_)+母亲额frist name;
然后将孩纸的名字输出即可!...
分类:
其他好文 时间:
2014-10-26 17:00:58
阅读次数:
154
Problem Description
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does no...
分类:
其他好文 时间:
2014-10-24 13:01:58
阅读次数:
279
Best Time to Buy and Sell Stock IISay you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the ...
分类:
其他好文 时间:
2014-10-23 12:23:23
阅读次数:
224
Best Time to Buy and Sell StockSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to compl...
分类:
其他好文 时间:
2014-10-22 21:54:00
阅读次数:
192
Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a...
分类:
其他好文 时间:
2014-10-19 22:35:19
阅读次数:
165
Choose the best routeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7361Accepted Submission(s): 2...
分类:
其他好文 时间:
2014-10-19 15:30:34
阅读次数:
279
知道是求连续最大子数组后就简单了。但是注意边界条件,如果最大子数组之和<0,那就不要交易了, 返回0.
public class Solution {
public int maxProfit(int[] prices) {
if(prices.length < 2)
return 0;
int n = prices....
分类:
其他好文 时间:
2014-10-19 00:06:49
阅读次数:
146