Back to problems

Solve Two Array Optimization Problems

Algorithm · Google · Hard

Two independent tasks follow; each carries a follow-up requirement that changes only what you must return, or how much memory you may use. Task 1. An integer array weights lists the mass of every link of a chain from one end to the other. Take out a single link at some index r, then join the surviving links end to end in their original relative order, producing a shorter chain of $$n - 1$$ links. Slice that shortened chain at exactly one position k, which divides it into a…

Checking your access…