technically-php / linear-partitioning
一个简单的库,使用动态规划方法解决线性划分问题
1.0.2
2022-11-28 11:20 UTC
Requires
- php: >=7.0
Requires (Dev)
- larapack/dd: 1.0
- phpunit/phpunit: ^6.0 || ^7.0 || ^8.0
This package is auto-updated.
Last update: 2024-08-28 15:22:02 UTC
README
基于《算法设计手册》一书的描述,作者:Steven S. Skiena。
- 利用动态规划原理
- O(n²)复杂度
- 完全注释的代码
- 测试套件
- 语义化版本控制
安装
composer require technically-php/linear-partitioning:^1.0
使用方法
use \TechnicallyPhp\LinearPartitioning\LinearPartitioning; $items = [100, 200, 300, 400, 500, 600, 700, 800, 900]; $ranges = LinearPartitioning::partition($items, 3); var_dump($ranges); // [ [100, 200, 300, 400, 500], [600, 700], [800, 900] ]