Autocoder

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. 1

    Best time to buy and sell a stock, one transaction.

    easy

    Track 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.

    python
    def max_profit(prices):
        low, best = float('inf'), 0
        for p in prices:
            low = min(low, p)
            best = max(best, p - low)
        return best
  2. 2

    Maximum drawdown of a price series.

    medium

    The 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.

    python
    def max_drawdown(prices):
        peak, worst = prices[0], 0.0
        for p in prices:
            peak = max(peak, p)
            worst = max(worst, (peak - p) / peak)
        return worst
  3. 3

    Order matching engine with price-time priority (limit orders).

    hard

    Use 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.

    python
    import 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 trades
  4. 4

    Price alerts: report alerts triggered when the price moves from old to new.

    medium

    Keep 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.

    python
    from 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 hit
  5. 5

    Next greater price: for each day, how many days until a higher price?

    medium

    Use 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.

    python
    def 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 ans
  6. 6

    Volume-weighted average price over a sliding window of trades.

    medium

    Keep 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.

    python
    from 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 None
  7. 7

    Maximum subarray sum: best contiguous stretch of daily returns.

    easy

    Kadane'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.

    python
    def max_subarray(a):
        cur = best = a[0]
        for x in a[1:]:
            cur = max(x, cur + x)
            best = max(best, cur)
        return best
    java
    static 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. 8

    Find two transactions that sum to a target amount.

    easy

    Scan 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.

    python
    def 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 None
  9. 9

    Validate a ledger: every transaction id must have debits equal to credits.

    easy

    Group 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).

    python
    from 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. 10

    Idempotent transfer between wallets.

    medium

    Keep 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.

    python
    class 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 result
  11. 11

    Top K gaining stocks from a stream of (symbol, change) updates.

    medium

    Keep 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.

    python
    import 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

See all in this section