We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a738fa8 commit 8b5cfddCopy full SHA for 8b5cfdd
575.distribute-candies.0.kt
@@ -0,0 +1,14 @@
1
+/*
2
+ * @lc app=leetcode id=575 lang=kotlin
3
+ *
4
+ * [575] Distribute Candies
5
+ */
6
+class Solution_distributeCandies_0 {
7
+ fun distributeCandies(candies: IntArray): Int {
8
+ val s = candies.size / 2
9
+ val countMap = candies.groupBy { it }.mapValues { it.value.size }
10
+ if (countMap.size > s) return s
11
+
12
+ return countMap.size
13
+ }
14
+}
0 commit comments