FastPrepMaximum Alternating-Index Packet Value
Problems/Maximum Alternating-Index Packet Value

Maximum Alternating-Index Packet Value

Infosys logoInfosys● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Infosys new grad online assessment. The report describes picking high-value packets with a fixed budget, greedily, while alternating between odd and even source indices. We chose the smallest set of rules that works: the budget is a count, parity starts at 0, packets may be reordered, values are not negative, and a method interface. Our version is about 82% the same as the reported question.

You are given nonnegative packet values and an integer budget. Select exactly budget packets. The selected packets must alternate between original 0-based even and odd indices; the first selected packet may come from either parity.

The selected values may be arranged in any order that satisfies the parity alternation. Return the maximum possible total value.

Function

maximumAlternatingPacketValue(packetValues: int[], budget: int) → long

Examples

Example 1

packetValues = [8,1,7,5,4,9]budget = 4return = 29

Choose even-index values 8 and 7 plus odd-index values 9 and 5.

Example 2

packetValues = [8,1,7,5,4,9]budget = 5return = 33

Starting with an even index permits three even-index and two odd-index packets.

Constraints

  • 1 <= packetValues.length <= 200000
  • 0 <= packetValues[i] <= 10^9
  • 1 <= budget <= packetValues.length

Source note: Interview prompt excerpt preserved as source evidence.

More Infosys Online Assessment questions

  • At Most K Jumps with Quadratic Transition CostOA · Seen Nov 2026
  • Hiking Club Fastest PaceOA · Seen Nov 2026
  • Lowest Common Ancestor with a Changing RootOA · Seen Nov 2026
  • Minimum Leaf Path Sum over All RootsOA · Seen Nov 2026
  • Split Array to Minimize the Largest SumOA · Seen Nov 2026
  • Cherry PickupOA · Seen Nov 2026
  • Lexicographically Smallest Grid Path with One Letter ChangeOA · Seen Nov 2026
  • Minimum Cost to Supply Water with Wells and PipesOA · Seen Nov 2026
  • Minimum Cost to Tile a Strip with Widths 1, 2, and 3OA · Seen Nov 2026
  • Minimum Rounds to Complete All TasksOA · Seen Nov 2026

Similar questions at other companies

  • Find Minimum TimeAlphaSense · OA
  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Minimum Cost of Every K-Capable Model SetTikTok · OATikTok interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions
  • Latest Arrival to Catch a BusAutodesk · OAAutodesk interview questions
All Infosys interview questionsSee Infosys hiring insights
Saved
class Solution {
    public long maximumAlternatingPacketValue(int[] packetValues, int budget) {
        // Write your code here.
    }

}
Checking account…