FastPrepMaximize the Even-Odd Index Product Gap
Problems/Maximize the Even-Odd Index Product Gap

Maximize the Even-Odd Index Product Gap

Infosys logoInfosys● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Infosys new grad onsite interview. The report gives the goal: the maximum product at even indices, the minimum product at odd indices, and the gap between them. We completed the rest: indices start at 0, values are distinct, limits, and an interface that uses long values. Our version is about 94% the same as the reported question.

Split an integer array by original 0-based index parity. From the even-index group, choose two distinct elements with maximum product. From the odd-index group, choose two distinct elements with minimum product.

Return the maximum even-index product minus the minimum odd-index product.

Function

maximizeParityProductGap(values: int[]) → long

Examples

Example 1

values = [5,1,-4,7,3,-2,6,4]return = 44

The even-index maximum product is 5 × 6 = 30 and the odd-index minimum product is 7 × -2 = -14.

Example 2

values = [1,2,3,4]return = -5

The only even pair has product 3 and the only odd pair has product 8.

Constraints

  • 4 <= values.length <= 200000
  • Both parity groups contain at least two values.
  • -10^9 <= values[i] <= 10^9

Source note: Interview prompt excerpt preserved as source evidence.

More Infosys Onsite Interview questions

  • Minimum Coins for a TargetONSITE INTERVIEW · Seen Nov 2026
  • Delete Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
  • Find Duplicate Employee RecordsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Insertion Steps to Make a String PalindromeONSITE INTERVIEW · Seen Nov 2026
  • Minimum Nonadjacent Flips for an Alternating Binary StringONSITE INTERVIEW · Seen Oct 2026
  • Tenth-Highest Distinct SalaryONSITE INTERVIEW · Seen Oct 2026
  • Assign Cookies With Matching ParityONSITE INTERVIEW · Seen Sep 2026
  • Count Equal Code Pairs Within Distance KONSITE INTERVIEW · Seen Sep 2026
  • Daily Successful Transactions Per DepartmentONSITE INTERVIEW · Seen Sep 2026
  • Detect Substring In Any RotationONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Retrieve Vectors by Cosine SimilarityHarvey · ONSITE INTERVIEWHarvey interview questions
  • Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Squirrel Nut Collection Shortest PathAmazon · ONSITE INTERVIEW
  • Expected Value of Modified DiceJane Street · ONSITE INTERVIEWJane Street interview questions
  • Linear Layer Forward and Backward PassesMeta · ONSITE INTERVIEWMeta interview questions
  • Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
  • Reservoir Sampling with Recorded DrawsStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • Koko Eating BananasTekion · ONSITE INTERVIEWTekion interview questions
  • Dense Vector Dot ProductCerebras · ONSITE INTERVIEW
  • Sliding-Window Averages as Reduced FractionsCoinbase · ONSITE INTERVIEWCoinbase interview questions
All Infosys interview questionsSee Infosys hiring insights
Saved
class Solution {
    public long maximizeParityProductGap(int[] values) {
        // Write your code here.
    }

}
Checking account…