uacs2024

导航

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

2022年10月23日 #

leetcode1002-查找共用字符

摘要: 1002. 查找共用字符 class Solution { public: vector<string> commonChars(vector<string>& words) { int size=words.size(); vector<string> res; int alp[26]={0}; 阅读全文

posted @ 2022-10-23 16:14 ᶜʸᵃⁿ 阅读(9) 评论(0) 推荐(0) 编辑

2022年10月8日 #

leetcode84-柱状图中最大的矩形

摘要: 84. 柱状图中最大的矩形 两个星期没写leetcode就连暴力解法都写不出了。 暴力解法 class Solution { public: int largestRectangleArea(vector<int>& heights) { int size=heights.size(),maxSiz 阅读全文

posted @ 2022-10-08 16:14 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0) 编辑

2022年9月29日 #

leetcode69-x的平方根

摘要: 69. x 的平方根 简单题,但是考察的内容可以有很多 首先是纯暴力法,毫无特色。速度也很慢。 class Solution { public: int mySqrt(int x) { long long i=1; while(1) { if(i*i<=x) i++; else break; } r 阅读全文

posted @ 2022-09-29 18:57 ᶜʸᵃⁿ 阅读(14) 评论(0) 推荐(0) 编辑

leetcode169-多数元素

摘要: 169. 多数元素 这道题虽然是简单题,但是有很多精妙的解法。详情看官方题解 class Solution { public: int majorityElement(vector<int>& nums) { int size=nums.size(); if(size<=2) return nums 阅读全文

posted @ 2022-09-29 14:32 ᶜʸᵃⁿ 阅读(14) 评论(0) 推荐(0) 编辑

2022年9月28日 #

leetcode977-有序数组的平方

摘要: 977. 有序数组的平方 原本直接暴力的做法没有利用到原数组是有序这个条件。这里直接把左边的绝对值大于右边的直接放到最后面,这样就减少很多不必要的操作。 class Solution { public: vector<int> sortedSquares(vector<int>& nums) { i 阅读全文

posted @ 2022-09-28 17:10 ᶜʸᵃⁿ 阅读(13) 评论(0) 推荐(0) 编辑

2022年9月26日 #

leetcode131-分割回文串 回溯与方便判断回文串的的判断表

摘要: 131. 分割回文串 这是看了卡尔的代码写出来的 class Solution { public: int size; vector<vector<string>> res; vector<string> path; bool isHuiwen(string s,int start,int end) 阅读全文

posted @ 2022-09-26 16:46 ᶜʸᵃⁿ 阅读(14) 评论(0) 推荐(0) 编辑

2022年9月24日 #

leetcode40-组合总和 II

摘要: 40. 组合总和 II 这题和 39. 组合总和 差不了多少。区别就是这一题提供的集合内有重复元素,而上一题没有重复元素。因为有重复元素,所以输出的结果里不能有重复的中间结果。 class Solution { public: int size,sum=0; vector<vector<int>> 阅读全文

posted @ 2022-09-24 19:12 ᶜʸᵃⁿ 阅读(17) 评论(0) 推荐(0) 编辑

leetcode39-组合总和

摘要: 39. 组合总和 首先是原始的错误代码 class Solution { public: int size,sum=0; vector<vector<int>> res; vector<int> path; void backTracking(vector<int>& candidates, int 阅读全文

posted @ 2022-09-24 18:13 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0) 编辑

回溯法抽象为树形结构后,其遍历过程就是:for循环横向遍历,递归纵向遍历,回溯不断调整结果集。

摘要: 回溯法抽象为树形结构后,其遍历过程就是:for循环横向遍历,递归纵向遍历,回溯不断调整结果集。 阅读全文

posted @ 2022-09-24 16:36 ᶜʸᵃⁿ 阅读(17) 评论(0) 推荐(0) 编辑

2022年9月23日 #

leetcode17-电话号码的字母组合

摘要: 17. 电话号码的字母组合 这题还是看了题解才写出来。一开始不懂得每一层递归处理不同数字对应的字母,又想一些二维数组的操作,就搞复杂了。 题中的index就代表当前正在处理第几个数字对应的字母,循环中,压入这个之后就轮到下一个数字的对应字母,最后再返回。 想这种不知道会输入多少个数字的最好的方法就是 阅读全文

posted @ 2022-09-23 20:03 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0) 编辑

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