Find Missing Element
Solutions
Approach - Iterative Technique
public class Solution
{
public static int FindMissingElement(int[] arr)
{
int n = arr.Length;
int total = (n + 1) * (n + 2) / 2;
for (int i = 0; i < n; i++)
total -= arr[i];
return total;
}
}
Last updated