Contains all elements and duplicates are taken into account The idea is to have a function which checks if all elements in a list are contained in another list. But not just the containedness has to be true, but also the times of containedness.
One could say the function has to be an extended version of containsAll , which checks only the containedness.
Here's my implementation of such a function:
fun main(args: Array&lt;String&gt;) {
    val toCheck = listOf(1, 2, 3, 4, 5, 6, 1, 1, 3)
    val expected = listOf(1, 1, 1, 3, 3, 4)

    val result = containsAllSameCount(toCheck, expected)
    println(&quot;Result =&gt; $result&quot;)

    val expected2 = listOf(1, 1, 3, 3, 4) // One 1 is missing!
    val result2 = containsAllSameCount(toCheck, expected2)
    println(&quot;Result 2 =&gt; $result2&quot;)
    /*
        Result =&gt; true
        Result 2 =&gt; false
     */
}

fun containsAllSameCount(toCheck: List&lt;Int&gt;, expected: List&lt;Int&gt;): Boolean {
    for (current in expected) {
        var currentInExpected = expected.filter { it == current }
        var currentInToCheck = toCheck.filter { it == current }

        if (currentInExpected.size != currentInToCheck.size) {
            return false
        }
    }

    return true
}

It's clear to me, that the filter-methods are used multiple times, when the same element is contained multiple times. Therefore I suppose that my implementation isn't the most efficient way to solve the task.
What do you think about my implementation?
What's a better way to solve the way?
The best way would be to change data structure. Instead of using a List&lt;Int&gt; you can use a Map&lt;Int, Int&gt;. If you want to have a List&lt;Int&gt; in the beginning, that's ok, you just need to convert it to a Map&lt;Int, Int&gt; and compare the maps.
Using the nice Kotlin methods in the stdlib, we can make the code into this:
fun &lt;T&gt; containsAllSameCount(toCheck: List&lt;T&gt;, expected: List&lt;T&gt;): Boolean {
    val toCheckCountMap = toCheck.groupBy { it }.mapValues { it.value.size }
    val expectedCountMap = expected.groupBy { it }.mapValues { it.value.size }
    return expectedCountMap.all { toCheckCountMap[it.key] == it.value }
}

I have also added generics here because the same logic applies whether it's a List&lt;Int&gt;, List&lt;String&gt; and so on.
Some other notes:

Use JUnit for proper tests.
The main method in Kotlin does not need to be declared with the args, simply fun main() { will do.
Use val instead of var whenever possible.
Instead of .filter and then checking the size, use .count