图的遍历和应用 1. 实现方式 :邻接矩阵可以使用vector。邻接矩阵的无穷表示方法: 2. 应用场景 :拓扑图、最小生成树、最短路径、二分图、DFS、BFS。 例题 全排列问题 匈牙利算法 —— 最大匹配 代码与知识点均学习自AcWing:https://www.acwing.com/activ ...
分类:
其他好文 时间:
2020-02-01 12:32:35
阅读次数:
73
本文简要的分析了下Collections.synchronizedList 、CopyOnWriteArrayList、Vector线程安全的实现机制并对它们的读,写,迭代性能进行了对比。 ...
分类:
其他好文 时间:
2020-02-01 10:35:48
阅读次数:
58
题目描述: 编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 示例 1: 输入: ["flower","flow","flight"] 输出: "fl" 示例 2: 输入: ["dog","racecar","car"] 输出: "" 解释: 输入不存在公共前 ...
分类:
其他好文 时间:
2020-02-01 00:28:25
阅读次数:
70
题链 tips: 1.倒序存储 2.进位、借位处理t 3.去除前导零 4.c++11新语法auto 5.A4A3A2A1A0(自然语言与代码存储相结合) 6.压位处理? //加法 #include<iostream> #include<vector> #include<cstdio> using n ...
分类:
其他好文 时间:
2020-01-31 21:00:27
阅读次数:
65
题目描述: 解法: 贪心法 class Solution { public: string intToRoman(int num) { vector<int> number = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; vector<string> ro ...
分类:
其他好文 时间:
2020-01-31 20:39:47
阅读次数:
92
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<queue> 5 #include<map> 6 #include<vector> 7 #include<set> 8 #include<string> ...
分类:
其他好文 时间:
2020-01-31 18:49:43
阅读次数:
71
树的直径 直径的性质 1. 任意两条直径必定相交 2. 所有直径必交于一点 找直径 任意一个点出发,找出最远点,从最远点,在找到最远点,连起来就是直径(两次$dfs$)。证明从略(反证法)。 P1099 树网的核 题目描述 设$T=(V,E,W)$是一个无圈且连通的无向图(也称为无根树),每条边到有 ...
分类:
其他好文 时间:
2020-01-31 18:38:12
阅读次数:
83
【1】基于范围的for循环演化过程 (1)C++98传统写法 1 // C++98 传统写法 2 3 #include <iostream> 4 using namespace std; 5 6 int main() 7 { 8 int arr[5] = { 1, 2, 3, 4, 5 }; 9 1 ...
分类:
编程语言 时间:
2020-01-31 18:31:26
阅读次数:
62
题目链接 方法1: bfs Code: #include <bits/stdc++.h> # define LL long long using namespace std; const int maxn=1000000+10; int N,M; vector<int> adj[maxn]; int ...
分类:
其他好文 时间:
2020-01-31 16:10:19
阅读次数:
79
一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。问总共有多少条不同的路径?
动态规划 ...
分类:
其他好文 时间:
2020-01-31 12:32:38
阅读次数:
69