stack like data structure kotlin

PHOTO EMBED

Fri Jun 17 2022 09:23:34 GMT+0000 (UTC)

Saved by @tonystark #undefined

/**
 * You can edit, run, and share this code.
 * play.kotlinlang.org
 */
fun main() {
    val numbers = listOf(1,2,3,4)
    
    var numSet: MutableSet<Int> = mutableSetOf()
    
    for (number in numbers) {
        numSet.add(number)
    }
    
    println(numSet.size == numbers.size)
    
}
content_copyCOPY

https://play.kotlinlang.org/#eyJ2ZXJzaW9uIjoiMS43LjAiLCJwbGF0Zm9ybSI6ImphdmEiLCJhcmdzIjoiIiwibm9uZU1hcmtlcnMiOnRydWUsInRoZW1lIjoiaWRlYSIsImNvZGUiOiIvKipcbiAqIFlvdSBjYW4gZWRpdCwgcnVuLCBhbmQgc2hhcmUgdGhpcyBjb2RlLlxuICogcGxheS5rb3RsaW5sYW5nLm9yZ1xuICovXG5mdW4gbWFpbigpIHtcbiAgICB2YWwgbnVtYmVycyA9IGxpc3RPZigxLDIsMyw0KVxuICAgIFxuICAgIHZhciBudW1TZXQ6IE11dGFibGVTZXQ8SW50PiA9IG11dGFibGVTZXRPZigpXG4gICAgXG4gICAgZm9yIChudW1iZXIgaW4gbnVtYmVycykge1xuICAgICAgICBudW1TZXQuYWRkKG51bWJlcilcbiAgICB9XG4gICAgXG4gICAgcHJpbnRsbihudW1TZXQuc2l6ZSA9PSBudW1iZXJzLnNpemUpXG4gICAgXG59In0