动态规划的算法:#includeint MaxSubsequenceSum(const int A[],int n){ int i,sum,MaxSum; sum=MaxSum=0; for(i=0;iMaxSum) MaxSum=sum; if...
分类:
其他好文 时间:
2014-06-18 17:56:31
阅读次数:
139
#includeint MinSubsequenceSum(const int A[],int n){ int i,sum,MinSum; sum=MinSum=0; for(i=0;i0) sum=0; } return MinSum;}void...
分类:
其他好文 时间:
2014-06-18 17:45:48
阅读次数:
173
#includeint MinSubsequenceSum(const int A[],int n){ int i,sum,MinSum; sum=MinSum=0; for(i=0;i0) sum=0; } return MinSum;}void...
分类:
其他好文 时间:
2014-06-18 17:45:03
阅读次数:
136
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-06-18 17:39:11
阅读次数:
260
1.对字符串进行hash大家可以看一下, SHA1 HashesGo by Example写道:The pattern for generating a hash is sha1.New(), sha1.Write(bytes), then sha1.Sum([]byte{}). 附上golang代...
分类:
其他好文 时间:
2014-06-18 16:07:48
阅读次数:
294
采用递归和三目表达式注意红色字体一定不能写成n-- 1 package com.hunag; 2 3 public class Sum { 4 5 static int sum; 6 public static int isum(int n) 7 { 8 ...
分类:
编程语言 时间:
2014-06-16 23:49:28
阅读次数:
456
题目
Divide two integers without using multiplication, division and mod operator.
方法
将除数倍加,直到大于被除数。
public int divide(int dividend, int divisor) {
int flag = 0;
if...
分类:
其他好文 时间:
2014-06-16 19:08:08
阅读次数:
200
Given a binary tree containing digits from
0-9 only, each root-to-leaf path
could represent a number.
An example is the root-to-leaf path
1->2->3 which represents the number 123.
F...
分类:
其他好文 时间:
2014-06-15 14:51:02
阅读次数:
167
题目
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
For example,
If n = 4 and k = 2, a solution is:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],...
分类:
其他好文 时间:
2014-06-15 14:10:54
阅读次数:
239
Problem Description
In a factory, there are N workers to finish two types of tasks (A and B). Each type has N tasks. Each task of type A needs xi time to finish, and each task of type B needs yj ti...
分类:
其他好文 时间:
2014-06-15 11:26:42
阅读次数:
195