You are stacking blocks to construct a pyramid, where each block is represented by a single character. You are given a string bottom, representing the base row of the pyramid, and an array of strings allowed, representing the valid triangular patterns.
For any two adjacent blocks with characters u and v on a given level, a block with character w can be placed directly above them on the next level if and only if the pattern formed by concatenating u, v, and w is present in allowed.
A level with
Return true if it is possible to build the pyramid up to the top level, or false otherwise.
Constraints:
bottom.length
allowed.length
allowed[i].length
All characters in bottom and allowed[i] are chosen from the set {'A', 'B', 'C', 'D', 'E', 'F'}.
All strings in allowed are unique.
You are stacking blocks to construct a pyramid, where each block is represented by a single character. You are given a string bottom, representing the base row of the pyramid, and an array of strings allowed, representing the valid triangular patterns.
For any two adjacent blocks with characters u and v on a given level, a block with character w can be placed directly above them on the next level if and only if the pattern formed by concatenating u, v, and w is present in allowed.
A level with
Return true if it is possible to build the pyramid up to the top level, or false otherwise.
Constraints:
bottom.length
allowed.length
allowed[i].length
All characters in bottom and allowed[i] are chosen from the set {'A', 'B', 'C', 'D', 'E', 'F'}.
All strings in allowed are unique.