在计算机科学中,并查集是一种树型的数据结构,用于处理一些不交集(Disjoint Sets)的合并及查询问题。有一个联合-查找算法(Union-find Algorithm)定义了两个用于此数据结构的操作: Find:确定元素属于哪一个子集。它可以被用来确定两个元素是否属于同一子集。 Union:将两个子集合并成同一个集合。 由于支持这两种操作,...
//visualgo.net/zh algorithmvisualizer 又一个可视化网站,这个网站的特点是界面看起来比前两个清爽,不过不支持中文,这个也不是什么大问题,主要是它提供了算法实现代码,并且可以支持Java、JS、C++等多种语言,并且执行过程和速度可控制,还能暂停播放,在控制台也能看到算法执行输出的中间结果,我感觉用起来还是比较舒服...
LeetCode454 四数相加Ⅱ:ACM 选手图解 LeetCode 四数相加Ⅱ【二叉树】LeetCode 94 二叉树的中序遍历...
技术标签: LeetCode algorithm leetcode 栈基本计算器 实现一个基本的计算器来计算一个简单的字符串表达式 s 的值。 示例1: 输入:s = “1 + 1” 输出:2 示例2: 输入:s = " 2-1 + 2 " 输出:3 示例3: 输入:s = “(1+(4+5+2)-3)+(6+8)” 输出:23 提示: 1 <= s.length <= 3...
简而言之就是BM多数投票算法(Boyer-Moore Majority Vote algorithm)。代码效率好像不高,还要找找更高效的算法。一刷很快ac,二刷一次ac。 要注意变量的初始化,将n1,n2初始化为任意两个不同的数就行,对应counter设置为0是关键。还要注意一点第一次遍历结束只是明确了n1,n2是出现频率最高的数,但是对应的counter是不...
15-Greedy-Algorithm 添加了「循环不变量」的代码。 Nov 22, 2020 17-Hash-Table 添加了第 49 题。 Jan 3, 2021 19-Breadth-First-Search 增加了广度优先遍历的一些问题。 Jan 3, 2021 22-divide-and-conquer 添加了分治算法的代码。 Dec 4, 2020 ...
#define debug #ifdef debug #include <time.h> #endif #include <iostream> #include <algorithm> #include <vector> #include <string.h> #include <map> #include <set> #include <stack> #include <queue> #include <math.h> #define MAXN ((int)1e5+7) #define ll long long int #define INF...
Algorithm upload the solution list Apr 14, 2021 Solution upload the solution 1865 May 17, 2021 classification upload the solution 938 Apr 26, 2021 README.md Update README.md Dec 7, 2020 Solution_List.md update solution list Apr 18, 2021 READ...
What if nums1's size is small compared to nums2's size? Which algorithm is better? What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the memory at once? Week 4: ...
#include <iostream> #include <stdio.h> #include <string> #include<string.h> #include <vector> #include <map> #include <stack> #include <algorithm> #include <stack> #include <queue> using namespace std; typedef struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int...