Solution
\n\n# Code\njava []\nclass Solution {\n    public int[] minBitwiseArray(List<Integer> nums) {\n        int n = nums.size();\n        int ans[] = new int[n];\n  
\n\n# Code\n```java []\nclass Solution {\n    public int[] minBitwiseArray(List<Integer> nums) {\n        int n = nums.size();\n        int ans[] = new int[n];\n        // Initialize all elements to -1\n        for (int i = 0; i < n; i++) {\n            ans[i] = -1;\n        }\n\n        for (int i = 0; i < nums.size(); i++) {\n            Integer val = nums.get(i);\n            for (int j = 0; j <= val; j++) {\n                if ((j | (j + 1)) == nums.get(i)) {\n                    ans[i] = j;\n                    break;\n                }\n            }\n\n        }\n        return ans ; \n\n    }\n}\n```
['Java']