Minimize Array Sum After K Halving Operations
Updated
Problem statement
Perform exactly k operations on an array of nonnegative integers. In one operation, choose an element, replace it by ceil(value/2), and put it back.
Return the minimum possible array sum after all operations.
Function
minimumSumAfterHalves(values: int[], k: int) → longExamples
Example 1
values = [10,20,7]k = 4return = 14Repeatedly reducing a current maximum yields the minimum sum.
Example 2
values = [1,1]k = 3return = 2Halving one leaves it at one, so the sum stays two.
Example 3
values = [5]k = 2return = 2Five becomes three, then two.
Constraints
1 <= values.length <= 100000.0 <= values[i] <= 10^9.0 <= k <= 100000.
More DocuSign Phone Screen questions
- Symmetric Binary TreePHONE SCREEN · Seen Oct 2026
- Union Area of Two RectanglesPHONE SCREEN · Seen Oct 2026
- Execute Cursor-Based Text Editor OperationsPHONE SCREEN · Seen Sep 2026
- Fizz and Buzz Words From 1 to nPHONE SCREEN · Seen Sep 2026
- Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Rain Kept Between WallsPHONE SCREEN · Seen Mar 2026
- Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Rebuild a Trip From Flight TicketsPHONE SCREEN · Seen Apr 2019
- Find the Words for Each PrefixPHONE SCREEN · Seen Sep 2018
Similar questions at other companies
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Defer Expenses to Preserve BalanceDRW · PHONE SCREENDRW interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Automation Pipeline, Part 3: Stage DurationPlaid · PHONE SCREENPlaid interview questions
- Minimum Sum After K Ceiling HalvingsAdobe · PHONE SCREENAdobe interview questions
- Furthest Building with Bricks and LaddersAmazon · PHONE SCREEN
- Schedule Unit-Time Jobs for the Most ProfitScale AI · PHONE SCREENScale AI interview questions
- Minimum Meeting RoomsSentry · PHONE SCREENSentry interview questions
- Minimum Operations to Halve an Array SumGrab · PHONE SCREENGrab interview questions