[C++] | Sliding Window | Explained with Comment
//Just like sliding window, we do this code as well. We maintain a map, tha store , that which index has been repeated and how many time, Eg :- 101 and 110 , ma
//Just like sliding window, we do this code as well. We maintain a map, tha store , that which index has been repeated and how many time, Eg :- 101 and 110 , map will have(indices like 2nd , 1st,0th) , then 0th index:- 1 , 1st index :- 1 , 2nd index :- 2)\n\nkeep 2 pointers i and j , from end\n\nLogic, start from end and move to start, at each step , add the indices of jth index, now we try to remove indices of ith index if, the map size is still same , else stop removing. Length will be (i-j+1)\n\n\n \n \n **CODE :- ** \n \n \n    void add(int n , unordered_map<int,int> & m)\n    {\n        int i = 0;\n        while(n > 0)\n        {\n            int r = n%2;\n            n/=2;\n            if(r == 1)\n            {\n                m[i]++;\n            }\n            i++;\n        }\n    }\n    \n     void del(int n , unordered_map<int,int> & m)\n    {\n        int i = 0;\n        while(n > 0)\n        {\n            int r = n%2;\n            n/=2;\n            if(r == 1)\n            {\n                m[i]--;\n                if(m[i] == 0)\n                {\n                    m.erase(i);\n                }\n            }\n            i++;\n        }\n    }\n    \n    vector<int> smallestSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        int i = n-1 , j = n-2 ;\n        \n        vector<int> ans(n,1);\n        \n        unordered_map<int,int> m ;\n        int sum = nums[n-1];\n        \n        add(nums[n-1] , m);\n        while(j >= 0)\n        {\n            \n            add(nums[j] , m);\n            \n            while(i > j)\n            {\n                int prev = m.size();\n                del(nums[i],m);\n                int new_val = m.size();\n                \n                if(prev == new_val)\n                {\n                    i--;\n                }\n                else\n                {\n                    add(nums[i],m);\n                    break;\n                }\n                \n                \n            }\n            \n            ans[j] = i-j+1;\n                \n                j--;\n            \n            \n        }\n        \n        return ans;\n    }
['Bit Manipulation', 'C', 'Sliding Window']