码迷,mamicode.com
首页 >  
搜索关键字:two sum    ( 31846个结果
wikioi 1282 约瑟夫问题 线段树
和上一题一样,寻找第K个位置,只不过需要处理一下下一个位置在哪,画图看看就知道了。 #include #include #include using namespace std; #define lson l , m , rt << 1 #define rson m + 1 , r , rt << 1 | 1 const int maxn = 30000+5; int sum[maxn<<...
分类:其他好文   时间:2014-05-15 20:07:28    阅读次数:262
[LeetCode] [Add Binary 2012-04-02 ]
Given two binary strings, return their sum (also a binary string).For example, a = "11" b = "1" Return "100".string 的操作,短string补位。两个“0”会输出一个“00”,要特殊处理...
分类:其他好文   时间:2014-05-15 17:47:57    阅读次数:283
外星人的供给站(贪心)
为了照到点Point(x0,y0),圆心可以在一个范围内移动,我们设该范围为(x,y)(Vec[i].x,Vec[i].y)表示第如果圆心在这个范围内,则第i个点就一定能照到,sum表示为了能照到前i个点,最靠近右边的圆的边界坐标。#define LOCAL#include#include#incl...
分类:其他好文   时间:2014-05-15 14:31:11    阅读次数:237
Leetcode 线性表 数 Add Two Numbers
题意:给定两个代表数字的链表,每个节点里存放一个digit,数字是逆方向的,将这两个链表相加起来 思路: 1.i, j遍历l1,l2至最长,短的补零 2..设置一个进位变量c, 第i次遍历 l1,l2,c的和除以10进位,mod10留在这一位 3.出循环后还要检查是不是还有进位 复杂度:O(m+n), 空间O(m+n)...
分类:其他好文   时间:2014-05-15 13:38:03    阅读次数:258
Segment Tree - Sum of given range
简单点说其实Segment Tree就是二分法的灵活运用。 需要的基础知识: 1 二分法 2 二叉树 3 最好熟悉堆排序 操作就是二分法和堆排序巧妙地合并起来。 有了这些基础知识Segment Tree就没有任何难度了。 参考原文: http://www.geeksforgeeks.org/segment-tree-set-1-sum-of-given-range/ ...
分类:其他好文   时间:2014-05-15 13:33:33    阅读次数:250
leetcode第一刷_Median of Two Sorted Arrays
这道题是我最初刷的那20多道之一,但一直没有过,被各种各样的情况折磨死了,直到把所有其他的题都写完,回来看大神对这道题是怎么处理的时候,才惊叹算法的奇妙。再次验证了我的想法,如果要处理各种各样的特殊情况,一定是算法本身有问题。 之前看过很多有关在两个排序数组中找中位数的解法,大多根据两个数组长度不同分了很多种情况,各种讨论。下面要介绍的方法并没有直接求中位数,而是把求中位数转换成了求两个数组合并...
分类:其他好文   时间:2014-05-15 12:21:05    阅读次数:273
【LeetCode】Two Sum
Two SumGiven 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...
分类:其他好文   时间:2014-05-15 10:48:59    阅读次数:322
Memocache 详细的工作机制
memcached集群2013-04-26 13:56:37|分类:memcached|标签:集群memcached|举报|字号订阅集群架构方面的问题 memcached是怎么工作的? Memcached的神奇来自两阶段哈希(two-stage hash)。Memcached就像一个巨大的、存储.....
分类:其他好文   时间:2014-05-15 10:04:33    阅读次数:490
Perforce 使用笔记
Perforce requires at least two executables: the server (p4d), and at least one Perforce client program (such as p4 on UNIX, or p4.exe on Windows).If y...
分类:其他好文   时间:2014-05-15 07:51:28    阅读次数:276
【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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!