Hard · Graphs
Subset Component
Given an array d of n non-negative 64-bit integers, consider, for each of its 2ⁿ subsets, the graph on the 64 bit positions in which every chosen number connects all of its own set bits; return the sum of the connected-component counts of all these graphs.
Examples
Example 1
d = [2, 5, 9]Output: sum = 504
Example 2
d = [3, 6, 5, 0]Output: sum = 1002
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.