Anthropic Senior coding interview questions
These are the 6 coding questions YourAlly has tagged for Anthropic at Senior. On the YourAlly ladder this is Senior, the same level as Google L5, Meta E5 and Amazon L6.
A coding round at a large tech company usually runs 45 to 60 minutes with one or two problems. You write code that runs, test it on your own examples and state its time and space cost. At this level the bar is a correct, tested solution you reach mostly on your own, with the trade-offs said out loud.
Practice a mock Anthropic Senior coding loopPractice Anthropic coding questions
Apply Ranked Byte Pair MergesFree to read
A byte pair tokenizer starts with each character as its own token. merges[r] = [left, right] is a merge rule with rank r, lower is applied first. Repeatedly merge the leftmost occurrence of the lowest-ranked adjacent pair until no rule applies, and return the final tokens.
Input: text = "aaab", merges = [["a","a"],["aa","b"]] Output: ["aa","a","b"]
What a strong answer covers
- Doubly linked list for O(1) merges
- Min-heap keyed by rank then position with lazy validation
- Interned token ids and spans so merges copy no characters
- Leftmost tie-break justified
- O(M + n log n) time and O(M + n) space
5 more coding questions
- Fewest Vocabulary Tokens to Encode Text Locked
- Parse Nested Policy Expressions Locked
- Redact Sensitive Spans Locked
- Sliding Window Maximum Latency Locked
- Token Bucket Rate Limiter Locked
Related pages
More Anthropic Senior rounds
- System design 4 questions
- Behavioral 4 questions
Anthropic coding at other levels
- Staff 5 questions
- Senior staff 5 questions
- Senior EM 4 questions
Other companies at this level
- Adobe Senior 7 questions
- Airbnb Senior 4 questions
- Amazon L6 10 questions
- Apple Senior 7 questions
- Cisco Senior 6 questions
- Google L5 14 questions