BitSet C++ solution. Was asked during onsite at a startup.

  • 0

    I was asked this question in an onsite interview at a startup in SF. I was interviewing for a product position. I somehow solved this using idea similar to the code I wrote below (onsite was just a flowchart). The interviewer was so happy he offered me the job right away :p. They had solved similar problem for a real analytics issue in ETL.

        vector<vector<int>> subsets(vector<int>& nums) {
        vector<vector<int>> ans;
        for(int i = 0; i < pow(2, nums.size()); i++){
            std::bitset<32> bits(i);
            vector<int> rowVector;
            for(int j = 0; j < 32; j++)
        return ans;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.