diff --git a/rs/missing-number.rs b/rs/missing-number.rs new file mode 100644 index 0000000..a9b9771 --- /dev/null +++ b/rs/missing-number.rs @@ -0,0 +1,6 @@ +impl Solution { + pub fn missing_number(nums: Vec) -> i32 { + let n = nums.len() as i32; + n * (n + 1) / 2 - nums.iter().sum::() + } +}