Skip to content

Commit 9ece4a5

Browse files
authored
Update js codes.docx
1 parent ee4192f commit 9ece4a5

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

js codes.docx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,21 @@ function findAllSubsetsoOfGivenSet(arr)
11671167
return result
11681168
}
11691169
console.log(findAllSubsetsoOfGivenSet([8,9]));
1170+
--------------------------------------------------------
1171+
function findAllSubsets(arr){
1172+
var result = []
1173+
for(var item of arr){
1174+
let tempSub = [...result]
1175+
for(var curr of tempSub){
1176+
result.push([...curr, item])
1177+
}
1178+
result.push([item])
1179+
}
1180+
result.push([])
1181+
return result
1182+
}
1183+
1184+
console.log(findAllSubsets([1,2]))
11701185
================================================================================================================================================================================
11711186
Code 82: To find the maximum repetation of the character in a string
11721187
function maxRepeating(str)

0 commit comments

Comments
 (0)