Back to problems

Get Maximum Sum of Strengths

Algorithm · Salesforce · Medium

You are given a sequence arr of n integers. You may repeatedly apply one maneuver: pick a position i (with 1 <= i < n) and exchange the entries at i and i+1. Every individual value may take part in at most a single such exchange throughout the entire procedure. For a 1-indexed location i, its contribution is defined as the product $$arr[i] \times i$$. Your goal is to determine the greatest achievable total contribution over all locations once the exchanges are done in the…

Checking your access…