Company: BNY Codedivas 2026
Difficulty: medium
Power of Array James is working on a project to calculate the strength of an array which is defined as the sum of absolute differences between specific pairs of elements in the array. For a given array, the strength is calculated as: Absolute difference between the first and last element Absolute difference between the second and second-last element and so on. For example, in the array {1,3,2}, the strength is: |1-2| + |3-3| + |2-1| = 2 To maximize the strength, the order of the elements in the array can be rearranged. For instance, {1,2,3} yields a higher strength: |1-3| + |2-2| + |3-1| = 4 James needs your help to find the total sum of the maximum strengths of all possible arrays. You are given two inputs an integer X , representing the length of the arrays and an integer I , representing the range of numbers from 1 to I. You task is to generate all possible combinations of numbers of length X using numbers from 1 to I and then rearrange each combination to achieve the maximum streng