Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painting Fence problem #1973

Open
Fatema110 opened this issue May 23, 2021 · 0 comments
Open

Painting Fence problem #1973

Fatema110 opened this issue May 23, 2021 · 0 comments

Comments

@Fatema110
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant