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.
I got stucked in a corner case, and then in a corner case of that case. It's easy to overlook when you have abstracted the problem. Thinking in "Lego", blocks only stick together vertically. If your wall has just one row those blocks are free from each other. Then:
1) (Almost) every wall of height 1 is going to be non-solid (answer = 0).
2) Unless... it consist of just one piece (answer = 1).
`if(n ==1) return (m<=4?1:0);`
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lego Blocks
You are viewing a single comment's thread. Return to all comments →
I got stucked in a corner case, and then in a corner case of that case. It's easy to overlook when you have abstracted the problem. Thinking in "Lego", blocks only stick together vertically. If your wall has just one row those blocks are free from each other. Then:
1) (Almost) every wall of height 1 is going to be non-solid (answer = 0).
2) Unless... it consist of just one piece (answer = 1).