Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lintcode16 Permutations II solution problem solution

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

[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/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report