Minimum Array End Leetcode Contest Solution