ClearTax Coding Round Questions
Last updated 2026-11-19
A tax product turns up practical coding problems: computing tax over progressive slabs, rounding money correctly, validating identifiers, merging date ranges to count days, spotting duplicate transactions and reconciling ledgers. This page works through twelve practice problems of that kind with solutions in Python and SQL, complexity and the mistakes that lose marks.
The slab figures below are illustrative numbers invented for practice, not current tax law. These are practice problems in the style of such assessments, not copies of any test. Use them with ClearTax interview questions and the DSA coding round guide.
| Languages here | Python and SQL |
|---|---|
| Themes | Money, validation, intervals, hashing, DP, SQL funnels |
| Level | Easy to hard |
How to approach these problems
For anything involving money, use integers or Decimal and say so. Write boundary cases first (income exactly at a slab limit, zero, negative). For text validation, define the format before the regular expression. For records, ask what counts as the same transaction before coding the comparison.
Hiring status
We hold no sourced facts about ClearTax tests, drives, openings or cutoffs, so none are stated. Use the company's own careers site for current information.
ClearTax Coding Round Questions: questions with worked answers
1 Progressive slab tax (illustrative slabs): nil up to 3,00,000; 5 percent from 3,00,000 to 7,00,000; 10 percent from 7,00,000 to 10,00,000; 20 percent above 10,00,000. Compute the tax for an income.
easyWalk the slabs, taxing only the part of income inside each band: min(income, upper) minus lower, times the rate. For 12,00,000: 4,00,000 x 5% = 20,000, plus 3,00,000 x 10% = 30,000, plus 2,00,000 x 20% = 40,000, total 90,000. O(number of slabs). Mistake: applying the top rate to the whole income instead of the marginal part. Use integers (rupees) or Decimal for amounts with paise.
pythonSLABS = [(0, 300_000, 0), (300_000, 700_000, 5), (700_000, 1_000_000, 10), (1_000_000, None, 20)] def tax(income): total = 0 for lo, hi, pct in SLABS: upper = income if hi is None else min(income, hi) if upper > lo: total += (upper - lo) * pct // 100 return total print(tax(1_200_000)) # 900002 Round a tax amount to the nearest ten rupees, with halves rounding up, without float error.
easyUse Decimal with quantize to an exponent of 1E1 and ROUND_HALF_UP, since Python's built-in round uses banker's rounding (halves go to the even neighbour) and floats cannot represent most decimals exactly. For integer rupees, (x + 5) // 10 * 10 does half-up for non-negative amounts. Mistake: round(x, -1), which gives round(15, -1) = 20 but round(25, -1) = 20, not 30.
pythonfrom decimal import Decimal, ROUND_HALF_UP def round_to_ten(x): return Decimal(x).quantize(Decimal("1E1"), rounding=ROUND_HALF_UP) print(round_to_ten("12345"), round_to_ten("12344.99")) # 1.235E+4 1.234E+4 print((12345 + 5) // 10 * 10) # 123503 Validate a PAN-style identifier: five uppercase letters, four digits, one uppercase letter.
easyA full-match regular expression states the format exactly: [A-Z]{5}[0-9]{4}[A-Z]. Use fullmatch (or anchors) so extra characters fail, and normalise case and whitespace before checking if the input is user-typed. O(length). Mistake: using search without anchors, which accepts a valid pattern inside a longer string. A format check does not prove the number belongs to anyone; that needs an official verification service.
pythonimport re PAN = re.compile(r"[A-Z]{5}[0-9]{4}[A-Z]") def valid_pan(s): return bool(PAN.fullmatch(s.strip().upper())) print(valid_pan("abcde1234f"), valid_pan("ABCDE12345")) # True False4 Mask a 12-digit identity number so only the last four digits show.
easyStrip separators, check the length, and replace all but the last four digits. O(length). Mistake: logging the full value before masking, which defeats the purpose; mask at the boundary where data enters logs and UIs.
pythondef mask(num): d = "".join(ch for ch in num if ch.isdigit()) if len(d) != 12: raise ValueError("expected 12 digits") return "XXXX XXXX " + d[-4:] print(mask("1234 5678 9012")) # XXXX XXXX 90125 Count the total days of residence from several overlapping stay periods, counting each day once.
mediumConvert dates to ordinals, sort the periods, merge overlaps, and sum the length of each merged period (end minus start plus one for inclusive days). O(n log n). For Apr 1 to Jun 30 and Jun 15 to Aug 31, the union is Apr 1 to Aug 31, which is 153 days. Mistake: adding the lengths of the periods, which double counts the overlap, and off-by-one when both endpoints are inclusive.
pythonfrom datetime import date def days_covered(periods): spans = sorted((s.toordinal(), e.toordinal()) for s, e in periods) total, cur_s, cur_e = 0, None, None for s, e in spans: if cur_e is None or s > cur_e: if cur_e is not None: total += cur_e - cur_s + 1 cur_s, cur_e = s, e else: cur_e = max(cur_e, e) return total + (cur_e - cur_s + 1 if cur_e is not None else 0) print(days_covered([(date(2026, 4, 1), date(2026, 6, 30)), (date(2026, 6, 15), date(2026, 8, 31))])) # 1536 Flag duplicate transactions: the same merchant and amount within 60 seconds of each other.
mediumSort by time and remember the last timestamp per (merchant, amount) key; flag a transaction if the same key was seen within the window, then update the stored time. O(n log n) for the sort. Mistake: comparing every pair (O(n squared)) and forgetting to update the last-seen time so chains of repeats are missed.
pythondef duplicates(txns, window=60): last, flagged = {}, [] for t, key in sorted(txns): if key in last and t - last[key] <= window: flagged.append((t, key)) last[key] = t return flagged print(duplicates([(0, "shop-499"), (30, "shop-499"), (200, "shop-499"), (10, "cafe-80")])) # [(30, 'shop-499')]7 Reconcile two lists of ledger entries: which entries appear in the bank list but not in ours, and the reverse (duplicates count).
mediumUse multiset subtraction with Counter, which respects duplicate entries: bank minus ours gives entries we are missing, ours minus bank gives entries the bank lacks. O(n + m). Mistake: using sets, which collapse two identical payments into one and hide a missing duplicate.
pythonfrom collections import Counter def reconcile(ours, bank): a, b = Counter(ours), Counter(bank) return list((b - a).elements()), list((a - b).elements()) print(reconcile(["p1", "p2", "p2"], ["p1", "p2", "p3"])) # (['p3'], ['p2'])8 Top K expense categories by total amount from a list of (category, amount) rows.
mediumSum per category in a dictionary, then take the K largest with a heap. O(n + m log k). Use integer paise for amounts. Mistake: sorting all categories when K is small, and not defining a tie-break when two totals are equal.
pythonimport heapq from collections import defaultdict def top_categories(rows, k): tot = defaultdict(int) for cat, amt in rows: tot[cat] += amt return heapq.nsmallest(k, tot.items(), key=lambda x: (-x[1], x[0])) print(top_categories([("rent", 900), ("food", 300), ("rent", 100), ("travel", 500)], 2)) # [('rent', 1000), ('travel', 500)]9 Choose deductions to maximise tax saving within an investment limit: each option has a cost and a saving, and can be chosen once (illustrative numbers, in thousands of rupees).
mediumIt is a 0/1 knapsack. dp[w] is the best saving using at most w of the budget; for each option iterate w downward so it is used once. With costs [50, 70, 100], savings [15, 20, 30] and a limit of 120, the best is the first two options for a saving of 35 (the 100 option alone gives only 30). O(n * limit). Mistake: iterating w upward, which allows an option more than once.
pythondef best_saving(costs, savings, limit): dp = [0] * (limit + 1) for cost, save in zip(costs, savings): for w in range(limit, cost - 1, -1): dp[w] = max(dp[w], dp[w - cost] + save) return dp[limit] print(best_saving([50, 70, 100], [15, 20, 30], 120)) # 3510 SQL: the conversion rate at each step of the filing funnel (started, details filled, submitted).
mediumCount distinct users per step, then divide by the number who started. COUNT(DISTINCT ...) avoids counting users who repeat a step, and the denominator should be the first step. Mistake: dividing by the previous step when the question asks for conversion from the start, and counting events instead of users.
sqlSELECT step, COUNT(DISTINCT user_id) AS users, ROUND(100.0 * COUNT(DISTINCT user_id) / (SELECT COUNT(DISTINCT user_id) FROM filing_events WHERE step = 'started'), 1) AS pct_of_started FROM filing_events WHERE step IN ('started', 'details_filled', 'submitted') GROUP BY step;11 SQL: each user's second filing attempt of a year, with its date.
mediumNumber each user's attempts by date with ROW_NUMBER partitioned by user and keep number 2. Users with one attempt produce no row. Mistake: MIN and MAX tricks, which cannot pick the second row, and ordering without a tie-breaker when two attempts share a timestamp.
sqlSELECT user_id, attempt_date FROM ( SELECT user_id, attempt_date, ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY attempt_date, attempt_id) AS n FROM filing_attempts WHERE EXTRACT(YEAR FROM attempt_date) = 2026 ) t WHERE n = 2;12 Find the minimum number of notes (denominations 1, 5, 10, 20, 50, 100, 200, 500) to pay a refund amount exactly.
hardDynamic programming over amounts: best[a] = 1 + min(best[a - d]) over denominations d no larger than a. For this particular denomination set, greedy largest-first is also optimal, but a DP is the safe general answer because greedy fails for arbitrary sets (for example 1, 3, 4 and amount 6). O(amount * denominations). Mistake: assuming greedy always works and not handling amounts that cannot be formed.
pythondef min_notes(amount, notes=(1, 5, 10, 20, 50, 100, 200, 500)): INF = amount + 1 best = [0] + [INF] * amount for a in range(1, amount + 1): for d in notes: if d <= a and best[a - d] + 1 < best[a]: best[a] = best[a - d] + 1 return best[amount] if best[amount] != INF else -1 print(min_notes(1273)) # 8 (500+500+200+50+20+1+1+1)
Frequently asked questions
What kind of coding problems suit a ClearTax-style assessment?
Data handling with correct money arithmetic, validation, interval merging, hashing, dynamic programming and SQL aggregation, alongside standard data structure problems.
Are the tax slabs here real?
No. The slab figures are invented for practice. Real rates change by year and regime, so always take current figures from official sources.
How do I avoid money bugs in a coding test?
Use integers or Decimal, round once at the specified step and test the boundaries of each slab.
Are these real ClearTax questions?
No. They are practice problems in the style of such assessments, not copies of any test.
Which language is best?
Python is concise for these problems and has Decimal built in; Java with BigDecimal is equally fine. Use the one you know best.
Related guides
More in Company Interview Questions
- ClearTax Interview Questions with Answers
- Coforge Coding Round Questions with Solutions
- Coforge Interview Questions for Freshers
- Cognizant Coding Round Questions with Solutions
- Cognizant Interview Questions for Freshers
- CRED Coding Round Questions with Solutions
- CRED Interview Questions and Answers
- Cyient coding round questions
- Cyient interview questions and answers
- D. E. Shaw Coding Round Questions With Solutions
- D. E. Shaw Interview Questions and Answers
- Delhivery Coding Round Questions