原文链接: https://leetcode-cn.com/problems/clone-graph 英文原文Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. class…
标签详情
图 分类
原文链接: https://leetcode-cn.com/problems/course-schedule 英文原文There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take…
原文链接: https://leetcode-cn.com/problems/course-schedule-ii 英文原文There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must t…
原文链接: https://leetcode-cn.com/problems/minimum-height-trees 英文原文A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes la…
原文链接: https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix 英文原文Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or dow…
原文链接: https://leetcode-cn.com/problems/reconstruct-itinerary 英文原文You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it.…
原文链接: https://leetcode-cn.com/problems/evaluate-division 英文原文You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi…
原文链接: https://leetcode-cn.com/problems/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 ind…
原文链接: https://leetcode-cn.com/problems/redundant-connection 英文原文In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled from 1 to n, with one additional edg…
原文链接: https://leetcode-cn.com/problems/redundant-connection-ii 英文原文In 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 …
原文链接: https://leetcode-cn.com/problems/network-delay-time 英文原文You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the …
原文链接: https://leetcode-cn.com/problems/cracking-the-safe 英文原文There is a safe protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1]. The safe has a peculiar way of checking the password. When y…
原文链接: https://leetcode-cn.com/problems/couples-holding-hands 英文原文There are n couples sitting in 2n seats arranged in a row and want to hold hands. The people and seats are represented by an integer array row where row[i] is the ID of the person sitti…
原文链接: https://leetcode-cn.com/problems/is-graph-bipartite 英文原文There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. …
原文链接: https://leetcode-cn.com/problems/cheapest-flights-within-k-stops 英文原文There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi…
原文链接: https://leetcode-cn.com/problems/all-paths-from-source-to-target 英文原文Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order. The graph is given as …
原文链接: https://leetcode-cn.com/problems/find-eventual-safe-states 英文原文There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where graph[i] is an integer array of nod…
原文链接: https://leetcode-cn.com/problems/sum-of-distances-in-tree 英文原文There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given the integer n and the array edges where edges[i] = [ai, bi] indicates that t…
原文链接: https://leetcode-cn.com/problems/keys-and-rooms 英文原文There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot enter a locked room without having its key. W…
原文链接: https://leetcode-cn.com/problems/shortest-path-visiting-all-nodes 英文原文You have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes connected with node i by an…
原文链接: https://leetcode-cn.com/problems/loud-and-rich 英文原文There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness. You are given an array richer where richer[i] = [ai, b…
原文链接: https://leetcode-cn.com/problems/reachable-nodes-in-subdivided-graph 英文原文You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with t…
原文链接: https://leetcode-cn.com/problems/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 i…
原文链接: https://leetcode-cn.com/problems/cat-and-mouse 英文原文A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all nodes b such that ab is an edge of the graph…
原文链接: https://leetcode-cn.com/problems/most-stones-removed-with-same-row-or-column 英文原文On 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 th…
原文链接: https://leetcode-cn.com/problems/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 gri…
原文链接: https://leetcode-cn.com/problems/satisfiability-of-equality-equations 英文原文You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different fo…
原文链接: https://leetcode-cn.com/problems/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: The town judge trusts nobody. Ever…
原文链接: https://leetcode-cn.com/problems/flower-planting-with-no-adjacent 英文原文You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes a bidirectional path between garden xi to garden yi. In each garden, you want …
原文链接: https://leetcode-cn.com/problems/shortest-path-with-alternating-colors 英文原文Consider a directed graph, with nodes labelled 0, 1, ..., n-1. In this graph, each edge is either red or blue, and there could be self-edges or parallel edges. Each [i, …
1 / 3