Sales by Match

  • + 0 comments

    Kotlin Solution

    fun sockMerchant(n: Int, ar: Array<Int>): Int {
            var numberOfPairs = 0
            ar.groupBy { it }.forEach {
                numberOfPairs += it.value.size / 2
            }
            return numberOfPairs
        }