leetcode并查集
文章平均质量分 78
Bryan要加油
这个作者很懒,什么都没留下…
展开
-
765. Couples Holding Hands(Leetcode每日一题-2021.02.14)--抄答案
ProblemN couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats.The peopl原创 2021-02-15 10:24:44 · 207 阅读 · 0 评论 -
839. Similar String Groups(Leetcode每日一题-2021.01.31)
ProblemTwo strings X and Y are similar if we can swap two letters (in different positions) of X, so that it equals Y. Also two strings X and Y are similar if they are equal.For example, “tars” and “rats” are similar (swapping at positions 0 and 2), and “原创 2021-01-31 19:39:08 · 152 阅读 · 0 评论 -
778. Swim in Rising Water(Leetcode每日一题-2021.01.30)--抄答案
ProblemOn an N x N grid, each square grid[i][j] represents the elevation at that point (i,j).Now rain starts to fall. At time t, the depth of the water everywhere is t. You can swim from a square to another 4-directionally adjacent square if and only if原创 2021-01-30 20:04:13 · 215 阅读 · 0 评论 -
1631. Path With Minimum Effort(Leetcode每日一题-2021.01.29)--抄答案
ProblemYou are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the原创 2021-01-29 19:44:48 · 216 阅读 · 0 评论 -
1579. Remove Max Number of Edges to Keep Graph Fully Traversable(Leetcode每日一题-2021.01.27)--抄答案
ProblemAlice and Bob have an undirected graph of n nodes and 3 types of edges:Type 1: Can be traversed by Alice only.Type 2: Can be traversed by Bob only.Type 3: Can by traversed by both Alice and Bob.Given an array edges where edges[i] = [typei, ui原创 2021-01-27 21:57:11 · 255 阅读 · 0 评论 -
959. Regions Cut By Slashes(Leetcode每日一题-2021.01.25)--抄答案
ProblemIn a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, , or blank space. These characters divide the square into contiguous regions.(Note that backslash characters are escaped, so a \ is represented as “\”.)Return the numb原创 2021-01-25 22:49:03 · 140 阅读 · 0 评论 -
1319. Number of Operations to Make Network Connected(Leetcode每日一题-2021.01.23)--抄答案
ProblemThere are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network where connections[i] = [a, b] represents a connection between computers a and b. Any computer can reach any other computer directly or indirectl原创 2021-01-23 21:48:13 · 149 阅读 · 1 评论 -
1489. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree(Leetcode每日一题-2021.01.21)--抄答案
ProblemGiven a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a sub原创 2021-01-21 20:19:05 · 338 阅读 · 0 评论 -
1584. Min Cost to Connect All Points(Leetcode每日一题-2021.01.19)
ProblemYou are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].The cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |v原创 2021-01-19 18:08:15 · 214 阅读 · 0 评论 -
721. Accounts Merge(Leetcode每日一题-2021.01.18)--抄答案
ProblemGiven a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account.Now, we would like to merge these accounts. Two acco原创 2021-01-18 20:42:42 · 235 阅读 · 0 评论 -
803. Bricks Falling When Hit(Leetcode每日一题-2021.01.16)--抄答案
ProblemYou are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space. A brick is stable if:It is directly connected to the top of the grid, orAt least one other brick in its four adjacent cells is stable.You are原创 2021-01-16 21:45:09 · 238 阅读 · 0 评论 -
947. Most Stones Removed with Same Row or Column(Leetcode每日一题-2021.01.15)
ProblemOn a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone.A stone can be removed if it shares either the same row or the same column as another stone that has not been removed.Given an ar原创 2021-01-15 21:12:29 · 183 阅读 · 0 评论 -
684. Redundant Connection(Leetcode每日一题-2021.01.13)--抄答案
ProblemIn this problem, a tree is an undirected graph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, …, N), with one additional edge added. The added edge has two different v原创 2021-01-13 20:59:40 · 169 阅读 · 0 评论 -
1202. Smallest String With Swaps(Leetcode每日一题-2021.01.11)
ProblemYou are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.You can swap the characters at any pair of indices in the given pairs any number of times.Return t原创 2021-01-11 21:54:25 · 185 阅读 · 0 评论 -
547. Number of Provinces(Leetcode每日一题-2021.01.07)
ProblemThere are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c.A province is a group of directly or ind原创 2021-01-07 19:47:58 · 558 阅读 · 0 评论 -
685. Redundant Connection II(Leetcode每日一题-2020.09.17)---抄答案
ProblemIn this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents.The gi原创 2020-09-17 21:39:16 · 289 阅读 · 0 评论 -
990. Satisfiability of Equality Equations(Leetcode每日一题-2020.06.08)
ProblemGiven an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: “a==b” or “a!=b”. Here, a and b are lowercase letters (not necessarily different) that原创 2020-06-08 20:51:28 · 197 阅读 · 0 评论