码迷,mamicode.com
首页 >  
搜索关键字:two sum    ( 31846个结果
递归实现数组求和
#includeint sum(int* a, int n){ return (0 == n)?0:(sum(a,n-1) + a[n-1]);}void sum1(int* a, int n,int& s){ if(0 == n) return; else {...
分类:其他好文   时间:2014-05-19 20:33:20    阅读次数:381
辽宁省赛——杨鲁斯卡尔专场-J
题意:就是一个人走到一个城市就会记录与该城市相连的城市有多少,最后判断这些城市是否全部相连;样例输入87 7 4 3 3 3 2 1105 4 3 3 2 2 2 1 1 1样例输出NOYES解题思路:其实就是判断无向连通图,sum#include#include#include #includeu...
分类:其他好文   时间:2014-05-19 10:13:47    阅读次数:306
HDU 1394 Minimum Inversion Number(逆序数)
题目链接:HDU 1394 Minimum Inversion Number【题意】给你一个1~N的数字组成的初始序列,然后每一次都将第一个数字移到最后,形成新的序列,然后求出这些序列的逆序数中的最小值。【思路】开始可以用任意一种方法(线段树 or 暴力 or 树状数组)计算出初始数列的逆序数sum...
分类:其他好文   时间:2014-05-19 09:50:31    阅读次数:282
two sum
Question 1: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...
分类:其他好文   时间:2014-05-19 09:35:41    阅读次数:321
[leetcode]_Merge Two Sorted Lists
题目:合并两个有序单链表思路:一开始想复杂了,以为必须在原链表上修改(绕来绕去还AC了,但是思路相当绕),其实没有,按照正常地合并两个数组同样的方法也对。代码:public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if(l1 ...
分类:其他好文   时间:2014-05-19 07:48:32    阅读次数:314
CareerCup之1.8 字符串移位包含问题
【题目】 原文: 1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one...
分类:其他好文   时间:2014-05-16 01:50:08    阅读次数:311
[LeetCode]3Sum
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....
分类:其他好文   时间:2014-05-16 01:34:36    阅读次数:293
LeetCode 011 Container With Most Water
【题目】 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a contain...
分类:其他好文   时间:2014-05-16 01:32:47    阅读次数:406
ZOJ 3635 线段树
线段树维护的是区间有多少个空位置,每次查询第X个空位置在哪,sum[rt]>=X就向左区间找,sum[rt] #include #include #include using namespace std; #define lson l , m , rt << 1 #define rson m + 1 , r , rt << 1 | 1 const int maxn = 55555; int...
分类:其他好文   时间:2014-05-15 20:19:48    阅读次数:256
2003-view-Animation-push
介绍ViewFlipper ViewFlipper Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip betwee...
分类:其他好文   时间:2014-05-15 18:37:44    阅读次数:356
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!