2023-12-09 18:42:21 +08:00
< p > You are given an integer array < code > deck< / code > where < code > deck[i]< / code > represents the number written on the < code > i< sup > th< / sup > < / code > card.< / p >
2022-03-27 18:35:17 +08:00
2023-12-09 18:42:21 +08:00
< p > Partition the cards into < strong > one or more groups< / strong > such that:< / p >
2022-03-27 18:35:17 +08:00
< ul >
2023-12-09 18:42:21 +08:00
< li > Each group has < strong > exactly< / strong > < code > x< / code > cards where < code > x > 1< / code > , and< / li >
< li > All the cards in one group have the same integer written on them.< / li >
2022-03-27 18:35:17 +08:00
< / ul >
2023-12-09 18:42:21 +08:00
< p > Return < code > true< / code > < em > if such partition is possible, or < / em > < code > false< / code > < em > otherwise< / em > .< / p >
2022-03-27 18:35:17 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > deck = [1,2,3,4,4,3,2,1]
< strong > Output:< / strong > true
< strong > Explanation< / strong > : Possible partition [1,1],[2,2],[3,3],[4,4].
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 18:35:17 +08:00
< pre >
< strong > Input:< / strong > deck = [1,1,1,2,2,2,3,3]
< strong > Output:< / strong > false
< strong > Explanation< / strong > : No possible partition.
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = deck.length < = 10< sup > 4< / sup > < / code > < / li >
< li > < code > 0 < = deck[i] < 10< sup > 4< / sup > < / code > < / li >
< / ul >