码迷,mamicode.com
首页 >  
搜索关键字:linq sum    ( 28189个结果
c#简单概念(面向对象,类)
好好学习c#代码,学了怎么调用类using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace robot{ class Program { static...
分类:其他好文   时间:2014-05-15 10:45:07    阅读次数:263
归并排序算法学习
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace MegreSort{ class Program { static void Main(s...
分类:其他好文   时间:2014-05-15 09:21:59    阅读次数:171
[LeetCode] K sum(2Sum、3Sum、4Sum)
2Sum & 3Sum & 4Sum & KSum...
分类:其他好文   时间:2014-05-15 05:33:56    阅读次数:270
LeetCode-001 Two Sum
LeetCode-001 Two Sum 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 numbers such that they add up to the target, where index1 must be less than index2...
分类:其他好文   时间:2014-05-15 04:34:50    阅读次数:293
UVALive 6609(Minimal Subarray Length)维护递增序列|RMQ
题意:给一个整数序列(可能有负数),求最短的连续序列使得序列之和大于等于整数x; 解法:第一种是On的复杂度:                   我们要的是sum[j]-sum[i]>=x,如果有两个决策j = sum[j'],那么j就是没用的。即维护一个sum[j]递增序列。然后每次可以二分查找,但是这里有个特点就是要得到最近的,可以同时维护一个left指针,left指针用于跟进更...
分类:其他好文   时间:2014-05-15 03:20:26    阅读次数:303
leetcode第一刷_3Sum
估计大家都会做twoSum,一头一尾两个指针,跟据和的大小移动就行了。 3sum能不能用相同的方法呢,我尝试用暴力做,居然过了。思路是先把数组排个序,让相同数字的都靠在一起,然后固定一个数,其他两个数就按照twosum的那一套来,只不过计算sum的时候多算了一个数而已。需要注意一个问题,靠在一起一样的数,只能在第一次遇到它的时候用,更准确一点说,每个相同的数,只有一次作为i或j或k的机会,而且不...
分类:其他好文   时间:2014-05-15 01:29:41    阅读次数:248
Leetcode 线性表 Two Sum
题意:给定一组数和另一个数,在这组数中找两个数,使它们的和等于给定的数 思路1: --> 错,因为题目要求返回下标。 1.排序 2.两个下标,一个指向头,一个指向尾 3.如果下标指向的两个元素相加大于给定的数,尾下标减一 如果小于,头下标加一 思路2: hash 1.用hash存储每个数的下标 2.数组,看hash[target-num[i]]是否存在 复杂度:时间O(n), 空间O(n)...
分类:其他好文   时间:2014-05-15 01:28:13    阅读次数:297
【LeetCode】- Two Sum(两数相加)
[ 问题: ] 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 numbers such that they add up to the ta...
分类:其他好文   时间:2014-05-15 00:04:39    阅读次数:377
鸽巢原理-poj3370
#include int main(int argc, char *argv[]){ int c = -1, n = -1; while (true) { scanf("%d%d",&c,&n); int arr[n],sum[n],b[n]; if (c + n == 0) { ...
分类:其他好文   时间:2014-05-14 23:11:50    阅读次数:391
hdu 3473 Minimum Sum(划分树-sum操作)
划分树。只是考虑求当前区间大于第k值的值得和,和小于第k值的和。显然可以在查询的时候直接搞出来。sum[d][i]表示第d层子区间l,r种l-i的和。写错了一个下标,检查了半辈子。。。 #include #include #include #include #include #include #include #include #include #include #define MP make_...
分类:其他好文   时间:2014-05-14 19:31:39    阅读次数:311
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!