• + 0 comments

    cpp code:

    long long strangeGrid(long long r,long long c) { long long result = 0;

    if (r % 2 != 0) {
        result = (r - 1) * 5 + (c - 1) * 2;  
    } 
    else {
        result = (r - 2) * 5 + (c - 1) * 2 + 1;
    }
    
    return result;
    

    }