php - Algorithm to count most repeated element; -
i have tree of structure blook
->house
->room
each room has data , specific status red
, blue
, green
, empty
.
i have iterate through tree , and display common color on each level
.
is there algorithm similar binarymask assign numeric value each color, , store there "sum" single integer , @ time able extract common color sum?
(if of colors have equal counts priority red > blue > green
taken)
use array that... this,
$colors = array('red' => 0, 'blue' => 0, 'green' => 0, 'empty' => 0); //assign values $colors['red'] += 1; //get maximun array_keys($colors, max($colors))
Comments
Post a Comment