Search
⌘K

Leetcode 265. Paint House II

Given n houses and k paint colors with a cost matrix, choose a color for each house so no two adjacent houses share a color and the total painting cost is minimized. The challenge is to design an efficient DP that handles large k (avoid naive O(n·k²)), typically by carrying forward the best and second-best previous costs to achieve O(n·k) time.

Asked at:

LinkedIn

LinkedIn


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid February, 2026

LinkedIn

LinkedIn

Senior

Late August, 2025

LinkedIn

LinkedIn

Senior

Comments

Your account is free and you can post anonymously if you choose.