题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {-1 2 1 -4}, and target = 1. The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). 题目大意:   给定一个数组S和一个目标值target,在S中寻找三个数,使它们的和最接近target。返回三个数的和。 思路:   一、暴力求解法:     大体思路是用一个变 继续阅读 >>


张根 16/04/12 19:14:02
题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav 作者:Jung_zhang 发表于 2016/04/12 19:14:02 原文链接 https://blog.csdn.net/Jung_zhang/article/details/51136075 阅读:926 继续阅读 >>


张根 16/04/12 19:14:02
题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)The solution set must not contain duplicate triplets. For example, given array S = {-1 0 1 2 -1 -4}, A solution 继续阅读 >>


张根 16/04/11 22:00:13
题目:   字典序问题,给定一个长度不超过6的小写字母升序字符串(字符串中的字符相对顺序和字母表中的顺序一致),迅速计算出在字典中的编码,字典如:     1   2   3   ...     26  27  28  ...     a   b   c   ...      z    ab  ac  ... 思路:       总体思路为先计算出给定字符串前所有的个数,然后再加一 代码&详细注释思路: #include <iostream> #include <cstdlib> //计算从i开始的长度为k的所有数的个数 //例如以a开头长度为2的所有组合个数 int CharacterCount(int i, int k) { int sum = 0; 继续阅读 >>


张根 16/04/10 23:03:53