leetcode

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

1324.cpp (605B)


0 class Solution { 1 public: 2 vector<string> printVertically(const string &s) { 3 vector<string> vec, res; 4 5 string tmp, buf; 6 stringstream ss(s); 7 while (ss >> tmp) 8 vec.push_back(tmp); 9 10 for (int i = 0; true; i++) { 11 tmp.clear(), buf.clear(); 12 for (const string &s : vec) { 13 if (s.size() <= i) 14 buf += " "; 15 else 16 tmp += buf + s[i], buf.clear(); 17 } 18 if (!tmp.size()) break; 19 res.push_back(tmp); 20 } 21 return res; 22 } 23 };