Most optimal O(N) - time and O(1) space solution NO Binary Search everything explained
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def smallestSubarrays(self, nums: List[int]) -> List[int]:\n\n\n        size = len(nums)\n        minimum_subarr_size = [-1]*size \n\n        # represent every set bits in your dictionary \n        # to avoided checking every time if the ith \n        # set bit is in  our last_seen index or not \n        last_seen = {i:-1 for i in range(32)} \n\n        # an edge case where the end elements are zeros \n        # since zero has no set bits \n        size -=  1\n        while size > -1 and nums[size] == 0: \n            minimum_subarr_size[size] = 1 \n            size -= 1\n\n        # we start from the end and \n        # traverse backwards \n        # since we only care about values to the right of current index. \n        for i in range(size,-1, -1): \n            num = nums[i]\n            j = 31 \n            # find the set bits \n            while num: \n                if num & 1: \n                    last_seen[j] = i \n                num >>= 1 \n                j -= 1 \n            \n            # our minimum_subarr_size would be index of least recently seen \n            # set bit plus one minus i or (i.e the length of subarray between)\n            # i and  least recently seen set bit index \n            minimum_subarr_size[i] = (max(last_seen.values()) +1) - i\n        return minimum_subarr_size\n\n\n\n        # Time: O(N)\n        # space: O(N) - used for minimum_subarr_size array \n        # we can optimize the space complexity to O(1) \n        # by updating the original array or (i.e)\n        # nums[i] =  (max(last_seen.values()) +1) - i\n        # finally retrun nums \n```
['Array', 'Hash Table', 'Bit Manipulation', 'Sliding Window', 'Python', 'C++', 'Python3']