FastPrepInventory Discount Tracker
Problems/Inventory Discount Tracker

Inventory Discount Tracker

Roblox logoRoblox● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Roblox intern online assessment on CodeSignal. The task is to read a store's price list and a log of sales and limited discounts, then return the total money earned.

The report says it was this exact question and includes a screenshot. The report does not give a limit on the total, so here the total always fits in a 32-bit integer.

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

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing that this question appeared in an interview on September 7, 2026! ٩(ˊᗜˋ*)و ♡ 🧡

Your task is to implement a simplified inventory tracker system for a large retail store. You are given a price list pricelist that describes the current market price for each item, and a transaction log logs where each record contains information about one of three types of transactions: sell, discount_start, or discount_end. The tracker should process all transactions and return the total revenue from all sales.

Each element in the price list follows this format: "<item_name>: <price>", which represents that <item_name> can be sold at the price of <price>.

Transactions are provided in the following format:

  • "sell <item_name>, <count>": the store sells <count> units of <item_name>.
  • "discount_start <item_name>, <discount_amount>, <max_count>": the store announces a discount, and now sells <item_name> at the price of price - <discount_amount>. However, only <max_count> units can be sold at the discounted price, and all additional units are sold at the original price. <max_count> can be at most 100, and there can only be one discount for each item at any time.
  • "discount_end <item_name>": the store announces the end of the discount for <item_name>. It is guaranteed that the item has a discount at this point.

Note: All transactions are sorted chronologically.

Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(logs.length2 * pricelist.length) will fit within the execution time limit.

Function

solution(pricelist: String[], logs: String[]) → int

Examples

Example 1

pricelist = ["item1: 100", "item2: 200"]logs = ["sell item1, 1", "sell item1, 2", "sell item2, 2", "discount_start item2, 40, 1", "sell item2, 2", "sell item1, 1", "discount_end item2", "sell item2, 1"]return = 1360

The transactions are processed in chronological order:

  • "sell item1, 1": revenue is 1 * 100 = 100.
  • "sell item1, 2": revenue is 2 * 100 = 200.
  • "sell item2, 2": revenue is 2 * 200 = 400.
  • "discount_start item2, 40, 1": item2 now has a discount of 40 for at most 1 unit.
  • "sell item2, 2": one unit is sold at 200 - 40 = 160, and the other unit is sold at the original price of 200, so revenue is 160 + 200 = 360.
  • "sell item1, 1": revenue is 1 * 100 = 100.
  • "discount_end item2": the discount for item2 ends.
  • "sell item2, 1": revenue is 1 * 200 = 200.

The total revenue is 100 + 200 + 400 + 360 + 100 + 200 = 1360.

Constraints

  • 1 ≤ pricelist.length ≤ 100
  • Each element of pricelist is a string in the format "<item_name>: <price>" where item_name consists of alphanumeric characters and price is a positive integer.
  • All item names in pricelist are unique.
  • 1 ≤ logs.length ≤ 1000
  • Each element of logs is one of the following formats:
    • "sell <item_name>, <count>" where 1 ≤ count ≤ 1000
    • "discount_start <item_name>, <discount_amount>, <max_count>" where discount_amount is a positive integer and 1 ≤ max_count ≤ 100
    • "discount_end <item_name>"
  • All item_name values referenced in logs exist in pricelist.
  • There can be at most one active discount per item at any time.
  • discount_end <item_name> is only issued when item_name currently has an active discount.
  • All transactions in logs are sorted chronologically.
  • A discount_start for an item will not be issued if that item already has an active discount.
  • The total revenue fits in a 32-bit signed integer.

More Roblox Online Assessment questions

  • Centered Block Placement QueriesOA · Seen Oct 2026
  • Robot Navigation Around LasersOA · Seen Oct 2026
  • Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
  • Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
  • Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
  • Track Received Byte RangesOA · Seen Sep 2026
  • Break a PalindromeOA · Seen Jun 2026
  • Count Pairs Differing in One DigitOA · Seen Oct 2025
  • Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
  • Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025

Similar questions at other companies

  • Split Tender Part 2 - Expiration DatesStripe · OAStripe interview questions
  • Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Segmented Durable Key-Value StoreOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Device Registry OperationsOnePay · PHONE SCREENOnePay interview questions
  • Server Log Summary and Minute AnomaliesNinjaTrader · PHONE SCREEN
  • Merge JSON Array FieldsTesla · PHONE SCREENTesla interview questions
  • Dictionary Records to an Editable XML TreeSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
  • JSON Identity VerificationKikoff · PHONE SCREENKikoff interview questions
  • Organization Reputation After Employee DeparturesHSBC · OAHSBC interview questions

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
  • Roblox New Grad Games and BQ: 25 Experiences (Part 3 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int solution(String[] pricelist, String[] logs) {
      // write your code here
    }
}
Checking account…