Minimum Array End Leetcode Sql Server