Practice Pyramid Transition Matrix
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Pyramid Transition Matrix
Problem Statement
You are stacking blocks to form a pyramid. Each block has a color, which is represented by a single letter. Each row of blocks contains one less block than the row beneath it and is centered on top. To make the pyramid aesthetically pleasing, there are only specific triangular patterns that are allowed. A triangular pattern consists of a single block stacked on top of two blocks. The patterns are given as a list of three-letter strings allowed, where the first two characters of a pattern represent the left and right bottom blocks respectively, and the third character is the top block. You start with a bottom row of blocks bottom, given as a single string, that you must use as the base of the pyramid. Given bottom and allowed, return true if you can build the pyramid all the way to the top such that every triangular pattern in the pyramid is in allowed, or false otherwise.
Source: Pyramid Transition Matrix on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
bottom = "BCD", allowed = ["BCC","CDE","CEA","FFF"]
true
# Example 2
bottom = "AAAA", allowed = ["AAB","AAC","BCD","BBE","DEF"]
false
Constraints
Related LeetCode Problems
Practice more problems similar to Pyramid Transition Matrix.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.