File size: 7,117 Bytes
f7c0146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{
    "id": 2433,
    "name": "best_poker_hand",
    "difficulty": "Easy",
    "link": "https://leetcode.com/problems/best-poker-hand/",
    "date": "1657324800000",
    "task_description": "You are given an integer array `ranks` and a character array `suits`. You have `5` cards where the `ith` card has a rank of `ranks[i]` and a suit of `suits[i]`. The following are the types of **poker hands** you can make from best to worst: `\"Flush\"`: Five cards of the same suit. `\"Three of a Kind\"`: Three cards of the same rank. `\"Pair\"`: Two cards of the same rank. `\"High Card\"`: Any single card. Return _a string representing the **best** type of **poker hand** you can make with the given cards._ **Note** that the return values are **case-sensitive**. **Example 1:** ``` **Input:** ranks = [13,2,3,1,9], suits = [\"a\",\"a\",\"a\",\"a\",\"a\"] **Output:** \"Flush\" **Explanation:** The hand with all the cards consists of 5 cards with the same suit, so we have a \"Flush\". ``` **Example 2:** ``` **Input:** ranks = [4,4,2,4,4], suits = [\"d\",\"a\",\"a\",\"b\",\"c\"] **Output:** \"Three of a Kind\" **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\". Note that we could also make a \"Pair\" hand but \"Three of a Kind\" is a better hand. Also note that other cards could be used to make the \"Three of a Kind\" hand. ``` **Example 3:** ``` **Input:** ranks = [10,10,2,12,9], suits = [\"a\",\"b\",\"c\",\"a\",\"d\"] **Output:** \"Pair\" **Explanation:** The hand with the first and second card consists of 2 cards with the same rank, so we have a \"Pair\". Note that we cannot make a \"Flush\" or a \"Three of a Kind\". ``` **Constraints:** `ranks.length == suits.length == 5` `1 <= ranks[i] <= 13` `'a' <= suits[i] <= 'd'` No two cards have the same rank and suit.",
    "public_test_cases": [
        {
            "label": "Example 1",
            "input": "ranks = [13,2,3,1,9], suits = [\"a\",\"a\",\"a\",\"a\",\"a\"]",
            "output": "\"Flush\" "
        },
        {
            "label": "Example 2",
            "input": "ranks = [4,4,2,4,4], suits = [\"d\",\"a\",\"a\",\"b\",\"c\"]",
            "output": "\"Three of a Kind\" "
        },
        {
            "label": "Example 3",
            "input": "ranks = [10,10,2,12,9], suits = [\"a\",\"b\",\"c\",\"a\",\"d\"]",
            "output": "\"Pair\" "
        }
    ],
    "private_test_cases": [
        {
            "input": [
                [
                    9,
                    12,
                    2,
                    4,
                    6
                ],
                [
                    "a",
                    "d",
                    "d",
                    "d",
                    "c"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    9,
                    12,
                    13,
                    1,
                    7
                ],
                [
                    "c",
                    "c",
                    "b",
                    "a",
                    "c"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    4,
                    11,
                    8,
                    2,
                    5
                ],
                [
                    "b",
                    "c",
                    "c",
                    "d",
                    "b"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    11,
                    1,
                    10,
                    13,
                    7
                ],
                [
                    "b",
                    "b",
                    "b",
                    "a",
                    "c"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    4,
                    12,
                    8,
                    9,
                    13
                ],
                [
                    "d",
                    "d",
                    "d",
                    "d",
                    "d"
                ]
            ],
            "output": "Flush"
        },
        {
            "input": [
                [
                    10,
                    5,
                    7,
                    13,
                    11
                ],
                [
                    "d",
                    "c",
                    "b",
                    "b",
                    "c"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    1,
                    11,
                    2,
                    4,
                    3
                ],
                [
                    "c",
                    "d",
                    "c",
                    "b",
                    "b"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    11,
                    6,
                    9,
                    4,
                    7
                ],
                [
                    "c",
                    "c",
                    "d",
                    "b",
                    "b"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    5,
                    7,
                    4,
                    3,
                    8
                ],
                [
                    "a",
                    "b",
                    "a",
                    "c",
                    "c"
                ]
            ],
            "output": "High Card"
        },
        {
            "input": [
                [
                    7,
                    3,
                    8,
                    11,
                    1
                ],
                [
                    "c",
                    "c",
                    "c",
                    "b",
                    "d"
                ]
            ],
            "output": "High Card"
        }
    ],
    "haskell_template": "bestHand :: [Int] -> [String] -> String\nbestHand ranks suits ",
    "ocaml_template": "let bestHand (ranks: int list) (suits: string list) : string =  ",
    "scala_template": "def bestHand(ranks: List[Int],suits: List[String]): String = { \n    \n}",
    "java_template": "public static String bestHand(List<Integer> ranks, List<String> suits) {\n\n}",
    "python_template": "class Solution(object):\n    def bestHand(self, ranks, suits):\n        \"\"\"\n        :type ranks: List[int]\n        :type suits: List[str]\n        :rtype: str\n        \"\"\"\n        "
}