1857.largest-color-value-in-a-directed-graph.pdf
92.3 KB
leetcode.com 2023-04-09
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#hash_table #dynamic_programming #graph #topological_sort #memoization #counting
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#hash_table #dynamic_programming #graph #topological_sort #memoization #counting
leetcode.com 2023-06-18
🔴2328.number-of-increasing-paths-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort #memoization #array #dynamic_programming #matrix
🔴2328.number-of-increasing-paths-in-a-grid
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort #memoization #array #dynamic_programming #matrix
Telegraph
number-of-increasing-paths-in-a-grid
You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions. Return the number of strictly increasing paths in the grid such that you can start from any cell and end at any cell. Since the answer may…
leetcode.com 2023-07-12
🟡802.find-eventual-safe-states
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🟡802.find-eventual-safe-states
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
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 nodes adjacent to node i, meaning there is an edge from node i to each node in…
leetcode.com 2023-07-13
🟡207.course-schedule
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🟡207.course-schedule
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
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 course bi first if you want to take course ai.
leetcode.cn 2023-07-28
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
Telegraph
parallel-courses-iii
给你一个整数 n ,表示有 n 节课,课程编号从 1 到 n 。同时给你一个二维整数数组 relations ,其中 relations[j] = [prevCoursej, nextCoursej] ,表示课程 prevCoursej 必须在课程 nextCoursej 之前 完成(先修课的关系)。同时给你一个下标从 0 开始的整数数组 time ,其中 time[i] 表示完成第 (i+1) 门课程需要花费的 月份 数。 请你根据以下规则算出完成所有课程所需要的 最少 月份数:
leetcode.com 2023-08-20
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🔴1203.sort-items-by-groups-respecting-dependencies
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
sort-items-by-groups-respecting-dependencies
There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belongs to no group. The items and the groups are zero indexed. A group can have no item belonging…
leetcode.com 2023-10-18
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
🔴2050.parallel-courses-iii
🏷️ Tags
#graph #topological_sort #array #dynamic_programming
Telegraph
parallel-courses-iii
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej…
leetcode.cn 2023-11-01
🔴2127.maximum-employees-to-be-invited-to-a-meeting
🏷️ Tags
#depth_first_search #graph #topological_sort
🔴2127.maximum-employees-to-be-invited-to-a-meeting
🏷️ Tags
#depth_first_search #graph #topological_sort
Telegraph
maximum-employees-to-be-invited-to-a-meeting
一个公司准备组织一场会议,邀请名单上有 n 位员工。公司准备了一张 圆形 的桌子,可以坐下 任意数目 的员工。 员工编号为 0 到 n - 1 。每位员工都有一位 喜欢 的员工,每位员工 当且仅当 他被安排在喜欢员工的旁边,他才会参加会议。每位员工喜欢的员工 不会 是他自己。 给你一个下标从 0 开始的整数数组 favorite ,其中 favorite[i] 表示第 i 位员工喜欢的员工。请你返回参加会议的 最多员工数目 。 示例 1: 输入:favorite = [2,2,1,2] 输出:3 解释:…
leetcode.com 2025-03-21
🟡2115.find-all-possible-recipes-from-given-supplies
🏷️ Tags
#graph #topological_sort #array #hash_table #string
🟡2115.find-all-possible-recipes-from-given-supplies
🏷️ Tags
#graph #topological_sort #array #hash_table #string
Telegraph
find-all-possible-recipes-from-given-supplies
You have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name recipes[i], and you can create it if you have all the needed ingredients from ingredients[i]. A recipe can…
leetcode.cn 2025-03-29
🔴2360.longest-cycle-in-a-graph
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
🔴2360.longest-cycle-in-a-graph
🏷️ Tags
#depth_first_search #breadth_first_search #graph #topological_sort
Telegraph
longest-cycle-in-a-graph
给你一个 n 个节点的 有向图 ,节点编号为 0 到 n - 1 ,其中每个节点 至多 有一条出边。 图用一个大小为 n 下标从 0 开始的数组 edges 表示,节点 i 到节点 edges[i] 之间有一条有向边。如果节点 i 没有出边,那么 edges[i] == -1 。 请你返回图中的 最长 环,如果没有任何环,请返回 -1 。 一个环指的是起点和终点是 同一个 节点的路径。 示例 1: 输入:edges = [3,3,4,2,3] 输出去:3 解释:图中的最长环是:2 -> 4 -> 3…
leetcode.cn 2025-05-26
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#graph #topological_sort #memoization #hash_table #dynamic_programming #counting
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#graph #topological_sort #memoization #hash_table #dynamic_programming #counting
Telegraph
largest-color-value-in-a-directed-graph
给你一个 有向图 ,它含有 n 个节点和 m 条边。节点编号从 0 到 n - 1 。 给你一个字符串 colors ,其中 colors[i] 是小写英文字母,表示图中第 i 个节点的 颜色 (下标从 0 开始)。同时给你一个二维数组 edges ,其中 edges[j] = [aj, bj] 表示从节点 aj 到节点 bj 有一条 有向边 。 图中一条有效 路径 是一个点序列 x1 -> x2 -> x3 -> ... -> xk ,对于所有 1 <= i < k ,从 xi 到 xi+1 在图中有一条有向边。路径的…
leetcode.com 2025-05-26
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#graph #topological_sort #memoization #hash_table #dynamic_programming #counting
🔴1857.largest-color-value-in-a-directed-graph
🏷️ Tags
#graph #topological_sort #memoization #hash_table #dynamic_programming #counting
Telegraph
largest-color-value-in-a-directed-graph
There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given…