Test case 4 is not being passed after a lot tries, i dont want to open editorial as i ll not get any points for that , test case 1,2,3 are passed well

#include <bits/stdc++.h>
using namespace std;

void printSpiralAnti(int **arr, int m, int n)
{
int startRow = 0;
int startCol = 0;
int endRow = m - 1;
int endCol = n - 1;

while (startRow <= endRow && startCol <= endCol)
{
    for (int i = startRow; i <= endRow; i++)
    {
        cout << arr[i][startCol] << ", ";
    }
    startCol++;
    for (int i = startCol; i <= endCol; i++)
    {
        cout << arr[endRow][i] << ", ";
    }
    endRow--;

    if (endCol > startCol)
    {
        for (int i = endRow; i >= startRow; i--)
        {
            cout << arr[i][endCol] << ", ";
        }
        endCol--;
    }

    if (endRow > startRow)
    {
        for (int i = endCol; i >= startCol; i--)
        {
            cout << arr[startRow][i] << ", ";
        }
        startRow++;
    }
}
cout << "END";

}

int main()
{
int m, n;
cin >> m >> n;
int **arr = new int *[n];
for (int i = 0; i < m; i++)
{
arr[i] = new int[n];
}

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> arr[i][j];
        }
    }
    printSpiralAnti(arr, m, n);

return 0;

}

hi @yamangoyal100_ff74db54bdf01539 write >= in if conditions

and what would be reason for that?

@yamangoyal100_ff74db54bdf01539 It will miss some rows or column when m!=n