上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页
摘要: https://www.acwing.com/problem/content/1102/ 数据范围为1e5 实际上还可以再继续细分,加入特判来优化耗时,但是意义不大 #include<iostream> #include<cstring> #include<cstdio> #include<queu 阅读全文
posted @ 2023-06-16 22:40 风乐 阅读(24) 评论(0) 推荐(0)
摘要: 朴素Dijkstra https://www.acwing.com/problem/content/description/851/ O(N^2) #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> us 阅读全文
posted @ 2023-05-18 17:17 风乐 阅读(31) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/description/804/ #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> usi 阅读全文
posted @ 2023-05-16 17:34 风乐 阅读(28) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/count-negative-numbers-in-a-sorted-matrix/ 1351. 统计有序矩阵中的负数 1.二分法:把每一行进行一遍二分,找到正数与负数的边界,且此时grid[i][mid]也为负数,即边界下标的对应值是负数的 阅读全文
posted @ 2023-04-26 22:26 风乐 阅读(42) 评论(0) 推荐(0)
摘要: git介绍:git是一款SCM软件,用来管理源码文件,需求文档,设计文档,开发文档等项目文件 在团队开发中,通过SCM软件管理这些文件,而业界用的较多的是git,它支持多人协作同时开发,且不需要中央服务器,而是分布式的版本控制系统 git也是linus为了方便管理linux内核而开发的 基础概念:1 阅读全文
posted @ 2023-04-26 12:31 风乐 阅读(44) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/find-smallest-letter-greater-than-target/ 简单二分,需要注意的是此题的二分check条件if(letters[mid]>target),这里的大于号是不能为大于等于的 若等于,则最后的l或r下标就会可 阅读全文
posted @ 2023-04-19 20:55 风乐 阅读(23) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/search-insert-position/ 简单二分,这里可以判断return,相当于剪枝 这里的写法最后更新后的l或r一定可以使得nums[l] 或者nums[r]>=target 所以退出循环最后的l或r就是第一个大于等于target 阅读全文
posted @ 2023-04-19 20:13 风乐 阅读(30) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/binary-search/ 简单二分 class Solution { public: int search(vector<int>& nums, int target) { int l=0,r=nums.size()-1; while(l 阅读全文
posted @ 2023-04-19 19:59 风乐 阅读(26) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/maximum-subarray/ 1.暴力+前缀和 class Solution { public: int maxSubArray(vector<int>& nums) { const int N = 1e5+10; int sums[N 阅读全文
posted @ 2023-04-16 18:16 风乐 阅读(34) 评论(0) 推荐(0)
摘要: 1e5的数据量,要求时间复杂度小于O(n^2) 1.可以排序后判断是否出现相同数字,O(nlogn) class Solution { public: bool containsDuplicate(vector<int>& nums) { sort(nums.begin(),nums.end()); 阅读全文
posted @ 2023-04-12 19:58 风乐 阅读(20) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页