[Lintcode] Paint House II whitewashed houses two

Source: Internet
Author: User
Tags lintcode

There is a row of n houses, each house can is painted with one of the K colors. The cost of painting a certain color is different. You had to paint all the houses such, that no, and adjacent houses have the same color.

The cost of painting a certain color are represented by a n x K cost matrix. For example, costs[0][0] are the cost of painting House 0 with color 0; COSTS[1][2] is the cost of Painting House 1 with color 2, and so on ... Find the minimum cost-to-paint all houses.

Notice

All costs is positive integers.

Example
Given n = 3, k = 3, costs = [[14,2,11],[11,14,5],[14,3,10]] return 10

House 0 was color 2, House 1 was Color 3, House 2 is color 2, 2 + 5 + 3 = 10

[Lintcode] Paint House II whitewashed houses two

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.