Problem Statement Given a list of array of numbers A,pick the smallest non-negative (≥ 0) then decreases each number of the array by the index of the selected number. This constitutes as one operation. What is the minimum number of operations to do till all kick powers become less than 0? Constraint 1<=Size of Array<=100 1<=Each Element<=1000
I was thinking of the following approach. Store the element's index in an array of size 100x1000(to handle duplicates) Sort the original array. (Nlogn) Iterate over the array with a pointer and maintain a sum of indexes so far and i) check if the current pointer has element less than 0 if yes then move on else ans+=1 and sum of index+=index of the current number(original index)
Is this optimized space and time complexity wise?