Back to problems

Solve Two Algorithm Problems

Algorithm · Amazon · Hard

Task 1 — Repeated removal around the smallest value You are handed an integer array arr. Carry out the following procedure over and over until nothing is left: Look at the entries that are still present and pick the one whose value is smallest; if more than one surviving entry shares that smallest value, pick the one whose original position comes first. Add the picked entry's value into a running total. That entry is then discarded, and so are its two immediate positions in…

Checking your access…