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/string_compression2.cpp | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 other/string_compression2.cpp (limited to 'other/string_compression2.cpp') diff --git a/other/string_compression2.cpp b/other/string_compression2.cpp deleted file mode 100644 index f4c41c8..0000000 --- a/other/string_compression2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int getLengthOfOptimalCompression(string s, int k) { - memset(dp, -1, sizeof(dp)); - str = s, p = s.size(); - return solve(0, k); - } - -private: - const static int N = 127; - int dp[N][N], p; - string str; - inline int helper(int x) { return x == 1 ? 0 : x < 10 ? 1 : x < 100 ? 2 : 3; } - int solve(int left, int k) { - if (k < 0) - return N; - if (left >= p || p - left <= k) - return 0; - int &ans = dp[left][k]; - if (ans != -1) - return ans; - ans = N; - int count[26] = {0}; - for (int i = left, j = 0; i < p; i++) { - j = max(j, ++count[str[j] - 'a']); - ans = min(ans, 1 + helper(j) + solve(i + 1, k - (i - left + 1 - j))); - } - return ans; - } -}; - -int main() { - Solution obj; - cout << obj.getLengthOfOptimalCompression("aaabcccd", 2); -} -- cgit v1.2.3