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/text_justification.cpp | 56 -------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 other/text_justification.cpp (limited to 'other/text_justification.cpp') diff --git a/other/text_justification.cpp b/other/text_justification.cpp deleted file mode 100644 index d45bead..0000000 --- a/other/text_justification.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - vector fullJustify(vector &words, int maxWidth) { - vector ans, taken; - int lineLen = 0; - for (auto word : words) { - if (lineLen + word.size() + taken.size() > maxWidth) { - ans.push_back(lineBegin(taken, maxWidth - lineLen)); - taken.clear(); - taken.push_back(word); - lineLen = word.size(); - } else { - taken.push_back(word); - lineLen += word.size(); - } - } - ans.push_back(lineEnd(taken, maxWidth - lineLen)); - return ans; - } - -private: - string lineBegin(vector &v, int toFill) { - string ans = ""; - if (v.size() == 1) { - ans += v[0]; - while (toFill--) - ans += ' '; - return ans; - } - int space = toFill / (v.size() - 1); - int extras = toFill % (v.size() - 1); - ans += v[0]; - for (int i = 1; i < v.size(); i++) { - for (int j = 0; j < space; j++) - ans += ' '; - if (extras) { - extras--; - ans += ' '; - } - } - return ans; - } - string lineEnd(vector &v, int toFill) { - string ans = v[0]; - for (int i = 1; i < v.size(); i++) { - toFill--; - ans += ' '; - ans += v[i]; - } - while (toFill--) - ans += ' '; - return ans; - } -}; -- cgit v1.2.3