随笔分类 - Union Find
摘要:StatusTitleSolutionAcceptanceDifficultyFrequency438. Find All Anagrams in a String50.0%Medium200. Number of Islands56.7%Medium2421. Number of Good Pat
阅读全文
摘要:There are n cities labeled from 1 to n. You are given the integer n and an array connections where connections[i] = [xi, yi, costi] indicates that the
阅读全文
摘要:[抄题]: There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a
阅读全文
摘要:[抄题]: Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of conn
阅读全文
摘要:[抄题]: Given 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 elem
阅读全文
摘要:[抄题]: 设计一个包含下面两个操作的数据结构:addWord(word), search(word) addWord(word)会在数据结构中添加一个单词。而search(word)则支持普通的单词查询或是只包含.和a-z的简易正则表达式的查询。 一个 . 可以代表一个任何的字母。 [暴力解法]:
阅读全文
摘要:[抄题]: 给出 n 个节点,标号分别从 0 到 n - 1 并且给出一个 无向边的列表 (给出每条边的两个顶点), 写一个函数去判断这张`无向`图是否是一棵树。 给出n = 5 并且 edges = [[0, 1], [0, 2], [0, 3], [1, 4]], 返回 true. 给出n =
阅读全文
摘要:[抄题]: 给一个01矩阵,求不同的岛屿的个数。 0代表海,1代表岛,如果两个1相邻,那么这两个1属于同一个岛。我们只考虑上下左右为相邻。 [暴力解法]: 时间分析: 空间分析: [思维问题]: [一句话思路]: 找到一个岛,用dfs沉没一片岛。 [输入量]:空: 正常情况:特大:特小:程序里处理到
阅读全文