We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Largest Pyramid
You are viewing a single comment's thread. Return to all 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?