Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Anthropic interview question

Web crawler restricted to one hostname, single-threaded then multi-threaded

Company:
Anthropic
Type:
Coding
Difficulty:
Medium
Reported:
November 16, 2026

Problem

Given a start_url and an html_parser with a method get_urls(url) that returns the links on a page, return all URLs reachable from start_url whose hostname is exactly the same as the hostname of start_url.

Rules:

  • Remove the fragment (everything from # onward) from a URL before comparing or storing it.
  • The hostname must match exactly.
  • The link graph may contain cycles; never crawl the same URL twice.

The examples omit the URL scheme for brevity.

First write a single-threaded version. Then write a multi-threaded version.

Example 1

Input:
  start_url = "a.com/x"
  links: "a.com/x" -> ["a.com/y#top", "b.com/z"]
         "a.com/y" -> ["a.com/x", "sub.a.com/w"]
Output: ["a.com/x", "a.com/y"] (any order)

b.com and sub.a.com have different hostnames; the fragment is stripped from "a.com/y#top"; the cycle back to x is ignored.

Constraints

  • Not stated; ask the interviewer.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern