Solve Inverse RMQ

Given a shuffled array of some segment tree that solves an RMQ task, determine if you can restore the original segment tree. Solving code challenges on HackerRank is one of the best ways to prepare for programming interviews.