Compress vertices into uniques and indices
Company: Applied
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates a candidate's ability to perform duplicate detection and compression of sequences of fixed-length tuples, exercising skills in data structures, mapping/hash concepts, array manipulation, and preserving first-seen ordering.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([[2,2,2], [0,1,0], [2,1,2], [0,1,0]],)
Expected Output: {'unique_vertices': [[2, 2, 2], [0, 1, 0], [2, 1, 2]], 'indices': [0, 1, 2, 1]}
Explanation: Prompt example.
Input: ([],)
Expected Output: {'unique_vertices': [], 'indices': []}
Explanation: No vertices.
Input: ([[1,2], [1,2], [1,3]],)
Expected Output: {'unique_vertices': [[1, 2], [1, 3]], 'indices': [0, 0, 1]}
Explanation: Repeated first vertex.
Hints
- Pick a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.