You are given an array arr[] of size n - 1, containing distinct integers ranging from 1 to n (inclusive), except one missing element. The task is to find and return the missing integer from the range.
Example 1
Input: arr[] = [1, 2, 3, 5]
Output: 4
Explanation: All the numbers from 1 to 5 are present except 4.
Example 2
Input: arr[] = [8, 2, 4, 5, 3, 7, 1]
Output: 6
Explanation: All the numbers from 1 to 8 are present except 6.
Example 3
Input: arr[] = [1]
Output: 2
Explanation: Only 1 is present so the missing element is 2.
Sign in to write, run, and submit your solution against the full test suite.