Stash Interview Question

A Leetcode Hard, won't give the specific question