aboutsummaryrefslogtreecommitdiff
path: root/other/text_justification.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
committerJack Sangdahl <[email protected]>2025-06-27 12:23:02 -0600
commita96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch)
treee2a2b3f49f9fb741be81415266ac93e74cff42ec /other/text_justification.cpp
parent694ad5ed71edcb1deccab54b72d706b779918276 (diff)
downloadleetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz
leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/text_justification.cpp')
-rw-r--r--other/text_justification.cpp56
1 files changed, 0 insertions, 56 deletions
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<string> fullJustify(vector<string> &words, int maxWidth) {
- vector<string> 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<string> &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<string> &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;
- }
-};