Groww Coding Round Questions With Solutions
Last updated 2026-11-19
Groww coding rounds are commonly described as mixing standard data structure problems with fintech-flavoured ones: stock price arrays, order matching, ledgers and alerts. The eleven practice problems below follow that mix, with the idea, code, complexity and a typical mistake for each.
They are practice problems, not real papers. For design and database questions see Groww interview questions, and for general strategy read how to crack a DSA coding round.
How to approach them
For stock problems, ask whether you may trade several times, hold several shares and how fees work, since each answer changes the algorithm. Use integers for money. Write helper functions so the main logic stays readable in a machine-coding round.
Hiring status
We have no sourced Groww hiring dates, numbers or format details, so none are stated. Use the company's own careers site for current roles, and see how to crack the online assessment for test strategy.
Groww Coding Round Questions With Solutions: questions with worked answers
1 Best time to buy and sell a stock, one transaction.
easyTrack the minimum price so far and the best profit from selling today. One pass, O(n) time, O(1) space. Mistake: sorting, which loses the order that makes buying before selling matter. Return zero if prices only fall.
pythondef max_profit(prices): low, best = float('inf'), 0 for p in prices: low = min(low, p) best = max(best, p - low) return best2 Maximum drawdown of a price series.
mediumThe drawdown at a point is the fall from the highest price so far. Track the running peak and the worst drop from it. O(n). Report it as a fraction of the peak if asked for a percentage. Mistake: comparing the global maximum and minimum, which ignores time order.
pythondef max_drawdown(prices): peak, worst = prices[0], 0.0 for p in prices: peak = max(peak, p) worst = max(worst, (peak - p) / peak) return worst3 Order matching engine with price-time priority (limit orders).
hardUse a max-heap for bids and a min-heap for asks, each ordered by price then by sequence number. For an incoming order, match against the opposite heap while the price crosses, trade at the resting order's price, and rest any remainder. Each order is pushed and popped once: O(log n) per operation. Mistake: using a plain sort per order, which is O(n log n) each time.
pythonimport heapq from itertools import count class Book: def __init__(self): self.bids, self.asks, self.seq = [], [], count() def submit(self, side, price, qty): trades = [] if side == 'B': while qty and self.asks and self.asks[0][0] <= price: p, s, q = heapq.heappop(self.asks) fill = min(qty, q) trades.append((p, fill)) qty -= fill if q > fill: heapq.heappush(self.asks, (p, s, q - fill)) if qty: heapq.heappush(self.bids, (-price, next(self.seq), qty)) else: while qty and self.bids and -self.bids[0][0] >= price: p, s, q = heapq.heappop(self.bids) fill = min(qty, q) trades.append((-p, fill)) qty -= fill if q > fill: heapq.heappush(self.bids, (p, s, q - fill)) if qty: heapq.heappush(self.asks, (price, next(self.seq), qty)) return trades4 Price alerts: report alerts triggered when the price moves from old to new.
mediumKeep alert thresholds in a sorted list. When the price moves from old to new, the triggered thresholds are those between old and new (inclusive of the new price). Find them with bisect and remove the slice. O(log n + k) to find, with O(n) slice deletion in a Python list; a balanced tree or heap per direction avoids it. Mistake: scanning every alert on every tick.
pythonfrom bisect import bisect_left, bisect_right, insort class Alerts: def __init__(self): self.th = [] def add(self, price): insort(self.th, price) def tick(self, old, new): lo, hi = min(old, new), max(old, new) i, j = bisect_left(self.th, lo), bisect_right(self.th, hi) hit = self.th[i:j] del self.th[i:j] return hit5 Next greater price: for each day, how many days until a higher price?
mediumUse a monotonic stack of indices with decreasing prices. When a price exceeds the price at the stack top, pop and set the wait to the index difference. Each index is pushed and popped once: O(n). Mistake: a nested loop, O(n squared). Days with no higher price keep zero.
pythondef days_until_higher(p): ans, st = [0] * len(p), [] for i, x in enumerate(p): while st and p[st[-1]] < x: j = st.pop() ans[j] = i - j st.append(i) return ans6 Volume-weighted average price over a sliding window of trades.
mediumKeep a deque of (price, quantity) trades plus running sums of price times quantity and of quantity. Add the new trade, evict trades older than the window, and VWAP is the first sum divided by the second. O(1) amortised. Mistake: recomputing sums over the whole window for each trade.
pythonfrom collections import deque class VWAP: def __init__(self, window): self.w, self.q, self.pv, self.v = window, deque(), 0, 0 def add(self, t, price, qty): self.q.append((t, price, qty)) self.pv += price * qty self.v += qty while self.q and self.q[0][0] <= t - self.w: _, p, qq = self.q.popleft() self.pv -= p * qq self.v -= qq return self.pv / self.v if self.v else None7 Maximum subarray sum: best contiguous stretch of daily returns.
easyKadane's algorithm: at each element, the best sum ending there is the larger of the element alone and the previous best plus the element. Track the global best. O(n), O(1) space. Mistake: initialising the best at zero, which is wrong when all values are negative.
pythondef max_subarray(a): cur = best = a[0] for x in a[1:]: cur = max(x, cur + x) best = max(best, cur) return bestjavastatic int maxSubarray(int[] a) { int cur = a[0], best = a[0]; for (int i = 1; i < a.length; i++) { cur = Math.max(a[i], cur + a[i]); best = Math.max(best, cur); } return best; }8 Find two transactions that sum to a target amount.
easyScan once with a dictionary from value to index; for each amount check whether the target minus the amount was already seen. O(n) time and space. Mistake: using the same element twice when the target is exactly double the value; checking before inserting avoids it.
pythondef two_sum(a, target): seen = {} for i, x in enumerate(a): if target - x in seen: return seen[target - x], i seen[x] = i return None9 Validate a ledger: every transaction id must have debits equal to credits.
easyGroup entries by transaction id and sum signed amounts (debit positive, credit negative). A transaction is valid when its sum is exactly zero, so use integer minor units. Report the ids with a non-zero sum. O(n).
pythonfrom collections import defaultdict def unbalanced(entries): # entries: (txn_id, 'D' or 'C', amount_in_paise) total = defaultdict(int) for tid, kind, amt in entries: total[tid] += amt if kind == 'D' else -amt return sorted(t for t, s in total.items() if s != 0)10 Idempotent transfer between wallets.
mediumKeep balances and a dictionary of processed request ids to results. If the id exists, return the stored result without changing balances; otherwise validate funds, apply both sides together and store the result. In a real system the check and apply run in one database transaction with a unique constraint on the id. Mistake: applying the debit and failing before the credit.
pythonclass Wallets: def __init__(self, balances): self.bal = dict(balances) self.done = {} def transfer(self, req_id, src, dst, amt): if req_id in self.done: return self.done[req_id] if amt <= 0 or self.bal.get(src, 0) < amt or dst not in self.bal: result = False else: self.bal[src] -= amt self.bal[dst] += amt result = True self.done[req_id] = result return result11 Top K gaining stocks from a stream of (symbol, change) updates.
mediumKeep the latest change per symbol in a dictionary and, when queried, take the K largest with heapq.nlargest. For frequent queries on many symbols, maintain a size-K min-heap with lazy deletion. Query cost O(n log K) with nlargest. Mistake: sorting all symbols on every update.
pythonimport heapq class Gainers: def __init__(self): self.change = {} def update(self, sym, pct): self.change[sym] = pct def top(self, k): return heapq.nlargest(k, self.change.items(), key=lambda t: t[1])
Frequently asked questions
Are Groww coding questions finance-specific?
They are commonly reported as a mix of standard DSA and problems with a trading flavour. No finance knowledge beyond the problem statement is normally needed.
How long is the machine-coding round?
Reports mention around 90 minutes, but confirm with your recruiter since formats change.
Which data structures matter most?
Heaps, hash maps, monotonic stacks and sorted structures are the most useful for these problems.
Can I use Java or Python?
Usually yes. Check the platform for allowed languages.
Related guides
More in Company Interview Questions
- Groww Interview Questions and Answers
- HCLTech Coding Round Questions with Solutions
- HCLTech Interview Questions for Freshers
- Hexaware Coding Round Questions with Solutions
- Hexaware Interview Questions for Freshers
- Honeywell Coding Round Questions with Solutions
- Honeywell Interview Questions and Answers for India Engineering Roles
- HSBC coding round questions with solutions
- HSBC interview questions with answers (technology graduates)
- IBM coding round questions
- IBM interview questions and answers
- Info Edge (Naukri) Interview Questions with Answers