3535. Unit Conversion II
ArrayMathDepth-First SearchBreadth-First SearchGraph Theory
Hints
Hint 1
Using a dfs, compute an array
fromRoot such that fromRoot[a] is the number of units of type a equivalent to a single unit of type 0.Hint 2
answer[i] = fromRoot[unitAi]-1 * fromRoot[unitBi]Preparing judge…