Best Poker Hand
扑克判断, 没啥可说的
class Solution {
public String bestHand(int[] ranks, char[] suits) {
if(flush(ranks, suits))
return "Flush";
if(three(ranks, suits))
return "Three of a Kind";
if(pair(ranks, suits))
return "Pair";
return "High Card";
}
public boolean pair(int[] r, char[] s) {
int[] rk = new int[15];
for(int rr : r){
rk[rr - 1]++;
}
for(int rrk : rk){
if(rrk >= 2)
return true;
}
return false;
}
public boolean flush(int[] r, char[] s) {
int[] c = new int[6];
for(char ss : s) {
c[ss - 'a']++;
}
for(int cc : c){
if(cc == 5)
return true;
}
return false;
}
public boolean three(int[] r, char[] s){
int[] rk = new int[15];
for(int rr : r){
rk[rr - 1]++;
}
for(int rrk : rk){
if(rrk >= 3)
return true;
}
return false;
}
}