There are two loops in the code. First loop executes 2^n times. the inter loop execute n times. Then time complexity is O(2^n * n) not O(2^n) ? Am I miss anything?
And also for the space complexity. we only create new hashset in the for loop. after every loop execute, hashset space will be garbage collected and reused. and every hashset has maximum n integers. So space complexity should be O(n).