随笔分类 -  LeetCode

上一页 1 ··· 7 8 9 10 11 12 13 下一页
摘要:"题目" c++ DFS ,代码写的又臭又长,Faster than 85.33% class Solution { public: set a[10][10]; set e; int b[10][10]; int c[10][10]; int judge(int i,int j,int x) { 阅读全文
posted @ 2019-08-03 11:56 Shendu.CC 阅读(123) 评论(1) 推荐(0)
摘要:"题目" class Solution { public: int tag[10]; bool isValidSudoku(vector & board) { for(int i=0;i 阅读全文
posted @ 2019-07-25 11:41 Shendu.CC 阅读(77) 评论(0) 推荐(0)
摘要:"题目" 二分练习 class Solution { public: vector searchRange(vector& nums, int target) { vector ans; if(nums.size()==0) { ans.push_back( 1); ans.push_back( 1 阅读全文
posted @ 2019-07-25 11:12 Shendu.CC 阅读(91) 评论(0) 推荐(0)
摘要:"题目" 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 阅读全文
posted @ 2019-07-22 20:05 Shendu.CC 阅读(107) 评论(0) 推荐(0)
摘要:"题目" c++ 解题思路,先用栈,模拟一下括号匹配,然后维护一个数字,能够进行括号匹配的都标上1 最后计算一下最长连续的1的区间长度就可以了。 class Solution { public: int a[100005]; char stack[100005]; int stack2[100005 阅读全文
posted @ 2019-07-22 14:06 Shendu.CC 阅读(84) 评论(0) 推荐(0)
摘要:"题目" 食之无味的题目 class Solution { public: map m; map m2; map m3; int b[100005]; int c[100005]; vector findSubstring(string s, vector& words) { vector ans; 阅读全文
posted @ 2019-07-16 19:14 Shendu.CC 阅读(90) 评论(0) 推荐(0)
摘要:"题目" 使用位运算模拟除法。 思路很简单。首先可以想到拿被除数减去除数,直到不能减为止。 但是这是很low的,我们可以用倍增的思想,任何数字都可以由2^x+2^y+2^z......组成的。 所以我们用被除数减去 除数 2^x ,那么商就+= 2^x ,然后减去得到差,继续再减 除数的2^x cl 阅读全文
posted @ 2019-07-15 20:48 Shendu.CC 阅读(95) 评论(0) 推荐(0)
摘要:"题目" 实现一个字符串 indexOf()的功能。class Solution { public: int next[100005]; int strStr(string haystack, string needle) { if(needle=="") return 0; return KMP( 阅读全文
posted @ 2019-07-13 09:54 Shendu.CC 阅读(86) 评论(0) 推荐(0)
摘要:"题目" c++ class Solution { public: int removeElement(vector& nums, int val) { int ans = nums.size(); int i=0; while(i 阅读全文
posted @ 2019-07-12 10:05 Shendu.CC 阅读(81) 评论(0) 推荐(0)
摘要:"题目" class Solution { public: int removeDuplicates(vector& nums) { int ans=nums.size(); int i=1; while(i 阅读全文
posted @ 2019-07-11 18:10 Shendu.CC 阅读(109) 评论(0) 推荐(0)
摘要:"题目" 阅读全文
posted @ 2019-07-09 19:19 Shendu.CC 阅读(116) 评论(0) 推荐(0)
摘要:"题目" 阅读全文
posted @ 2019-07-04 14:26 Shendu.CC 阅读(89) 评论(0) 推荐(0)
摘要:"题目" 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 阅读全文
posted @ 2019-07-03 10:05 Shendu.CC 阅读(79) 评论(0) 推荐(0)
摘要:"题目" 阅读全文
posted @ 2019-07-02 17:11 Shendu.CC 阅读(78) 评论(0) 推荐(0)
摘要:"题目" class Solution { public: char a[10005]; int pos=0;; bool isValid(string s) { if(s.length()==0) return true; for(int i=0;i 阅读全文
posted @ 2019-07-02 17:10 Shendu.CC 阅读(104) 评论(0) 推荐(0)
摘要:"题目" c++ 阅读全文
posted @ 2019-06-30 11:09 Shendu.CC 阅读(181) 评论(0) 推荐(0)
摘要:"题目" class Solution { public: char a[10][5]={{'\0'},{'\0'},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t 阅读全文
posted @ 2019-06-28 08:58 Shendu.CC 阅读(89) 评论(0) 推荐(0)
摘要:"题目" 和之前的一样的思路 O(N^(k 1)) class Solution { public: vector fourSum(vector& nums, int target) { sort(nums.begin(),nums.end()); int length = nums.size(); 阅读全文
posted @ 2019-06-28 08:40 Shendu.CC 阅读(91) 评论(0) 推荐(0)
摘要:"题目" 和上一题一样的思路 阅读全文
posted @ 2019-06-25 19:05 Shendu.CC 阅读(90) 评论(0) 推荐(0)
摘要:"题目" 这道题目其实和上一题有点相似。 N的三次方是肯定过不了的,N的2次方是解决方案。 可以用HashTable,Dictionary,Map等等, 但是最优的思路是,将数组排序,从两头开始计算两个数的和,最终效率为N的3次方 class Solution { public: map,int m 阅读全文
posted @ 2019-06-25 14:33 Shendu.CC 阅读(114) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 下一页