小堃哥的专栏

写博客:网址链接+名称:oj名+所用算法名称+该题注意事项和心得

HDOJ+DFS使用了stack+貌似题目设计不合理,那个方向数组+DFS的标记和stack模板

点击打开链接///确定最大递归深度,确定递归终止条件,确定每层递归做什么 #include #include #include #include #include #include #include #include #include #define INF 0x3f3f3f3f using na...

2016-02-24 17:15:57

阅读数 353

评论数 0

leetcode1004+Dp 注意剪枝

https://leetcode.com/problems/max-consecutive-ones-iii/ //cnt_0[i]来表示数组A中前i个数中有多少个0 //若cnt_0[i] - cnt_0[j] > K,那么更小的j值肯定也不满足条件,所以在遍历的时候, //只...

2019-05-27 12:59:49

阅读数 0

评论数 0

leetcode973+距离最近原点的K个点,sort

https://leetcode.com/problems/k-closest-points-to-origin/ class Solution { public: static bool cmp(pair<int, int>a, pair<i...

2019-05-26 19:26:35

阅读数 3

评论数 0

leetcode946+栈模拟

https://leetcode.com/problems/validate-stack-sequences/ class Solution { public: bool validateStackSequences(vector<int>&...

2019-04-28 00:39:40

阅读数 22

评论数 0

leetcode945+ 排序之后贪心

https://leetcode.com/problems/minimum-increment-to-make-array-unique/ class Solution { public: int minIncrementForUnique(vector<int&...

2019-04-27 21:15:17

阅读数 11

评论数 0

leetcode939+最小矩形面积,hash的set来判断另外两个点存在不存在

https://leetcode.com/problems/minimum-area-rectangle/ class Solution { public: int minAreaRect(vector<vector<int>>&...

2019-04-27 13:15:39

阅读数 9

评论数 0

leetcode931,求第一层到最后一层,最小的路径和,Dp

https://leetcode.com/problems/minimum-falling-path-sum/ class Solution { public: int minFallingPathSum(vector<vector<int>&...

2019-04-27 00:21:13

阅读数 6

评论数 0

leetcode926+ 翻转01使得0都在1前面,Dp

https://leetcode.com/problems/flip-string-to-monotone-increasing/ //dp[i][0] str[0:i-1] 最后字符为 0 时,最少 换字符数。 //dp[i][1] str[0:i-1] 最后字符为 1 时,最少 换字符数。...

2019-04-25 23:07:46

阅读数 6

评论数 0

leetcode921+最少括号匹配,stack+贪心

https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/ class Solution { public: int minAddToMakeValid(string S) { stack&a...

2019-04-21 19:14:27

阅读数 5

评论数 0

leetcode852+单峰找到山顶,暴力

https://leetcode.com/problems/peak-index-in-a-mountain-array/ class Solution { public: int peakIndexInMountainArray(vector<int>&a...

2019-04-18 20:35:16

阅读数 5

评论数 0

leetcode896+判断是递增还是递减,两个flage标记

https://leetcode.com/problems/monotonic-array/ class Solution { public: bool isMonotonic(vector<int>& A) { if(A.s...

2019-04-13 11:12:43

阅读数 4

评论数 0

tx+algorithm

#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> #include &l...

2019-04-11 23:37:35

阅读数 20

评论数 0

leetcode881+ 乘船问题,双指针

https://leetcode.com/problems/boats-to-save-people/ class Solution { public: int numRescueBoats(vector<int>& people, int ...

2019-04-11 23:21:56

阅读数 26

评论数 0

leetcode872+经典二叉树递归存储叶子节点

https://leetcode.com/problems/leaf-similar-trees/ struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val...

2019-04-06 22:01:48

阅读数 8

评论数 0

leetcode873+最长的fibonaci,暴力

https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/ class Solution(object): def lenLongestFibSubseq(self, A): "...

2019-04-05 17:19:12

阅读数 130

评论数 0

leetcode869+判读各位数字重新组合是否为2的幂

https://leetcode.com/problems/reordered-power-of-2/ class Solution { public: bool check(vector<int>&vis, string& ...

2019-04-05 16:16:51

阅读数 5

评论数 0

模拟除法

int main() { string s; cin >> s; //输入被除数 int result[100001]; //结果 int divisor; cin >> divisor; //输入除数...

2019-03-24 21:13:09

阅读数 16

评论数 0

leetcode861+贪心,二进制和统计

https://leetcode.com/problems/score-after-flipping-matrix/ //贪心 class Solution { public: void FlipRow(vector<vector<int>&a...

2019-03-24 19:59:43

阅读数 15

评论数 0

leetcode856+栈的使用,记得才开始要push记录最终的分数

https://leetcode.com/problems/score-of-parentheses/ class Solution { public: int scoreOfParentheses(string S) { stack<int&gt...

2019-03-23 22:34:55

阅读数 7

评论数 0

leetcode846+set的使用,和循环的表示好

https://leetcode.com/problems/hand-of-straights/ class Solution { public: bool isNStraightHand(vector<int>& hand, int W) ...

2019-03-23 17:33:57

阅读数 37

评论数 0

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