会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
branna
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
8
9
···
45
下一页
2020年6月22日
118. 杨辉三角(动态规划,二维数组)
摘要: 118. 杨辉三角 二维数组 class Solution { public: vector<vector<int>> generate(int numRows) { vector<vector<int>>a; if(numRows==0) { return a; } if(numRows==1)
阅读全文
posted @ 2020-06-22 12:19 branna
阅读(274)
评论(0)
推荐(0)
2020年6月21日
48. 旋转图像(顺时针)
摘要: 48. 旋转图像 class Solution { public: void rotate(vector<vector<int>>& matrix) { for(int i=0;i<matrix.size()/2;i++)//将行看做一个整体,逆序存放 { swap(matrix[i],matrix
阅读全文
posted @ 2020-06-21 22:14 branna
阅读(158)
评论(0)
推荐(0)
560. 和为K的子数组
摘要: 560. 和为K的子数组 暴力O(n^2) 利用前缀和做差有多少组差为k class Solution { public: int subarraySum(vector<int>& nums, int k) { int sum[nums.size()+10]; int ops=0; sum[ops]
阅读全文
posted @ 2020-06-21 16:36 branna
阅读(145)
评论(0)
推荐(0)
75. 颜色分类(三指针移动||计数排序)
摘要: 75. 颜色分类 根据题意提示,用计数排序扫描每个颜色的个数,然后重新往数组里填充012的个数即可,一趟扫描 class Solution { public: void sortColors(vector<int>& nums) { map<int,int>mp; for(int i=0;i<num
阅读全文
posted @ 2020-06-21 13:33 branna
阅读(207)
评论(0)
推荐(0)
2020年6月19日
670. 最大交换
摘要: 670. 最大交换 贪心O(n): class Solution { public: int maximumSwap(int num) { string s=to_string(num); map<char,int>mp; for(int i=0;i<s.length();i++) mp[s[i]]
阅读全文
posted @ 2020-06-19 17:20 branna
阅读(176)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
8
9
···
45
下一页
公告