Identify read-only files from permission records
Company: Jump Trading
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: nan
Interview Round: Take-home Project
Quick Answer: This question evaluates proficiency in parsing and filtering structured data by interpreting Unix-like permission strings and extracting filenames based on permission semantics.
Constraints
- 0 <= len(records) <= 100000
- Each record is a tuple (owner, permission, filename)
- permission is exactly 9 characters long and contains only 'r', 'w', 'x', and '-'
- Filenames are unique
Examples
Input: ([('alice', 'r--r--r--', 'a.txt'), ('bob', 'rw-r--r--', 'b.txt'), ('carl', 'r-xr-xr-x', 'c.sh')],)
Expected Output: ['a.txt', 'c.sh']
Explanation: a.txt and c.sh have no 'w' in their permission strings, while b.txt does.
Input: ([],)
Expected Output: []
Explanation: An empty input list produces an empty output list.
Input: ([('zoe', '---------', 'empty.bin')],)
Expected Output: ['empty.bin']
Explanation: The permission string contains no write permission at all, so the file is read-only.
Input: ([('dana', 'r-xrw-r--', 'group.txt'), ('erin', 'r-xr-xrwx', 'other.txt'), ('fran', 'rwxr-xr-x', 'owner.txt')],)
Expected Output: []
Explanation: Each file has at least one 'w' somewhere in the permission string, so none are read-only.
Input: ([('gina', 'r--r--r--', 'notes.md'), ('harry', 'r-xr-xr-x', 'run.sh'), ('ivy', 'r--rw-r--', 'draft.txt'), ('jack', '---------', 'hidden')],)
Expected Output: ['notes.md', 'run.sh', 'hidden']
Explanation: notes.md, run.sh, and hidden contain no 'w'. draft.txt has write permission in the group section.
Hints
- You do not need to analyze owner, group, and others separately if all you care about is whether write permission exists anywhere.
- A single pass through the records is enough: if 'w' is not in the permission string, add the filename to the answer.