CRED Coding Round Questions with Solutions
Last updated 2026-11-19
CRED sells a credit-card bill payment and rewards experience to people with good credit scores, so the natural data in its problems is card numbers, statement lines, due dates, reward coins and merchant offers. Candidate write-ups describe a long machine-coding build followed by a DSA round with harder problems and the odd puzzle. The ten exercises below borrow that flavour: money-safe arithmetic, calendar edge cases, expiring balances, and a few algorithms with a real sting.
All ten are original practice problems, not recalled questions. Read CRED interview questions for the conceptual and HR side, and how to crack a low-level design interview if the build round worries you more than the algorithms.
What to rehearse for a fintech build round
Money code has a few non-negotiables: integers for amounts, explicit handling of month-end dates, and no silent failures when a balance is too low. Train yourself to state those three assumptions out loud before typing anything, because a reviewer who sees them early reads the rest of your code more kindly.
The DSA round is described as harder than a typical campus test, so practise stating two candidate approaches and picking one with a reason. Problems 5, 9 and 10 below are the ones where a quick brute force will not survive, so time yourself on them first.
Hiring status
This site holds no sourced statement about current CRED openings. Check careers.cred.club for live roles. Everything above about round shape is candidate-reported and may differ for your track.
CRED Coding Round Questions with Solutions: questions with worked answers
1 Validate a card number with the Luhn check.
easyWalk the digits from the right, doubling every second one and subtracting 9 whenever the doubled value exceeds 9, then require the sum to be a multiple of 10. Strip spaces and dashes first and reject anything shorter than a plausible card length. Linear time, constant space. The usual slip is doubling from the left, which only works by accident when the length is even.
pythondef luhn_ok(num): digits = [int(c) for c in num if c.isdigit()] if len(digits) < 12: return False total = 0 for i, d in enumerate(reversed(digits)): if i % 2 == 1: d *= 2 if d > 9: d -= 9 total += d return total % 10 == 0javastatic boolean luhnOk(String num) { int total = 0, count = 0; boolean dbl = false; for (int i = num.length() - 1; i >= 0; i--) { char c = num.charAt(i); if (c < '0' || c > '9') continue; int d = c - '0'; if (dbl) { d *= 2; if (d > 9) d -= 9; } total += d; dbl = !dbl; count++; } return count >= 12 && total % 10 == 0; }2 Compute the next bill due date when the anchor day is the 31st.
easyKeep the anchor day (31) separately from the date you last produced. To get the next month, add one month to the year-month pair, ask the calendar for that month's length, and take the smaller of the anchor and the length. Because the anchor is never overwritten, January 31 gives February 28 and then March 31 again. Constant time. Beginners store the clamped date and then drift to the 28th forever.
pythonimport calendar, datetime def next_due(current, anchor_day): y = current.year + (current.month == 12) m = current.month % 12 + 1 last = calendar.monthrange(y, m)[1] return datetime.date(y, m, min(anchor_day, last))javaimport java.time.*; static LocalDate nextDue(LocalDate current, int anchorDay) { YearMonth ym = YearMonth.from(current).plusMonths(1); return ym.atDay(Math.min(anchorDay, ym.lengthOfMonth())); }3 Reward coins that expire: earn, redeem oldest first, report balance.
mediumTreat each earn event as a lot with an expiry day and a remaining count, kept in a queue because lots expire in the order they were earned when validity is fixed. Before any balance or redeem call, discard lots whose expiry is not after today. Redeeming consumes from the front lot, spilling into the next. Each lot is touched a bounded number of times, so redeem is amortised linear in lots used. The trap is redeeming expired points, or deducting from a lot and forgetting to pop it at zero.
pythonfrom collections import deque class Coins: def __init__(self): self.lots = deque() # [expiry_day, remaining] def earn(self, pts, expiry): self.lots.append([expiry, pts]) def _drop(self, today): self.lots = deque(l for l in self.lots if l[0] > today) def balance(self, today): self._drop(today) return sum(l[1] for l in self.lots) def redeem(self, pts, today): if self.balance(today) < pts: return False while pts: lot = self.lots[0] take = min(lot[1], pts) lot[1] -= take pts -= take if lot[1] == 0: self.lots.popleft() return Truejavaimport java.util.*; class Coins { private final ArrayDeque<int[]> lots = new ArrayDeque<>(); // {expiry, remaining} void earn(int pts, int expiry) { lots.addLast(new int[]{expiry, pts}); } int balance(int today) { lots.removeIf(l -> l[0] <= today); int s = 0; for (int[] l : lots) s += l[1]; return s; } boolean redeem(int pts, int today) { if (balance(today) < pts) return false; while (pts > 0) { int[] lot = lots.peekFirst(); int take = Math.min(lot[1], pts); lot[1] -= take; pts -= take; if (lot[1] == 0) lots.pollFirst(); } return true; } }4 Merge the statements of several cards into one date-ordered list.
mediumEach card's statement is already sorted, so a min-heap holding one cursor per card gives the global order. Push the first line of every card, pop the smallest date, emit it, and push that card's next line. With N lines in total and k cards the cost is O(N log k) and the heap holds at most k entries. Concatenating and sorting works but throws away the sortedness and costs O(N log N). Ties on date need a second key such as the card index, otherwise Python compares unrelated tuples.
pythonimport heapq def merge_statements(streams): heap = [(s[0][0], i, 0) for i, s in enumerate(streams) if s] heapq.heapify(heap) out = [] while heap: day, i, j = heapq.heappop(heap) out.append((day, streams[i][j][1], i)) if j + 1 < len(streams[i]): heapq.heappush(heap, (streams[i][j + 1][0], i, j + 1)) return outjavaimport java.util.*; static List<int[]> mergeStatements(int[][][] streams) { PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[0] != b[0] ? a[0] - b[0] : a[1] - b[1]); for (int i = 0; i < streams.length; i++) if (streams[i].length > 0) pq.add(new int[]{streams[i][0][0], i, 0}); List<int[]> out = new ArrayList<>(); while (!pq.isEmpty()) { int[] t = pq.poll(); out.add(new int[]{t[0], streams[t[1]][t[2]][1], t[1]}); if (t[2] + 1 < streams[t[1]].length) pq.add(new int[]{streams[t[1]][t[2] + 1][0], t[1], t[2] + 1}); } return out; }5 Pick non-overlapping merchant offers to maximise total cashback.
hardThis is weighted interval scheduling. Sort offers by end day. Let dp[i] be the best total using the first i offers; for offer i either skip it (dp[i-1]) or take it and add dp[j], where j is the count of earlier offers ending no later than its start, found by binary search. O(n log n) time, O(n) space. Greedy by reward or by earliest end fails because a big late offer can beat two small early ones. Decide up front whether an offer ending on day 5 may chain with one starting on day 5.
pythonimport bisect def max_cashback(offers): # (start, end, reward), half-open offers = sorted(offers, key=lambda o: o[1]) ends = [o[1] for o in offers] dp = [0] * (len(offers) + 1) for i, (s, e, r) in enumerate(offers, 1): j = bisect.bisect_right(ends, s, 0, i - 1) dp[i] = max(dp[i - 1], dp[j] + r) return dp[-1]javaimport java.util.*; static int maxCashback(int[][] offers) { // {start, end, reward} Arrays.sort(offers, (a, b) -> a[1] - b[1]); int n = offers.length; int[] dp = new int[n + 1]; for (int i = 1; i <= n; i++) { int lo = 0, hi = i - 1; // count of offers ending <= start while (lo < hi) { int mid = (lo + hi) / 2; if (offers[mid][1] <= offers[i - 1][0]) lo = mid + 1; else hi = mid; } dp[i] = Math.max(dp[i - 1], dp[lo] + offers[i - 1][2]); } return dp[n]; }6 Flag a repeat charge: same card, merchant and amount within 60 seconds.
mediumRemember the latest timestamp for each (card, merchant, amount) key. When a new charge arrives and its key was seen no more than 60 seconds ago, flag it; in every case update the stored time. This is O(1) per charge and O(distinct keys) memory, which you can bound by evicting keys older than the window. Comparing against the first sighting instead of the most recent one misses chains of charges spaced 40 seconds apart.
pythondef flag_repeats(txns, window=60): last, flagged = {}, [] for idx, (ts, card, merchant, amount) in enumerate(txns): key = (card, merchant, amount) if key in last and ts - last[key] <= window: flagged.append(idx) last[key] = ts return flaggedjavaimport java.util.*; static List<Integer> flagRepeats(long[] ts, String[] card, String[] merchant, long[] amount, long window) { Map<String, Long> last = new HashMap<>(); List<Integer> flagged = new ArrayList<>(); for (int i = 0; i < ts.length; i++) { String key = card[i] + "|" + merchant[i] + "|" + amount[i]; Long prev = last.get(key); if (prev != null && ts[i] - prev <= window) flagged.add(i); last.put(key, ts[i]); } return flagged; }7 Fewest dice throws to finish a snakes-and-ladders board.
mediumModel squares as nodes and each throw of 1 to 6 as an edge of equal cost, then run breadth-first search from square 1. When you land on the foot of a ladder or the mouth of a snake, redirect to its other end before marking the square visited. The first time the last square is dequeued, its depth is the answer. O(n) states with six edges each. Applying a jump twice in a row is wrong: the destination of a jump is never itself a jump start in a legal board, but if your code follows chains you will overcount.
pythonfrom collections import deque def min_throws(cells, jumps): seen = {1} q = deque([(1, 0)]) while q: pos, d = q.popleft() if pos == cells: return d for roll in range(1, 7): nxt = pos + roll if nxt > cells: continue nxt = jumps.get(nxt, nxt) if nxt not in seen: seen.add(nxt) q.append((nxt, d + 1)) return -1javaimport java.util.*; static int minThrows(int cells, Map<Integer, Integer> jumps) { boolean[] seen = new boolean[cells + 1]; ArrayDeque<int[]> q = new ArrayDeque<>(); q.add(new int[]{1, 0}); seen[1] = true; while (!q.isEmpty()) { int[] cur = q.poll(); if (cur[0] == cells) return cur[1]; for (int roll = 1; roll <= 6; roll++) { int nxt = cur[0] + roll; if (nxt > cells) continue; nxt = jumps.getOrDefault(nxt, nxt); if (!seen[nxt]) { seen[nxt] = true; q.add(new int[]{nxt, cur[1] + 1}); } } } return -1; }8 Rearrange offer codes so no two equal ones sit side by side.
mediumCount each character, then repeatedly take the most frequent one that is not the character you just placed. A max-heap does this: pop the top, append it, hold it aside for one step, and push it back with a decremented count after the next pop. If the output ends up shorter than the input, no arrangement exists, which happens exactly when one character exceeds half the length rounded up. O(n log k) for k distinct characters. Forgetting to hold the previous character aside lets the same letter be chosen twice running.
pythonimport heapq from collections import Counter def reorganize(s): heap = [(-c, ch) for ch, c in Counter(s).items()] heapq.heapify(heap) out, held = [], None while heap: c, ch = heapq.heappop(heap) out.append(ch) if held: heapq.heappush(heap, held) held = None if c + 1 < 0: held = (c + 1, ch) return ''.join(out) if len(out) == len(s) else ''javaimport java.util.*; static String reorganize(String s) { int[] cnt = new int[128]; for (char c : s.toCharArray()) cnt[c]++; PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> b[0] - a[0]); for (int c = 0; c < 128; c++) if (cnt[c] > 0) pq.add(new int[]{cnt[c], c}); StringBuilder sb = new StringBuilder(); int[] held = null; while (!pq.isEmpty()) { int[] top = pq.poll(); sb.append((char) top[1]); if (held != null) { pq.add(held); held = null; } if (top[0] > 1) held = new int[]{top[0] - 1, top[1]}; } return sb.length() == s.length() ? sb.toString() : ""; }9 Design a least-frequently-used cache with O(1) get and put.
hardKeep three maps: key to value, key to use count, and use count to an insertion-ordered set of keys, plus the current minimum count. A touch moves the key from bucket f to f+1 and bumps the minimum if bucket f emptied and was the minimum. Eviction removes the oldest key in the minimum bucket, which breaks frequency ties by recency. Every operation is O(1). Classic misses: resetting the minimum to 1 only on insert but not updating it on touch, and ignoring a capacity of zero.
pythonfrom collections import defaultdict, OrderedDict class LFUCache: def __init__(self, cap): self.cap, self.val, self.cnt = cap, {}, {} self.bucket = defaultdict(OrderedDict) self.low = 0 def _touch(self, k): f = self.cnt[k] del self.bucket[f][k] if not self.bucket[f] and self.low == f: self.low += 1 self.cnt[k] = f + 1 self.bucket[f + 1][k] = None def get(self, k): if k not in self.val: return -1 self._touch(k) return self.val[k] def put(self, k, v): if self.cap == 0: return if k in self.val: self.val[k] = v self._touch(k) return if len(self.val) == self.cap: old, _ = self.bucket[self.low].popitem(last=False) del self.val[old] del self.cnt[old] self.val[k], self.cnt[k] = v, 1 self.bucket[1][k] = None self.low = 1javaimport java.util.*; class LFUCache { private final int cap; private int low = 0; private final Map<Integer, Integer> val = new HashMap<>(), cnt = new HashMap<>(); private final Map<Integer, LinkedHashSet<Integer>> bucket = new HashMap<>(); LFUCache(int cap) { this.cap = cap; } private void touch(int k) { int f = cnt.get(k); bucket.get(f).remove(k); if (bucket.get(f).isEmpty() && low == f) low++; cnt.put(k, f + 1); bucket.computeIfAbsent(f + 1, x -> new LinkedHashSet<>()).add(k); } int get(int k) { if (!val.containsKey(k)) return -1; touch(k); return val.get(k); } void put(int k, int v) { if (cap == 0) return; if (val.containsKey(k)) { val.put(k, v); touch(k); return; } if (val.size() == cap) { int old = bucket.get(low).iterator().next(); bucket.get(low).remove(old); val.remove(old); cnt.remove(old); } val.put(k, v); cnt.put(k, 1); bucket.computeIfAbsent(1, x -> new LinkedHashSet<>()).add(k); low = 1; } }10 Recover the rank order of membership tiers from a sorted list of tier codes.
hardCompare each adjacent pair of codes; the first differing letters give one precedence edge. Build a graph of those edges and run Kahn's topological sort, emitting letters whose in-degree reaches zero. If fewer letters come out than exist, the input contained a cycle and no order is valid. An invalid prefix case, such as the longer code appearing before its own prefix, must also fail. O(total characters + edges). Adding the same edge twice inflates the in-degree and makes a valid input look cyclic.
pythonfrom collections import deque def order_tiers(words): adj = {c: set() for w in words for c in w} indeg = {c: 0 for c in adj} for a, b in zip(words, words[1:]): if len(a) > len(b) and a.startswith(b): return '' for x, y in zip(a, b): if x != y: if y not in adj[x]: adj[x].add(y) indeg[y] += 1 break q = deque(c for c in indeg if indeg[c] == 0) out = [] while q: c = q.popleft() out.append(c) for n in adj[c]: indeg[n] -= 1 if indeg[n] == 0: q.append(n) return ''.join(out) if len(out) == len(adj) else ''javaimport java.util.*; static String orderTiers(String[] words) { Map<Character, Set<Character>> adj = new LinkedHashMap<>(); Map<Character, Integer> indeg = new LinkedHashMap<>(); for (String w : words) for (char c : w.toCharArray()) { adj.putIfAbsent(c, new HashSet<>()); indeg.putIfAbsent(c, 0); } for (int i = 0; i + 1 < words.length; i++) { String a = words[i], b = words[i + 1]; if (a.length() > b.length() && a.startsWith(b)) return ""; for (int j = 0; j < Math.min(a.length(), b.length()); j++) { char x = a.charAt(j), y = b.charAt(j); if (x != y) { if (adj.get(x).add(y)) indeg.merge(y, 1, Integer::sum); break; } } } ArrayDeque<Character> q = new ArrayDeque<>(); for (var e : indeg.entrySet()) if (e.getValue() == 0) q.add(e.getKey()); StringBuilder sb = new StringBuilder(); while (!q.isEmpty()) { char c = q.poll(); sb.append(c); for (char n : adj.get(c)) if (indeg.merge(n, -1, Integer::sum) == 0) q.add(n); } return sb.length() == adj.size() ? sb.toString() : ""; }
Frequently asked questions
Why do fintech problems insist on integer amounts?
Floating point cannot store 0.1 exactly, so sums of rupee amounts drift by fractions of a paisa. Store paise as integers and decide a rounding rule, such as half-up on the last step only.
Which of these ten should I attempt first when short on time?
Start with the Luhn check and the due-date problem, since both are quick and test calendar and digit edge cases. Leave the LFU cache and tier ordering for a calm session; both punish a half-remembered design.
Is the build round done on my own machine?
Candidate reports are mixed, with some describing a timed build and others a take-home. Follow the instructions in your own invite rather than assuming.
What should I do if my build is not finished when time ends?
Submit a working core and a short note listing what is missing and how you would add it. A small runnable system with clean classes is usually judged more kindly than a larger one that crashes.
Sources
Related guides
More in Company Interview Questions
- 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
- Delhivery Interview Questions with Answers
- Dell Coding Round Questions with Solutions
- Dell Technologies Interview Questions and Answers for India Freshers
- Deloitte coding round questions
- Deloitte interview questions and answers
- Deutsche Bank coding round questions with solutions