上一页 1 2 3 4 5 6 7 8 ··· 45 下一页
摘要: 1299. 将每个元素替换为右侧最大元素 直接从后往前更新最大值存入数组中,然后逆置数组,删去最前的,在随扈补一个-1即可。 class Solution { public: vector<int> replaceElements(vector<int>& arr) { vector<int>v; 阅读全文
posted @ 2020-06-26 16:52 branna 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 719. 找出第 k 小的距离对 思路: 首先采用了暴力求差值,11组数据超时,优化后利用map来求,结果在最后的两组超时。。然而还是要用二分写,二分差值,最小的为0,最大的是排完序后最后一个数的值减去第一个数的值,取mid,然后在原来数组里继续二分找有多少对差值cnt是小于等于mid的。 若对数c 阅读全文
posted @ 2020-06-26 13:39 branna 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 35. 搜索插入位置 二分查找位置即可 class Solution { public: int searchInsert(vector<int>& nums, int target) { int left=0,right=nums.size(); while(left<right) { int m 阅读全文
posted @ 2020-06-25 17:28 branna 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 第一种办法sudo spctl --master-disable(安全与隐私中允许任何来源的应用安装) 若是第一种还打不开,sudo xattr -r -d com.apple.quarantine空格加上finder中打不开的应用路径(直接拖进终端) 阅读全文
posted @ 2020-06-24 17:33 branna 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 119. 杨辉三角 II class Solution { public: vector<int> getRow(int rowIndex) { vector<vector<int>> dp(rowIndex+10); if(rowIndex==0) { dp[0].push_back(1); re 阅读全文
posted @ 2020-06-22 12:35 branna 阅读(118) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 45 下一页