Largest Pyramid

  • + 0 comments

    How is the last test example possible? From the second example we conclude that i, j are 1-based:
    s = 1, min(1, 1, 2*1 - 1, 2*1 - 1) = min(1, 1, 1, 1) = 1.
    0-based won't work:
    min(0, 0, 2*1 - 0, 2*1 - 0) = min(0, 0, 2, 2) = 2 =/= 1

    So consider the last test example:
    Let's check the bottom right corner (i = 6, j = 5).
    s = 3, min(6, 5, 2*3 - 6, 2*3 - 5) = min(6, 5, 0, 1) = 0 =/= 1

    I think no pyramid of size s should exists outside the square {i < 2s, j < 2s}, cause to make
    min(i, j, 2s - i, 2s - j) > 0,
    i, j should be less than 2s and the pyramid of size 1 is of height 1 as well.

    Am I wrong?