Skip to content

Commit 39fe33d

Browse files
authored
Merge pull request #870 from pontusdacke/268-missing-number
Add csharp solution to 268 Missing Number
2 parents f1ca6d2 + abeb38f commit 39fe33d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: csharp/268-Missing-Number.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Solution {
2+
public int MissingNumber(int[] nums) {
3+
int sum = 0;
4+
int total = nums.Length * (nums.Length + 1) / 2;
5+
for (int i = 0; i < nums.Length; i++) {
6+
sum += nums[i];
7+
}
8+
return total - sum;
9+
}
10+
}

0 commit comments

Comments
 (0)