YourAlly

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

  1. Fewest Vocabulary Tokens to Encode Text Locked
  2. Parse Nested Policy Expressions Locked
  3. Redact Sensitive Spans Locked
  4. Sliding Window Maximum Latency Locked
  5. Token Bucket Rate Limiter Locked

Sign up free to practice all 6

Related pages

More Anthropic Senior rounds

Anthropic coding at other levels

Other companies at this level

Company guide

Anthropic interview guide in Academy