Flower Bouquets π
A flower shop has only two types of flower bouquets:
p dollars.q dollars.
The flowers are grown in a single row. Consider the row as a one-dimensional array where each cell either contains a rose or a cosmos. For example, the image is based on the array 001101011, here 0 indicates rose, and 1 indicates cosmos.
Any bouquet must be formed from consecutive flowers. For example, in a bouquet, the flower from consecutive indices (i, i+1, and i+2) in the array can be present, but not from non-consecutive indices (i and i+2). In the array shown, there are no bouquets of type 1, but 3 bouquets of type 2 can be created.
Given a binary string representing the garden row, determine the maximum revenue possible. It is not necessary to use every flower.
Complete the function flowerBouquets in the editor.
flowerBouquets has three parameters:
int p: the cost of a type 1 bouquetint q: the cost of a type 2 bouquetstring s: the garden pattern as a binary string where0indicates rose and1indicates cosmos
Returns
int: the maximum value of flower bouquets
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 β€ p, q β€ 10001 β€ |s| β€ 100000