FastPrepBase Unit Conversions
Problems/Base Unit Conversions

Base Unit Conversions

Adobe logoAdobe● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Adobe new grad online assessment. The task was to take a set of conversion rates between units and work out the value of every connected unit compared with a starting unit, by multiplying the rates outward from it.

The report gives no input format, limits or examples. Here, the units are numbered 0 to n - 1, unit 0 is the starting unit, every other unit is reached from it by exactly one chain of forward conversions, and each answer is returned modulo 10^9 + 7 because the products grow very large. We use up to 1000 units and factors up to 10^9.

Our version is about 85% the same as the reported question.

There are n types of units, numbered from 0 to n - 1. You are given a 2D integer array conversions with n - 1 rows. Each row [sourceUnit, targetUnit, conversionFactor] means that one unit of type sourceUnit is worth conversionFactor units of type targetUnit.

Unit 0 is the base unit. Starting from it, you can reach every other unit by following conversions forward, and there is exactly one way to do so for each unit.

Return an array baseUnitConversion of length n, where baseUnitConversion[i] is the number of units of type i that are worth one unit of type 0. These numbers can be very large, so return each one modulo 10^9 + 7.

Function

baseUnitConversions(conversions: int[][]) → int[]

Examples

Example 1

conversions = [[0,1,3],[1,2,4]]return = [1,3,12]
  • Unit 0 is the base, so its value is 1.
  • One unit 0 equals 3 units of type 1.
  • Each unit 1 equals 4 units of type 2, so one unit 0 equals 3 * 4 = 12 units of type 2.

Example 2

conversions = [[2,3,5],[0,2,10],[0,1,2]]return = [1,2,10,50]
  • The conversions are not listed from the base outward: [2, 3, 5] comes before unit 2 is known.
  • From unit 0: unit 2 is 10 and unit 1 is 2.
  • Unit 3 hangs off unit 2: 10 * 5 = 50.
  • The answer is [1, 2, 10, 50].

Example 3

conversions = [[0,1,1000000000],[1,2,1000000000]]return = [1,1000000000,49]
  • Unit 1 is 1000000000, which is below 10^9 + 7, so it stays as is.
  • Unit 2 is 10^18. Since 10^9 is 7 less than 10^9 + 7, the product leaves the same remainder as (-7) * (-7) = 49.
  • The answer is [1, 1000000000, 49].

Constraints

  • 2 <= n <= 1000
  • conversions.length == n - 1
  • conversions[i] == [sourceUnit, targetUnit, conversionFactor]
  • 0 <= sourceUnit, targetUnit < n
  • 1 <= conversionFactor <= 10^9
  • Unit 0 can be converted into every other unit through exactly one chain of forward conversions.

More Adobe Online Assessment questions

  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Top-Funded Villages and ProjectsOA · Seen Aug 2026
  • Count Parent Nodes With a Target SumOA · Seen Aug 2026
  • Largest Binary Number by ConcatenationOA · Seen Aug 2026
  • Count Events by CategoryOA · Seen Aug 2026
  • Graph M-ColoringOA · Seen Aug 2026
  • Hall of Shifting TilesOA · Seen Aug 2026
  • K-th Ancestor Subtree Preorder QueryOA · Seen Aug 2026
  • Maze ReachabilityOA · Seen Aug 2026
  • Minimum Numeric Code TransformationOA · Seen Aug 2026

Similar questions at other companies

  • Maximum Data Transfer TimeMicrosoft · OAMicrosoft interview questions
  • Longest Transfer Time in a Server TreeRippling · OARippling interview questions
  • Special Diameter EndpointsAgoda · OAAgoda interview questions
  • Diameter of an Acyclic Undirected GraphSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • All Nodes Distance K in a Binary TreeAmazon · PHONE SCREEN
  • Tree DiameterQualcomm · PHONE SCREENQualcomm interview questions
  • Frog Position After T SecondsInMobi · PHONE SCREENInMobi interview questions
  • Part 1: The Narrowest KeyScale AI · OAScale AI interview questions
  • Tree Pythagorean TriplesIBM · OAIBM interview questions
  • Minimum Cleaning Robot RunsHSBC · OAHSBC interview questions

Interview reports that mention this question

  • Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int[] baseUnitConversions(int[][] conversions) {
        // Write your code here.
    }
}
Checking account…