914. X of a Kind in a Deck of Cards Easy

@problem@discussion
#Array#Hash Table#Math#Counting#Number Theory



1/**
2 * [914] X of a Kind in a Deck of Cards
3 *
4 * In a deck of cards, each card has an integer written on it.
5 * Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where:
6 * 
7 * 	Each group has exactly X cards.
8 * 	All the cards in each group have the same integer.
9 * 
10 *  
11 * Example 1:
12 * 
13 * Input: deck = [1,2,3,4,4,3,2,1]
14 * Output: true
15 * Explanation: Possible partition [1,1],[2,2],[3,3],[4,4].
16 * 
17 * Example 2:
18 * 
19 * Input: deck = [1,1,1,2,2,2,3,3]
20 * Output: false
21 * Explanation: No possible partition.
22 * 
23 *  
24 * Constraints:
25 * 
26 * 	1 <= deck.length <= 10^4
27 * 	0 <= deck[i] < 10^4
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/
33// discuss: https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn has_groups_size_x(deck: Vec<i32>) -> bool {
39        false
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_914() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.