Solución
solution.tsTypeScript
function subsets(nums: number[]): number[][] {
const limit = Math.pow(2,nums.length)
const resp = []
for(let i = 0; limit > i; i++){
const bin = i.toString(2)
if(!bin.includes('1')){
resp.push([])
} else {
const reverseBin = bin.split('').reverse()
const arr = []
reverseBin.forEach( (num, index) => {
if( num == '1'){
arr.push(nums[index])
}
})
resp.push(arr)
}
}
return resp
}
// No modificar: necesario para evaluar el resultado.
export { subsets };0respuestas