C++ Solution to Leetcode 565. Array Nesting