Anthropic Software Engineer Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Convert stack samples to trace events
Question Implement convertToTrace(samples) that, given a chronologically ordered vector of stack samples (each sample contains a timestamp and a call-...
Implement thread-safe blocking queue
Question Design and implement a thread-safe bounded blocking queue that supports concurrent enqueue and dequeue operations using standard synchronizat...
Solve programming task with follow-ups
Question Pure programming problem solving: implement the core algorithmic solution, then extend it to ( 1) support a constraint of consecutive N eleme...
Implement file deduplication at scale
Write a program to deduplicate files in a very large directory tree. Identify groups of identical files without loading entire files into memory. Outl...
Simulate stack traces from logs
Given a list of log entries describing function calls, each formatted as "<id> <event> <timestamp>" where event ∈ {START, END} and timestamps are inte...
Parse and Reconstruct Stack Trace
Given a multi-line stack trace string from a single thread (e.g., each frame is in the form 'at Module::Function(file:line)'), design and implement a ...
Apply bitwise tricks for performance
For an integer-heavy inner loop, propose bit-level optimizations that reduce branches and memory traffic: e.g., population count usage, fast modulo by...
Compute exclusive times and call stack from logs
Design an algorithm that, given a single-threaded program's execution log, computes per-function exclusive durations and reconstructs the active call ...
Parse and Reconstruct Stack Trace
Given a multi-line stack trace string from a single thread (e.g., each frame is in the form 'at Module::Function(file:line)'), design and implement a ...
Implement hostname-restricted web crawler
Implement a single-threaded web crawler that, given a starting URL startUrl and an interface getUrls(url) that returns all hyperlinks on the page at u...
Detect duplicate files efficiently
You are given access to a very large file system containing file paths and read access to file contents. Design an algorithm to identify groups of fil...
Design high-throughput hashing for kernels
Design a high-throughput hash-based lookup to be called inside a tight kernel. Choose between open addressing and chaining, specify the load factor, p...
Implement a recency-eviction bounded cache
Implement an in-memory key–value store with a fixed capacity N that uses recency-based eviction. Support: get(key) -> value or -1 if missing, and put(...
Compute exclusive times and call stack from logs
Design an algorithm that, given a single-threaded program's execution log, computes per-function exclusive durations and reconstructs the active call ...
Design an in-memory banking service
Design an in-memory banking service supporting timestamped operations and edge-case semantics. Implement: ( 1) create_account(id, t): Create a new acc...
Compute exclusive times and call stack from logs
Design an algorithm that, given a single-threaded program's execution log, computes per-function exclusive durations and reconstructs the active call ...
Parse and Reconstruct Stack Trace
Given a multi-line stack trace string from a single thread (e.g., each frame is in the form 'at Module::Function(file:line)'), design and implement a ...
Implement file deduplication at scale
Implement a command-line tool to find duplicate files in a directory tree. Use OS/pathlib primitives to recursively enumerate files. Apply prefilters ...
Design file deduplication algorithm
Design an algorithm to deduplicate files in a storage system. Compare fixed-size versus content-defined chunking and explain how you would choose hash...
Design and implement a Python solution
Design and implement a solution in Python for a problem specified by the interviewer. Outline your approach and chosen data structures, justify key de...