Fill Tree Values with Adjacent Difference Exactly 1 to Minimize Sum
Given an undirected tree with n nodes (0..n-1), where only some nodes have known values. Assign integer values to all unknown nodes such that for every pair of adjacent nodes the absolute difference o...
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Standard Input
Execution Result:
