Anthropic Software Engineer Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
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 staircase printing and distributed mode/median
Problem A: Print a “staircase” pattern Implement a function that prints a staircase with n rows. Input - An integer n (n >= 1) Output - Print n lines....
Generate outputs for images and pipelines
You are given m input images and n processing pipelines. - Each pipeline is an ordered list of k operations (e.g., resize, rotate, crop, blur, color t...
Design a single- and multi-threaded web crawler
Web Crawler (single-threaded, then multi-threaded) You are given: - A starting URL startUrl (e.g., "http://news.example.com/a/index.html"). - An inter...
Find duplicate files and apply image operations
Part A — Find duplicate files by content You are given a list of directory records. Each record is a string describing a directory path followed by on...
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 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 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...
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 ...
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 ...
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...
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...
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 ...
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 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...
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...