educative.io

Unable to fit the time complexity and space requirements of this problem

The ideal solution asks for O(2^n) time complexity but generating all subsets itself takes O(n*2^n) time. If we use DP to solve this then we need more space and it won’t be O(1). Can you please guide me which ideal solution is the problem hinting at?