In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 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, return all possible permutations.
Notice:You can assume that there is no duplicate numbers in the list.
Given a list of numbers, returns all its possible permutations.
Note: you can assume that there are no repeated numbers.
[topic link]
Http://www.lintcode.com/en/problem/permutations/
[topic Analysis]
When we encounter this kind of problem, obviously, the first idea is that we first go back to DFS and recursively solve it. For each element in the array, we find the Permutations headed by him, which requires that in recursion, we have to start traversing from the first element of the array. In this way, another problem is introduced. We will visit the same element many times, which is not the answer we want. So we introduced an array of type bool to record which element was traversed (find the corresponding by subscript). In solving each Permutation, if we visit this element, we set it to true in the bool array of the following table. After the visit, we set it to false.
Time complexity analysis: this problem is the same as Combination, so for the solution to this problem, the time complexity is also the same
O (n!)
[answer link]
Https://www.jiuzhang.com/solutions/permutations/
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.