If we igone the -1 and created a directed graph with 1 as a root. We just need to check is there any cycle ion the graph or not. If we found cycle then the answer is "Not Valid" otherwise "Valid"

Statistics

82% Solution Ratio
alamkhanEarliest, Dec '20
nusuBotFastest, 0.1s
insane_curiousLightest, 6.0 MB
Deshi_TouristShortest, 1042B
Toph uses cookies. By continuing you agree to our Cookie Policy.