def test_next_permutation__21(self): nums = [2,1] NextPermutation().nextPermutation(nums) self.assertEqual([1,2], nums)
def test_next_permutation__1231(self): # 1,2,3,1 → 1,3,2,1 nums = [1, 2, 3, 1] NextPermutation().nextPermutation(nums) self.assertEqual([1, 3, 1, 2], nums)
def test_next_permutation__115(self): # 1,1,5 → 1,5,1 nums = [1, 1, 5] NextPermutation().nextPermutation(nums) self.assertEqual([1, 5, 1], nums)
def test_next_permutation__321(self): # 3,2,1 → 1,2,3 nums = [3, 2, 1] NextPermutation().nextPermutation(nums) self.assertEqual([1, 2, 3], nums)
def test_next_permutation__132(self): ## 1,2,3 → 1,3,2 nums = [1, 3, 2] NextPermutation().nextPermutation(nums) self.assertEqual([2, 1, 3], nums)
def test_next_permutation__empty(self): nums = [] NextPermutation().nextPermutation(nums) self.assertEqual([], nums)