You are given an arithmetic progression (AP) in which exactly one term is missing and represented by a placeholder (_). Your task is to find and return the missing term.
An arithmetic progression is a sequence in which the difference between consecutive terms remains constant. The given sequence is guaranteed to form a valid AP when the missing term is restored.
Input: seq = [2, 4, _, 8, 10]
Output: 6
Explanation: The common difference is 2. Therefore, the missing term is 6.
Input: seq = [5, 10, 15, _, 25]
Output: 20
Explanation: The common difference is 5. Therefore, the missing term is 20.
Input: seq = [_, 3, 5, 7]
Output: 1
Explanation: The common difference is 2. The term immediately before 3 is 1.
Sign in to write, run, and submit your solution against the full test suite.