You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where `i `and `j` are two different indexes of bit 1s in `m`, and `next = m & ~(1 << i) & ~(1 << j)` represents the subset `m` excluding `A[i]` and `A[j]`.
66
66
67
+
### Complexity Analysis
68
+
69
+
We traverse the binary masks from `2` to `2^N - 1` so the outer `for` loop will run `O(2^N)` time.
70
+
71
+
In each round of `for` loop, we take `O(N^2)` time to traverse all the pairs of elements in the subset `m`.
72
+
73
+
Thus, overall it takes `O(2^N * N^2)` time.
74
+
75
+
And the space complexity is apparently `O(2^N)` as well because of the `dp` array.
0 commit comments