Parse Case Law Citations Into Volume Reporter and Page
Last updated: November 29, 2026
Quick Overview
Write a parser that turns a case citation string such as '550 F.3d 1023, 1030 (9th Cir. 2008)' into structured fields: volume, reporter, first page, optional pin cite, optional court, and optional year.
Harvey
November 29, 20260
0
0 solved
Write a parser that turns a case citation string such as '550 F.3d 1023, 1030 (9th Cir. 2008)' into structured fields: volume, reporter, first page, optional pin cite, optional court, and optional year.
Citations are central to Harvey's legal research answers, where every claim should point at a verifiable source. This screen checks careful string handling, clean use of regular expressions or a hand tokenizer, and judgment about malformed input.
What the Interviewer Expects
- Identify the grammar before coding: volume, reporter, page, optional pin, optional parenthetical
- Handle multi-word reporters like 'Cal. App. 4th'
- Return None or an error for strings that do not match
- Normalize whitespace in the reporter
- Write a few tests covering optional parts
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you extract every citation from a full brief rather than parse one string?
- How do you handle 'Id.' and 'supra' short forms that refer back to earlier citations?
- How would you validate the reporter against a known list?
- What about parallel citations separated by commas?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
A citation has the shape <volume> <reporter> <page>[, <pin>] [(<court> <year>)]. Volume and page are integers. The reporter can contain letters, digits, periods, and spaces (U.S., F.3d, `Cal. Ap...
High-Level Design
Anchor a regex at both ends so partial matches fail. The tricky part is the reporter, because it can contain digits (F.3d, 4th). Making the reporter group lazy and requiring whitespace then digits...