vector<vector<int>> solution(vector<vector<int>> input)
{
for (int i = 0; i < input.size(); i++)
{
deque<int> one;
bool isadd = false;
for (int p = 0; p < input[0].size(); ++p)
{
if (one.empty())
{
if (input[i][p] != 0)
{
one.push_back(input[i][p]);
}
}
else
{
int tail = one.back();
if (tail == input[i][p]&&isadd==false)
{
one.pop_back();
one.push_back(2 * tail);
isadd = true;
}
else
{
if (input[i][p] != 0)
{
one.push_back(input[i][p]);
isadd = false;
}
}
}
}
while (one.size() != input[0].size())
{
one.push_back(0);
}
vector<int> temp(one.begin(), one.end());
input[i] = temp;
}
return input;
}
我也是,我一直怀疑样例是有问题的