Reported July 2026
Upstartstring

Scale Ingredient Quantities

Reported by candidates from Upstart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Upstart OA. Under 2s to a working solution.
Founder's read

The data structure this Upstart problem hinges on is plain old strings, and the whole thing is a parsing exercise. It was reported in July 2026. Each ingredient line starts with an integer, then a unit, then a name. You multiply the integer by people and keep everything else exactly as it was. No graph, no DP, no clever trick. The risk is sloppy string handling when your brain expects something harder. If you blank on the split logic during the OA, StealthCoder runs invisibly on your desktop and can hand you a clean solution. Most people won't need it here.

The problem

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 = 8
return = ["800 g flour","400 g water","80 g sugar"]
Each leading quantity is multiplied by 8.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is string parsing. For each entry, find the first space, take everything before it as the quantity, parse it to an int, multiply by people, then concatenate the result with the remainder of the string starting at that space. Don't split on every space and rejoin, because that can mangle spacing in the unit or name. Use indexOf on the first space and substring instead. The common pitfalls are overflow if quantities and people are large (use a 64-bit integer if the language defaults to 32), and assuming the quantity is always a single digit. Also watch for an empty array, which should return an empty array. Time is O(total characters) and space is O(total characters) for the output. If the format throws you in the live OA, StealthCoder is the hedge that reads the prompt and gives you working code fast.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Scale Ingredient Quantities cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Upstart's OA.

Upstart reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Scale Ingredient Quantities FAQ

How hard is the Scale Ingredient Quantities problem really?+

Easy. It's string parsing with one multiplication. The difficulty is only in being careful: find the leading integer, multiply it, and keep the rest of the string untouched. If you've ever split a string on the first space, you can finish this quickly.

What's the trick to solving it?+

Split only at the first space. Parse the part before it as an integer, multiply by people, and append the original remainder, including that space. Avoid splitting on all spaces and rejoining, since that risks changing the unit or ingredient name formatting.

Do I need to worry about overflow?+

Possibly. The statement says integer quantities and an integer people count, so the product could exceed 32-bit range with large inputs. Use a 64-bit type like long in Java or rely on Python's big ints. It costs nothing and removes a hidden failure case.

What edge cases should I test?+

Test an empty ingredients array, people equal to 1, a multi-digit quantity like 100, and names containing multiple words such as olive oil. Also confirm the output preserves the unit and name exactly. These cover nearly every way a naive solution breaks.

How do I prepare for this in 48 hours?+

Practice first-space parsing in your main language: indexOf, substring, and int conversion. Write this solution once from memory, then run it on two or three custom examples. Spend the rest of your time on harder patterns, since this one is a warm-up level string task.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Upstart.

OA at Upstart?
Invisible during screen share
Get it