Next Permutation, Remove Duplicates from Sorted List II

Exercises from LeetCode, both are accepted