java - 请问这种排列算法的难度在什么水平?
伊谢尔伦
伊谢尔伦 2017-04-18 10:48:09
0
1
527

https://segmentfault.com/q/10... 这个问题中有四种对4位整型数组进行排列组合的算法,一个一个按照运行顺序写下来觉得很有意思,我肯定直接写不出来,想问一下算法界的大神们,这种算法大概是什么水平的?如果是很简单的那种,我大概真的要去补一下了...另外,除了死记硬背,这么刁钻的设计是怎么想出来的...

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
巴扎黑

The process of full arrangement can be regarded as a tree traversal process. Each leaf node is an arrangement. However, it should be noted that the edges of each subtree cannot overlap with the edges of the parent node.
The tree traversal process is easy to handle, either recursively, using a stack or queue, or even setting up an array to save the state. The problem that the edges of the subtree cannot overlap with the edges of the parent node is also easy to handle. When traversing the subtree, only traverse available , and just mark it after traversing it.
I think this problem is easier to solve if it is converted into a tree. It can be implemented in various ways.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!