DSAEasyArraysMath
Find the Missing Number
đ Problem
You're given an array containing n distinct numbers from 0 to n (one number is missing). Find the missing number.
đ§ Approach
The sum of numbers from 0 to n has a known formula: n*(n+1)/2. Calculate this expected sum, then subtract the actual sum of the array's elements â the difference is the missing number. This avoids sorting or extra memory entirely.