Rust Solution
Complexity\n- Time complexity:\nO(nm)\n\n- Space complexity:\nO(nm)\n\n# Code\n\nuse std::collections::*;\n\nimpl Solution {\n  pub fn smallest_subarrays(nums: 
# Complexity\n- Time complexity:\n$$O(n*m)$$\n\n- Space complexity:\n$$O(n*m)$$\n\n# Code\n```\nuse std::collections::*;\n\nimpl Solution {\n  pub fn smallest_subarrays(nums: Vec<i32>) -> Vec<i32> {\n    let n = nums.len();\n    let mut result = vec![0;n];\n    let mut memo = vec![VecDeque::new();35];\n\n    for i in 0..n {\n      let v = nums[i];\n      for j in 0..35 {\n        if v >> j & 1 == 1 {\n          memo[j].push_back(i);\n        }\n      }\n    }\n\n    for i in 0..n {\n      let mut max = i;\n      for j in 0..35 {\n        if !memo[j].is_empty() {\n          max = max.max(memo[j][0]);\n\n          if memo[j][0] == i {\n            memo[j].pop_front();\n          }\n        }\n      }\n\n      result[i] = (max - i + 1) as i32;\n    }\n\n    result\n  }\n}\n```
['Rust']