Skip to content

Commit 8b5cfdd

Browse files
committed
575/kt
1 parent a738fa8 commit 8b5cfdd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

575.distribute-candies.0.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)