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/zigzag_conversion.cpp | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 other/zigzag_conversion.cpp (limited to 'other/zigzag_conversion.cpp') diff --git a/other/zigzag_conversion.cpp b/other/zigzag_conversion.cpp deleted file mode 100644 index f7e6b74..0000000 --- a/other/zigzag_conversion.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// 6. Zigzag Conversion -#include "leetcode.h" - -/* - * the string "PAYPALISHIRING" is written in zigzag pattern on a given number - * of rows like this: - * P A H N - * A P L S I I G - * Y I R - * and then read line by line: "PAHNAPLSIIGYIR". write function that will take - * a string and mak this conversion give a number of rows. - */ - -class Solution { -public: - string convert(string s, int numRows) { - if (numRows <= 1) - return s; - const int len = s.size(); - string *str = new string[numRows]; - int row = 0, step = 1; - for (int i = 0; i < len; ++i) { - str[row].push_back(s[i]); - if (row == 0) - step = 1; - else if (row == numRows - 1) - step = -1; - row += step; - } - s.clear(); - for (int i = 0; i < numRows; ++i) - s.append(str[i]); - delete[] str; - return s; - } -}; - -int main() { - Solution obj; - cout << obj.convert("PAYPALISHIRING", 3) << endl; // expect: PAHNAPLSIIGYIR - cout << obj.convert("PAYPALISHIRING", 4) << endl; // expect: PINALSIGYAHRPI - cout << obj.convert("A", 1) << endl; // expect: A -} -- cgit v1.2.3