一:Minimum Size Subarray Sum(最小长度子数组的和O(N)) 题目: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray o ...
题目: 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 e ...
分类:
其他好文 时间:
2017-04-16 15:14:39
阅读次数:
139
1. Two Sum 一、暴力,很简单也很容易想到,竟然AC了,以为会超时。 二、映射表 要点在于,hashMap可以通过key取value,但无法根据value取key。所以要反过来加才行 167. Two Sum II - Input array is sorted 双指针问题 4.11再做 ...
分类:
其他好文 时间:
2017-04-10 15:58:55
阅读次数:
162
2017/3/15 21:47:04 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a ...
分类:
其他好文 时间:
2017-03-27 00:28:56
阅读次数:
240
2017/3/23 15:41:47 Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. N ...
分类:
其他好文 时间:
2017-03-27 00:24:53
阅读次数:
228
1 //双指针对十个数排序 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #define N 8 6 //2017.3.5 7 int main() 8 { 9 //初始化数组 赋值N个数 用指针数组指向 10 int num[N]; 11 int * ...
分类:
编程语言 时间:
2017-03-10 23:50:54
阅读次数:
391
#include #include #include using namespace std; char s[100],*dic[]={"zero","one","two","three","four","five","six","seven","eight","nine"}; int A[5],B... ...
分类:
其他好文 时间:
2017-03-07 10:43:39
阅读次数:
119
题目链接:Codeforces Round #400 C. Molly's Chemicals 题意: 给你n个数,和一个数k,现在问你有多少个区间和等于k的r次方,r从0到无穷。 题解: 由于有负数的存在,不能用双指针,我们先把前缀和sum求出来。 现在就转换为要求有多少个sum[r]-sum[l ...
分类:
其他好文 时间:
2017-02-25 14:56:31
阅读次数:
181
2.6 Alyona and Triangles 凸包,双指针,最大面积三角形 1 #include <cstdio> 2 #include <algorithm> 3 #include <cmath> 4 #include <vector> 5 using namespace std; 6 //l ...
分类:
其他好文 时间:
2017-02-11 10:58:43
阅读次数:
190
设$f[i][j][k]$表示前$i$个物品买了$j$个,消耗$k$个钻石,最少花多少钱,可以通过简单的DP求出。 枚举拥有的钻石数以及最多能购买的物品数的下界,那么钱数的下界是定值。 将$n$个箱子折半搜索,按钻石数分组并排序,枚举左半边每种方案,在右半边双指针求出总概率即可。 时间复杂度$O(n ...
分类:
其他好文 时间:
2017-02-06 22:14:10
阅读次数:
240