- 博客(105)
- 收藏
- 关注
原创 Mamba环境配置(超算11.7 本机WSL 11.8)
遂采用在conda中管理cuda的解决方案,先安装cuda,安装完torch之后再安装nvcc,最后再尝试安装causal-conv1d。后续发现2.0.1版本的torch所支持的triton版本过低导致,于是采用同时适配11.8及11.7的2.1.0版本torch。根据自己的torch版本和python版本进行选择下载安装,本地whl也直接通过上述安装步骤完成,且能正常使用。进行离线安装,ps:whl文件前一晚下载极其慢且会中断,第二天下载飞快。首先在超算上进行安装。安装成功,且能正常使用。
2024-11-22 15:32:23
428
原创 每日一题——删除最短的子数组使剩余数组有序(3.25)
public:return 0;++i) {left = i;break;j > 0;--j) {--left;break;
2023-04-02 18:31:08
279
原创 每日一题——执行操作后字典序最小的字符串(3.19)
public:s = s + s;vis[i] = 1;j < 10;j++) {0 : 9;k++) {p < n;p += 2) {p < n;p += 2) {return res;
2023-04-02 18:29:25
275
原创 每日一题——分割两个字符串得到回文串
然后发现超时之后进行更正判断,发现只需刨去字符串a与字符串b相同前后缀之后,判断剩余的字符串a/b是不是回文串即可。
2023-03-18 17:06:24
522
原创 每日一题——给定行和列的和求可行矩阵
思路:做得时候想不出来,只想到了要不要考虑回溯,不断试错。但想了想时间花费太大。然后题解中的贪心算法显然极其优秀。
2023-03-14 16:22:32
332
原创 数组--------加一
classSolution{public:vector<int>plusOne(vector<int>&digits){vector<int>res;for(inti=digits.size()-1;i>=0;i--){res.push_back(digits[i]);}intnum=1;...
2021-07-02 22:32:07
107
原创 数组----存在重复元素
法一:classSolution{public:boolcontainsDuplicate(vector&nums){unordered_mapflag;for(inti=0;i<nums.size();i++){if(flag.count(nums[i])){returntrue;}else...
2021-06-29 21:26:52
77
原创 数组------存在重复元素||
classSolution{public:boolcontainsNearbyDuplicate(vector&nums,intk){unordered_mapflag;for(inti=0;i<nums.size();i++){if(!flag.count(nums[i])){flag[nums[i]]=i;}...
2021-06-28 11:13:32
108
原创 数组--------汇总区间
classSolution{public:vectorsummaryRanges(vector&nums){vectorres;if(nums.size()==0){returnres;}elseif(nums.size()==1){res.push_back(to_string(nums[0]));...
2021-06-28 10:30:47
97
原创 数组-----丢失的数字
法一:classSolution{public:intmissingNumber(vector&nums){intsum=0;inttemp=0;for(inti=0;i<nums.size();i++){temp=temp+i;sum=sum+nums[i];}retur...
2021-06-27 22:01:09
108
原创 二叉树---二叉树的所有路径
classSolution{public:vectorbinaryTreePaths(TreeNode*root){vectorres;if(root==NULL)returnres;path(root,"",res);returnres;}voidpath(TreeNode*root,stringtemp,vector&res){...
2021-06-26 22:23:17
138
2
原创 二叉树-------二叉搜索树的最近公共祖先
classSolution{public:TreeNode*lowestCommonAncestor(TreeNode*root,TreeNode*p,TreeNode*q){if(p->val<root->val&&q->val<root->val){returnlowestCommonAncestor(root->left,p,q);...
2021-06-24 17:20:16
197
2
原创 二叉树----路径总和
一开始有好多细节没有注意到,但结果还是好的classSolution{public:intres=0;boolhasPathSum(TreeNode*root,inttargetSum){returnjudge(root,targetSum,res);}booljudge(TreeNode*root,inttargetSum,intres){if(root==NULL){...
2021-06-24 17:04:45
93
原创 链表------删除链表中的节点
讲道理,这题目我没看懂。classSolution{public:voiddeleteNode(ListNode*node){node->val=node->next->val;node->next=node->next->next;}};
2021-06-23 15:27:25
74
原创 链表----移除链表元素
classSolution{public:ListNode*removeElements(ListNode*head,intval){if(head==NULL)returnNULL;ListNode*res=newListNode(val+1);res->next=head;ListNode*ans=res;while(res->ne...
2021-06-23 15:24:11
95
原创 双指针----相交链表
classSolution{public:ListNode*getIntersectionNode(ListNode*headA,ListNode*headB){if(headA==NULL||headB==NULL)returnNULL;ListNode*pA=headA;ListNode*pB=headB;while(pA!=pB){...
2021-06-23 15:23:09
99
原创 双指针-------移动零
双指针解法:classSolution{public:voidmoveZeroes(vector<int>&nums){inti=0,j=0;while(j<nums.size()){if(nums[j]==0){j++;}else{nums...
2021-06-03 21:49:23
75
原创 双指针-----移除元素
我的菜逼解法:classSolution{public:intremoveElement(vector<int>&nums,intval){for(inti=0;i<nums.size();i++){if(nums[i]==val){nums.erase(nums.begin()+i);i--;...
2021-06-03 21:41:07
85
原创 双指针---------删除有序数组中的重复项
我的菜逼解法:classSolution{public:intremoveDuplicates(vector<int>&nums){for(inti=0;i<nums.size();i++){inttemp=nums[i];if(i+1!=nums.size()){if(temp==nums[i+1])...
2021-06-03 21:32:49
122
原创 滑动窗口--------字符串的排列
classSolution{public:boolcheckInclusion(strings1,strings2){unordered_map<char,int>need,window;for(inti=0;i<s1.size();i++){charc=s1[i];need[c]++;}intright...
2021-06-03 11:28:34
101
原创 滑动窗口-------无重复字符的最长子串
滑动:classSolution{public:intlengthOfLongestSubstring(strings){unordered_map<char,int>window;intleft=0,right=0;intres=0;while(right<s.size()){charc=s[right];...
2021-06-03 11:26:12
102
原创 滑动窗口-----找到字符串中所有字母异位词
classSolution{public:vector<int>findAnagrams(strings,stringp){unordered_map<char,int>need,window;for(inti=0;i<p.size();i++){charc=p[i];need[c]++;}int...
2021-06-03 10:50:57
97
转载 滑动窗口算法-----最小覆盖子串
从labuladong的算法中一路学到了滑动窗口框架,感觉收获颇多:https://labuladong.gitbook.io/algo/mu-lu-ye/hua-dong-chuang-kou-ji-qiao-jin-jie滑动窗口之前没有怎么接触,除了数据结构之中的kmp算法感觉与这类问题有相通之处。classSolution{public:stringminWindow(strings,stringt){unordered_map&...
2021-06-03 10:14:31
91
原创 链表----删除排序链表中的重复元素
classSolution{public:ListNode*deleteDuplicates(ListNode*head){ListNode*res=head;while(head!=NULL){if(head->next==NULL){break;}while(head->val==head-...
2021-06-01 20:30:22
60
原创 链表------合并两个有序链表
classSolution{public:ListNode*mergeTwoLists(ListNode*l1,ListNode*l2){if(l1==NULL)returnl2;if(l2==NULL)returnl1;ListNode*res=newListNode(0);ListNode*ans=res;while(l1!=NULL&...
2021-05-31 20:55:35
77
原创 双指针-----反转字符串
classSolution{public:voidreverseString(vector<char>&s){intlow=0;inthigh=s.size()-1;while(low<high){chartemp=s[low];s[low]=s[high];s[high]=tem...
2021-05-31 20:54:52
90
原创 双指针-------两数之和II输入有序数组
classSolution{public:vector<int>twoSum(vector<int>&numbers,inttarget){intlow=0;inthigh=numbers.size()-1;intmid;while(low<=high){if(numbers[low]+numbers[hig...
2021-05-31 20:54:44
64
原创 双指针------二分查找
数据太小,运行起来感觉和线性查找没啥不同classSolution{public:intsearch(vector<int>&nums,inttarget){intlow=0;inthigh=nums.size()-1;intmid;while(low<=high){mid=(low+high)/2;...
2021-05-29 16:23:27
87
原创 双指针------删除链表的倒数第N个结点
classSolution{public:ListNode*removeNthFromEnd(ListNode*head,intn){ListNode*first=head;ListNode*second=head;intcount=n;while(count!=0){first=first->next;coun...
2021-05-29 16:22:00
79
原创 双指针-------链表的中间结点
classSolution{public:ListNode*middleNode(ListNode*head){if(head==NULL||head->next==NULL)returnhead;ListNode*first=head;ListNode*second=head;while(first!=NULL&&first->next...
2021-05-29 16:21:13
89
原创 双指针-------环形链表II
classSolution{public:ListNode*detectCycle(ListNode*head){if(head==NULL||head->next==NULL)returnNULL;ListNode*first=head;ListNode*second=head;while(first!=NULL&&first->next...
2021-05-29 16:20:35
85
原创 双指针-------环形链表
classSolution{public:boolhasCycle(ListNode*head){if(head==NULL)returnfalse;ListNode*first=head;ListNode*second=head;while(first->next!=NULL&&first->next->next!=NULL){...
2021-05-29 16:19:54
95
原创 链表学习-----回文链表
classSolution{public:boolisPalindrome(ListNode*head){ListNode*first=head;ListNode*second=head;while(first!=NULL&&first->next!=NULL){first=first->next->next;...
2021-05-29 16:18:25
55
原创 双指针------回文数
classSolution{public:boolisPalindrome(intx){if(x<0)returnfalse;stringtemp=to_string(x);intl,r;for(l=0,r=temp.size()-1;l<r;l++,r--){if(temp[l]!=temp[r]){...
2021-05-29 16:17:11
179
原创 链表学习-----K个一组翻转链表
classSolution{public:ListNode*reverseKGroup(ListNode*head,intk){if(head==NULL)returnhead;ListNode*a=head;ListNode*b=head;for(inti=0;i<k;i++){if(b==NULL)returnh...
2021-05-29 16:16:12
70
原创 链表学习--------反转链表II
classSolution{public:ListNode*successor=NULL;ListNode*reverseBetween(ListNode*head,intleft,intright){if(left==1)returnreverse(head,right);head->next=reverseBetween(head->next,left-1,right-1);...
2021-05-29 16:15:13
83
原创 链表学习-------反转链表
这个思维当时理解了挺久。classSolution{public:ListNode*reverseList(ListNode*head){if(head==NULL)returnNULL;if(head->next==NULL)returnhead;ListNode*last=reverseList(head->next);head->next->...
2021-05-29 16:13:54
62
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人