Maximize the Index-Weighted Sum with Disjoint Swaps

Problem

Given an integer array nums, you may swap elements at any two distinct positions, but each element may participate in at most one swap. You may perform zero or more swaps.

Let a be the...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: