BrowserStack Coding Round Questions With Solutions
Last updated 2026-11-19
BrowserStack coding exercises are commonly described as more practical than a pure algorithm test: parse something, build a small utility, control asynchronous work, or design a small data structure that works with edge cases covered. The ten practice problems below follow that style, with JavaScript and Python solutions.
They are practice problems, not real papers. For concepts and design see BrowserStack interview questions, and for general pacing read how to crack a DSA coding round.
How to approach practical problems
Clarify input and output formats first, then write a small test list before coding: empty input, malformed input, large input. Practical rounds reward code that is readable and handles failure sensibly.
Hiring status
We have no sourced BrowserStack hiring dates, numbers or format details, so none are stated. Check the company's own careers site for current roles. For test strategy see how to crack the online assessment.
BrowserStack Coding Round Questions With Solutions: questions with worked answers
1 Implement debounce.
easyReturn a wrapper that clears the pending timer on each call and schedules the function after the delay, so only the last call in a burst runs. Preserve this and arguments. Used for search boxes and resize handlers. Throttle differs: it runs at most once per interval. Mistake: creating the timer variable inside the wrapper, which loses it between calls.
javascriptfunction debounce(fn, delay) { let timer; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); }; }2 Run async tasks with a concurrency limit (promise pool).
mediumStart up to the limit of workers that each pull the next task index until none remain, then await all workers. Results are stored by index so order is preserved. Mistake: starting all tasks with Promise.all, which ignores the limit and can overload a service.
javascriptasync function pool(tasks, limit) { const results = new Array(tasks.length); let next = 0; async function worker() { while (next < tasks.length) { const i = next++; results[i] = await tasks[i](); } } await Promise.all(Array.from({ length: Math.min(limit, tasks.length) }, worker)); return results; }3 Deep clone an object, handling arrays, dates and cycles.
mediumRecurse with a WeakMap from original to clone so cycles resolve to the same copy. Handle arrays and plain objects by copying own keys, and Dates by constructing a new Date. In modern runtimes structuredClone does this for most data, but not functions. Mistake: JSON.parse(JSON.stringify(x)), which drops undefined and functions, turns dates into strings and throws on cycles.
javascriptfunction deepClone(x, seen = new WeakMap()) { if (x === null || typeof x !== 'object') return x; if (x instanceof Date) return new Date(x); if (seen.has(x)) return seen.get(x); const out = Array.isArray(x) ? [] : {}; seen.set(x, out); for (const k of Object.keys(x)) out[k] = deepClone(x[k], seen); return out; }4 Flatten a nested object into dotted keys.
easyWalk recursively, joining the path with dots for plain objects, and store leaf values (including arrays treated as leaves unless stated) under the joined key. O(total keys). Mistake: treating null as an object, which crashes when iterating it.
pythondef flatten(obj, prefix=''): out = {} for k, v in obj.items(): key = f'{prefix}.{k}' if prefix else k if isinstance(v, dict) and v: out.update(flatten(v, key)) else: out[key] = v return out5 Compare two semantic version strings.
easySplit on dots, compare the numeric parts left to right as integers (not strings, since "10" is less than "9" lexicographically), treating missing parts as zero. Return -1, 0 or 1. O(length). Mistake: comparing strings lexicographically.
pythondef compare_versions(a, b): x = [int(p) for p in a.split('.')] y = [int(p) for p in b.split('.')] n = max(len(x), len(y)) x += [0] * (n - len(x)) y += [0] * (n - len(y)) return (x > y) - (x < y)6 Parse a query string into an object, handling repeated keys and encoding.
mediumSplit on ampersands, split each pair on the first equals sign, decode both parts, and collect repeated keys into a list. Mistake: splitting on every equals sign, which breaks values that contain it, and forgetting to decode plus signs as spaces in form-encoded strings.
pythonfrom urllib.parse import unquote_plus def parse_qs(q): out = {} for pair in q.lstrip('?').split('&'): if not pair: continue k, _, v = pair.partition('=') k, v = unquote_plus(k), unquote_plus(v) if k in out: if not isinstance(out[k], list): out[k] = [out[k]] out[k].append(v) else: out[k] = v return out7 Match a cron field against a time (supports star, lists, ranges and steps).
hardFor each field, split on commas; each part is a star, a number, a range a-b, optionally with a slash step. Expand it into the matching set within the field bounds and test membership. Mistake: applying the step from zero instead of from the range start.
pythondef field_matches(expr, value, lo, hi): for part in expr.split(','): rng, _, step = part.partition('/') step = int(step) if step else 1 if rng == '*': a, b = lo, hi elif '-' in rng: a, b = map(int, rng.split('-')) else: a = int(rng) b = hi if step != 1 or '/' in part else a if a <= value <= b and (value - a) % step == 0: return True return False8 Retry with exponential backoff.
mediumAttempt the call; on failure wait base times 2 to the power attempt (optionally with random jitter to avoid synchronised retries) and try again up to a maximum number of attempts, then rethrow. Retry only transient errors such as timeouts and 5xx, never validation errors. Mistake: no cap or jitter, which can create retry storms.
javascriptasync function retry(fn, attempts = 5, base = 100) { for (let i = 0; ; i++) { try { return await fn(); } catch (e) { if (i + 1 >= attempts) throw e; const delay = base * 2 ** i * (0.5 + Math.random() / 2); await new Promise((r) => setTimeout(r, delay)); } } }9 Find the minimum number of meeting rooms or browser sessions needed.
mediumSort start and end times separately and sweep: a session starting before the earliest remaining end needs a new machine, otherwise it reuses one. O(n log n). This is the same as the maximum overlap of intervals, a natural fit for a device-grid capacity question.
pythondef max_concurrent(sessions): starts = sorted(s for s, e in sessions) ends = sorted(e for s, e in sessions) j = used = best = 0 for s in starts: while ends[j] <= s: j += 1 used -= 1 used += 1 best = max(best, used) return best10 Validate an HTML-like tag nesting (matching open and close tags).
mediumUse a stack of open tag names. On an open tag push it; on a close tag the stack top must be the same name, otherwise the markup is invalid. At the end the stack must be empty. Handle self-closing tags by not pushing them. O(n).
pythonimport re def valid_tags(html): st = [] for m in re.finditer(r'<(/?)([a-zA-Z][a-zA-Z0-9]*)[^>]*?(/?)>', html): closing, name, selfclose = m.groups() if selfclose: continue if closing: if not st or st.pop() != name: return False else: st.append(name) return not st
Frequently asked questions
Is the BrowserStack coding round algorithmic?
Candidate accounts describe a mix: some algorithm questions and some practical tasks. Prepare both and check your invitation.
Which language should I choose?
Use the language you are strongest in, unless the role specifies one. JavaScript is useful for web-focused roles.
Should I write tests?
Yes where time allows. A few edge-case tests show care and catch mistakes.
How can I practise machine coding?
Pick small utilities like those above, build them from scratch under a timer, and add edge-case tests.
Related guides
More in Company Interview Questions
- BrowserStack Interview Questions and Answers
- Cadence Coding Round Questions with Solutions
- Cadence Interview Questions and Answers for India R&D Software Roles
- Capgemini Coding Round Questions with Solutions
- Capgemini Interview Questions for Freshers
- Cisco Coding Round Questions with Solutions in Python and Java
- Cisco Interview Questions and Answers: Networking and SDE Roles
- Citi coding round questions with solutions
- Citi interview questions with answers (technology analyst)
- ClearTax Coding Round Questions
- ClearTax Interview Questions with Answers
- Coforge Coding Round Questions with Solutions