From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/count_distinct_int.rs | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 other/count_distinct_int.rs (limited to 'other/count_distinct_int.rs') diff --git a/other/count_distinct_int.rs b/other/count_distinct_int.rs deleted file mode 100644 index 32ce622..0000000 --- a/other/count_distinct_int.rs +++ /dev/null @@ -1,35 +0,0 @@ -//2442. Count Number of Distinct Integers After Reverse Operations -use std::collections::HashSet; -struct Solution; - -/* - * array nums contains positive integers - * take each integer in array and reverse its digits (eg. 13 -> 31) - * then *add* it to end of array. return number of distinct integers. - * [1,13,10,12,31] becomes [1,13,10,12,31,1,31,1,21,13] - * and total num of distinct ints = 6 - */ - -impl Solution { - pub fn count_distinct_integers(nums: Vec) -> i32 { - let mut hs: HashSet = nums.iter().map(|&n| Self::reverse(n)).collect(); - hs.extend(nums.iter()); - hs.len() as i32 - } - fn reverse(mut n: i32) -> i32 { - let mut rev: i32 = 0; - while n > 0 { - rev *= 10; - rev += n % 10; - n /= 10; - } - rev - } -} - -fn main() { - let nums1 = vec![1,13,10,12,31]; - let nums2 = vec![2,2,2]; - println!("{}", Solution::count_distinct_integers(nums1)); //expect: 6 - println!("{}", Solution::count_distinct_integers(nums2)); //expect: 1 -} -- cgit v1.2.3