There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-07-27 09:53:12
阅读次数:
350
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-07-27 09:49:52
阅读次数:
237
用STL中的list写的,TLE
#include
#include
#include
#include
#include
using namespace std;
list l;
list::iterator it1,it2,it3,it4,it5,it;
void work(int a,int a1=1,int a2=1)
{
it1=find(l.begin(),l.end(...
分类:
其他好文 时间:
2014-07-26 17:23:02
阅读次数:
815
Problem Description:
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers
sums to T.
Each number in C may only b...
分类:
其他好文 时间:
2014-07-26 15:24:02
阅读次数:
252
给定整数m,n和数组x[n],找出某个I,使得x[i]+x[i+1]+x[i+2]+x[i+3]+x[i+4]…x[i+m]最接近于零。
(0
一.暴力解法
遍历各个i值,计算子序列的和,然后求出最接近0的
int find(int a[],int n,int m) //寻找m+1个数字,使得他们的和最小
{
int i=0;
int thissum=0;
int j...
分类:
其他好文 时间:
2014-07-26 15:06:30
阅读次数:
233
Problem Description
A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. You are to find all the hat’s words in a dictionary.
Input
...
分类:
其他好文 时间:
2014-07-26 15:02:10
阅读次数:
220
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA...
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The lon....
分类:
编程语言 时间:
2014-07-26 14:50:11
阅读次数:
226
模式匹配函数在string库中功能最强大的函数是:string.find(字符串查找)string.gsub(全局字符串替换)string.gfind(全局字符串查找)string.gmatch(返回查找到字符串的迭代器)这些函数都是基于模式匹配的。与其他脚本语言不同的是,Lua并不使用POSIX规...
分类:
其他好文 时间:
2014-07-26 14:27:12
阅读次数:
352
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="...
分类:
其他好文 时间:
2014-07-26 14:24:50
阅读次数:
251