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.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 other/count_distinct_int.cpp (limited to 'other/count_distinct_int.cpp') diff --git a/other/count_distinct_int.cpp b/other/count_distinct_int.cpp deleted file mode 100644 index ff5c1d6..0000000 --- a/other/count_distinct_int.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// 2442. Count Number of Distinct Integers After Reverse Operations -#include "leetcode.h" - -/* - * 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 - */ - -class Solution { -public: - int countDistinctIntegers(vector &nums) { - // unordered set constructor to insert 'nums' - // note: a set only maintains unique values in it - unordered_set us(nums.begin(), nums.end()); - // find reverse of every num - for (auto i : nums) { - int n = 0; - while (i) { - int rem = i % 10; - n = n * 10 + rem; - i /= 10; - } - // insert (to end) reverse - us.insert(n); - } - // we can simply return the size since - // every element in a set is unique - return us.size(); - } -}; - -int main() { - Solution obj; - vector nums1 = {1, 13, 10, 12, 31}, nums2 = {2, 2, 2}; - cout << obj.countDistinctIntegers(nums1) << endl; // expect: 6 - cout << obj.countDistinctIntegers(nums2) << endl; // expect: 1 -} -- cgit v1.2.3