We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 25b350e commit 0fa77dfCopy full SHA for 0fa77df
78.子集.js
@@ -0,0 +1,27 @@
1
+/*
2
+ * @lc app=leetcode.cn id=78 lang=javascript
3
+ *
4
+ * [78] 子集
5
+ */
6
+
7
+// @lc code=start
8
+/**
9
+ * @param {number[]} nums
10
+ * @return {number[][]}
11
12
+var subsets = function(nums) {
13
+ const result = [];
14
+ const n = 2 ** nums.length;
15
+ for (let i = 0; i < n; i++) {
16
+ const t = [];
17
+ const str = i.toString(2);
18
+ for (let j = 0; j < nums.length; j++) {
19
+ if (str[j] === '1') {
20
+ t.push(nums[str.length - 1 - j]);
21
+ }
22
23
+ result.push(t);
24
25
+ return result;
26
+};
27
+// @lc code=end
0 commit comments