FastPrepScale Ingredient Quantities

Scale Ingredient Quantities

Upstart logoUpstart● EasyFULLTIMEOA
Learn

Problem statement

Each string in ingredients begins with an integer quantity followed by its unit and ingredient name. Multiply every quantity by people and preserve the rest of each string.

Function

scaleIngredients(ingredients: String[], people: int) → String[]

Examples

Example 1

ingredients = ["100 g flour","50 g water","10 g sugar"]people = 8return = ["800 g flour","400 g water","80 g sugar"]

Each leading quantity is multiplied by 8.

More Upstart problems

See Upstart hiring insights
public String[] scaleIngredients(String[] ingredients, int people) {
  // write your code here
}
ingredients["100 g flour","50 g water","10 g sugar"]
people8
expected["800 g flour", "400 g water", "80 g sugar"]
Checking account…