Menu
CoddyTech

最终挑战 #2

Coddy 拓扑排序:图算法 课程的第 9 课,共 9 课。

challenge icon

挑战

中等

再来一道挑战,使用拓扑排序。

编写一个名为 longestPath 的函数,它接收 n 和 DAG(有向无环图)的扁平 edges 数组,并返回图中最长路径上的边数。

例如,在链 0->1->2->3 中,最长路径有 3 条边。

亲手试试

#include <stdlib.h>

int longestPath(int n, int* edges, int edges_size) {
    // 在这里编写代码
    return 0;
}

拓扑排序:图算法中的所有课

自己练习: C 在线编译器