276. Paint Fence

Problem

Count the number of ways to paint n fence posts with k colors such that no more than 2 adjacent posts have the same color.

There are n fence posts to be painted with k colors. Count the number of ways to paint them such that no more than 2 adjacent posts have the same color.

Examples
Input: [3,2]
Output: 6
Hints
Related Problems

276. Paint Fence

Count the number of ways to paint n fence posts with k colors such that no more than 2 adjacent posts have the same color.