Find the Missing Number
EasyGoogle, Facebook, Amazon
0 views
0 likes
Array Math Algorithm
Problem Description
Find the Missing Number
Given an array of size 'n' containing n-1 distinct numbers in the range of 1 to n. Find the missing number.
Write a function that takes an array of integers as an input and returns the missing number.
Example 1:
Input: [1, 2, 4, 5, 6]
Output: 3Example 2:
Input: [2, 3, 1, 5]
Output: 4Constraints:
- The array contains distinct integers in the range 1 to n.
- The size of the array is n-1.
Solution
Click to load code editor