Java 8 API 1 line solution (no Hash Map)

  • 1

    Count all distinct kinds of candies and decide how many of them can be given to a sister:

    public class Solution {
        public int distributeCandies(int[] candies) {
            return Math.min(candies.length / 2, (int);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.