diff options
Diffstat (limited to 'other/single_number.rs')
-rw-r--r-- | other/single_number.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/other/single_number.rs b/other/single_number.rs deleted file mode 100644 index c724ebf..0000000 --- a/other/single_number.rs +++ /dev/null @@ -1,22 +0,0 @@ -struct Solution; - -impl Solution { - pub fn single_number(nums: Vec<i32>) -> i32 { - let mut n = nums; - n.sort(); - let mut tmp = vec![n[0]]; - for i in 1..n.len() { - if tmp.len() == 0 || tmp[tmp.len() - 1] != n[i] { - tmp.push(n[i]); - } else { - tmp.pop(); - } - } - tmp[0] - } -} - -fn main() { - let nums = vec![2,2,1]; - print!("{}", Solution::single_number(nums)); -} |