Autocoder

ZS Associates Coding and Case Logic Questions

Last updated 2026-11-19

Consulting-analytics screens mix several skills in one sitting: quick business arithmetic, logical reasoning, data interpretation and, for technology and analytics tracks, SQL and coding. This page gives twelve practice problems across those skills, with worked solutions, Python and SQL code where it helps, and the mistakes that lose marks.

They are practice problems in that style, not copies of any test. Use them with ZS Associates interview questions, how to crack the SQL interview and the DSA coding round guide.

Languages herePython and SQL
Also coveredBusiness maths, logic puzzles, data interpretation
LevelEasy to medium

How to approach these problems

For arithmetic, convert percentages to multipliers (a 20 percent rise is x1.2) and keep a running check on magnitude. For logic puzzles, list constraints and eliminate. For SQL on sales data, define the grain and the denominator before writing a query. For code, test on the smallest example you can verify by hand.

Hiring status

We hold no sourced facts about ZS Associates tests, drives, openings or cutoffs, so none are stated. Use the firm's own careers site for current information.

ZS Associates Coding and Case Logic Questions: questions with worked answers

  1. 1

    Two successive changes: a price rises 25 percent and then falls 20 percent. What is the net change, and what single change reverses it?

    easy

    Multiply the factors: 1.25 x 0.8 = 1.00, so there is no net change. Always multiply, not add, percentage changes. For a reversal question, if the price rose by 25 percent, a fall of 25/125 = 20 percent returns it to the original price, which is why the two cancel here.

  2. 2

    Weighted average: product A is 60 percent of volume at Rs 100 and B is 40 percent at Rs 150. What is the average price, and what happens if A's price rises 10 percent?

    easy

    The average price is 0.6 x 100 + 0.4 x 150 = 60 + 60 = Rs 120. If A rises to Rs 110, the average is 0.6 x 110 + 0.4 x 150 = 66 + 60 = Rs 126, an increase of 5 percent, half of A's 10 percent because A is only 60 percent of the volume and B does not change. Mistake: averaging the two prices without weights, which gives Rs 125.

    python
    vol = {"A": 0.6, "B": 0.4}
    price = {"A": 100, "B": 150}
    avg = sum(vol[k] * price[k] for k in vol)
    price["A"] = 110
    avg2 = sum(vol[k] * price[k] for k in vol)
    print(avg, avg2, round((avg2 / avg - 1) * 100, 1))   # 120.0 126.0 5.0
  3. 3

    Logic: five runners finish a race. E finishes first, C last, A before B, and B before D. What is the order?

    medium

    E is first and C is last, so the middle three positions hold A, B and D. A is before B and B is before D, so the order of those three is A, B, D. The full order is E, A, B, D, C. Check each condition against it. Constraint puzzles are solved by fixing the extremes first and then chaining the remaining relations.

  4. 4

    Logic: you meet two people, one always lies and one always tells the truth. You may ask one question to find which door is safe. What do you ask?

    medium

    Ask either person: "If I asked the other person which door is safe, what would they say?" and then choose the opposite door. If you ask the truth-teller, he truthfully reports the liar's false answer; if you ask the liar, he lies about the truth-teller's true answer. Either way you hear the wrong door, so take the other one.

  5. 5

    Data interpretation: a company's revenue is Rs 80, 100, 130 and 156 crore over four years. Which year had the highest growth rate, and what is the overall CAGR?

    medium

    Year-on-year growth: 100/80 = 25 percent, 130/100 = 30 percent, 156/130 = 20 percent. The highest rate is in year three (30 percent), though the largest absolute rise is also in year three (Rs 30 crore). CAGR over three intervals is (156 / 80)^(1/3) - 1 = 1.95^(0.3333) - 1, about 24.9 percent. Mistake: counting four periods instead of three intervals.

    python
    rev = [80, 100, 130, 156]
    growth = [round(b / a - 1, 3) for a, b in zip(rev, rev[1:])]
    cagr = (rev[-1] / rev[0]) ** (1 / (len(rev) - 1)) - 1
    print(growth, round(cagr, 3))   # [0.25, 0.3, 0.2] 0.249
  6. 6

    Python: given quotas and sales per representative, compute attainment (sales divided by quota) and list representatives above 100 percent, best first.

    medium

    Compute the ratio per representative, filter above 1.0 and sort descending. Guard against a zero quota. O(n log n). Mistake: integer division in older Python versions, and sorting by sales instead of attainment, which favours large territories.

    python
    reps = {"Asha": (120, 100), "Ravi": (90, 100), "Meera": (200, 150), "Kabir": (50, 0)}
    att = {n: s / q for n, (s, q) in reps.items() if q > 0}
    print(sorted(((n, round(a, 2)) for n, a in att.items() if a > 1), key=lambda x: -x[1]))
    # [('Meera', 1.33), ('Asha', 1.2)]
  7. 7

    SQL: representatives who met or exceeded quota in all four quarters of 2026.

    medium

    Group by representative, require exactly four quarter rows, and require that the number of quarters meeting quota also equals four. Conditional counting inside HAVING does it in one pass. Mistake: filtering rows to sales >= quota in WHERE, which drops failing quarters and lets anyone with a single good quarter through.

    sql
    SELECT rep_id
    FROM quarterly_sales
    WHERE year = 2026
    GROUP BY rep_id
    HAVING COUNT(*) = 4
       AND SUM(CASE WHEN sales >= quota THEN 1 ELSE 0 END) = 4;
  8. 8

    SQL: the top 10 percent of representatives by sales within each territory.

    medium

    NTILE(10) splits each territory's representatives into ten buckets ordered by sales; bucket 1 is the top tenth. NTILE sizes differ by at most one when the count is not divisible by 10, so territories with fewer than ten representatives still give each rep a bucket, and bucket 1 holds the first. Mistake: forgetting PARTITION BY territory, which ranks across the whole company.

    sql
    SELECT rep_id, territory, sales
    FROM (
      SELECT rep_id, territory, sales,
             NTILE(10) OVER (PARTITION BY territory ORDER BY sales DESC) AS decile
      FROM rep_sales
    ) t
    WHERE decile = 1;
  9. 9

    Python: schedule the maximum number of non-overlapping client meetings from a list of (start, end) times.

    medium

    Greedy by earliest finish time: sort by end, and take a meeting whenever its start is at or after the end of the last chosen one. This is provably optimal because finishing earliest leaves the most room. O(n log n). Mistake: sorting by start time or by shortest duration, both of which have counterexamples.

    python
    def max_meetings(meetings):
        count, last_end = 0, float('-inf')
        for s, e in sorted(meetings, key=lambda m: m[1]):
            if s >= last_end:
                count += 1
                last_end = e
        return count
    
    print(max_meetings([(1, 4), (3, 5), (0, 6), (5, 7), (8, 9), (5, 9)]))  # 3
  10. 10

    Python: the maximum total sales over any k consecutive months.

    medium

    Sliding window: compute the sum of the first k months, then slide by adding the new month and subtracting the one leaving. O(n) time, O(1) space. Mistake: recomputing each window sum, which is O(nk), and not handling k greater than the number of months.

    python
    def best_window(a, k):
        if k > len(a):
            return None
        cur = sum(a[:k])
        best = cur
        for i in range(k, len(a)):
            cur += a[i] - a[i - k]
            best = max(best, cur)
        return best
    
    print(best_window([5, 1, 8, 2, 9, 3], 3))  # 19
  11. 11

    Python: in a sorted list of cumulative monthly sales, find the first month where cumulative sales exceed a target.

    medium

    Binary search for the insertion point to the right of the target: bisect_right returns the first index with a value strictly greater than the target. O(log n). Return -1 if the index equals the length. Mistake: using bisect_left, which finds the first value greater than or equal, and treating "reached" and "exceeded" as the same.

    python
    from bisect import bisect_right
    
    def first_exceeding(cum, target):
        i = bisect_right(cum, target)
        return i if i < len(cum) else -1
    
    print(first_exceeding([10, 25, 25, 40, 60], 25))  # 3
  12. 12

    Case-logic in code: simulate expected profit for a launch with 40 percent chance of Rs 20 crore and 60 percent chance of Rs 2 crore, at cost Rs 5 crore, and find the break-even probability.

    hard

    The expected value is p x 20 + (1 - p) x 2 minus 5. Setting it to zero gives 18p + 2 = 5, so p = 3/18, about 0.167. At p = 0.4 the expected gain is 0.4 x 20 + 0.6 x 2 - 5 = Rs 4.2 crore. A simulation should agree with the formula for large samples, which is a useful check of your algebra. Mistake: stating the expected value and ignoring the 60 percent chance of a loss, which a decision maker needs to see.

    python
    import random
    
    def expected(p):
        return p * 20 + (1 - p) * 2 - 5
    
    print(round(expected(0.4), 2), round(3 / 18, 3))   # 4.2 0.167
    
    random.seed(1)
    sims = [(20 if random.random() < 0.4 else 2) - 5 for _ in range(100000)]
    print(round(sum(sims) / len(sims), 1))             # about 4.2

Frequently asked questions

What is tested in ZS style written rounds?

General guidance for consulting-analytics firms: quantitative aptitude, logical reasoning, data interpretation and, for technology tracks, coding or SQL. We hold no sourced description of the current test, so confirm with your recruiter.

How do I speed up business arithmetic?

Practise percentage multipliers, weighted averages and CAGR until they are automatic, and round to two significant figures during estimates.

Which SQL topics matter?

Joins, group by with having, conditional aggregation, window functions and NTILE or RANK for top-n questions.

Are these real ZS test questions?

No, they are practice problems in the style of consulting-analytics screens, not copies of any test.

Do I need to know a lot of programming?

It depends on the track. Basic Python, arrays and a few greedy and sliding-window patterns cover most practice problems of this kind.

Related guides

More in Company Interview Questions

See all in this section