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/palindrome_pairs.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 other/palindrome_pairs.cpp (limited to 'other/palindrome_pairs.cpp') diff --git a/other/palindrome_pairs.cpp b/other/palindrome_pairs.cpp deleted file mode 100644 index 8048069..0000000 --- a/other/palindrome_pairs.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vvd palindromePairs(vector &words) { - unordered_map um; - for (int i = 0; i < words.size(); i++) { - string x = words[i]; - reverse(x.begin(), x.end()); - um[x] = i; - } - vvd ans; - for (int j = 0; j < words.size(); j++) { - string str = words[j]; - for (int i = 0; i <= str.size(); i++) { - string prefix = str.substr(0, i), suffix = str.substr(i); - if (!prefix.empty() && isPalindrome(prefix) && um.count(suffix) && - j != um[suffix]) - ans.push_back({um[suffix], j}); - if (isPalindrome(suffix) && um.count(prefix) && j != um[prefix]) - ans.push_back({j, um[prefix]}); - } - } - return ans; - } - -private: - bool isPalindrome(string &str) { - int i = 0, j = str.size() - 1; - while (i < j) { - if (str[i] != str[j]) - return false; - i++; - j--; - } - return true; - } -}; -- cgit v1.2.3