Check whether a target is the sum of two of the first n Fibonacci numbers
Company: Hudson River Trading
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
Given an integer `n` and an integer `target`, determine whether `target` can be expressed as the sum of two (not necessarily distinct) Fibonacci numbers from the first `n` Fibonacci numbers.
The Fibonacci sequence is defined as `F(0) = 0`, `F(1) = 1`, and `F(i) = F(i-1) + F(i-2)` for `i >= 2`. Return `True` if such a pair exists, otherwise return `False`.
### Function Signature
```python
def fibonacci_sum_check(n: int, target: int) -> bool:
```
### Rules
- The first `n` Fibonacci numbers are `F(0), F(1), ..., F(n-1)`. For `n = 7` that list is `[0, 1, 1, 2, 3, 5, 8]`.
- Both numbers of the pair must come from that list.
- The same number may be used twice, so `F(i) + F(i)` counts as a pair.
### Constraints
- `1 <= n <= 30`
- `0 <= target <= 10^9`
### Examples
```text
Input: n = 7, target = 8
Output: True
```
The first 7 Fibonacci numbers are `[0, 1, 1, 2, 3, 5, 8]`. We can form 8 as 3 + 5 (or 0 + 8).
```text
Input: n = 5, target = 7
Output: False
```
The first 5 Fibonacci numbers are `[0, 1, 1, 2, 3]`. The largest possible sum is 3 + 3 = 6, so no pair reaches 7.
```text
Input: n = 4, target = 4
Output: True
```
The list is `[0, 1, 1, 2]`. No two different entries add up to 4, but 2 + 2 = 4 is allowed because a number may be used twice.
Overview: Decide whether a target integer equals the sum of two values taken from the first n Fibonacci numbers, where the same value may be used twice. It tests generating a sequence iteratively, searching for a pair sum in sorted data, and handling edge cases such as reuse and a target of zero.