Return the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.
{
"colors": "abaca",
"edges": [
[
0,
1
],
[
0,
2
],
[
2,
3
],
[
3,
4
]
]
}3{
"colors": "a",
"edges": [
[
0,
0
]
]
}-1{
"colors": "hhqhuq",
"edges": [
[
0,
1
],
[
0,
2
],
[
2,
3
],
[
3,
4
],
[
3,
5
],
[
5,
1
]
]
}3Sign in to Run Code and Submit