自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 收藏
  • 关注

原创 终于安装上TensorFlow了,孩子泪目

试了找到的帖子里面的所有办法,一直WARNING、ERROR,之前放弃了很多次,但是没有办法不能再拖了。。。也看了Python是不是64位。用了清华镜像,可能是网络问题一直没对。终于试了这个方法成功了:https://blog.youkuaiyun.com/weixin_42840933/article/details/85308265豆瓣镜像 +获得ssl认证(输入指令后就去上课了,不知道行不行,很绝望,回来居然安装好了,泪目)(因为还在下其他视频所以挂了vpn,不知道有没有必要)不知道ssl认证是啥,搜了一

2021-04-07 18:20:00 978

原创 1 Introduction  介绍

1 Introduction 介绍Thetermcomputergraphicsdescribesanyuseofcomputerstocreateandmanipulateimages.Thisbookintroducesthealgorithmicandmathematicaltoolsthatcanbeusedtocreateallkindsofimages-realisticvisualeffects,informative...

2021-03-27 11:59:12 679 4

原创 lc 973.middle 最接近原点的 K 个点(***自定义sort比较函数)

评论https://leetcode-cn.com/problems/k-closest-points-to-origin/comments/659297自定义compare函数https://leetcode-cn.com/problems/k-closest-points-to-origin/solution/sortzi-ding-yi-pai-xu-by-heroding/bool compare(vector<int>& a, vector<int> ..

2020-11-17 00:14:12 204

原创 lc 122.easy买卖股票的最佳时机II(***贪心算法)

