Redirecting to
NADOS
- Fibonacci-dp
- Fibonacci-dp
- Climb Stairs
- Climb Stairs
- Climb Stairs With Variable Jumps
- Climb Stairs With Variable Jumps
- Climb Stairs With Minimum Moves
- Climb Stairs With Minimum Moves
- Min cost In Maze Traversal
- Min Cost In Maze Traversal
- Goldmine
- Goldmine
- Target Sum Subsets - DP
- Target Sum Subsets - Dp
- Coin Change Combinations
- Coin Change Combination
- Coin Change Permutations
- Coin Change Permutations
- Zero One Knapsack
- Zero One Knapsack
- Unbounded Knapsack
- Unbounded Knapsack
- Fractional Knapsack - Official
- Count Binary Strings
- Count Binary Strings
- Arrange Buildings
- Arrange Buildings
- Count Encodings
- Count Encodings
- Count A+B+C subsequences
- Count A+b+c+ Subsequences
- Maximum Sum Non Adjacent Elements
- Maximum Sum Non Adjacent Elements
- Paint House
- Paint House
- Paint House-Many colors
- Paint House - Many Colors
- Paint Fence
- Paint Fence
- Tiling with 2*1 Tiles
- Tiling With 2 * 1 Tiles
- Tiling with M*1 Tiles
- Tiling With M * 1 Tiles
- Friends Pairing
- Friends Pairing
- Partition Into Subsets
- Partition Into Subsets
- Buy And Sell Stocks - 1 Transaction Allowed
- Buy And Sell Stocks - One Transaction Allowed
- Buy and sell Stocks - Infinite Transaction Allowed
- Buy And Sell Stocks - Infinite Transactions Allowed
- Buy & Sell Stocks With Transaction Fee - Infinite Transactions Allowed
- Buy And Sell Stocks With Transaction Fee - Infinite Transactions Allowed
- Buy & Sell Stock - Cooldown
- Buy And Sell Stocks With Cooldown - Infinite Transaction Allowed
- Buy and Sell Stocks- Two Transactions Allowed
- Buy And Sell Stocks - Two Transactions Allowed
- Buy and Sell Stocks- K Transactions Allowed
- Buy And Sell Stocks - K Transactions Allowed
Paint Fence
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.1. You are given a number n and a number k in separate lines, representing the number of fences and number of colors.Input Format
2. You are required to calculate and print the number of ways in which the fences could be painted so that not more than two consecutive fences have same colors.
A number nOutput Format
A number k
A number representing the number of ways in which the fences could be painted so that not more than two fences have same colors.Question Video Constraints
1 <= n <= 10Sample Input
1 <= k <= 10
8Sample Output
3
3672
-
Asked in Companies
-
Related Topics
Your profile is incomplete!
Please click here to complete your profile to continue submitting questions.
Video Solution
Code Solution
{ }
Editor Settings
Font Size
Key Binding
Keyboard Shortcut
- fold Alt-L|Ctrl-F1
- unfold Alt-Shift-L|Ctrl-Shift-F1
- Gotoend Ctrl-End
- Gotostart Ctrl-Home
- Movelinesup Alt-Up
- Movelinesdown Alt-Down
- Undo Ctrl-Z
- Redo Ctrl-Shift-Z|Ctrl-Y
- Replace Ctrl-H
- Togglecomment Ctrl-/
- ToggleBlockComment Ctrl-Shift-/
- Removeline Ctrl-D
{ }
Run
Editor Settings
Font Size
Key Binding
Keyboard Shortcut
- fold Alt-L|Ctrl-F1
- unfold Alt-Shift-L|Ctrl-Shift-F1
- Gotoend Ctrl-End
- Gotostart Ctrl-Home
- Movelinesup Alt-Up
- Movelinesdown Alt-Down
- Undo Ctrl-Z
- Redo Ctrl-Shift-Z|Ctrl-Y
- Replace Ctrl-H
- Togglecomment Ctrl-/
- ToggleBlockComment Ctrl-Shift-/
- Removeline Ctrl-D