Preparation resource for Anthropic SWE coding interviews, including full problem statements, solutions, and system design insights based on recent candidate reports. This document will evolve over time
- Web Crawler Problem - Full Solution
- Additional Anthropic Coding Interview Questions
- Anthropic System Design Interview Prep
- Mock Interviews & Practice Resources
Difficulty: Moderately Challenging
Round Asked: Anthropic Phone Screen
Build a single-threaded web crawler that discovers all URLs reachable from a starting URL, filtering by hostname.
Given types / helpers:
type Url = str
class LinkProvider:
def get_links(self, url: Url) -> List[Url]:
"""Return the outgoing links found on the given page.
Think of this as: "open this page and list the URLs it directly links to."
"""
pass
def get_hostname(url: Url) -> str:
"""Return the hostname portion of a URL.
Example:
Input: "https://site.com/blog/article-1"
Output: "site.com"
"""
raise NotImplementedErrorTask: Implement:
def crawl_same_host(start_url: Url, provider: LinkProvider) -> Set[Url]Requirements: Return the set of all unique URLs that meet both conditions:
- They can be discovered by starting at
start_urland repeatedly following links returned byprovider.get_links - They have the same hostname as
start_url(i.e.,get_hostname(url) == get_hostname(start_url))
Include start_url in the returned set.
Constraints:
- Output order does not matter
For step-by-step video walkthrough see this
from __future__ import annotations
from typing import List, Set
from collections import deque
Url = str
class LinkProvider:
def get_links(self, url: Url) -> List[Url]:
"""Return the outgoing links found on the given page."""
pass
def get_hostname(url: Url) -> str:
"""Return the hostname portion of a URL."""
raise NotImplementedError
def crawl_same_host(start_url: Url, provider: LinkProvider) -> Set[Url]:
# determine the target hostname once
target_hostname = get_hostname(start_url)
# initialise data structures
# - seen urls: every url we have already encountered before
# - result urls: every valid same-host url that should be returned
# - urls to visit: valid same-host urls whose outgoing links we still need to process
seen_urls: Set[Url] = set()
result_urls: Set[Url] = set()
urls_to_visit: deque[Url] = deque()
# seed the traversal with start_url
# - mark it as seen
# - add it to the result
# - enqueue it for processing
seen_urls.add(start_url)
result_urls.add(start_url)
urls_to_visit.append(start_url)
# process urls to visit while there is still work to do
while urls_to_visit:
# - take one url from the front of the queue
current_url = urls_to_visit.popleft()
# for each linked url:
for linked_url in provider.get_links(current_url):
# - skip if we have already seen it
if linked_url in seen_urls:
continue
# - otherwise mark it as seen immediately
seen_urls.add(linked_url)
# - if it is on the same hostname:
# - add it to the result
# - enqueue it for future processing
if get_hostname(linked_url) == target_hostname:
result_urls.add(linked_url)
urls_to_visit.append(linked_url)
# return result, i.e. all valid same-host urls encountered
return result_urlsTime Complexity: O(V + E) where V = unique URLs, E = total links
Space Complexity: O(V) for tracking visited URLs
These questions have appeared in recent Anthropic SWE coding interviews (CodeSignal OA, phone screens, and onsite rounds). Summaries provided below — full problem statements and solutions available in the practice course.
1. Web Crawler II (Concurrent)
- Extend single-threaded crawler to use multiple workers (threads/async tasks)
- Handle shared state safely under concurrency
- Must reliably terminate when all work is complete
2. Stack Trace Conversion
- Convert profiler stack snapshots into start/end events
- Handle nested function calls and recursion
- Manage same-timestamp event ordering
3. Duplicate File Finder
- Traverse directory tree to find files with identical content
- Optimize for large files (avoid loading everything into memory)
- Handle symbolic links and edge cases
4. LRU Cache with Persistence
- Implement standard LRU cache (get/put operations)
- Discuss how to make cache survive process restarts
- Consider disk storage and usage order restoration
5. Profiler Trace Denoising
- Filter short-lived function calls from sampling profiler data
- Track consecutive appearances threshold
- Emit events only for confirmed long-running calls
6. Recipe Catalog
- Store recipes with ingredients, cook times, ratings
- Search by ingredient, filter by time constraints
- Suggest meals based on available ingredients
7. Task Tracker
- Create tasks with priorities, support prefix search
- Assign tasks with deadlines, track completion
- Report overdue tasks, handle assignment state transitions
8. Record Store (In-Memory Database)
- Support field-level operations with TTL (time-to-live)
- Conditional writes (compare-and-set/delete)
- Historical queries (get value at past timestamp)
9. Bank Ledger
- Account creation, deposits, transfers
- Delayed cashback scheduling (credited after 24 hours)
- Balance history queries, spending rankings
10. Worker Mode Tracker
- Collect data from multiple worker shards
- Track most frequent values globally
- Support worker removal (erase historical contributions)
11. Greedy Tokenizer
- Longest-match tokenization with vocabulary lookup
- Handle overlapping tokens, prefix validation
- Fall back to unknown token when no match found
12. Count Smaller to the Right
- For each element, count how many smaller elements exist to its right
- Optimize beyond brute force O(n²) approach
- Use merge sort for O(n log n) solution
For full problem statements with detailed solutions:
Anthropic Interview Prep Course - Complete Question Bank
Hidden Gotcha in System Design Rounds
Anthropic's system design interviews have specific expectations that catch candidates off guard. Watch this 60-second breakdown of what to watch out for:
The Hidden Gotcha in Anthropic's System Design Interview
Detailed breakdown of Anthropic system design interview questions, evaluation criteria, and preparation strategies:
Anthropic System Design Interview Questions - Complete Guide
Topics covered:
- Common system design questions asked at Anthropic
- What interviewers evaluate (scalability, tradeoffs, API design)
- How to structure your system design answers
- Anthropic-specific expectations vs. standard FAANG
Practice Anthropic-style coding interviews with senior FAANG+ engineers who can simulate real interview conditions and provide detailed feedback.
Book a Mock Interview - Coditioning
Connect with other candidates preparing for Anthropic and top tech companies. Practice coding interviews together, give each other feedback, and improve interview skills.
Find a peer mock partner:
- Browse match profiles: Peer Mock Search Board - filter by target companies (Anthropic, Google, Meta, Amazon), experience level, and interview domains
- Join the community: Coditioning Discord - coordinate practice sessions, share experiences, and get prep tips
This guide compiles Anthropic SWE coding interview questions and patterns based on candidate reports. Interview formats and questions may evolve over time.
Last updated: March 2026
For the most current preparation resources: