FastPrepClient Stock Position Operations
Problems/Client Stock Position Operations

Client Stock Position Operations

Optiver logoOptiver● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Optiver phone screen. The report asks for buy and sell operations in a stock system. Each position is tracked by client, symbol, and quantity. The report does not say what each call returns or what happens when a sale is too big. Here, each good trade returns the new position. A sale of more than you hold is rejected and nothing changes. A position query lets you check the state. The client-symbol position changes match the report.

Process every command in operations in order. Each client starts with a position of zero shares in every symbol.

  • BUY:client:symbol:quantity: add quantity shares to that client-symbol position and output the resulting quantity as a decimal string.
  • SELL:client:symbol:quantity: if the position contains at least quantity shares, subtract them and output the resulting quantity. Otherwise, leave the position unchanged and output REJECTED.
  • POSITION:client:symbol: output the current quantity, or 0 if that position has never been traded.

Return one output for every command. Positions belonging to different clients or symbols are independent.

Function

processStockPositions(operations: String[]) → String[]

Examples

Example 1

operations = ["BUY:alice:AAPL:10","BUY:alice:AAPL:5","SELL:alice:AAPL:8","POSITION:alice:AAPL"]return = ["10","15","7","7"]

Alice's AAPL position grows to 15, then a successful sale reduces it to 7.

Example 2

operations = ["BUY:bob:MSFT:4","SELL:bob:MSFT:5","POSITION:bob:MSFT","POSITION:bob:GOOG"]return = ["4","REJECTED","4","0"]

Bob cannot sell five MSFT shares while holding four, so the rejected sale leaves the position unchanged. An unseen symbol has position zero.

Example 3

operations = ["BUY:alice:NVDA:3","BUY:bob:NVDA:6","SELL:alice:NVDA:3","POSITION:alice:NVDA","POSITION:bob:NVDA"]return = ["3","6","0","0","6"]

Alice's and Bob's NVDA positions are independent. Alice sells her entire position while Bob continues to hold six shares.

Constraints

  • 1 <= operations.length <= 100000
  • Every operation is exactly one of the documented command forms.
  • Each client and symbol is 1 to 24 ASCII letters, digits, underscores, or hyphens.
  • 1 <= quantity <= 1000000000 for BUY and SELL.
  • Every resulting position fits in a signed 64-bit integer.

More Optiver interview questions

  • Multi-Level Inventory Storage SystemOA · PHONE SCREEN · Seen Aug 2026
  • Implement a FIFO QueuePHONE SCREEN · Seen Nov 2025
  • Implement TriePHONE SCREEN · Seen Aug 2025
  • Overheat Prevention ControllerOA · Seen Nov 2026
  • Power Cell BankOA · Seen Nov 2026
  • Count Straight-Line Word Occurrences in a GridOA · Seen Sep 2026
  • Fastest Average Speed over a Rolling KilometerOA · Seen Sep 2026
  • Proportional Momentum Investment StatisticsOA · Seen Aug 2026
  • Count Bounded Share TransactionsOA · Seen Aug 2026
  • Count Ordered Size SequencesOA · Seen Aug 2026

Similar questions at other companies

  • LRU CacheAthenahealth · PHONE SCREEN
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Paged KV Cache AccessNVIDIA · PHONE SCREENNVIDIA interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
  • Mutable Points in a Hash Set and a ListMillennium · PHONE SCREENMillennium interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions

Optiver interview experiences

  • Optiver SWE Intern OA: CPU Temperature Simulation: 1 Experience
  • Optiver Trading Intern Market-Making Games: 1 Experience
  • Optiver Quant Trader Intern Technical Interview: 1 Experience
  • Optiver SWE Intern System Design Interview: 15 Experiences
All Optiver interview questionsSee Optiver hiring insights
Saved
class Solution {
    public String[] processStockPositions(String[] operations) {
      // write your code here
    }
}
Checking account…