Skip to content

Commit bbfd944

Browse files
committed
Runtime: 0 ms (Top 100.00%) | Memory: 6.4 MB (Top 78.82%)
1 parent 943625d commit bbfd944

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1+
// Runtime: 0 ms (Top 100.00%) | Memory: 6.4 MB (Top 78.82%)
12
class Solution {
23
public:
34
vector<string> printVertically(string s) {
4-
5+
56
int row = 0, col = 0;
6-
7+
78
stringstream sso(s);
89
string buffer;
9-
10+
1011
while (sso >> buffer)
1112
{
1213
row++;
1314
col = max((int)buffer.size(),col);
1415
}
15-
16+
1617
vector<vector<char>> matrix(row, vector<char>(col,' '));
17-
18+
1819
sso = stringstream(s);
19-
20+
2021
int i = 0;
2122
while (sso >> buffer)
2223
{
2324
for (int j = 0; j < buffer.size(); j++)
2425
matrix[i][j] = buffer[j];
2526
i++;
2627
}
27-
28+
2829
vector<string> res;
2930
for (int j = 0; j < col; j++)
3031
{
3132
string item;
3233
for (int i = 0; i < row; i++)
3334
item.push_back(matrix[i][j]);
34-
35+
3536
for (int i = item.size()-1; i >= 0; i--)
3637
{
3738
if (item[i] != ' ')
@@ -42,7 +43,7 @@ class Solution {
4243
}
4344
res.push_back(item);
4445
}
45-
46+
4647
return res;
4748
}
48-
};
49+
};

0 commit comments

Comments
 (0)