I recently gave interview at groww for SDE2 role backend. It consists of 3 technical rounds and then HM + HR I guess.
I was given a problem from leetcode: https://leetcode.com/problems/distinct-subsequences/
Gave naive solution using recursion first, then optimised it by introducing memoization. Was asked about time complexity for both the approaches.
Started with intro, then straight to choice of your IDE, asked to design stock broker system which also handles the logic of order matching (buy and sell order), with support partial fulfillments.
Cleared this round, got call from HR next day to schedule next round.
Below are the points which were finalised:
We need to create stock broker application
Requirements:
-> Create user (portfolio)
-> Admin can add stock (we should have role management)
-> User can view portfolio, and remaining balance
-> User can add money to wallet
-> Users can buy and sell stock (We have to do order matching as well) -> FIFO order processing if multiple orders avl with same price, other wise best price
-> User can see datewise order history
-> The order should have a strict price band (for buying/selling any stock) -> +- 20%
-> Order can do partial matching, maintain history of each matching and record the qty matched.
EG:
buying price >= selling price then only matching will happen
seller 1 -> 100 -> qty 10 / 2
seller 2 -> 105 -> qty 5
buyer 1 -> 102 -> qty 8
buyer 2 -> 106 -> 7 qty
order -> 100 -> seller 1 sold 8 qty to buyer 1
There were 2 person in panel, started with intro, was asked to design autosquare off system to reduce risk in intraday trading.
Below was the problem statement give:
You are building an Automated Intraday Risk Management Service for a stock trading platform. The platform receives continuous live price ticks for thousands of stocks, reaching up to millions of updates per second.
To manage risk, the platform needs to automatically ""square off"" (close) a user's intraday positions if the stock price moves by a specific percentage relative to the previous day closing price
Example Triggers:
Square off RELIANCE position if the price price reaches 118 and prev close is 100 and upper circuit is 120
When a percentage-based condition is satisfied, the system must execute a trade to exit the position.
Functional Requirements
The Square-Off Service should support:
Create Risk Rule
Users or administrators can define square-off rules on stocks
Real-Time Evaluation
The system must continuously calculate the percentage change of live ticks against the reference price
Automatic Execution
When the percentage threshold is breached, the system must immediately send a ""Sell"" or ""Cover"" order to the exchange.
Status Notification
Notify the user via push notification or email once the position has been successfully closed.
Non-Functional Requirements
Ultra-Low Latency
The calculation and order execution must happen within milliseconds of the price tick arrival to avoid slippage.
High Scale
Support for 10M+ active positions across the user base.
Handle a throughput of 1M+ price ticks per second.
High Availability & Reliability
The service must be ""always-on"" during market hours; missing a square-off could result in significant financial loss for the user.
Strict Idempotency
The system must ensure a position is squared off exactly once. It must not fire multiple exit orders for the same trigger.
Fault Tolerance
If a node fails, another must immediately take over the evaluation of those specific positions to ensure no risk rules are missed.I gave a solution, but got confused in few things when having deep dives.
My Solution: https://excalidraw.com/#json=br87st9nXz8G38hFjsD5o,djncX0IoHHn6U5xCTfv7nw
Anyone have suggestion or better approach for the solution please do let me know
Rejected in System design round. (Last technical round)