Find missing numbers in sequences
Company: Optiver
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Take-home Project
Quick Answer: This question evaluates sequence pattern recognition, numerical reasoning with integers and rational numbers, and the ability to infer recurrences or closed-form relations from series data.
Part 1: Number Logic - Fill the Missing Term
Constraints
- 4 <= len(sequence) <= 30
- Exactly one entry is '?'
- The full sequence matches exactly one supported family
- If the sequence is geometric, all known terms are non-zero and the ratio is rational
Examples
Input: ['3', '7', '11', '?', '19']
Expected Output: "15"
Explanation: This is an arithmetic progression with common difference 4.
Input: ['16', '8', '4', '?', '1']
Expected Output: "2"
Explanation: This is a geometric progression with ratio 1/2.
Input: ['?', '1', '1', '2', '3', '5']
Expected Output: "0"
Explanation: Fibonacci-like sequence: 0, 1, 1, 2, 3, 5. This is an edge case with the missing value at the first position.
Input: ['1', '4', '9', '?', '25']
Expected Output: "16"
Explanation: These are consecutive squares, so the sequence has constant non-zero second difference.