skills[i]. A squad is any non-empty subset of the fighters. The strength of a squad is the square of its highest skill multiplied by its lowest skill.
Return the sum of strengths over all possible squads. Fighters with equal skill are still different people. The answer can be huge, so return it modulo 10⁹ + 7.skills=[3, 1, 2] → 76
Squads: [3] → 27, [1] → 1, [2] → 8, [3,1] → 9, [3,2] → 18, [1,2] → 4, [3,1,2] → 9. The sum is 76.
skills=[2, 2] → 24
Three squads, each with strength 2² · 2 = 8, for a total of 24.
skills=[5] → 125
skills=[3, 1, 2]
76
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.