FastPrepInventory Revenue Across Supply, Sell, and Return Logs
Problems/Inventory Revenue Across Supply, Sell, and Return Logs

Inventory Revenue Across Supply, Sell, and Return Logs

ZipRecruiter logoZipRecruiter● HardFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three ZipRecruiter OA reports describe supply, selling the cheapest first, return with the original and new price, and one revenue per sell. One source has no employment label, so FULLTIME and NEW GRAD are both kept. We supplied a String[][] input.

You are given a list of operations. Each operation is a list of strings. Process the operations in order. Each one has one of these forms:

  • [supply,item,count,price]: add count units of the item to stock, each with this unit price.
  • [sell,item,count]: sell count units of the item. Always sell the cheapest units first. The stock always has enough units for the sale. The sale's revenue is the total price of the units sold.
  • [return,item,count,originalSalePrice,newPrice]: count units come back. Put them back in stock with unit price newPrice. The value originalSalePrice names the earlier sale lot the units came from. A return gives no output.

Return a list with the revenue of each sell operation, in the order the sells happen.

Function

inventoryRevenue(operations: String[][]) → long[]

Examples

Example 1

operations = [["supply","apple","2","5"],["supply","apple","1","3"],["sell","apple","2"],["return","apple","1","5","4"],["sell","apple","2"]]return = [8,9]

The first sale takes the two cheapest units, priced 3 and 5, so its revenue is their sum. The return puts one unit back in stock at its new price. The second sale takes the units priced 4 and 5, so its revenue is their sum. The output lists both revenues in order.

Example 2

operations = [["supply","x","1","7"],["sell","x","1"]]return = [7]

The one supplied unit is sold.

Constraints

  • 1 <= operations.length <= 100000
  • Counts and prices are positive integers.

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • In-Memory File SystemAirbnb · OAAirbnb interview questions
  • Power Cell BankOptiver · OAOptiver interview questions
  • Split Tender Part 4 - RefundsStripe · OA · PHONE SCREENStripe interview questions
  • LFU CacheSnowflake · OA · ONSITE INTERVIEWSnowflake interview questions
  • Arithmetic Triplets After QueriesCapital One · OACapital One interview questions
  • Named Async Task SchedulerAirwallex · OAAirwallex interview questions
  • LFU CacheArista Networks · OAArista Networks interview questions
  • Weighted LFU CacheMicrosoft · OAMicrosoft interview questions
  • Task Management SystemCoinbase · OACoinbase interview questions
  • Task Management SystemAnthropic · OAAnthropic interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long[] inventoryRevenue(String[][] operations) {
        // Write your code here.
    }

}
Checking account…