常用算法讲解
最短路径:Dijkstra 算法
https://leetcode-cn.com/problems/network-delay-time/solution/by-nehzil-d1b8/
最短路径
https://leetcode-cn.com/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/solution/zui-duan-lu-jing-mo-ban-da-ji-he-cban-fl-gs7u/
https://leetcode.cn/problems/find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance/solution/zui-duan-lu-jing-mo-ban-da-ji-he-cban-fl-gs7u/
并查集关键函数
int find(int x, vector<int>& parent) { if (parent[x] == x) { return x; } parent[x] = find(parent[x], parent); return parent[x]; } void Merge(int x, int y, vector<int>& parent) { parent[find(x, parent)] = find(y, parent); }
贪心算法:
https://leetcode.cn/problems/non-overlapping-intervals/solution/wu-zhong-die-qu-jian-by-leetcode-solutio-cpsb/
https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons/solution/yong-zui-shao-shu-liang-de-jian-yin-bao-qi-qiu-1-2/
双指针,单调栈
https://leetcode.cn/problems/trapping-rain-water/solution/jie-yu-shui-by-leetcode-solution-tuvc/
浙公网安备 33010602011771号