All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2201_2300.s2206_divide_array_into_equal_pairs.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.32
Show newest version
package g2201_2300.s2206_divide_array_into_equal_pairs

// #Easy #Array #Hash_Table #Bit_Manipulation #Counting
// #2023_06_27_Time_221_ms_(71.43%)_Space_37.6_MB_(85.71%)

class Solution {
    fun divideArray(nums: IntArray): Boolean {
        val freq = IntArray(501)
        for (num in nums) {
            ++freq[num]
        }
        for (f in freq) {
            if (f % 2 != 0) {
                return false
            }
        }
        return true
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy