perm audit reponse寄出之后,劳动局会有receipt么?还是石沉大海# EB23 - 劳工卡
B*t
1 楼
小弟的代码在此,能通过small的test,但是large时说memory limit exceeded,难道
这题还能in place不成?
class Solution {
public:
string convert(string s, int nRows) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(nRows == 1)
return s;
int circle = 2*nRows - 2;
string ret;
for(int i = 0; i < nRows; i++)
{
int j = i;
while(j < s.size())
{
ret.push_back(s[j]);
j += circle;
if(i != 0 && i != nRows - 1)
if((j - i*2) < s.size())
ret.push_back(s[j - i*2]);
}
}
return ret;
}
};
这题还能in place不成?
class Solution {
public:
string convert(string s, int nRows) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(nRows == 1)
return s;
int circle = 2*nRows - 2;
string ret;
for(int i = 0; i < nRows; i++)
{
int j = i;
while(j < s.size())
{
ret.push_back(s[j]);
j += circle;
if(i != 0 && i != nRows - 1)
if((j - i*2) < s.size())
ret.push_back(s[j - i*2]);
}
}
return ret;
}
};