Painting bikes in your shed
Suppose there's a shed full of bikes, and you need to paint them all before selling them. The bikes can all be painted one of 3 colors:
Each color has a certain cost associated with it. Additionally, no two adjacent bikes can be painted the same color (e.g. you can't use the same color 2x in a row).
We can represent the cost of painting each bike through a matrix that will be of n x 3 shape. For example, cost represents the cost of painting the first bike green, cost represents the cost of painting the third bike red.
Given this information, write a function that returns the minimum cost of painting the bikes.
# Input: [[3,2,4],[3,4,6]] # Output: 5 # Here we would paint the first bike with the second color, blue, # since $2 is the minimum cost, and we would paint the second house # with the first color, green, since that represents the minimum cost # and will not be painted the same color as the bike to the left of it
Subscribe to premium account to see the solution.Get premium now