Menu

(Solved) : Given Array Integers Position Search Among Previous Positions Last Left Position Contains Q37165655 . . .

Given array of integers, for each position i, search among theprevious positions for the last (from the left) position thatcontains a smaller value. Store this value at position i in theanswer. If no such value can be found, store -1 instead.

Example

For items = [3, 5, 2, 4, 5], the output should be
arrayPreviousLess(items) = [-1, 3, -1, 2, 4].

Expert Answer


Answer to Given array of integers, for each position i, search among the previous positions for the last (from the left) position …

OR