FastPrepFlower Bouquets πŸ’
Problems/Flower Bouquets πŸ’

Flower Bouquets πŸ’

Atlassian logoAtlassian● MediumINTERNOA

Updated Jul 2026

QuestionFunctionExamplesConstraints

Problem statement

A flower shop has only two types of flower bouquets:

  • Type 1: This contains three roses and costs p dollars.
  • Type 2: This contains one cosmos and one rose and costs 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:

    1. int p: the cost of a type 1 bouquet
    2. int q: the cost of a type 2 bouquet
    3. string s: the garden pattern as a binary string where 0 indicates rose and 1 indicates cosmos

    Returns

    int: the maximum value of flower bouquets

    Examples

    Example 1

    p = 2q = 3s = "0001000"return = 5
    There are two bouquets of three roses (Type 1) at indices (0, 1, 2), and (4, 5, 6) that sell for 2+2 = 4. There is one Type 1 bouquet (0, 1, 2) and one Type 2 bouquet at (3, 4). They sell for 2+3 = 5.

    Constraints

    • 1 ≀ p, q ≀ 1000
    • 1 ≀ |s| ≀ 100000

    More Atlassian interview questions

    • Merge Overlapping IntervalsPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
    • Tennis Court SchedulingPHONE SCREEN Β· ONSITE INTERVIEW Β· Seen Nov 2026
    • Deterministic Word Guess SolverONSITE INTERVIEW Β· Seen Oct 2026
    • Generate Word Guess FeedbackONSITE INTERVIEW Β· Seen Oct 2026
    • Bounded Word Guess SolverONSITE INTERVIEW Β· Seen Oct 2026
    • Implement a Rate LimiterPHONE SCREEN Β· Seen Oct 2026
    • Word Guess Feedback ColorsONSITE INTERVIEW Β· Seen Oct 2026
    • Longest Consistent Activity StreakPHONE SCREEN Β· Seen Sep 2026
    • Music Player Operation SequencePHONE SCREEN Β· Seen Sep 2026
    • Underline Shortest Unique SubstringsPHONE SCREEN Β· Seen Aug 2026

    Similar questions at other companies

    • Maximum Equal-Bit Pairs in a SubsequenceAmazon Β· OA
    • Longest Subsequence That Is a SubstringBooking.com Β· OA
    • Count Digit Replacements with No Equal Adjacent DigitsMicrosoft Β· OAMicrosoft interview questions
    • Palindrome CounterGoldman Sachs Β· OAGoldman Sachs interview questions
    • Longest String ChainVisa Β· OAVisa interview questions
    • Minimum-Cost Digit String DecodingSquadStack.ai Β· OA
    • Maximum Redundancy After One Segment FlipBloomberg LP Β· OABloomberg LP interview questions
    • Substrings Without a Target SubsequencePhonePe Β· OAPhonePe interview questions
    • Minimum Edit-Distance String for Each QueryTarget Β· OA
    • Longest Subsequence That Is a SubstringWells Fargo Β· OAWells Fargo interview questions

    Atlassian interview experiences

    • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
    • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
    • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
    All Atlassian interview questionsSee Atlassian hiring insights
    Saved
    class Solution {
        public int flowerBouquets(int p, int q, String s) {
            // write your code here
        }
    
    }
    Checking account…