Salesforce uses an array of lead scores, leadScores, to prioritize potential clients. Each lead score is a positive integer representing the potential value of a lead. In some cases, the lead scores need to be optimized by splitting them into more granular scores for better prioritization.
Given an array leadScores of n positive integers, the following operation can be performed O or more times:
The task is to determine the minimum number of operations required to sort the leadScores array in ascending order.
n = 3 leadScores = [3, 4, 3]
The array can be sorted in 2 operations:
Select i = 0, leadScores[0] = 3. Choose x = 1 and y = 2. Replace leadScores[0] with x and y. leadScores' = [1, 2, 4, 3].
Select i = 2, leadScores[2] = 4. Choose x = 2 and y = 2. Replace leadScores[2] with x and y. leadScores' = [1, 2, 2, 2, 3].