Autocoder

Postman Coding Round Questions With Solutions

Last updated 2026-11-19

Postman coding exercises are commonly described as practical and API-flavoured: build a small router, merge JSON documents, paginate results, or write an async utility, with clean code that handles edge cases. 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 Postman interview questions, and for general pacing see how to crack a DSA coding round.

Approach

Confirm the exact input and output, including error cases, then sketch the data structures. In API-style problems the edge cases are the problem: missing keys, empty bodies, duplicates, unexpected types.

Hiring status

We have no sourced Postman hiring dates, numbers or format details, so none are stated. Use the company's own careers site for current roles. See how to crack the online assessment for general strategy.

Postman Coding Round Questions With Solutions: questions with worked answers

  1. 1

    Build a URL router with path parameters such as /users/:id.

    medium

    Split registered patterns into segments. To match, split the path and compare segment counts and each segment: a segment starting with a colon captures the value, others must be equal. Return the handler and captured parameters. O(segments) per route, and a trie of segments scales better with many routes. Mistake: matching by prefix, which lets /users/1/extra match /users/:id.

    javascript
    class Router {
      constructor() { this.routes = []; }
      add(pattern, handler) {
        this.routes.push({ parts: pattern.split('/').filter(Boolean), handler });
      }
      match(path) {
        const segs = path.split('/').filter(Boolean);
        for (const { parts, handler } of this.routes) {
          if (parts.length !== segs.length) continue;
          const params = {};
          let ok = true;
          for (let i = 0; i < parts.length && ok; i++) {
            if (parts[i].startsWith(':')) params[parts[i].slice(1)] = segs[i];
            else ok = parts[i] === segs[i];
          }
          if (ok) return { handler, params };
        }
        return null;
      }
    }
  2. 2

    Implement a JSON merge patch (RFC 7386 style).

    medium

    Recursively merge the patch into the target: if the patch value is an object, merge it into the target's object (creating one if needed); a null value deletes the key; any other value replaces. Arrays are replaced whole. Mistake: mutating the input instead of working on a copy when the caller expects immutability.

    python
    def merge_patch(target, patch):
        if not isinstance(patch, dict):
            return patch
        result = dict(target) if isinstance(target, dict) else {}
        for k, v in patch.items():
            if v is None:
                result.pop(k, None)
            else:
                result[k] = merge_patch(result.get(k), v)
        return result
  3. 3

    Token bucket rate limiter.

    medium

    Store tokens and the last refill time. On each request, add elapsed time times the rate (up to capacity), then allow if at least one token is available and consume it. O(1) per request. It permits bursts up to the capacity while enforcing the average rate. Mistake: refilling with a timer thread per bucket instead of computing lazily.

    python
    class TokenBucket:
        def __init__(self, rate, capacity, now=0.0):
            self.rate, self.cap = rate, capacity
            self.tokens, self.last = capacity, now
        def allow(self, now):
            self.tokens = min(self.cap, self.tokens + (now - self.last) * self.rate)
            self.last = now
            if self.tokens >= 1:
                self.tokens -= 1
                return True
            return False
  4. 4

    Paginate through all pages of an API with an async generator.

    medium

    Loop: fetch a page with the current cursor, yield its items, and continue while the response gives a next cursor. Consumers use for await and can stop early without fetching extra pages. Mistake: collecting all pages into an array first, which uses unbounded memory.

    javascript
    async function* allItems(fetchPage) {
      let cursor = null;
      do {
        const { items, next } = await fetchPage(cursor);
        yield* items;
        cursor = next;
      } while (cursor);
    }
  5. 5

    Group and count API log entries by status class.

    easy

    Iterate once, derive the class as the status code divided by 100 (2xx, 4xx and so on), and count in a dictionary. O(n). Return the classes in sorted order for stable output. Mistake: using floating division, giving 2.04 instead of 2.

    python
    from collections import Counter
    
    def status_classes(codes):
        c = Counter(f'{code // 100}xx' for code in codes)
        return dict(sorted(c.items()))
  6. 6

    Parse HTTP headers into a case-insensitive map.

    easy

    Split each line on the first colon, trim whitespace, lowercase the name, and join repeated headers with a comma (set-cookie is the usual exception and stays separate). Lookup lowercases the key. Mistake: splitting on every colon, which breaks values like timestamps or URLs.

    python
    def parse_headers(raw):
        out = {}
        for line in raw.splitlines():
            if not line.strip() or ':' not in line:
                continue
            name, _, value = line.partition(':')
            name, value = name.strip().lower(), value.strip()
            out[name] = f'{out[name]}, {value}' if name in out else value
        return out
  7. 7

    Implement Promise.all yourself.

    medium

    Return a new promise that resolves when all inputs resolve, with results in input order, and rejects as soon as one rejects. Wrap each input with Promise.resolve to accept plain values, count completions, and resolve immediately with an empty array for empty input. Mistake: pushing results in completion order.

    javascript
    function promiseAll(items) {
      return new Promise((resolve, reject) => {
        const results = new Array(items.length);
        let done = 0;
        if (items.length === 0) return resolve(results);
        items.forEach((p, i) => {
          Promise.resolve(p).then((v) => {
            results[i] = v;
            if (++done === items.length) resolve(results);
          }, reject);
        });
      });
    }
  8. 8

    Detect a diff between two JSON objects and list changed paths.

    medium

    Recurse over the union of keys. If both values are objects, recurse with the path extended; if the values differ, record the path. A key present on one side only is a change. O(total keys). Mistake: comparing objects with equality, which tests identity, not content.

    python
    def diff(a, b, path=''):
        out = []
        for k in sorted(set(a) | set(b)):
            p = f'{path}.{k}' if path else k
            if k not in a or k not in b:
                out.append(p)
            elif isinstance(a[k], dict) and isinstance(b[k], dict):
                out += diff(a[k], b[k], p)
            elif a[k] != b[k]:
                out.append(p)
        return out
  9. 9

    Design an async task queue that runs jobs one at a time in order.

    hard

    Keep a promise chain: each add appends a step to the tail, so a job starts only after the previous one settles, and an error in one job must not break the chain. Return the job's own promise to the caller. For limited concurrency instead of one, use the pool pattern with workers. Mistake: letting a rejected job reject the chain, which stops all later jobs.

    javascript
    class SerialQueue {
      constructor() { this.tail = Promise.resolve(); }
      add(job) {
        const run = this.tail.then(job);
        this.tail = run.catch(() => {});
        return run;
      }
    }
  10. 10

    Top-k most frequent endpoints from a request log.

    easy

    Count requests per endpoint with a dictionary and select the top k with a heap of size k, or sort by (negative count, name). O(n log k) with a heap. For streaming logs, a count-min sketch approximates counts in fixed memory. Mistake: sorting the whole table when only k results are needed.

    python
    import heapq
    from collections import Counter
    
    def top_endpoints(log, k):
        c = Counter(log)
        return heapq.nsmallest(k, c, key=lambda e: (-c[e], e))

Frequently asked questions

Is the Postman coding round algorithmic or practical?

Candidate accounts describe both, with a lean towards practical, API-flavoured tasks. Check your invitation.

Which language should I use?

JavaScript or Node is natural for many roles; otherwise use the language you are strongest in.

Should I write tests?

Yes where time allows, since edge-case tests show care.

How do I practise?

Build small utilities like these under a timer, then review for edge cases and readability.

Related guides

More in Company Interview Questions

See all in this section