When will the below solution not work?


#1

vector<vector > Solution::generateMatrix(int A) {
vector<vector> result(A,vector(A,0));

int num = 1;
int l = 0;
int r = A-1;
int t = 0;
int b = A-1;

while(l <= r && t <= b)
{
    for (int i = l; i <= r; i++)
    {
        result[t][i] = num++;
    }
    t++;
    for(int i = t; i <= b; i++)
    {
        result[i][r] = num++;
    }
    r--;
    for(int i = r; i >= l; i--)
    {
        result[b][i] = num++;
    }
    b--;
    for(int i = b; i >= t; i--)
    {
        result[i][l] = num++;
    }
    l++;
}
return result;

}