The Upstart online assessment contained four implementation-oriented coding problems covering string parsing, duplicate removal, anagram detection, and a stateful restaurant simulation. The first three questions were relatively straightforward, while the final problem required carefully tracking arrivals, departures, seating capacity, waiting guests, and whether a customer had already paid earlier in the day.
Interview Details
Question 1 — Adjust Recipe Quantities
Implement adjust_quantities(nb_persons, ingredients). You are given a recipe written for one person and need to scale it for nb_persons. Each ingredient is represented as a string beginning with a positive integer quantity, followed by a space and the ingredient description.
For example:
2 eggs
200 grams of flour
150 grams of sugar
1 liter(s) of milk
2 eggs
200 grams of flour
150 grams of sugar
1 liter(s) of milk
For nb_persons = 3, the result should be:
6 eggs
600 grams of flour
450 grams of sugar
3 liter(s) of milk
6 eggs
600 grams of flour
450 grams of sugar
3 liter(s) of milk
Only the leading quantity should be multiplied. The remainder of the ingredient string should stay unchanged, even if it contains other numeric characters. The order of the ingredients must also be preserved.
Question 2 — Filter Duplicates While Preserving Order
Implement filter_duplicates(data). Given an array, return the same values with duplicates removed while preserving the order of their first appearance. For example [7, 6, 4, 3, 3, 4, 9] should return [7, 6, 4, 3, 9]
The input is guaranteed to be defined. The program reads input from standard input and writes the result to standard
Unlock Full Details
Create a free account to unlock this interview experience report.