FastPrepMaximum Combined Distance Across Five Arrays
Problems/Maximum Combined Distance Across Five Arrays

Maximum Combined Distance Across Five Arrays

Nutanix logoNutanix● MediumINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2020 intern report from the Nutanix online assessment gave the whole task. You get five arrays of the same length. For two indices, add up how far apart the five arrays' values are at those indices, plus how far apart the indices are. Find the largest total.

The report gives no limits and no examples. It does not say whether both indices can be the same. Here they can, so arrays with one element give 0. The limits are our choice: each array has 1 to 5 * 10^4 elements, and every value is from -10^6 to 10^6.

Our version is about 95% the same as the reported question.

You are given five integer arrays a, b, c, d and e, all of the same length n.

For two indices i and j (each from 0 to n - 1), define

f(i, j) = |a[i] - a[j]| + |b[i] - b[j]| + |c[i] - c[j]| + |d[i] - d[j]| + |e[i] - e[j]| + |i - j|

Return the largest value of f(i, j) over all pairs of indices. The two indices may be the same, in which case f(i, i) = 0.

Function

maxCombinedDistance(a: int[], b: int[], c: int[], d: int[], e: int[]) → int

Examples

Example 1

a = [1,3]b = [2,0]c = [0,0]d = [5,4]e = [-1,1]return = 8

With i = 0 and j = 1 the six terms are |1 - 3| = 2, |2 - 0| = 2, |0 - 0| = 0, |5 - 4| = 1, |-1 - 1| = 2 and |0 - 1| = 1. They add up to 8.

Choosing the same index twice gives 0, so the answer is 8.

Example 2

a = [0,4,1]b = [2,2,-3]c = [1,0,1]d = [0,0,0]e = [3,-1,2]return = 13
  • Indices 0 and 1: 4 + 0 + 1 + 0 + 4 + 1 = 10.
  • Indices 0 and 2: 1 + 5 + 0 + 0 + 1 + 2 = 9.
  • Indices 1 and 2: 3 + 5 + 1 + 0 + 3 + 1 = 13.

The best pair is indices 1 and 2, even though indices 0 and 2 are farther apart. The answer is 13.

Example 3

a = [7]b = [-2]c = [0]d = [9]e = [4]return = 0

There is only one index, so i = j = 0 and every term is 0. The answer is 0.

Constraints

  • a.length == b.length == c.length == d.length == e.length == n
  • 1 <= n <= 5 * 10^4
  • -10^6 <= a[i], b[i], c[i], d[i], e[i] <= 10^6

More Nutanix Online Assessment questions

  • Good SubsequencesOA · Seen Jul 2026
  • Min Cost to Connect All PointsOA · Seen Jun 2026
  • Digit Changes for a Multiple of 9OA · Seen Aug 2025
  • Gas Station Loop StartOA · Seen Aug 2025
  • Number of Players (for MTS2)OA · Seen Oct 2024
  • Work Schedules (for MTS2)OA · Seen Oct 2024
  • Minimum Operations to Convert ArrayOA · Seen Apr 2024
  • No Adjacent CharactersOA · Seen Apr 2024
  • Build a BST From a ListOA · Seen Nov 2022
  • Delete Even-Valued Nodes From a Linked ListOA · Seen Nov 2022

Similar questions at other companies

  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Power-of-Two Removal OperationsIBM · OAIBM interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA

Interview reports that mention this question

  • Nutanix Intern Debugging Round and Interviews: 25 Experiences

Nutanix interview experiences

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)
  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public int maxCombinedDistance(int[] a, int[] b, int[] c, int[] d, int[] e) {
        // Write your code here.
    }
}
Checking account…