Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Lintcode16 Permutations II solution problem solution

Shulou Source: shulou.com Published: 2022-06-03 06:05:12 09月24日 Update

[topic description]

Given a list of numbers with duplicate number in it. Find all unique permutations.

Give a list with duplicate numbers and find out all the different arrangements in the list.

[topic link]

Http://www.lintcode.com/en/problem/permutations-ii/

[topic Analysis]

Like the solution of Permutations, it is necessary to consider "de-duplication". Sort the array first, so that in DFS, you can first determine whether the previous number is equal to yourself, and if it is equal, the preceding number must be used before you can use it, so that there is no repetitive arrangement.

Compared with Permitations's code, only 3 lines have been added, Line 8, 23 and 24.

[answer link]

Http://www.jiuzhang.com/solutions/permutations-ii/

Tags: Title time link different number that is number array answer solution sort problem solution Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB OPPO Reno Linux Shulou Tech Info