Sort by

recency

|

268 Discussions

|

  • + 0 comments

    Hi, in the tests 7 and 8 the results are behind int range, so I changed the signature: public static long strangeGrid(int r, int c) and also changed the variable type in the main(): long result = Result.strangeGrid(r, c); All the test are passed now.

  • + 0 comments

    def strangeGrid(r, c): # Write your code here # if r is even : if r%2==0: return int(((((r/2-1)*5+c)*2)-1)) else: return int((((((r-1)/2)*5)+c)*2)-2)

  • + 0 comments

    def strangeGrid(r, c): # Write your code here # if r is even : if r%2==0: return int(((((r/2-1)*5+c)*2)-1)) else: return int((((((r-1)/2)*5)+c)*2)-2)

  • + 0 comments

    def strangeGrid(r, c): return 5*r - 11 + 2*c if r % 2 == 0 else 5*r - 7 + 2*c

  • + 1 comment

    int strangeGrid(int r, int c) { // Base value for the row group (each pair of rows increases base by 10) int base = (r - 1) / 2 * 10;

    // Check if the row is odd or even
    if (r % 2 == 1) {
        // Odd row: Start at base, increment by 2 for each column
        return base + (c - 1) * 2;
    } else {
        // Even row: Start at base + 1, increment by 2 for each column
        return base + 1 + (c - 1) * 2;
    }
    

    }