leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

commit c2b48d325baa1eb01391be3ad89a1f7b5891f94b
parent 6aab8e1022ac6062449a52da487b0a5bcaa8a84a
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sat, 28 Sep 2024 10:11:04 +0200

1 Random Problem

Diffstat:
AProblems/2075.cpp | 18++++++++++++++++++
MREADME.md | 1+
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/Problems/2075.cpp b/Problems/2075.cpp @@ -0,0 +1,18 @@ +class Solution { + public: + string decodeCiphertext(const string &encodedText, int rows) const { + const int col = size(encodedText) / rows; + string res; + + for (int i = 0; i < col; i++) { + for (int j = i; j < size(encodedText); j += (col + 1)) { + res += encodedText[j]; + } + } + + while (!res.empty() && res.back() == ' ') + res.pop_back(); + + return res; + } +}; diff --git a/README.md b/README.md @@ -1097,6 +1097,7 @@ for solving problems. | 2070 | Medium | [Most Beautiful Item for Each Query](Problems/2070.cpp) | | 2073 | Easy | [Time Needed to Buy Tickets](Problems/2073.cpp) | | 2074 | Medium | [Reverse Nodes in Even Length Groups](Problems/2074.cpp) | +| 2075 | Medium | [Decode the Slanted Ciphertext](Problems/2075.cpp) | | 2079 | Medium | [Watering Plants](Problems/2079.cpp) | | 2085 | Easy | [Count Common Words With One Occurrence](Problems/2085.cpp) | | 2087 | Medium | [Minimum Cost Homecoming of a Robot in a Grid](Problems/2087.cpp) |