본문 바로가기

뇌세포덩어리""/알고리즘

[leetcode] union find 문제들

https://leetcode.com/problems/find-if-path-exists-in-graph/description/

 

Find if Path Exists in Graph - LeetCode

Find if Path Exists in Graph - There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-direct

leetcode.com

 

https://leetcode.com/problems/number-of-provinces/

 

Number of Provinces - LeetCode

Number of Provinces - There 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 d

leetcode.com

https://leetcode.com/problems/accounts-merge/

 

Accounts Merge - LeetCode

Accounts Merge - Given a list of accounts where 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 a

leetcode.com

 

https://leetcode.com/problems/find-the-town-judge/

 

Find the Town Judge - LeetCode

Find the Town Judge - In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: 1. The town judge trusts nobody. 2. Everybody (except for the town judge) trusts

leetcode.com

https://leetcode.com/problems/regions-cut-by-slashes/

 

Regions Cut By Slashes - LeetCode

Regions Cut By Slashes - An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. These characters divide the square into contiguous regions. Given the grid grid represented as a string array, return th

leetcode.com

 

https://leetcode.com/problems/lexicographically-smallest-equivalent-string/

 

Lexicographically Smallest Equivalent String - LeetCode

Lexicographically Smallest Equivalent String - You are given two strings of the same length s1 and s2 and a string baseStr. We say s1[i] and s2[i] are equivalent characters. * For example, if s1 = "abc" and s2 = "cde", then we have 'a' == 'c', 'b' == 'd',

leetcode.com

 

https://leetcode.com/problems/possible-bipartition/

 

Possible Bipartition - LeetCode

Possible Bipartition - We want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not go into the same group. Given the integer n and the array dislikes where dislikes[

leetcode.com

 

https://leetcode.com/problems/smallest-string-with-swaps/

 

Smallest String With Swaps - LeetCode

Smallest String With Swaps - You 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 

leetcode.com

 

https://leetcode.com/problems/path-with-minimum-effort/

 

Path With Minimum Effort - LeetCode

Path With Minimum Effort - You 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 ho

leetcode.com

 

https://leetcode.com/problems/number-of-provinces/

 

Number of Provinces - LeetCode

Number of Provinces - There 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 d

leetcode.com

 

 

https://leetcode.com/problems/maximal-network-rank/

 

Maximal Network Rank - LeetCode

Can you solve this real interview question? Maximal Network Rank - There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi. The

leetcode.com