</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSâ€ēPractice Problems
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.

← Back to all Problems