<?php
class Solution
{
/**
* @param Integer[] $ranks
* @param String[] $suits
* @return String
*/
function bestHand(array $ranks, array $suits)
{
$suits = array_count_values($suits);
if (count($suits) == 1) {
return 'Flush';
}
$ranks = array_count_values($ranks);
if (count($ranks) == 5) {
return 'High Card';
}
foreach ($ranks as $v) {
if ($v > 2) {
return 'Three of a Kind';
}
}
return 'Pair';
}
}
$solution = new Solution();
var_dump($solution->bestHand([4,4,2,4,4], ["d","a","a","b","c"]));
力扣第2347题
最新推荐文章于 2024-11-04 12:20:00 发布