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.
- Lego Blocks
- Discussions
Lego Blocks
Lego Blocks
Sort by
recency
|
79 Discussions
|
Please Login in order to post a comment
this question would be Hard Level in Leetcode
One of the dumbest question I have ever seen. This is mathematical problem not algorithm or data structure.
┌──┬─┐
┼──┼─┼
┼──┴─┼
└────┘
Is this a valid wall? There are 2 rows with the same breaks but the total break doesnt reach the full height.
Q1: why {n:1 m:5} would be 0, and {n:1 m:3} would be want 1
A1: m > 4, and the widest wall is 4, so the wall must has at least two block, and that cause a vertical break, and is invalid
Q2: how to understand the calculation of invalid wall? (valid left part) * (all right part)
A2:
left part is valid, that is said left part does not have vertical break
at least one vertical break is between left part and right part
[ left part | right part ] the two part combined together is a wall that has at least one vertical break wall, and that is invalid
My solution, with comments in case it helps: