Minimum Beauty
Updated
Problem statement
You are given an integer array arr of length n and an integer k. Split arr into exactly k non-empty subarrays of consecutive elements, so that every element belongs to exactly one subarray.
The score of a subarray is its largest element times its number of elements. For example, the score of [1, 4, 2] is 4 * 3 = 12. The beauty of a split is the largest score among its k subarrays.
Return the minimum possible beauty over all ways to split arr into exactly k subarrays.
Function
minimumBeauty(arr: int[], k: int) → intExamples
Example 1
arr = [1,4,2,5,1]k = 2return = 12There are four ways to cut the array into two parts. [1] [4, 2, 5, 1] has scores 1 and 5 * 4 = 20, so its beauty is 20. [1, 4] [2, 5, 1] has scores 8 and 15, beauty 15. [1, 4, 2] [5, 1] has scores 12 and 10, beauty 12. [1, 4, 2, 5] [1] has scores 20 and 1, beauty 20. The smallest beauty is 12.
Example 2
arr = [2,2,2,2,2]k = 2return = 6Every element is 2, so a part of length L scores 2 * L. The two parts have lengths that add up to 5, so the longer one has length at least 3 and scores at least 6. Lengths 3 and 2 give scores 6 and 4, so the answer is 6.
Example 3
arr = [6,1,1,1]k = 2return = 6The part that holds 6 scores at least 6. Putting 6 alone gives [6] [1, 1, 1] with scores 6 and 1 * 3 = 3, so the beauty is 6. Any other cut puts more elements next to 6 and scores 12 or 18. So the answer is 6.
Constraints
1 <= k <= n <= 1000, wheren = arr.length1 <= arr[i] <= 100000
More Bloomberg LP Online Assessment questions
- Count Distinct Arrays After Decrement OperationsOA · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Longest Distance in a Frequency-Limited NetworkOA · Seen Sep 2026
- Maximum Redundancy After One Segment FlipOA · Seen Sep 2026
- Sum of Pipeline Response TimesOA · Seen Sep 2026
- Merge IntervalsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Design an Ordered StreamOA · PHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
- Count Teams Outscoring a Target TeamOA · Seen Feb 2023
- Ashley Loves Numbers (Financial Engineer)OA · Seen Nov 2019
- Consecutive Sum (Financial Engineer Intern)OA · Seen Nov 2019
Similar questions at other companies
- Minimum Operations to Make a SubsequenceGoogle · OAGoogle interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Split Array Largest SumAuxoAI · OA
- Data ReorganizationGoldman Sachs · OAGoldman Sachs interview questions
- Find Optimal LevelAmazon · OA
- Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Array NullificationQRT · OA
- Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)