Freshworks Coding Round Questions with Solutions
Last updated 2026-11-19
Freshworks builds customer-support and CRM software, so the objects in its world are tickets, agents, contacts, SLAs and automation rules. Candidate accounts of the coding round describe medium-difficulty algorithm questions together with a walk through your resume, which means the interviewer is judging how clearly you reason as much as whether the output is right.
The ten exercises below take that SaaS vocabulary and turn it into compact problems: breach counting, skill-based routing, shift scheduling, duplicate-contact merging, template rendering, log ordering, a rule parser and a field-history store. They are original practice material rather than recalled questions. For concept and HR preparation see Freshworks interview questions, and for general routine see the DSA round guide.
A routine for a medium problem and a resume chat
Spend the first minutes on the input: its size, whether values repeat, whether it can be empty. Then say your approach and its cost before typing. After the code, trace one small example by hand and name the test you would add next. That sequence is more convincing than a fast but silent solution.
Because your resume is part of the same conversation, pick two projects and be ready to justify every library and algorithm named on them. A line such as a hash map or a queue on your resume invites a follow-up on how it behaves under load, and the problems below, especially routing and history storage, are good rehearsals for that.
Hiring status
Sourced updates live at Freshworks hiring, and live openings are on the company's careers page at freshworks.com/company/careers. Round details here come from candidate write-ups and may not match your track.
Freshworks Coding Round Questions with Solutions: questions with worked answers
1 Count how many open tickets have breached their SLA at each of several checkpoints.
easySort the unresolved tickets' deadlines once. For each checkpoint time t, the number breached is the count of deadlines not later than t, which is an upper-bound binary search. Sorting costs O(n log n) and each query O(log n), far better than rescanning all tickets per query. The off-by-one to watch is whether a ticket whose deadline equals t counts as breached; state your reading and use bisect_right or left accordingly.
pythonimport bisect def breached_counts(deadlines, checkpoints): d = sorted(deadlines) return [bisect.bisect_right(d, t) for t in checkpoints]javaimport java.util.*; static int[] breachedCounts(int[] deadlines, int[] checkpoints) { int[] d = deadlines.clone(); Arrays.sort(d); int[] out = new int[checkpoints.length]; for (int i = 0; i < checkpoints.length; i++) { int lo = 0, hi = d.length; while (lo < hi) { int mid = (lo + hi) >>> 1; if (d[mid] <= checkpoints[i]) lo = mid + 1; else hi = mid; } out[i] = lo; } return out; }2 Design a ticket router that hands each new ticket to the next agent who has the required skill.
mediumKeep one rotating queue of agents per skill. Assigning pops the front agent, appends them to the back and returns them, which is O(1). Adding an agent appends them to the queue of every skill they hold; removing one deletes them from each queue in O(agents). Return a clear empty result when nobody has the skill rather than raising. The common flaw is a single global pointer, which skews fairness across skills because agents with several skills are picked more often.
pythonfrom collections import defaultdict, deque class Router: def __init__(self): self.queues = defaultdict(deque) def add(self, agent, skills): for s in skills: self.queues[s].append(agent) def remove(self, agent): for q in self.queues.values(): if agent in q: q.remove(agent) def assign(self, skill): q = self.queues.get(skill) if not q: return None agent = q.popleft() q.append(agent) return agentjavaimport java.util.*; class Router { private final Map<String, ArrayDeque<String>> queues = new HashMap<>(); void add(String agent, List<String> skills) { for (String s : skills) queues.computeIfAbsent(s, k -> new ArrayDeque<>()).addLast(agent); } void remove(String agent) { for (ArrayDeque<String> q : queues.values()) q.remove(agent); } String assign(String skill) { ArrayDeque<String> q = queues.get(skill); if (q == null || q.isEmpty()) return null; String agent = q.pollFirst(); q.addLast(agent); return agent; } }3 Insert a new agent shift into a sorted list of non-overlapping shifts, merging where they touch.
mediumWalk the list in three phases. Copy every shift that ends before the new one starts; then absorb every shift that starts no later than the new end by widening the new interval; finally append the widened interval and copy the rest. One pass, O(n) time. People often compare with strict inequality and fail to merge shifts that share an endpoint, or they re-sort the whole list, which wastes the existing order.
pythondef insert_shift(shifts, new): s, e = new out, i, n = [], 0, len(shifts) while i < n and shifts[i][1] < s: out.append(shifts[i]) i += 1 while i < n and shifts[i][0] <= e: s, e = min(s, shifts[i][0]), max(e, shifts[i][1]) i += 1 out.append([s, e]) out.extend(shifts[i:]) return outjavaimport java.util.*; static List<int[]> insertShift(List<int[]> shifts, int[] nw) { int s = nw[0], e = nw[1], i = 0, n = shifts.size(); List<int[]> out = new ArrayList<>(); while (i < n && shifts.get(i)[1] < s) out.add(shifts.get(i++)); while (i < n && shifts.get(i)[0] <= e) { s = Math.min(s, shifts.get(i)[0]); e = Math.max(e, shifts.get(i)[1]); i++; } out.add(new int[]{s, e}); while (i < n) out.add(shifts.get(i++)); return out; }4 Merge duplicate customer records that share any email address.
hardTreat every email as a node and join all emails inside one record with union-find. After processing all records, group emails by their root and output each group with the owner's name and the emails sorted. With path compression this is close to linear in the number of emails plus the sort. Merging by name is wrong because different customers can share a name, and forgetting to sort the final emails makes output order unstable.
pythonfrom collections import defaultdict def merge_contacts(records): # [name, email, email, ...] parent, owner = {}, {} def find(x): while parent[x] != x: parent[x] = parent[parent[x]] x = parent[x] return x for rec in records: for e in rec[1:]: parent.setdefault(e, e) owner[e] = rec[0] parent[find(e)] = find(rec[1]) groups = defaultdict(list) for e in parent: groups[find(e)].append(e) result = [[owner[r]] + sorted(es) for r, es in groups.items()] return sorted(result, key=lambda g: g[1])javaimport java.util.*; static List<List<String>> mergeContacts(List<List<String>> records) { Map<String, String> parent = new HashMap<>(), owner = new HashMap<>(); for (List<String> rec : records) { for (int i = 1; i < rec.size(); i++) { String e = rec.get(i); parent.putIfAbsent(e, e); owner.put(e, rec.get(0)); parent.put(find(parent, e), find(parent, rec.get(1))); } } Map<String, TreeSet<String>> groups = new HashMap<>(); for (String e : parent.keySet()) groups.computeIfAbsent(find(parent, e), k -> new TreeSet<>()).add(e); List<List<String>> result = new ArrayList<>(); for (var en : groups.entrySet()) { List<String> g = new ArrayList<>(); g.add(owner.get(en.getKey())); g.addAll(en.getValue()); result.add(g); } result.sort((a, b) -> a.get(1).compareTo(b.get(1))); return result; } static String find(Map<String, String> parent, String x) { while (!parent.get(x).equals(x)) { parent.put(x, parent.get(parent.get(x))); x = parent.get(x); } return x; }5 Fill a canned-reply template such as Hello {{name}}, leaving unknown placeholders untouched.
mediumScan left to right. When you see two opening braces, find the next pair of closing braces, trim the key between them, and substitute its value if present or copy the original token if not. Anything else is copied character by character. Because you never rescan inserted text, a value that itself contains braces cannot cause recursion. O(length of template + output). Calling replace once per key in a loop is the tempting shortcut, and it expands braces inside earlier values.
pythondef render(tpl, ctx): out, i = [], 0 while i < len(tpl): if tpl.startswith('{{', i): j = tpl.find('}}', i + 2) if j != -1: key = tpl[i + 2:j].strip() out.append(str(ctx[key]) if key in ctx else tpl[i:j + 2]) i = j + 2 continue out.append(tpl[i]) i += 1 return ''.join(out)javaimport java.util.*; static String render(String tpl, Map<String, String> ctx) { StringBuilder out = new StringBuilder(); int i = 0; while (i < tpl.length()) { if (tpl.startsWith("{{", i)) { int j = tpl.indexOf("}}", i + 2); if (j != -1) { String key = tpl.substring(i + 2, j).trim(); out.append(ctx.containsKey(key) ? ctx.get(key) : tpl.substring(i, j + 2)); i = j + 2; continue; } } out.append(tpl.charAt(i++)); } return out.toString(); }6 Reorder event log lines so text logs come first in alphabetical order and numeric logs keep their original order.
easySplit each line at its first space into an identifier and a body. If the body starts with a digit it is a numeric log, kept in a separate list in arrival order; otherwise it is a text log. Sort text logs by body, breaking ties by identifier, and append the numeric ones. O(n log n x line length). The classic mistake is sorting by the whole line, which puts the identifier ahead of the body, or deciding the log type from the identifier instead of the body.
pythondef reorder_logs(logs): text, numeric = [], [] for line in logs: ident, body = line.split(' ', 1) (numeric if body[0].isdigit() else text).append((body, ident, line)) text.sort() return [t[2] for t in text] + [n[2] for n in numeric]javaimport java.util.*; static List<String> reorderLogs(List<String> logs) { List<String> text = new ArrayList<>(), numeric = new ArrayList<>(); for (String line : logs) { int sp = line.indexOf(' '); if (Character.isDigit(line.charAt(sp + 1))) numeric.add(line); else text.add(line); } text.sort(Comparator.comparing((String l) -> l.substring(l.indexOf(' ') + 1)) .thenComparing(l -> l.substring(0, l.indexOf(' ')))); text.addAll(numeric); return text; }7 Remove the n-th ticket from the end of a singly linked queue in one pass.
mediumPlace a dummy node before the head, then advance a fast pointer n steps ahead. Move fast and a slow pointer together until fast reaches the last node; slow now sits just before the node to delete, so relink around it. The dummy handles removal of the head without a special case. One pass, O(1) space. Walking the list twice is acceptable but not the point of the question, and forgetting the dummy breaks when n equals the length.
pythonclass Node: def __init__(self, val, nxt=None): self.val, self.nxt = val, nxt def remove_nth_from_end(head, n): dummy = Node(0, head) fast = slow = dummy for _ in range(n): fast = fast.nxt while fast.nxt: fast, slow = fast.nxt, slow.nxt slow.nxt = slow.nxt.nxt return dummy.nxtjavaclass Node { int val; Node next; Node(int val, Node next) { this.val = val; this.next = next; } } static Node removeNthFromEnd(Node head, int n) { Node dummy = new Node(0, head), fast = dummy, slow = dummy; for (int i = 0; i < n; i++) fast = fast.next; while (fast.next != null) { fast = fast.next; slow = slow.next; } slow.next = slow.next.next; return dummy.next; }8 Serialise a category tree to a string and rebuild exactly the same tree from it.
hardWrite a preorder walk, emitting each value and a marker such as # for every missing child, separated by commas. To rebuild, read tokens in order: a marker returns nothing, otherwise create a node and build its left then right subtree from the following tokens. Both directions are O(n). Without markers for empty children the string is ambiguous, and splitting on a character that can appear in a value corrupts the result. Very deep trees may need an iterative builder to avoid stack overflow.
pythonclass TreeNode: def __init__(self, val, left=None, right=None): self.val, self.left, self.right = val, left, right def serialize(root): out, stack = [], [root] while stack: node = stack.pop() if node is None: out.append('#') else: out.append(str(node.val)) stack.append(node.right) stack.append(node.left) return ','.join(out) def deserialize(data): tokens = iter(data.split(',')) def build(): t = next(tokens) if t == '#': return None node = TreeNode(int(t)) node.left = build() node.right = build() return node return build()javaimport java.util.*; class TreeNode { int val; TreeNode left, right; TreeNode(int val) { this.val = val; } } static String serialize(TreeNode root) { StringBuilder sb = new StringBuilder(); ArrayDeque<TreeNode> stack = new ArrayDeque<>(); stack.push(root); while (!stack.isEmpty()) { TreeNode n = stack.pop(); if (n == null) { sb.append("#,"); continue; } sb.append(n.val).append(','); stack.push(n.right); stack.push(n.left); } return sb.toString(); } static TreeNode deserialize(String data) { Iterator<String> it = Arrays.asList(data.split(",")).iterator(); return build(it); } private static TreeNode build(Iterator<String> it) { String t = it.next(); if (t.equals("#")) return null; TreeNode n = new TreeNode(Integer.parseInt(t)); n.left = build(it); n.right = build(it); return n; }9 Evaluate an automation rule such as (vip AND urgent) OR NOT closed against a set of true facts.
hardWrite a small recursive-descent parser with one function per precedence level: OR calls AND, AND calls NOT, NOT calls an atom, and an atom is either a parenthesised OR or a fact name. Each level loops over its own operator. Always parse the right operand before combining, so short-circuiting never leaves tokens unread. Linear in the expression length. Splitting on OR then AND with plain string operations mishandles brackets, and evaluating the right side lazily skips tokens and desynchronises the parser.
pythonimport re def eval_rule(expr, facts): toks = re.findall(r'\(|\)|\w+', expr) pos = 0 def peek(): return toks[pos] if pos < len(toks) else None def take(): nonlocal pos pos += 1 return toks[pos - 1] def parse_or(): v = parse_and() while peek() == 'OR': take() r = parse_and() v = v or r return v def parse_and(): v = parse_not() while peek() == 'AND': take() r = parse_not() v = v and r return v def parse_not(): if peek() == 'NOT': take() return not parse_not() return atom() def atom(): t = take() if t == '(': v = parse_or() take() return v return t in facts return parse_or()javaimport java.util.*; import java.util.regex.*; class Rule { private final List<String> toks = new ArrayList<>(); private final Set<String> facts; private int pos = 0; Rule(String expr, Set<String> facts) { this.facts = facts; Matcher m = Pattern.compile("\\(|\\)|\\w+").matcher(expr); while (m.find()) toks.add(m.group()); } boolean eval() { return orExpr(); } private String peek() { return pos < toks.size() ? toks.get(pos) : null; } private boolean orExpr() { boolean v = andExpr(); while ("OR".equals(peek())) { pos++; boolean r = andExpr(); v = v || r; } return v; } private boolean andExpr() { boolean v = notExpr(); while ("AND".equals(peek())) { pos++; boolean r = notExpr(); v = v && r; } return v; } private boolean notExpr() { if ("NOT".equals(peek())) { pos++; return !notExpr(); } String t = toks.get(pos++); if (t.equals("(")) { boolean v = orExpr(); pos++; return v; } return facts.contains(t); } }10 Store the history of a ticket field and answer what its value was at a past timestamp.
mediumKeep, for each key, a time-sorted list of change timestamps and a parallel list of values. A lookup binary-searches for the last timestamp not after the query and returns the matching value, or nothing if the query predates the first change. Writes in time order append in O(1); out-of-order writes insert in O(n). Lookup is O(log n). Searching for an exact timestamp instead of the nearest earlier one is the usual wrong turn, as is returning the latest value regardless of time.
pythonimport bisect from collections import defaultdict class FieldHistory: def __init__(self): self.times = defaultdict(list) self.vals = defaultdict(list) def set(self, key, value, ts): t = self.times[key] i = bisect.bisect_left(t, ts) if i < len(t) and t[i] == ts: self.vals[key][i] = value else: t.insert(i, ts) self.vals[key].insert(i, value) def get(self, key, ts): i = bisect.bisect_right(self.times[key], ts) return self.vals[key][i - 1] if i else Nonejavaimport java.util.*; class FieldHistory { private final Map<String, TreeMap<Integer, String>> data = new HashMap<>(); void set(String key, String value, int ts) { data.computeIfAbsent(key, k -> new TreeMap<>()).put(ts, value); } String get(String key, int ts) { TreeMap<Integer, String> t = data.get(key); if (t == null) return null; Map.Entry<Integer, String> e = t.floorEntry(ts); return e == null ? null : e.getValue(); } }
Frequently asked questions
How hard are the problems in a Freshworks coding round?
Candidate write-ups describe medium LeetCode-level questions. That is a reported pattern from a small sample, not a promise, so keep a few harder problems in your practice mix.
Do I need to know SaaS or helpdesk concepts beforehand?
No. The domain in these ten problems is only dressing. What matters is recognising the underlying structure: a queue, a union-find, a parser or a sorted history.
What should I revise from my resume?
For each project, the data model, one algorithm you chose and why, and one thing that went wrong. Interviewers often start from a resume line and move into a coding follow-up.
Is it fine to talk through my code while writing it?
It is encouraged. Narrate decisions briefly, such as why a deque rather than a list, and stop talking when you need to concentrate on a tricky index.
Sources
Related guides
More in Company Interview Questions
- Freshworks Interview Questions and Answers
- Goldman Sachs coding round questions with solutions
- Goldman Sachs interview questions with answers (engineering analyst)
- Google Coding Round Questions with Solutions in Python and Java
- Google Interview Questions and Answers for SDE Roles
- Groww Coding Round Questions With Solutions
- 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