FastPrepFairest Chocolate Packets
Problems/Fairest Chocolate Packets

Fairest Chocolate Packets

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem picks m packets whose chocolate counts sit as close together as possible. A post from March 2022 comes from an engineer with three and a half years of experience who received an MTS-2 offer in Noida after January 2022 interviews. It says only that the hour-long first technical round included some variation of this well-known task. The round also had a binary-search question and questions on operating systems and the C++ language. The post does not describe the variation.

Our choices: the standard form, with one packet per student, where you make the largest chosen count minus the smallest as small as possible. There are 1 to 5000 packets of 1 to 10^9 pieces, with m from 1 to the number of packets. The examples are new.

Because the variation is unknown, our version is about 60% the same as the reported question.

There are packets.length packets of chocolate, and packet i holds packets[i] pieces. You must hand one packet to each of m students, so you choose exactly m different packets.

The spread of a choice is the largest number of pieces among the chosen packets minus the smallest. Return the smallest spread you can get.

Function

minPacketSpread(packets: int[], m: int) → int

Examples

Example 1

packets = [15,4,22,9,11,30,6]m = 3return = 5

Sorted, the packets are 4, 6, 9, 11, 15, 22, 30. Taking 4, 6, 9 gives a spread of 9 - 4 = 5, and so does 6, 9, 11. No three packets are closer, so the answer is 5.

Example 2

packets = [8,8,3,8]m = 3return = 0

The three packets of 8 have a spread of 0.

Example 3

packets = [40,1,25]m = 3return = 39

Every packet must be given out, so the spread is 40 - 1 = 39.

Constraints

  • 1 <= m <= packets.length <= 5000
  • 1 <= packets[i] <= 10^9

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Integer Compression OffsetHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Tagged Metric Window SumsDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Maximum Visible DronesAnduril · PHONE SCREENAnduril interview questions
  • Minimum Parking Roof LengthAmerican Express · OAAmerican Express interview questions
  • Count Max Num Teams 🥝Amazon · OA
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Sliding Window MedianAuxoAI · OA
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions

Interview reports that mention this question

  • Adobe MTS Interview Questions: 12 Experiences (Part 2 of 6)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public int minPacketSpread(int[] packets, int m) {
        // Write your code here.
    }
}
Checking account…