评论https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/comments/87652class Solution {public: int maxProfit(vector<int>& prices) { int len=prices.size(), sum=0; if(len<=1) return 0; for(int i=1;i..

2020-11-17 00:09:32 179

原创 lc 1122.easy 数组的相对排序

自己写的class Solution {public: vector<int> relativeSortArray(vector<int>& arr1, vector<int>& arr2) { vector<int> ans; int len1=arr1.size(); int added[len1]; memset(added,0,sizeof(added)..

2020-11-17 00:04:58 134

原创 lc 406.middle根据身高重建队列(****数学问题,***自定义sort比较函数)

评论区高能!!!https://leetcode-cn.com/problems/queue-reconstruction-by-height/comments/62983官方题解(这tm是阅读理解吧!!)https://leetcode-cn.com/problems/queue-reconstruction-by-height/solution/gen-ju-shen-gao-zhong-jian-dui-lie-by-leetcode-sol/class Solution {pub..

2020-11-17 00:01:07 165

原创 力扣周赛215.2 middle 确定两个字符串是否接近(字符串)

看了别人的思路自己写的,思路懂了就不难https://leetcode-cn.com/problems/determine-if-two-strings-are-close/solution/hen-jian-dan-de-ban-fa-by-handsomeluoyang/class Solution {public: bool closeStrings(string word1, string word2) { if(word1.size() != word2..

2020-11-15 12:47:53 208

原创 lc 922. easy按奇偶排序数组 II【***双指针】

自己写的超时了class Solution {public: vector<int> sortArrayByParityII(vector<int>& A) { for(int i=0;i<A.size();++i){ if(i%2==0 && A[i]%2==1){ for(int j=i+1;j<A.size();++j) ..

2020-11-12 23:41:53 125

原创 lc 31.middle下一个排列【****数学问题】

题解https://leetcode-cn.com/problems/next-permutation/solution/xia-yi-ge-pai-lie-suan-fa-xiang-jie-si-lu-tui-dao-/class Solution {public: void nextPermutation(vector<int>& nums) { int len=nums.size(), i=len-1; while(i&g..

2020-11-10 23:31:26 138

原创 lc 327.hard区间和的个数【*****递归】

327. 区间和的个数难度 困难给定一个整数数组nums,返回区间和在[lower, upper]之间的个数,包含lower和upper。区间和S(i, j)表示在nums中,位置从i到j的元素之和,包含i和j(i≤j)。说明:最直观的算法复杂度是O(n2) ,请在此基础上优化你的算法。示例:输入: nums = [-2,5,-1], lower = -2, upper = 2,输出: 3 解释: 3个区间分别是: [0,0], [2...

2020-11-08 00:17:40 162

原创 lc 1356. easy根据数字二进制下 1 的数目排序【****位运算,***排序】

1356. 根据数字二进制下 1 的数目排序难度 简单给你一个整数数组arr。请你将数组中的元素按照其二进制表示中数字1的数目升序排序。如果存在多个数字二进制中1的数目相同,则必须将它们按照数值大小升序排列。请你返回排序后的数组。示例 1:输入:arr = [0,1,2,3,4,5,6,7,8]输出:[0,1,2,4,8,3,5,6,7]解释:[0] 是唯一一个有 0 个 1 的数。[1,2,4,8] 都有 1 个 1 。[3,5,6] 有 2 个 1 。[7...

2020-11-07 19:53:42 168

原创 lc57.hard 插入区间(区间重叠的判断,扩大待插入区间的范围,***找到插入位置)

class Solution {public: vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) { int len=intervals.size(); int start=newInterval[0], end=newInterval[1]; vec...

2020-11-04 23:25:13 147

原创 lc 941.easy有效的山脉数组(cmp lc845数组中的最长山脉)

又是模拟爬山,不过要简单很多,一定是先上再下。class Solution {public: bool validMountainArray(vector<int>& A) { int len=A.size(), i=1; if(len<3) return false; while(i<len && A[i]>A[i-1]) ++i; if(i==1 || i==len..

2020-11-03 23:17:52 96

原创 lc 349.easy两个数组的交集(数组,我用的unordered_set哈希表)

官方题解https://leetcode-cn.com/problems/intersection-of-two-arrays/solution/liang-ge-shu-zu-de-jiao-ji-by-leetcode-solution/我:class Solution {public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { ..

2020-11-02 22:19:22 163

原创 lc 140.hard单词拆分II【①动态规划->lc139.单词拆分;②*****枚举 - 回溯法】

官方题解https://leetcode-cn.com/problems/word-break-ii/solution/dan-ci-chai-fen-ii-by-leetcode-solution/抄答案:class Solution {public: unordered_set<string> wordDictSet; unordered_map<int, vector<string>> sen; //记录每个下标对应的字符 以它开头..

2020-11-01 23:20:02 188

原创 lc 139.middle单词拆分【****动态规划】

官方题解【动态规划】https://leetcode-cn.com/problems/word-break/solution/dan-ci-chai-fen-by-leetcode-solution/class Solution {public: bool wordBreak(string s, vector<string>& wordDict) { unordered_set<string> wordDictSet; fo..

2020-11-01 23:14:25 264

原创 lc 463.easy 岛屿的周长(二维数组,数学问题)

我看的代码https://leetcode-cn.com/problems/island-perimeter/comments/43681官方题解https://leetcode-cn.com/problems/island-perimeter/solution/dao-yu-de-zhou-chang-by-leetcode-solution/class Solution {public: int islandPerimeter(vector<vector<int&...

2020-10-30 22:28:30 141

原创 lc 19.删除链表的倒数第N个节点(链表,***快慢指针)

官方题解https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/solution/shan-chu-lian-biao-de-dao-shu-di-nge-jie-dian-b-61/我看的代码https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/comments/105722class Solution {public: Li..

2020-10-29 20:35:17 235

原创 lc 129.求根到叶子节点数字之和【***递归】

官方题解https://leetcode-cn.com/problems/sum-root-to-leaf-numbers/solution/qiu-gen-dao-xie-zi-jie-dian-shu-zi-zhi-he-by-leetc//** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * ..

2020-10-29 19:42:49 138

原创 lc 1207.独一无二的出现次数(数组)

自己写的嘻嘻嘻class Solution {public: bool uniqueOccurrences(vector<int>& arr) { sort(arr.begin(), arr.end()); int len=arr.size(), cnt=0; if(len<=1) return true; vector<int> re; for(int i=1;i&lt..

2020-10-28 22:32:56 110

原创 lc 1365.[easy]有多少小于当前数字的数字【***计数排序】

官方题解https://leetcode-cn.com/problems/how-many-numbers-are-smaller-than-the-current-number/solution/you-duo-shao-xiao-yu-dang-qian-shu-zi-de-shu-zi--2/最朴素的方法:二重循环class Solution {public: vector<int> smallerNumbersThanCurrent(vector<int&g..

2020-10-26 23:34:46 95

原创 lc 845.middle数组中的最长山脉

欧买噶,第一次自己做出了middle,鸡冻!!官方题解https://leetcode-cn.com/problems/longest-mountain-in-array/solution/shu-zu-zhong-de-zui-chang-shan-mai-by-leetcode-sol/我是强行模拟爬山过程,用类似贪心的思想,每次记下最长山脉。代码看起来很长,其实思路很单纯的!然后我发现像这种模拟其实挺麻烦的,需要各种数据来检错,覆盖所有情况。。class Solution {pub..

2020-10-25 11:22:36 120

原创 lc 234.[easy]回文链表(快慢指针,翻转链表,比较两个链表)->lc143

欧买噶,鸡冻,第一次自己写出通过了,而且就是空间O(1)。用了前面学的快慢指针找中间结点,翻转链表,比较两个链表。注意找的中间结点是n/2向下取整,然后翻转n/2向上取整处的链表。n为奇数时,l1会多一个结点,此时整个链表也是回文,返回true。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : v..

2020-10-23 22:22:25 122

原创 lc 763.划分字母区间(字符串,双指针)【***贪心算法】

官方题解https://leetcode-cn.com/problems/partition-labels/solution/hua-fen-zi-mu-qu-jian-by-leetcode-solution/class Solution {public: vector<int> partitionLabels(string S) { vector<int> re; int endc[26], len=S.size(); ...

2020-10-22 23:52:43 231

原创 lc 925.长按键入(字符串,双指针)

官方题解https://leetcode-cn.com/problems/long-pressed-name/solution/chang-an-jian-ru-by-leetcode-solution/class Solution {public: bool isLongPressedName(string name, string typed) { int i=0, j=0, len1=name.size(), len2=typed.size(); w..

2020-10-21 22:16:18 188

原创 lc 143.重排链表【****①找中间结点;②翻转中间结点之后的链表,形成两个链表;③合并两个链表】

官方题解https://leetcode-cn.com/problems/reorder-list/solution/zhong-pai-lian-biao-by-leetcode-solution//** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ..

2020-10-20 23:43:08 137

原创 lc 206.反转链表

迭代法:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* reverseList(ListNode* head) { if(!head ||..

2020-10-20 22:45:47 105

原创 lc 876.链表的中间结点【***链表 - 快慢指针】

官方题解https://leetcode-cn.com/problems/middle-of-the-linked-list/solution/lian-biao-de-zhong-jian-jie-dian-by-leetcode-solut//** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x)..

2020-10-20 22:28:22 103

原创 lc 844.比较含退格的字符串【①重构字符串,然后比较;②***逆序遍历字符串】

官方题解https://leetcode-cn.com/problems/backspace-string-compare/solution/bi-jiao-han-tui-ge-de-zi-fu-chuan-by-leetcode-solu/①重构字符串,然后比较class Solution {public: bool backspaceCompare(string S, string T) { string s,t; int i; ...

2020-10-19 23:29:12 101

原创 lc1002.查找常用字符(字符串数组)

class Solution {public: vector<string> commonChars(vector<string>& A) { int minfre[26], fre[26]; vector<string> re; if(!A.size()) return re; memset(minfre,100,26*sizeof(int)); for(int i...

2020-10-15 15:13:17 95

原创 lc 24.两两交换链表中的节点(链表,交换顺序)

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne...

2020-10-13 23:35:22 168

原创 lc 142.环形链表II【返回入环结点,①***用哈希表;②*****快慢指针,如何利用相遇点 找到入环点?】

官方题解https://leetcode-cn.com/problems/linked-list-cycle-ii/solution/huan-xing-lian-biao-ii-by-leetcode-solution/①***用哈希表/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val..

2020-10-10 14:46:59 110

原创 lc 141.环形链表【****神奇的快慢指针】【*****双指针的用途】

官方题解https://leetcode-cn.com/problems/linked-list-cycle/solution/huan-xing-lian-biao-by-leetcode-solution/【*****链表双指针用途】https://leetcode-cn.com/problems/linked-list-cycle/solution/yi-wen-gao-ding-chang-jian-de-lian-biao-wen-ti-h-2//** * Definition f..

2020-10-09 23:16:41 136

原创 lc 462.最少移动次数 使数组元素相等II【数学问题:所有数字与m之差 的绝对值 之和 最小】

结论是m为中位数,简单证明:https://leetcode-cn.com/problems/minimum-moves-to-equal-array-elements-ii/comments/97616class Solution {public: int minMoves2(vector<int>& nums) { sort(nums.begin(),nums.end()); int n=nums.size(); i..

2020-10-08 20:01:51 182

原创 lc 75.颜色分类【***荷兰国旗问题】

题目中的方法:class Solution {public: void sortColors(vector<int>& nums) { int cnt0,cnt1,cnt2; cnt0=cnt1=cnt2=0; for(int i=0;i<nums.size();++i){ if(nums[i]==0) cnt0++; else if(nums[i]==1) cnt1..

2020-10-07 23:53:36 106

原创 lc 834.树中距离之和【*****树形DP】

看了这个题解看懂了https://leetcode-cn.com/problems/sum-of-distances-in-tree/solution/c-liang-ci-dfsde-dao-da-an-by-congwang357-2/核心就在这里:※求出递推式;※先使用后序遍历求出ans[root]和所有cnt[i],然后使用前序遍历用ans[node]求出ans[node的孩子];※使用用数组存储邻接点的方式存储图。class Solution {public: ..

2020-10-07 23:19:54 128

原创 lc15.三数之和【*****枚举+剪枝+双指针】

class Solution {public: vector<vector<int>> threeSum(vector<int>& nums) { int n=nums.size(); sort(nums.begin(),nums.end()); vector<vector<int>> re; for(int a=0;a<n;++a){ ...

2020-10-06 19:37:20 112

原创 lc18.四数之和(枚举+剪枝+双指针)->lc15

官方题解https://leetcode-cn.com/problems/4sum/solution/si-shu-zhi-he-by-leetcode-solution/class Solution {public: vector<vector<int>> fourSum(vector<int>& nums, int target) { vector<vector<int>> re; i..

2020-10-06 19:35:32 144

原创 lc 2.两数相加(链表)

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(ne...

2020-10-04 22:31:31 168

原创 LCP 19.秋叶收藏集【*****动态规划】

官方题解https://leetcode-cn.com/problems/UlBDOe/solution/qiu-xie-shou-cang-ji-by-leetcode-solution/class Solution {public: int minimumOperations(string leaves) { int n=leaves.size(); int f[n][3]; f[0][0]=(leaves[0]=='y'), f...

2020-10-04 20:11:15 81

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除