2347. Best Poker Hand Easy

@problem@discussion
#Array#Hash Table#Counting



1/**
2 * [2347] Best Poker Hand
3 *
4 * You are given an integer array ranks and a character array suits. You have 5 cards where the i^th card has a rank of ranks[i] and a suit of suits[i].
5 * The following are the types of poker hands you can make from best to worst:
6 * <ol>
7 * 	"Flush": Five cards of the same suit.
8 * 	"Three of a Kind": Three cards of the same rank.
9 * 	"Pair": Two cards of the same rank.
10 * 	"High Card": Any single card.
11 * </ol>
12 * Return a string representing the best type of poker hand you can make with the given cards.
13 * Note that the return values are case-sensitive.
14 *  
15 * Example 1:
16 * 
17 * Input: ranks = [13,2,3,1,9], suits = ["a","a","a","a","a"]
18 * Output: "Flush"
19 * Explanation: The hand with all the cards consists of 5 cards with the same suit, so we have a "Flush".
20 * 
21 * Example 2:
22 * 
23 * Input: ranks = [4,4,2,4,4], suits = ["d","a","a","b","c"]
24 * Output: "Three of a Kind"
25 * Explanation: The hand with the first, second, and fourth card consists of 3 cards with the same rank, so we have a "Three of a Kind".
26 * Note that we could also make a "Pair" hand but "Three of a Kind" is a better hand.
27 * Also note that other cards could be used to make the "Three of a Kind" hand.
28 * Example 3:
29 * 
30 * Input: ranks = [10,10,2,12,9], suits = ["a","b","c","a","d"]
31 * Output: "Pair"
32 * Explanation: The hand with the first and second card consists of 2 cards with the same rank, so we have a "Pair".
33 * Note that we cannot make a "Flush" or a "Three of a Kind".
34 * 
35 *  
36 * Constraints:
37 * 
38 * 	ranks.length == suits.length == 5
39 * 	1 <= ranks[i] <= 13
40 * 	'a' <= suits[i] <= 'd'
41 * 	No two cards have the same rank and suit.
42 * 
43 */
44pub struct Solution {}
45
46// problem: https://leetcode.com/problems/best-poker-hand/
47// discuss: https://leetcode.com/problems/best-poker-hand/discuss/?currentPage=1&orderBy=most_votes&query=
48
49// submission codes start here
50
51impl Solution {
52    pub fn best_hand(ranks: Vec<i32>, suits: Vec<char>) -> String {
53        String::new()
54    }
55}
56
57// submission codes end
58
59#[cfg(test)]
60mod tests {
61    use super::*;
62
63    #[test]
64    fn test_2347() {
65    }
66}
67


Back
© 2025 bowen.ge All Rights Reserved.