Meta Coding Interview / Online Assessment: Find the Missing Integer in an Arithmetic Progression

21 Views
No Comments

Given an array of integers that is an arithmetic progression missing one integer, return the missing integer.

Example: [1, 2, 4, 5] -> 3

The key idea is to identify the missing value in an arithmetic progression. Since the numbers should follow a constant difference, you can infer the common difference from the endpoints and the array length, then scan for the first gap that breaks the pattern. Another clean approach is to compute the expected sum of the full progression and subtract the actual sum. Both solutions are linear time, and the sum-based version uses constant extra space.

END
 0