diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/string_compression2.cpp | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/string_compression2.cpp')
-rw-r--r-- | other/string_compression2.cpp | 37 |
1 files changed, 0 insertions, 37 deletions
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); -} |