Contact me:

上一页 1 2 3 4 5 6 7 ··· 16 下一页
摘要: leetcode的提交不知道是不是有问题,我写的在本地跑起来比官方答案快,但是提交失败。 ##我的思路 正推,字符串首尾各放一指针,向中间查找相同项,找到后开始判断是否回文串,当两指针相遇判断结果,记录长度。并且第一个找到的回文串肯定是最大,所以前面的指针向前继续查找 string longestP 阅读全文
posted @ 2021-12-24 19:21 impwa 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 1,确定状态 2,找到转移公式 3,确定初始条件以及边界条件 ##leetcode53 最大子数组和 https://leetcode-cn.com/problems/maximum-subarray/ 两者关系转换条件--后无效性! ###求连续项最大和 class Solution { publ 阅读全文
posted @ 2021-12-23 11:01 impwa 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 爬楼梯问题抽象出来就是斐波那契数列求和, 像这样递推公式,第一时间想到就是用递归 ##普通树形递归 一提交就爆栈,当n过大时压不住 case 10: result = 89; case 20: result = 10946; case 45: result = 1836311903; class S 阅读全文
posted @ 2021-12-22 10:51 impwa 阅读(49) 评论(0) 推荐(0) 编辑
摘要: ##哈希表 初始:将key通过hash function转换到地址 查询:将查询值通过哈希转换,访问内存地址,对比key值 ##使用 查询key值,O(k) class Solution { public: vector<int> twoSum(vector<int> nums,int t){ un 阅读全文
posted @ 2021-12-21 10:48 impwa 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 第一次写成了O(n^2) 没搞懂初始化构建大顶堆有什么用,就每次都从下往上比较然后生成大顶堆; 要让复杂度降到nlog(n)得利用堆的性质呀,从上往下比较才能是logn class Solution { public: vector<int> sortArray(vector<int>& nums) 阅读全文
posted @ 2021-12-20 16:34 impwa 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 1.前后两指针互换 void Qrank(vector<int>& nums,int start,int over){ if(start>=over) return; int left=start; int right=over; // int rdm = rand() % (over - star 阅读全文
posted @ 2021-12-19 18:54 impwa 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 主要就是利用左右指针把O(n3)降到O(n2) 剩下的就想办法排除重复 class Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> ts;//返回 int m = num 阅读全文
posted @ 2021-12-18 15:26 impwa 阅读(20) 评论(0) 推荐(0) 编辑
摘要: ##最容易想到的 利用sort() class Solution { public: void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) { for(int i=0;i<n;i++){ nums1[m+i]=nums2[i 阅读全文
posted @ 2021-12-18 11:32 impwa 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 抽象基类的派生子类构造函数按照初始化列表的写法怎么也写不对,查资料后记录 ##要点如下 公有类型派生类不能访问基类私有成员 --但我这里基类没有private成员 为什么要调用父类的构造函数? 构造函数用来初始化类的对象,与父类的其它成员不同,它不能被子类继承(子类可以继承父类所有的成员变量和成员方 阅读全文
posted @ 2021-12-12 09:57 impwa 阅读(1875) 评论(0) 推荐(0) 编辑
摘要: 下载源代码包 解压 使用MSYS2或MINGW64 cd ./configure make make install 阅读全文
posted @ 2021-12-11 17:53 impwa 阅读(314) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 16 下一页