From ffada26f33e248d0e93ebe67b94d1207e5f28983 Mon Sep 17 00:00:00 2001 From: Abhishek Tripathi <42455093+abhishektripathi66@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:27:00 +0530 Subject: [PATCH] Create XofaKindinaDeckofCards.java --- Leetcode/XofaKindinaDeckofCards.java | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Leetcode/XofaKindinaDeckofCards.java diff --git a/Leetcode/XofaKindinaDeckofCards.java b/Leetcode/XofaKindinaDeckofCards.java new file mode 100644 index 0000000..b89ae28 --- /dev/null +++ b/Leetcode/XofaKindinaDeckofCards.java @@ -0,0 +1,42 @@ +/** +914. X of a Kind in a Deck of Cards +Solved +Easy +Topics +Companies +You are given an integer array deck where deck[i] represents the number written on the ith card. + +Partition the cards into one or more groups such that: + +Each group has exactly x cards where x > 1, and +All the cards in one group have the same integer written on them. +Return true if such partition is possible, or false otherwise. + + */ +class Solution { + public boolean hasGroupsSizeX(int[] deck) { + if(deck.length<2) return false; + Map a = new HashMap<>(); + for(int i=0;i=2 ? true : false; + + + } + + public int gcd(int a, int b){ + if(b==0){ + return a ; + } + return gcd(b, a%b); + } +}