You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a fence, with n posts and k available colors, we need to find out how many different
ways we can paint the fence so that at most two adjacent posts have the same color.
Output the answer modulo 10^9 + 7
How many posts are there on the fence? 3
How many colors are available? 7
The number of ways to color the given posts is 336
SAMPLE II
How many posts are there on the fence? 5
How many colors are available? 0
No color is available to paint!!!
Time Complexity: O(n) where 'n' is the number of posts to paint
Space Complexity: O(n)
The text was updated successfully, but these errors were encountered:
Painting Fence problem
In a fence, with n posts and k available colors, we need to find out how many different
ways we can paint the fence so that at most two adjacent posts have the same color.
Output the answer modulo 10^9 + 7
How many posts are there on the fence? 3
How many colors are available? 7
The number of ways to color the given posts is 336
SAMPLE II
How many posts are there on the fence? 5
How many colors are available? 0
No color is available to paint!!!
Time Complexity: O(n) where 'n' is the number of posts to paint
Space Complexity: O(n)
The text was updated successfully, but these errors were encountered: