07 2019 档案
摘要:"题目"
阅读全文
摘要:"题目" class Solution { public: int tag[10]; bool isValidSudoku(vector & board) { for(int i=0;i
阅读全文
摘要:"题目" 二分练习 class Solution { public: vector searchRange(vector& nums, int target) { vector ans; if(nums.size()==0) { ans.push_back( 1); ans.push_back( 1
阅读全文
摘要:"题目" c++ 二分 class Solution { public: int search(vector& nums, int target) { if(nums.size()==0) return 1; int start=0; int end = nums.size() 1; int ans
阅读全文
摘要:"题目" c++ 解题思路,先用栈,模拟一下括号匹配,然后维护一个数字,能够进行括号匹配的都标上1 最后计算一下最长连续的1的区间长度就可以了。 class Solution { public: int a[100005]; char stack[100005]; int stack2[100005
阅读全文
摘要:"题目" c++
阅读全文
摘要:"题目" 食之无味的题目 class Solution { public: map m; map m2; map m3; int b[100005]; int c[100005]; vector findSubstring(string s, vector& words) { vector ans;
阅读全文
摘要:"题目" 使用位运算模拟除法。 思路很简单。首先可以想到拿被除数减去除数,直到不能减为止。 但是这是很low的,我们可以用倍增的思想,任何数字都可以由2^x+2^y+2^z......组成的。 所以我们用被除数减去 除数 2^x ,那么商就+= 2^x ,然后减去得到差,继续再减 除数的2^x cl
阅读全文
摘要:"题目" 实现一个字符串 indexOf()的功能。class Solution { public: int next[100005]; int strStr(string haystack, string needle) { if(needle=="") return 0; return KMP(
阅读全文
摘要:"题目" c++ class Solution { public: int removeElement(vector& nums, int val) { int ans = nums.size(); int i=0; while(i
阅读全文
摘要:"题目" class Solution { public: int removeDuplicates(vector& nums) { int ans=nums.size(); int i=1; while(i
阅读全文
摘要:"题目" include include using namespace std; int dfs(int a,int b,int ans) { if(a%b==0) { return ans; } else if(a b&&a
阅读全文
摘要:"题目"
阅读全文
摘要:"题目"
阅读全文
摘要:"题目" 思路,维护一个最小堆。 一开始把二维数组里的每一维的第一个元素都放到堆里。也就是第一列的元素都放到堆里。 此后,出堆。再进堆,没次出堆,都把 出堆的元素 在数组里的下一个元素 入堆。循环这种操作。 每次出堆的元素都是最小的。 这样的效率就是O(n log(n)) one pass && f
阅读全文
摘要:"题目" class Solution { public: int s[10005]; vector res; vector generateParenthesis(int n) { if(n==0) return res; fun("",0,0,0,0,n); return res; } void
阅读全文
摘要:"题目"
阅读全文
摘要:"题目" class Solution { public: char a[10005]; int pos=0;; bool isValid(string s) { if(s.length()==0) return true; for(int i=0;i
阅读全文