There are
ntypes of units indexed from0ton - 1. You are given a 2D integer arrayconversionsof lengthn - 1, whereconversions[i] = [sourceUniti, targetUniti, conversionFactori]. This indicates that a single unit of typesourceUnitiis equivalent toconversionFactoriunits of typetargetUniti.Return an array
baseUnitConversionof lengthn, wherebaseUnitConversion[i]is the number of units of typeiequivalent to a single unit of type 0. Since the answer may be large, return eachbaseUnitConversion[i]modulo109 + 7.
1 | class Solution { |