Skip to content

Commit abeb38f

Browse files
committed
Add csharp solution to 268 Missing Number
1 parent f110883 commit abeb38f

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)