Flower Bouquets π
Learn this problemProblem statement
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.
Function
flowerBouquets(p: int, q: int, s: String) β int
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
Examples
Example 1
p = 2q = 3s = "0001000"return = 5Constraints
1 β€ p, q β€ 10001 β€ |s| β€ 100000
More Atlassian problems
- Planning ProductionOA Β· Seen Feb 2025
- K-Means ClusteringOA Β· Seen Feb 2025
- Minimum Sorted Erasure OperationsOA Β· Seen Jun 2024
- Count Analogous ArraysOA Β· Seen Mar 2024
- Get Maximum ScoreOA Β· Seen Mar 2024
- Better Compression π¦OA Β· Seen Mar 2024
- Romanizer π‘OA Β· Seen Mar 2024
- Binary Search Tree IteratorOA Β· Seen Nov 2023