摘要:
#include <iostream> #include<vector> using namespace std; const int maxn=2e5+5; vector<int>graph[maxn];//邻接表 void addedge(int u,int v) { graph[u].empl 阅读全文
posted @ 2025-01-11 19:22
Marinaco
阅读(39)
评论(0)
推荐(0)
摘要:
题目链接:https://leetcode.cn/problems/course-schedule-ii/description/ 题意: 给定n门课程,规定只有学完某一个课程才能继续学下一门课程,让你输出学习顺序。如果成环,则返回空数组 思路: 拓补排序,入度删除法 需要提前准备一个indegre 阅读全文
posted @ 2025-01-11 19:09
Marinaco
阅读(14)
评论(0)
推荐(0)
摘要:
int n=20;//点的个数 int m=21;//边的个数 const int maxn=25; //邻接矩阵建图 int gra1[maxn][maxn]; void build(int n,int m,int from[],int to[],int weight[]) { for(int i 阅读全文
posted @ 2025-01-11 15:47
Marinaco
阅读(26)
评论(0)
推荐(0)
摘要:
题目链接:https://leetcode.cn/problems/decode-string/ 题意: 嵌套递归 class Solution { public: int where; string repeat(string path,int cnt) { string ans=""; for( 阅读全文
posted @ 2025-01-11 15:18
Marinaco
阅读(16)
评论(0)
推荐(0)
摘要:
题目链接:https://leetcode.cn/problems/maximal-rectangle/description/ 题意: 给定一个只有0和1的矩阵,试求只包含1的长方形的最大面积 思路: 每行将矩阵压缩成一个高度数组,转化为求矩形最大面积 class Solution { publi 阅读全文
posted @ 2025-01-11 12:20
Marinaco
阅读(41)
评论(0)
推荐(0)
摘要:
题目链接:https://leetcode.cn/problems/sum-of-subarray-minimums/ 题意: 给定一个数组,让你求子数组最小值的和,复杂度O(N) 思路: 单调栈(获得每个位置左边比它小且离它最近的数,右边比它小且离它最近的数,那么在这之间它本身就是区间最小值) c 阅读全文
posted @ 2025-01-11 11:02
Marinaco
阅读(27)
评论(0)
推荐(0)

浙公网安备 33010602011771号