Asked inDE Shaw,Quality Testing Intern

Find the Missing Number in an Arithmetic Progression

You are given a sorted array consisting of ‘N’ distinct integers, forming a nearly complete Arithmetic Progression, except for one missing element. Your task is to find the missing number in the sequence.

Input:

The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains a single positive integer 'N' denoting the number of elements in the sequence.
The second line of each test case contains 'N' space-separated integers.

Output:

For each test case, output a single integer that represents the missing element in the given sequence.
Print the result for each test case on a new line.

Example:

Input:
T = 1
N = 5
sequence = [1, 3, 7, 9, 11]
Output:
5

Explanation:

The given sequence is missing '5'. The sequence should be [1, 3, 5, 7, 9, 11].

Constraints:

  • 1 ≤ T ≤ 50
  • 3 ≤ N ≤ 104
  • -109 ≤ Arr[i] ≤ 109

Note:

1. An Arithmetic Progression sequence is defined as a sequence [arr0, arr1, ..., arrn-1] where for each 'i' (0 ≤ i < n - 1), arr[i+1] - arr[i] is the same constant.

2. There is exactly one element missing in the sequence.

3. All numbers in the sequence are distinct.

4. The first and last elements in the sequence are guaranteed to be present.

Be the first one to answer
Select
Add answer anonymously...
DE Shaw Quality Testing Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits