刚刚遇到一个棘手的算法问题,求解
求解
------解决方案--------------------
$a = array(1,2,2,3,1,2,3,1,1);<br />$st = array(1 => 0);<br />$d = 1;<br />foreach($a as $v) {<br /> @$st[$v]++;<br /> if($v >= $d) {<br /> $d = $v;<br /> }else{<br /> while($v < $d) {<br /> unset($st[$d--]);<br /> }<br /> }<br /> $r[] = join('.', $st);<br />}<br />print_r($r);