上一页 1 2 3 4 5 6 7 ··· 20 下一页
摘要: ``` class Solution { public: vector productExceptSelf(vector& nums) { vector q; int t=1; for(auto i:nums) { q.push_back(t); t*=i; } t=1; for(int i=num 阅读全文
posted @ 2023-07-13 10:35 穿过雾的阴霾 阅读(7) 评论(0) 推荐(0)
摘要: ``` class Solution { public: ListNode* reverse(ListNode* head)//翻转以head为头节点的链表 { if(!head||!head->next) return head; auto a=head,b=head->next; while(b 阅读全文
posted @ 2023-07-12 12:17 穿过雾的阴霾 阅读(7) 评论(0) 推荐(0)
摘要: # 小根堆 ``` class Solution { public: int findKthLargest(vector& nums, int k) { priority_queue,greater> q; for(auto x:nums) { if(q.size()& nums, int k) { 阅读全文
posted @ 2023-07-10 12:46 穿过雾的阴霾 阅读(12) 评论(0) 推荐(0)
摘要: ``` class Solution { public: bool canFinish(int n, vector>& pre) { if(pre.empty()||pre[0].empty()) return true; vector> g(n,vector(n,false)); for(auto 阅读全文
posted @ 2023-07-09 11:49 穿过雾的阴霾 阅读(5) 评论(0) 推荐(0)
摘要: ``` /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x 阅读全文
posted @ 2023-07-08 14:48 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0)
摘要: ``` class Solution { public: bool st[310][310]; int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0}; int m,n; int numIslands(vector>& g) { int res=0; n=g.size(),m=g 阅读全文
posted @ 2023-07-07 12:11 穿过雾的阴霾 阅读(5) 评论(0) 推荐(0)
摘要: ``` class Solution { public: int majorityElement(vector& nums) { int cnt=1; int res=nums[0]; for(int i=1;i<nums.size();i++) { if(nums[i]==res) cnt++; 阅读全文
posted @ 2023-07-07 11:54 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0)
摘要: ``` /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class 阅读全文
posted @ 2023-07-05 18:43 穿过雾的阴霾 阅读(10) 评论(0) 推荐(0)
摘要: #使用双栈 ``` class MinStack { public: stack st, min_st; MinStack() { min_st.push(INT_MAX); } void push(int val) { st.push(val); int min_val=min_st.top(); 阅读全文
posted @ 2023-07-05 10:39 穿过雾的阴霾 阅读(13) 评论(0) 推荐(0)
摘要: ``` class Solution { public: static const int N=20010; int f[N],g[N]; int maxProduct(vector& nums) { int n=nums.size(); int res=nums[0]; f[0]=g[0]=num 阅读全文
posted @ 2023-07-04 11:27 穿过雾的阴霾 阅读(7) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 20 下一页