In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "JS how to achieve array full permutation output algorithm", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "JS how to achieve array full permutation output algorithm" this article.
The sample code is as follows:
Function permute (input) {var permArr = [], usedChars = []; function main (input) {var I, ch; for (I = 0; I < input.length; iTunes +) {ch = input.splice (I, 1) [0]; usedChars.push (ch); if (input.length = = 0) {permArr.push (usedChars.slice ());} main (input) Input.splice (I, 0, ch); usedChars.pop ();} return permArr} return main (input);}; console.log (permute ([5,3,7,1]))
The other is to sort by string.
Function permutate (str) {var result= []; if (str.length==1) {return [str]} else {var preResult=permutate (str.slice (1)); for (var j = 0; j < preResult.length; jlength +) {for (var k = 0; k < preResult [j] .length + 1) Temp +) {var temp= preResult [j] .slice (0djk) + str [0] + preResult.slice (k); result.push (temp);}} return result;}} console.log (permutate ("abc")) These are all the contents of the article "how to implement the array full permutation output algorithm in JS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.