You are given an array of integers ranging from 1 to n. The numbers are in random order, and exactly one number is missing in the sequence. Write a function to find the missing number without sorting the array.
Example:
Input: [3, 7, 1, 2, 8, 4, 5]
Output: 6
Step 1: Calculate the total sum of 1 to N. by using (n * (n + 1)) / 2
Step 2: Iterate over the array and Substract the current number from totalSum
Step 3: Return the totalSum, which is nothing but the missing number

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?