Z02
Longest Overtime Work Chain
Problem Statement & Objective
Identify the longest consecutive dependency chain in an organizational task tree.
Function Signature (Python)
longest_overtime_work_chain(n: int, lines: list[list[int]]) -> intInput & Output Contract
Output Rule:En uzun basit yolun toplam ağırlığı. n <= 1 ise 0.
System Constraints
1 <= n <= 10^5
hatlar.length == n - 1 (n=1 ise boş)
1 <= uzunluk <= 10^4
Girdi her zaman geçerli bir bağlı ağaçtır.Example Execution Walkthrough
n = 4, hatlar = [[0,1,3], [1,2,4], [2,3,5]]
şebeke: 0 --3-- 1 --4-- 2 --5-- 3
en uzun rota: 0 -> 3, uzunluk 3 + 4 + 5 = 12
cevap: 12Example Test Scenarios (3)
Example 1
Input:
[4,[[0,1,3],[1,2,4],[2,3,5]]]Expected Output:
12Example 2: 3 Düğüm Doğrusal Hat (15)
Input:
[3,[[0,1,5],[1,2,10]]]Expected Output:
15Example 3: V Şekilli Hat (10)
Input:
[3,[[0,1,4],[0,2,6]]]Expected Output:
10