Company: ShapeCrunch_1stjuly

Difficulty: medium

Problem Statement

A CRM platform keeps an array of lead scores, leadScores , used to rank potential clients by priority. Each score is a positive integer standing in for how valuable that lead might be. Sometimes these scores need to be broken down into finer-grained values to prioritize leads more precisely. Given an array leadScores of n positive integers, you may perform the operation below any number of times, including zero: Pick a lead score at index i where 0 <= i < n . Pick any two integers x and y such that x + y = leadScores[i] . Swap out leadScores[i] for the two new scores x and y . Determine the fewest operations needed to make leadScores sorted in ascending order. Example n = 3 leadScores = [3, 4, 3] The array can be sorted in 2 operations: Pick i = 0 , leadScores[0] = 3 . Pick x = 1 and y = 2 . Swap leadScores[0] for x and y . leadScores' = [1, 2, 4, 3] . Pick i = 2 , leadScores[2] = 4 . Pick x = 2 and y = 2 . Swap leadScores[2] for x and y . leadScores' = [1, 2, 2, 2, 3] . The arra

More ShapeCrunch_1stjuly OA questionsInterview experiences