会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
阿牧遥
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
10
···
43
下一页
2015年1月23日
[topcoder]TheGridDivTwo
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13628&rd=16278标程是BFS,我用DFS,都可解。这里复杂的把pair写了hash函数,其实直接用个矩阵来存bool就可以了。#include #include #incl...
阅读全文
posted @ 2015-01-23 23:14 阿牧遥
阅读(383)
评论(0)
推荐(0)
2015年1月22日
[topcoder]TheConsecutiveIntegersDivOne
摘要: http://community.topcoder.com/stat?c=problem_statement&pm=13625&rd=16278首先,如果记得曼哈顿距离最小值那个问题,会想起一维的情况可证,点出现在中位数那里是最小的。这里也可证明,四个点,出现在中位数位置是最小的。题解里的做法是,试...
阅读全文
posted @ 2015-01-22 23:24 阿牧遥
阅读(306)
评论(0)
推荐(0)
2014年12月31日
[leetcode]Maximum Product Subarray
摘要: DP.类似最大和。就是要记录正的和负的两种情况。class Solution {public: int maxProduct(int A[], int n) { vector positive(n); vector minus(n); int resu...
阅读全文
posted @ 2014-12-31 23:15 阿牧遥
阅读(189)
评论(0)
推荐(0)
[leetcode]Find Minimum in Rotated Sorted Array
摘要: 二分class Solution {public: /* test: [1] test: [2, 1] test: [3, 1, 2] test: [2, 3, 1] test: [3, 4, 1, 2] test: [3, 4, 5, 1, 2] *...
阅读全文
posted @ 2014-12-31 23:13 阿牧遥
阅读(141)
评论(0)
推荐(0)
[leetcode]Find Minimum in Rotated Sorted Array II
摘要: 二分,各种情况。class Solution {public: int findMin(vector &num) { int size = num.size(); int minVal = num[size-1]; findMinRe(num, 0, ...
阅读全文
posted @ 2014-12-31 23:12 阿牧遥
阅读(149)
评论(0)
推荐(0)
[leetcode]Min Stack
摘要: 老题目。两个栈。class MinStack { stack stk; stack minstk;public: void push(int x) { stk.push(x); if (minstk.empty() || minstk.top() >= ...
阅读全文
posted @ 2014-12-31 23:11 阿牧遥
阅读(159)
评论(0)
推荐(0)
[leetcode]Intersection of Two Linked Lists
摘要: 老题了。class Solution {public: ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { ListNode *tailA = headA; ListNode *tail...
阅读全文
posted @ 2014-12-31 23:10 阿牧遥
阅读(138)
评论(0)
推荐(0)
[leetcode]Find Peak Element
摘要: 类似二分。class Solution {public: int findPeakElement(const vector &num) { int size = num.size(); int left = 0; int right = size - ...
阅读全文
posted @ 2014-12-31 23:09 阿牧遥
阅读(122)
评论(0)
推荐(0)
[leetcode]Maximum Gap
摘要: 用分桶的做法,思路参考自网友,很精妙。class Solution {public: int maximumGap(vector &num) { int size = num.size(); if (size minBucket(bucketSize, INT_M...
阅读全文
posted @ 2014-12-31 23:08 阿牧遥
阅读(167)
评论(0)
推荐(0)
[leetcode]Compare Version Numbers
摘要: 本人的做法是转化成vector再处理,各种情况就比较简单了。class Solution {public: int compareVersion(string version1, string version2) { vector v1 = convert(version1); ...
阅读全文
posted @ 2014-12-31 23:07 阿牧遥
阅读(172)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
10
···
43
下一页
公告