
g0001_0100.s0078_subsets.solution.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
// #Medium #Top_100_Liked_Questions #Top_Interview_Questions #Array #Bit_Manipulation #Backtracking
// #Algorithm_II_Day_9_Recursion_Backtracking #Udemy_Backtracking/Recursion
// #Big_O_Time_O(2^n)_Space_O(n*2^n) #2023_10_02_Time_50_ms_(94.61%)_Space_44.8_MB_(75.83%)
const subsets = (nums: number[]): number[][] => {
const sets: number[][] = [[]]
for (const num of nums) sets.push(...sets.map((set) => [...set, num]))
return sets
}
export { subsets }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy