Skip to content

Commit

Permalink
Add csharp solution to 268 Missing Number
Browse files Browse the repository at this point in the history
  • Loading branch information
SPponmag committed Aug 20, 2022
1 parent f110883 commit abeb38f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions csharp/268-Missing-Number.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class Solution {
public int MissingNumber(int[] nums) {
int sum = 0;
int total = nums.Length * (nums.Length + 1) / 2;
for (int i = 0; i < nums.Length; i++) {
sum += nums[i];
}
return total - sum;
}
}

0 comments on commit abeb38f

Please sign in to comment.