随笔分类 - Algorithm Learning
数据结构和算法学习,程序设计竞赛
摘要:常用排序算法C++实现
阅读全文
摘要:Daily Algorithm Learning.
阅读全文
摘要:232场周赛 class Solution { // 暴力 public: bool areAlmostEqual(string s1, string s2) { int len = s1.length(); int cnt = 0; int idx1 = 0, idx2 = 0; string t
阅读全文
摘要:class Solution { public: int cnt = 0; int numberOfMatches(int n) { // 偶数 / 2 // 奇数 产生 (n - 1) / 2 + 1 个队伍 if (n == 1) return cnt; if (n % 2 == 0) { cn
阅读全文
摘要:一个常见面试题,递归调用,将有序链表转为搜索二叉树和搜索二叉平衡树
阅读全文
摘要:思路: 暴力。 class Solution { public: int countGoodTriplets(vector<int>& arr, int a, int b, int c) { int cnt = 0; for(int i = 0; i < arr.size(); i++){ for
阅读全文
摘要:LeetCode 199周赛 前三题题解
阅读全文
摘要:#2020蓝桥杯十一届七月省赛CB组 考生须知 A:跑步训练 // 模拟 #include <stdio.h> #include <iostream> #include <map> using namespace std; int main() { int start = 1000; int fla
阅读全文
摘要:2020十一届蓝桥杯-七月省赛 不是CB组的 两种做法 #include <stdio.h> #include <iostream> using namespace std; int dfs(int n) { if (n == 1) return 7; else if (n % 2 == 0) {
阅读全文
摘要:##LeetCode周赛190题解-1455-1456-1457-1458 class Solution { public: void SplitString(const std::string& s, std::vector<std::string>& v, const std::string&
阅读全文
摘要:``` #include int main() { int e[10][10], k, j, n, m, t1, t2, t3; int inf = 9999999; scanf("%d%d", &n, &m); //初始化 for (i = 1; i e[i][k] + e[k][j]) e[i][j] = e[i][k] + e[k][j]; //输出最终的结果 for (i = 1; i <
阅读全文
摘要:图的遍历dfs和bfs 深度优先遍历图的主要思想就是: 首先以一个未被访问过的顶点作为起始顶点,沿当前顶点的边走到未访问过的顶点:当没有未访问过的顶点时,则回到上一个顶点,继续试探访问别的顶点,知道所以的顶点都被访问过。 对于深度优先遍历图来说: 就是沿着一个分支走到底,发现无顶点可访问,则回溯一个
阅读全文
摘要:KMP算法学习 KMP中用到的函数详解 1. prefix_table() 2. move_prefix_table() 3. kmp_search()
阅读全文
摘要:Leetcode 183场周赛 1 2 3
阅读全文
摘要:算法并查集的学习 用到的函数 : 用到的数据逻辑表示 : int find_root(int x, int parent[])函数的实现 int union_vertices(int x, int y, int parent[], int rank[])函数的实现
阅读全文
摘要:C++常用类型STL库用法总结 1.string类总结: 定义方法: include , 除此之外还要using namespace std; 使用方法: string 重载了 += 、 +、!= 、==、= 、 、 使用方法: 创建二维向量: `cout include using namespa
阅读全文
摘要:字符串的去重全排列 应用场景暴力破解填空题目 全排列 调用方式: `perm(list, 0, strlen(list) 1)`
阅读全文

浙公网安备 33010602011771号