You are given an integer
You are also given a 2D integer array conversions of length conversions[i] = [sourceUnit_i, targetUnit_i, conversionFactor_i] indicates that sourceUnit_i is equal to conversionFactor_i units of targetUnit_i.
You are also given a 2D integer array queries, where queries[j] = [unitA_j, unitB_j] asks for the number of units of unitB_j that equal unitA_j.
Return an array of integers representing the answer to each query. Since the answer may be a fractional value or very large, compute the result modulo
Note: The division
is calculated as , where is the modular multiplicative inverse of modulo .
Constraints:
conversions.length
sourceUnit_i, targetUnit_i
conversionFactor_i
queries.length
unitA_j, unitB_j
It is guaranteed that unit
You are given an integer
You are also given a 2D integer array conversions of length conversions[i] = [sourceUnit_i, targetUnit_i, conversionFactor_i] indicates that sourceUnit_i is equal to conversionFactor_i units of targetUnit_i.
You are also given a 2D integer array queries, where queries[j] = [unitA_j, unitB_j] asks for the number of units of unitB_j that equal unitA_j.
Return an array of integers representing the answer to each query. Since the answer may be a fractional value or very large, compute the result modulo
Note: The division
is calculated as , where is the modular multiplicative inverse of modulo .
Constraints:
conversions.length
sourceUnit_i, targetUnit_i
conversionFactor_i
queries.length
unitA_j, unitB_j
It is guaranteed that unit