C++ solution to Leetcode 1695. Maximum Erasure Value