摘要: bool clash(int c1,int l1,int r1,int c2,int l2,int r2){ if(c1&c2)return false; if(l1&l2)return false; if(r1&r2)return false; return true;} int ans;void 阅读全文
posted @ 2017-07-12 12:58 朽木の半夏 阅读(128) 评论(0) 推荐(0) 编辑
摘要: int max(int a,int b){ if(a>b)return a; return b;}int maxCoins(int* nums, int numsSize) { int a[555]; int n = numsSize; int dp[555][555]; memset(dp,0,s 阅读全文
posted @ 2017-07-12 12:57 朽木の半夏 阅读(90) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r 阅读全文
posted @ 2017-07-12 12:56 朽木の半夏 阅读(107) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int fk(int l,int r,vector<int>& nums){ if(nums[l]<=nums[r])return nums[l]; int m = (l+r)/2; int k1 = fk(l,m,nums); int k2 = fk 阅读全文
posted @ 2017-07-12 12:55 朽木の半夏 阅读(70) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int fk(int l,int r,vector<int>& nums){ if(nums[l]<nums[r]||l==r)return nums[l]; int m = (l+r)/2; int k1 = fk(l,m,nums); int k2 阅读全文
posted @ 2017-07-12 12:54 朽木の半夏 阅读(86) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: struct node{ char fs[25]; int fk[25]; int len ; node(){ memset(fs,0,sizeof(fs)); memset(fk,0,sizeof(fk)); len = 0; }}; node de 阅读全文
posted @ 2017-07-12 12:52 朽木の半夏 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 给一个数组,找出其中连续的最长是: 如 -1 1 20 0 3 100 2 最长连续是 -1 0 1 2 3 返回 5 做法:用字典树标记数字是否出现过。起到hash作用。然后在遍历 拓展左右两个端点。讲道理,特地用了字典树就是在查询的时候 能顺手删除元素,防止 1 - 10000 这样 阅读全文
posted @ 2017-07-12 12:39 朽木の半夏 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after ra 阅读全文
posted @ 2017-07-12 12:25 朽木の半夏 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 题目描述:找出两个有序数组合并之后的中位数。复杂度控制在log(N) 如: nums1 = [1, 2]nums2 = [3, 4]The median is (2 + 3)/2 = 2.5 思路: 先转成logN内求两个数组第K大,二分即可实现。 在求 第(N+2)/2 是多少,以及 (N+1)/ 阅读全文
posted @ 2017-07-12 12:22 朽木の半夏 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 题目描述: 找出一个字符串中,不含有相同字符的最长子串。 做法: 开一个200的bool数组标记,Ascll码 是否已经出现过了。遍历即可。 AC代码: class Solution { int a[200]; public: int lengthOfLongestSubstring(string 阅读全文
posted @ 2017-07-12 12:12 朽木の半夏 阅读(87) 评论(0) 推荐(0) 编辑