FastPrepMinimum Total Weight
Problems/Minimum Total Weight

Minimum Total Weight

Snowflake logoSnowflake● MediumINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Special thanks: 𓆝﹏𓊝﹏🫧A heartfelt thank you to A 🐳﹏⋆。°

There are n chocolates and the weight of the chocolates is given as an array of integers weights[n], where weights[i] denote the weight of the ith chocolate. Every day, one can pick one chocolate, eat half of it, and put the remaining half back. Find the minimum possible total weight of the remaining chocolates after d days. Note that one can eat the same chocolate multiple times. The weight of the part eaten can be calculated as floor(weights[i]/2).

Function

findMinWeight(weights: int[], d: int) → int

Complete the function findMinWeight in the editor below.

findMinWeight has the following parameters:

  1. int weights[n]: an array of integers representing weights of chocolates, indexed 0 to n-1
  2. int d: an integer representing the number of days

Returns int: the minimum total weight of chocolates after d days.

Examples

Example 1

weights = [30, 20, 25]d = 4return = 31
Example 1 illustration

Day Weight of the chocolate picked Weight eaten Remaining weight Result

  1. 1 20 10 10 [30,10,25]
  2. 2 25 12 13 [30,10,13]
  3. 3 30 15 15 [15,10,13]
  4. 4 15 7 8 [8, 10, 13]

The total weight of chocolates on day 4 is 8 + 10 + 13, which is the minimum possible weight after 4 days.

Example 2

weights = [2]d = 1return = 1

On day 1, eat the chocolate with weight 2, and the remaining weight becomes 1. The array becomes [1], with the sum of weights 1.

Example 3

weights = [2, 3]d = 1return = 4

On day 1, pick either of the chocolates:

  • chocolate with weight 2, weights' = [1, 3], with a total weight of 4.
  • chocolate with weight 3, weights' = [2, 2], with a total weight of 4.

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ weights[i] ≤ 10^4 (where 0 ≤ i < n)
  • 1 ≤ d ≤ 2*10^6

More Snowflake interview questions

  • Minimum StackPHONE SCREEN · Seen Nov 2026
  • Design In-Memory File SystemPHONE SCREEN · Seen Nov 2026
  • Merge Two Binary TreesPHONE SCREEN · Seen Nov 2026
  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
  • Parallel Courses IIIONSITE INTERVIEW · Seen Nov 2026
  • Safest Shortest Path Through a GridOA · Seen Nov 2026
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Task SchedulerAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Cost to Merge Values into OnePayPal · OAPayPal interview questions
  • Maximum K-Star SumC3.ai · OAC3.ai interview questions
  • Maximum Sum of a K-StarMicrosoft · OAMicrosoft interview questions
  • Maximum ScoreNVIDIA · OANVIDIA interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Task SchedulingJP Morgan Chase · OAJP Morgan Chase interview questions
  • Decreasing SubsequencesGoogle · OAGoogle interview questions
  • Get Maximum AmountIBM · OAIBM interview questions
  • Optimize TikTok Reels ViewingTikTok · OATikTok interview questions

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public int findMinWeight(int[] weights, int d) {
      // write your code here
    }

}
Checking account…