Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or...
分类:
其他好文 时间:
2014-10-19 06:53:24
阅读次数:
142
Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the". 1 cl...
分类:
其他好文 时间:
2014-10-19 02:41:38
阅读次数:
197
测试#include #include #include using namespacestd;class Test{public: Test() { cout ptr(new Test); return 0;}
分类:
系统相关 时间:
2014-10-19 02:38:30
阅读次数:
230
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
其他好文 时间:
2014-10-19 01:21:45
阅读次数:
204
1、用双重循环逐个遍历(超时)2、用list B的append和remove函数(超时)3、用dict B(AC) 1 class Solution: 2 # @param A, a list of integer 3 # @return an integer 4 def s...
分类:
编程语言 时间:
2014-10-19 01:18:21
阅读次数:
246
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="...
分类:
其他好文 时间:
2014-10-19 01:17:06
阅读次数:
314
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n...
分类:
其他好文 时间:
2014-10-19 01:13:19
阅读次数:
210
Problem:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. ...
分类:
其他好文 时间:
2014-10-19 01:12:55
阅读次数:
190
知道是求连续最大子数组后就简单了。但是注意边界条件,如果最大子数组之和<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
明白了上一题是求最大的连续子数组之和后,这题就更加简单了,遇到小于0的就不要加。
public class Solution {
public int maxProfit(int[] prices) {
if(prices.length < 2)
return 0;
int n = prices.length;
...
分类:
其他好文 时间:
2014-10-19 00:05:52
阅读次数:
194