NeetCode #663LC-276Medium1-D Dynamic ProgrammingNC Algo100
← Back to All Problems#663 · #276 · Paint Fence(栅栏涂色)
📌 Problem Statement & Constraints
There are
n fence posts and k colours. Paint the posts so that no more than two adjacent posts share the same colour. Return the number of valid colourings. Constraints: 1 <= n <= 50, 1 <= k <= 10^5.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!