排列组合公式/排列组合计算公式公式P是指排列,从N个元素取R个进行排列。 公式C是指组合,从N个元素取R个,不进行排列了,但在php中我们可以用N种方法写出来了,但每一种写法的性能会不同,下面我们就来看看吧。
需求是这样的:
找到数组中所有可能的指定长度的组合,要求没有重复。
方法一:
代码如下 | 复制代码 |
function getCombinationToString($arr,$m){ $temp_list2 = getCombinationToString($arr, $m); var_dump($t); |
执行时间:238ms。
方法二:
代码如下 | 复制代码 |
function getCombinAryByNum( $arr, $num,$t=array()) { $arr = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18); var_dump($ss); |
执行时间:710ms。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
