Our hero, Homer, has just woken to a horrible discovery! While sleeping at work, several of the power plants in the state have lost power. Even worse, his boss is on the way to his office, and if he doesn't have the situation fixed in time, he'll be fired. He's called you, desperately asking for help, and you've agreed to help him figure things out.
Homer has given you connectionCost, in which the j-th character of the i-th element indicates the cost to restart power plant j using power plant i; a digit ('0'-'9') stands for a cost of 0-9, while an uppercase letter ('A'-'Z') stands for a cost of 10-35. Homer has also given you the plantList, in which the i-th character indicates whether the i-th plant is still working after the power outage; a 'Y' indicates that it has power, otherwise, it is an 'N'. A plant can only be used to power another plant if it currently has power. Finally, he gives you numPlants, the minimum number of plants that need to be powered to save Homer's job. You need to return the minimum cost needed to power at least numPlants plants.
|