/**
使用雙隊(duì)列,一個(gè)記錄全部數(shù)據(jù)存炮,一個(gè)記錄最大的數(shù)字
*/
????class?MaxQueue?{
????private??$maxQueue?=?[];
????private?$numQueue?=?[];
????function?__construct()?{
????????$this->maxQueue?=?[];
????????$this->numQueue?=?[];
????}
????/**
?????*?@return?Integer
?????*/
????function?max_value()?{
????????return?$this->maxQueue[0]?$this->maxQueue[0]:-1;
????}
????/**
?????*?@param?Integer?$value
?????*?@return?NULL
?????*/
????function?push_back($value)?{
????????array_push($this->numQueue,$value);
????????while(!empty($this->maxQueue)?&&?($this->maxQueue[count($this->maxQueue)-1]?<=?$value))?{
????????????array_pop($this->maxQueue);
????????}
????????array_push($this->maxQueue,$value);
????}
????/**
?????*?@return?Integer
?????*/
????function?pop_front()?{
????????$num?=?array_shift($this->numQueue);
????????if($num?==?$this->maxQueue[0]){
????????????array_shift($this->maxQueue);
????????}
????????return?$num?$num:-1;
????}
}