自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Cross

一半惊喜,一半遗憾。

  • 博客(19)
  • 收藏
  • 关注

原创 stack 底层简单实现 动态数组

代码:#include #include using namespace std;template class Stack{private : T* data; /// 给指针分配一个内存空间 int sz; /// 动态数组的大小 int len; /// 栈的元素个数public : Stack(){ data=new T[1]

2016-10-31 16:56:52 667

原创 vector 简单底层实现

代码:#include #include #include using namespace std;template class Vector{private : T* data; /// 动态数组 指针指向一个内存空间 int len; /// 当前存在元素个数 int sz; /// 当前动态数组的大小public : Vector(){

2016-10-31 15:49:39 2238

原创 网易笔试题 分析

链接:戳这里题意:小易是一个数论爱好者,并且对于一个数的奇数约数十分感兴趣。一天小易遇到这样一个问题: 定义函数f(x)为x最大的奇数约数,x为正整数。 例如:f(44) = 11.现在给出一个N,需要求出 f(1) + f(2) + f(3).......f(N)例如: N = 7 f(1) + f(2) + f(3) + f(4) + f(5) + f(6) + f

2016-10-26 17:10:37 646

原创 leetcode 18. 4Sum 暴力枚举

链接:戳这里题意:给出长度为n的整数序列和目标target,定义一个四元组a[i]+a[j]+a[k]+a[l]==target 输出所有满足条件的四元组 ,两个四元组不同当且仅当至少一个元素不同思路:先升序排序,枚举当前a[i],然后再枚举a[j],接下来在区间[j+1,n-1]中找出两个a[l],a[r]使得a[i]+a[j]+a[l]+a[r]=tar因为是升

2016-10-26 14:15:09 329

原创 leetcode 15. 3Sum 暴力枚举

链接:戳这里题意:给出长度为n的整数序列,要求找出满足条件的所有不同三元组使得三个数和为0两个三元组不相同意义为:集合中至少有一个数不同思路:序列按升序排序,枚举a[k],接着在[0,k-1]选出两个数a[i],a[j] 相加使得和为-a[k],即为答案 复杂度O(n*n)由于序列是升序排序,所以a[i]+a[j]的值是会随着i,j的移动而显得有单调性当a[i]

2016-10-26 12:23:10 411

原创 leetcode 11. Container With Most Water 贪心

链接:戳这里题意:给出长度为n的正整数序列 h[i] ,表示一条竖直线段为 [i,0] [i,hi]现在从上往下浇水,问任意选两条线段使得装水的容量最大,输出装满水之后容器竖截面的面积思路:贪心思想,枚举l=0,r=n 对于当前最佳答案区间[l,r] 答案为: (r-l)*min(h[l],h[r])那么需要找出中间的区间是否存在一个更大的(r1-l1)*h[i

2016-10-25 21:39:46 378

原创 leetcode 3. Longest Substring Without Repeating Characters dp

链接:戳这里题意:给出一串字符串,输出最长的子序列长度满足(该子序列中不出现重复的元素)思路:dp[i] 表示在当前位置i的值为x,存在上一个x出现的位置为dp[i]那么维护一个左边界L,L每次更新是因为出现了x......x类似这样的情况,更新为L=max(L,第一个x出现的位置)因为你不管怎么取都不能在往第一个出现x的位置左边走了对于 x..x..y..y.

2016-10-24 21:32:05 238

原创 leetcode 2. Add Two Numbers 指针链表

题目链接:戳这里代码:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {publi

2016-10-24 17:51:23 203

原创 Codeforces Round #376 (Div. 2) C 并查集

链接:戳这里C. Sockstime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputArseniy is already grown-up and in

2016-10-17 20:24:05 644

原创 2016-2017 CT S03E05: Codeforces Trainings Season 3 Episode 5 J

链接:戳这里题意:二维平面上给出n(奇数)个点,要求找出能包围n/2+1个点的面积最小的矩形,该矩形平行于坐标轴思路:枚举矩形的width的边界,然后把框起来的点按y排序,枚举当前y,然后找到Y[I+m-1]的位置,统计最小面积代码:#include #include #include #include using namespace std

2016-10-16 13:18:00 797

原创 hdu 5928 极角排序+dp

链接:戳这里Birthday GiftTime Limit: 9000/4500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionBoth Mr. Frog and Wallice love running. Wallice missed

2016-10-15 14:57:55 848

原创 hdu 5091 线段树+扫描线思想

链接:戳这里Beam CannonTime Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionRecently, the γ galaxies broke out Star Wars. Each planet i

2016-10-13 19:51:22 437

原创 Intel Code Challenge Elimination Round (Div.1 + Div.2, combined) C 并查集

链接:戳这里C. Destroying Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array consisting of n non-negative in

2016-10-07 21:57:22 386

原创 hdu 5927 DFS

链接:戳这里Auxiliary SetTime Limit: 9000/4500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/OtherProblem DescriptionGiven a rooted tree with n vertices, some of the vertices are

2016-10-06 17:49:54 738 2

原创 hdu 5908 模拟

链接:戳这里Abelian PeriodTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)Problem DescriptionLet S be a number string, and occ(S,x) means the times

2016-10-05 14:29:49 445

原创 hdu 5918 KMP

链接:戳这里Sequence ITime Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionMr. Frog has two sequences a1,a2,⋯,an and b1,b2,⋯,bm and a n

2016-10-04 17:37:48 1062 2

原创 Codeforces Round #375 (Div. 2) D bfs

链接:戳这里D. Lakes in Berlandtime limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard outputThe map of Berland

2016-10-04 16:58:29 271

原创 Codeforces Round #374 (Div. 2) D 贪心+优先队列

链接:戳这里D. Maxim and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Maxim has found an array of n integers, neede

2016-10-01 16:11:38 542

原创 Codeforces Round #374 (Div. 2) C bfs+dp

链接:戳这里C. Journeytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Irina arrived to one of the most famous cities of Ber

2016-10-01 15:19:20 432

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除