256. Paint House

n colors solutions, traditional DP

time: O(3m), costs' matrix size(3 colors), if n colors, it will be O(mn)

space: O(3m)

use variables

time: O(m)

space: O(1)

Last updated

Was this helpful?