Available question text
Count the number of ways to paint n fence posts with k colors such that no more than two adjacent posts have the same color. This is a dynamic programming problem where you derive a recurrence by tracking configurations that end with the same color as the previous post versus a different color.
Related questions
Continue with questions that share topics or the same question type.
- Erect the Fence
Coding
- Erect the Fence II
Coding
- Number of Ways to Paint N × 3 Grid
Coding
- Paint House
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Amazon
Leetcode 276. Paint Fence
Reported Feb 3, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source