⬆︎
×

[LC] 3046 Split the Array

Java

/**
 * <a href="https://leetcode.cn/problems/split-the-array/">Split the Array</a>
 * 数组;哈希表;计数
 */
class Solution {
    public boolean isPossibleToSplit(int[] nums) {
        int[] cnt = new int[101];
        for (int num : nums) {
            cnt[num]++;
            if (cnt[num] > 2) {
                return false;
            }
        }
        return true;
    }
}

发表评论