[LeetCode] 47. Permutations II


質問する



に答える

  • セットを使用して重複項目を除去します.
  • map関数とlambda式を使用してtupleをlistに変換し、返します.
  • コード#コード#

    from itertools import permutations
    
    class Solution:
        def permuteUnique(self, nums: List[int]) -> List[List[int]]:
            return list(map(lambda x : list(x), list(set(permutations(nums)))))