Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Roblox interview question

Choose production quantities that maximize profit under raw material limits

Company:
Roblox
Round:
Technical
Type:
Coding
Difficulty:
Medium
Reported:
June 2, 2026

Problem

A factory can make P kinds of products from M kinds of raw material. Making one unit of product p consumes recipes[p][m] units of material m and earns profits[p]. You have stock[m] units of each material. Decide how many whole units of each product to make so that total material use never exceeds the stock, and return the maximum total profit.

The interviewer also asks how you would plan quickly by hand in a timed planning exercise.

Example 1

Input: recipes = [[2, 1], [1, 2]], profits = [3, 4], stock = [8, 7]
Output: 17

Make 3 units of product 0 and 2 of product 1: materials used are 8 and 7, profit 9 + 8.

Example 2

Input: recipes = [[3], [2]], profits = [5, 3], stock = [4]
Output: 6

Product 0 has the better profit per unit of material, but two units of product 1 use the stock fully and earn more.

Constraints

  • 1 <= P <= 6, 1 <= M <= 3
  • 0 <= recipes[p][m] <= 10, each recipe uses at least one material
  • 0 <= stock[m] <= 20, 1 <= profits[p] <= 100

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern