Calculate the sum of first n integers i.e. n*(n+1)/2 and calculate the sum of integers in the array and subtract sum1 - sum2

{

public class Solution {

```
public int missingNumber(int[] nums) {
if(nums.length == 0)
return 0;
int n = nums.length;
int sum = n*(n+1)/2;
int sum2=0;
for(int i : nums){
sum2 +=i;
}
return sum-sum2;
} }
```

}