Next Permutation Problem Leetcode Sql