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/reorganise_string.cpp | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 other/reorganise_string.cpp (limited to 'other/reorganise_string.cpp') diff --git a/other/reorganise_string.cpp b/other/reorganise_string.cpp deleted file mode 100644 index 7a42643..0000000 --- a/other/reorganise_string.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// 767. Reorganize String -#include "leetcode.h" - -/* - * given a string 's', rearrange the characters of 's' so that any two adjacent - * characters are not the same. return any possible arrangement of 's', or - * return "" if not possible. - */ - -class Solution { -public: - string reorganizeString(string s) { - vector cnt(26); - int most_freq = 0, i = 0; - for (char c : s) - if (++cnt[c - 'a'] > cnt[most_freq]) - most_freq = (c - 'a'); - if (2 * cnt[most_freq] - 1 > s.size()) - return ""; - while (cnt[most_freq]) { - s[i] = ('a' + most_freq); - i += 2; - cnt[most_freq]--; - } - for (int j = 0; j < 26; j++) - while (cnt[j]) { - if (i >= s.size()) - i = 1; - s[i] = ('a' + j); - cnt[j]--; - i += 2; - } - return s; - } -}; - -int main() { - Solution obj; - cout << obj.reorganizeString("aab"); // expect: aba - cout << obj.reorganizeString("aaab"); // expect: -} -- cgit v1.2.3