The idea to the solution for this medium LC problem is to use bit manipulation to iterate through all possible combination of bits and use this bits to generate the list of subsets. For example, a given array is [1,2,3], you could represent a subset of {1,2,3} as 111, {1,2} as 110, {1} as 100 and so on and so forth.

class Solution {
fun subsets(nums: IntArray): List<List<Int>> {
var output = mutableListOf<List<Int>>()
for(i in 0 until (1 shl nums.size)){
var list = mutableListOf<Int>()
for(x in 0 until nums.size){
if(i and (1 shl x) > 0) list.add(nums[x])
}

Runtime: 152 ms, faster than 98.41% of Kotlin online submissions for Subsets.